NSString *type_;
NSString *version_;
+ NSString *defaultIcon_;
+
BOOL trusted_;
}
- (NSString *) label;
- (NSString *) origin;
- (NSString *) version;
+
+- (NSString *) defaultIcon;
@end
@implementation Source
while (!value.empty() && value[0] == ' ')
value = value.substr(1);
- if (name == "Description")
+ if (name == "Default-Icon")
+ defaultIcon_ = [[NSString stringWithCString:value.c_str()] retain];
+ else if (name == "Description")
description_ = [[NSString stringWithCString:value.c_str()] retain];
else if (name == "Label")
label_ = [[NSString stringWithCString:value.c_str()] retain];
return version_;
}
+- (NSString *) defaultIcon {
+ return defaultIcon_;
+}
+
@end
/* }}} */
/* Package Class {{{ */
[description_ setBackgroundColor:clear];
[description_ setFont:small];
- source_ = [[UITextLabel alloc] initWithFrame:CGRectMake(12, 72, 150, 20)];
+ source_ = [[UITextLabel alloc] initWithFrame:CGRectMake(12, 72, 225, 20)];
[source_ setBackgroundColor:clear];
[source_ setFont:large];
}
- (void) setPackage:(Package *)package {
+ Source *source = [package source];
+
UIImage *image = nil;
if (NSString *icon = [package icon])
image = [UIImage imageAtPath:[icon substringFromIndex:6]];
+ if (image == nil) if (NSString *icon = [source defaultIcon])
+ image = [UIImage imageAtPath:[icon substringFromIndex:6]];
if (image == nil)
image = [UIImage applicationImageNamed:@"unknown.png"];
[version_ setText:[package latest]];
[description_ setText:[package tagline]];
- Source *source = [package source];
NSString *label;
bool trusted;
- if (source == nil) {
+ if (source != nil) {
+ label = [source label];
+ trusted = [source trusted];
+ } else if ([[package id] isEqualToString:@"firmware"]) {
label = @"Apple";
trusted = false;
} else {
- label = [source label];
- trusted = [source trusted];
+ label = @"Unknown/Local";
+ trusted = false;
}
[source_ setText:[NSString stringWithFormat:@"from %@", label]];
--- /dev/null
+#!/bin/bash
+
+shopt -s extglob nullglob
+
+function df_() {
+ free=$(df -B1 "$1")
+ free=${free% *%*}
+ free=${free%%*( )}
+ free=${free##* }
+ echo "${free}"
+}
+
+function mv_() {
+ src=$1
+ dst=$2
+
+ if [[ -e ${dst} ]]; then
+ dst=$(mktemp -d /var/cydia.XXXXXX)
+ else
+ mkdir -p "${dst}"
+ fi
+
+ if [[ -e ${src} ]]; then
+ chmod --reference="${src}" "${dst}"
+ chown --reference="${src}" "${dst}"
+
+ cp -aT "${src}" "${dst}" || {
+ rm -rf "${dst}"
+ exit 1
+ }
+
+ rm -rf "${src}"
+ else
+ chmod 775 "${dst}"
+ chown root.admin "${dst}"
+ fi
+
+ ln -s "${dst}" "${src}"
+}
+
+function shift_() {
+ dir=$1
+ dst=$2
+
+ if [[ -d ${dir} && ! -h ${dir} ]]; then
+ used=$(du -bs "${dir}")
+ used=${used%%$'\t'*}
+ free=$(df_ /var)
+
+ if [[ $((used + 524288)) -lt ${free} ]]; then
+ mv_ "${dir}" "${dst}"
+ fi
+ elif [[ -h ${dir} && ! -e ${dir} ]]; then
+ rm -f "${dir}"
+ mv_ "${dir}" "${dst}"
+ fi
+}
+
+shift_ "$@"