Skip to content

Commit

Permalink
Switch entirely to the C version of fakefsify
Browse files Browse the repository at this point in the history
Also manages to add an unfakefsify tool.
  • Loading branch information
tbodt committed Oct 18, 2020
1 parent b6f43cf commit c18df37
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 293 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ jobs:
dist: bionic
addons:
apt:
packages:
- ninja-build
packages:
- ninja-build
- libarchive-dev
install:
- source ~/virtualenv/python3.6/bin/activate
- pip install meson
Expand All @@ -20,6 +21,7 @@ jobs:
compiler: gcc
- <<: *linux
compiler: clang

- language: objective-c
os: osx
osx_image: xcode11.5
Expand All @@ -30,6 +32,7 @@ jobs:
packages:
- ninja
- llvm
- libarchive
update: true
script:
- xcodebuild -project iSH.xcodeproj -scheme iSH -sdk iphoneos CODE_SIGNING_ALLOWED=NO
2 changes: 1 addition & 1 deletion app/Roots.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import <FileProvider/FileProvider.h>
#import "Roots.h"
#import "AppGroup.h"
#include "fs/fakefsify.h"
#include "tools/fakefs.h"

static NSURL *RootsDir() {
static NSURL *rootsDir;
Expand Down
8 changes: 4 additions & 4 deletions iSH.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
BB0F553623A0ACFC0032A2A1 /* pydann2.png in Resources */ = {isa = PBXBuildFile; fileRef = BB0F553523A0ACFC0032A2A1 /* pydann2.png */; };
BB0FC5921F980A6C00803272 /* Terminal.m in Sources */ = {isa = PBXBuildFile; fileRef = BB0FC5911F980A6B00803272 /* Terminal.m */; };
BB101B382364CF57000A93BC /* FontPickerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB101B372364CF57000A93BC /* FontPickerViewController.m */; };
BB10E5C3248DBA7B009C7A74 /* fakefsify.c in Sources */ = {isa = PBXBuildFile; fileRef = BB10E5C2248DBA7B009C7A74 /* fakefsify.c */; };
BB10E5C3248DBA7B009C7A74 /* fakefs.c in Sources */ = {isa = PBXBuildFile; fileRef = BB10E5C2248DBA7B009C7A74 /* fakefs.c */; };
BB10E5C9248DBAAC009C7A74 /* libarchive.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BB10E5C8248DBAA1009C7A74 /* libarchive.a */; };
BB10E5CE248DBE66009C7A74 /* Roots.m in Sources */ = {isa = PBXBuildFile; fileRef = BB10E5CD248DBE66009C7A74 /* Roots.m */; };
BB10E5D0248DC21D009C7A74 /* Roots.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BB10E5CF248DC21D009C7A74 /* Roots.storyboard */; };
Expand Down Expand Up @@ -210,7 +210,7 @@
BB101B6C2364EC2F000A93BC /* sync.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sync.c; sourceTree = "<group>"; };
BB101B6D2364EC2F000A93BC /* fifo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fifo.c; sourceTree = "<group>"; };
BB10E0C1248DA5B0009C7A74 /* libarchive.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = libarchive.xcodeproj; path = ../deps/libarchive.xcodeproj; sourceTree = "<group>"; };
BB10E5C2248DBA7B009C7A74 /* fakefsify.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = fakefsify.c; path = fs/fakefsify.c; sourceTree = SOURCE_ROOT; };
BB10E5C2248DBA7B009C7A74 /* fakefs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = fakefs.c; path = tools/fakefs.c; sourceTree = SOURCE_ROOT; };
BB10E5CC248DBE66009C7A74 /* Roots.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Roots.h; sourceTree = "<group>"; };
BB10E5CD248DBE66009C7A74 /* Roots.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Roots.m; sourceTree = "<group>"; };
BB10E5CF248DC21D009C7A74 /* Roots.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Roots.storyboard; sourceTree = "<group>"; };
Expand Down Expand Up @@ -446,7 +446,7 @@
BB10E5D2248DCFEA009C7A74 /* RootsTableViewController.m */,
BBAEE33A249BDADC0069EBB5 /* ProgressReportViewController.h */,
BBAEE33B249BDADC0069EBB5 /* ProgressReportViewController.m */,
BB10E5C2248DBA7B009C7A74 /* fakefsify.c */,
BB10E5C2248DBA7B009C7A74 /* fakefs.c */,
BB10E0C1248DA5B0009C7A74 /* libarchive.xcodeproj */,
);
name = Roots;
Expand Down Expand Up @@ -1179,7 +1179,7 @@
BB10E5CE248DBE66009C7A74 /* Roots.m in Sources */,
BBCC9D962365430800424C83 /* SceneDelegate.m in Sources */,
BB82A7FD21B4C2E8006AA5FD /* AboutExternalKeyboardViewController.m in Sources */,
BB10E5C3248DBA7B009C7A74 /* fakefsify.c in Sources */,
BB10E5C3248DBA7B009C7A74 /* fakefs.c in Sources */,
8632A7BF219A59FB00F02325 /* UserPreferences.m in Sources */,
BB10E5D3248DCFEA009C7A74 /* RootsTableViewController.m in Sources */,
BB792B631F96D90D00FFB7A4 /* main.m in Sources */,
Expand Down
7 changes: 3 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ includes = [include_directories('.')]
threads = dependency('threads')
librt = cc.find_library('rt', required: false)
libm = cc.find_library('m', required: false)
sqlite3 = cc.find_library('sqlite3')

dependencies = [librt, libm, threads, sqlite3]

subdir('vdso') # ish depends on the vdso

Expand Down Expand Up @@ -139,10 +142,6 @@ else
]
endif

sqlite3 = cc.find_library('sqlite3')

dependencies = [librt, libm, threads, sqlite3]

libish = library('ish', src,
include_directories: includes)
ish = declare_dependency(
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/e2e.bash
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ if [ ! -d "$FS" ]; then
echo "###### Downloading Alpine"
wget "$ALPINE_IMAGE" -O e2e_out/alpine.tar.gz
echo "###### Unpacking Alpine"
./tools/fakefsify.py e2e_out/alpine.tar.gz "$FS"
./build/tools/fakefsify e2e_out/alpine.tar.gz "$FS"
echo "###### Configuring iSH and installing base libraries"
grep -E "^nameserver" /etc/resolv.conf | head -1 | $ISH /bin/sed -n "w /etc/resolv.conf"
$ISH /bin/sh -c "apk update && apk add build-base python2 python3"
Expand Down
2 changes: 1 addition & 1 deletion fs/fakefsify.c → tools/fakefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

#define ISH_INTERNAL
#include "fs/fake.h"
#include "fs/fakefsify.h"
#include "fs/sqlutil.h"
#include "tools/fakefs.h"
#include "misc.h"

// I have a weird way of error handling
Expand Down
File renamed without changes.
33 changes: 28 additions & 5 deletions tools/fakefsify.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
#include <stdio.h>
#include <string.h>
#include <libgen.h>

#define ISH_INTERNAL
#include "fs/fake.h"
#include "fs/fakefsify.h"
#include "tools/fakefs.h"

enum cmd {
cmd_import,
cmd_export,
};

int main(int argc, const char *argv[]) {
enum cmd cmd = cmd_import;
if (strcmp(basename((char *) argv[0]), "unfakefsify") == 0) {
cmd = cmd_export;
}

if (argc != 3) {
fprintf(stderr, "wrong number of arguments\n");
fprintf(stderr, "usage: %s <rootfs archive> <destination dir>\n", argv[0]);
switch (cmd) {
case cmd_import:
fprintf(stderr, "usage: %s <rootfs.tar.gz> <fakefs>\n", argv[0]);
break;
case cmd_export:
fprintf(stderr, "usage: %s <fakefs> <rootfs.tar.gz>\n", argv[0]);
break;
}
return 1;
}
const char *archive_path = argv[1];
const char *fs = argv[2];

struct fakefsify_error err;
if (!fakefs_import(archive_path, fs, &err, (struct progress) {})) {
bool (*func)(const char *, const char *, struct fakefsify_error *, struct progress) = NULL;
if (cmd == cmd_import)
func = fakefs_import;
else if (cmd == cmd_export)
func = fakefs_export;
if (!(*func)(argv[1], argv[2], &err, (struct progress) {})) {
fprintf(stderr, "error!!1! %d %d %s\n", err.line, err.type, err.message);
return 1;
}
Expand Down
105 changes: 0 additions & 105 deletions tools/fakefsify.py

This file was deleted.

Loading

0 comments on commit c18df37

Please sign in to comment.