Skip to content

Commit

Permalink
Make it possible to update old filesystems to ODR APK
Browse files Browse the repository at this point in the history
mkdir -p /ish/apk && \
echo 'file:///ish/apk/main' > /etc/apk/repositories && \
mount -t apk apk /ish/apk && \
tar -xf /ish/apk/main/x86/apk-tools-static-2.10.5-r1.apk -C / && \
apk.static add apk-tools && \
rm /sbin/apk.static
  • Loading branch information
tbodt committed Nov 29, 2020
1 parent e8d7d7e commit ce07f20
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 11 additions & 0 deletions app/APKFilesystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ static int apkfs_close(struct fd *fd) {
return 0;
}

static int apkfs_getpath(struct fd *fd, char *buf) {
if (fd->ops == &apkfs_dir_ops) {
strcpy(buf, "");
} else if (fd->ops == &apkfs_file_ops) {
NSBundleResourceRequest *req = (__bridge NSBundleResourceRequest *) fd->data;
strcpy(buf, [@"/" stringByAppendingString:[req.tags.anyObject stringByReplacingOccurrencesOfString:@":" withString:@"/"]].UTF8String);
}
return 0;
}

static int apkfs_dir_readdir(struct fd *fd, struct dir_entry *entry) {
return 0;
}
Expand All @@ -164,6 +174,7 @@ static int apkfs_dir_readdir(struct fd *fd, struct dir_entry *entry) {
.open = apkfs_open,
.fstat = apkfs_fstat,
.close = apkfs_close,
.getpath = apkfs_getpath,
};

static const struct fd_ops apkfs_dir_ops = {
Expand Down
7 changes: 4 additions & 3 deletions app/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,19 @@ - (int)boot {
int err = mount_root(&fakefs, root.fileSystemRepresentation);
if (err < 0)
return err;

fs_register(&iosfs);
fs_register(&iosfs_unsafe);
fs_register(&apkfs);

// need to do this first so that we can have a valid current for the generic_mknod calls
err = become_first_process();
if (err < 0)
return err;

// /etc/ish-version is the last ish version that opened this root. Not used for anything yet, but could be used to know whether to change the root if needed in a future update.
// /ish/version is the last ish version that opened this root. Not used for anything yet, but could be used to know whether to change the root if needed in a future update.
BOOL has_ish_version = NO;
struct fd *ish_version = generic_open("/ish/version", O_WRONLY_|O_TRUNC_, 0644);
struct fd *ish_version = generic_open("/ish/version", O_WRONLY_|O_CREAT_|O_TRUNC_, 0644);
if (!IS_ERR(ish_version)) {
has_ish_version = YES;
NSString *version = NSBundle.mainBundle.infoDictionary[(__bridge NSString *) kCFBundleVersionKey];
Expand All @@ -85,7 +87,6 @@ - (int)boot {
}

if (has_ish_version && [NSBundle.mainBundle URLForResource:@"OnDemandResources" withExtension:@"plist"] != nil) {
fs_register(&apkfs);
generic_mkdirat(AT_PWD, "/ish/apk", 0755);
do_mount(&apkfs, "apk", "/ish/apk", "", 0);
}
Expand Down

0 comments on commit ce07f20

Please sign in to comment.