Skip to content

Commit

Permalink
Lower browsers to level 1, begin setting up for refactor
Browse files Browse the repository at this point in the history
Browser profiles have been lowered to level 1 to allow hardware keys to
function (#14) and I've began setting up for a code refactor

All databases will be moved out of the code directly, into JSON files
where it'll be much easier to maintain and audit
  • Loading branch information
mgord9518 committed Sep 3, 2024
1 parent 675f34f commit d029b09
Show file tree
Hide file tree
Showing 24 changed files with 546 additions and 197 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
git submodule update --recursive --init
./resources/install_deps.sh
- name: Build libaisap
run: |
./resources/build_libaisap.sh
#- name: Build libaisap
# run: |
# ./resources/build_libaisap.sh

- name: Build aisap-cli
run: |
Expand All @@ -42,5 +42,6 @@ jobs:
*.AppImage
*.shImg
*.zsync
libaisap*.a
libaisap*.so
# TODO
#libaisap*.a
#libaisap*.so
12 changes: 6 additions & 6 deletions profiles/profile_database.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
},
{
"names": [ "brave" ],
"level": 2,
"level": 1,
"filesystem": [
"xdg-download:rw"
],
Expand Down Expand Up @@ -208,7 +208,7 @@
},
{
"names": [ "chromium" ],
"level": 2,
"level": 1,
"filesystem": [
"xdg-download:rw"
],
Expand Down Expand Up @@ -491,7 +491,7 @@
},
{
"names": [ "firefox", "firefox beta", "firefox nightly" ],
"level": 2,
"level": 1,
"filesystem": [
"xdg-download:rw"
],
Expand Down Expand Up @@ -801,7 +801,7 @@
},
{
"names": [ "librewolf" ],
"level": 2,
"level": 1,
"filesystem": [
"xdg-download:rw"
],
Expand Down Expand Up @@ -863,7 +863,7 @@
},
{
"names": [ "microsoft edge" ],
"level": 2,
"level": 1,
"filesystem": [
"xdg-download:rw"
],
Expand Down Expand Up @@ -1623,7 +1623,7 @@
},
{
"names": [ "zen browser" ],
"level": 2,
"level": 1,
"filesystem": [
"xdg-download:rw"
],
Expand Down
36 changes: 36 additions & 0 deletions spooky/spooky_database.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"TODO": "Read this file in isspooky.go",
"paths": [
"/",
"/etc",
"/home",
"${HOME}",
"${HOME}/.profile",
"${HOME}/.bashrc",
"${HOME}/.zshrc"
],
"trees": [
"${HOME}/apps",
"${HOME}/Apps",
"${HOME}/AppImages",
"${HOME}/appimages",
"${HOME}/Applications",
"${HOME}/applications",
"${HOME}/go",
"${HOME}/.ssh",
"${HOME}/.vim",
"${HOME}/.gnupg",
"${HOME}/.firefox",
"${HOME}/.mozilla",
"$HOME/.cache",
"$HOME/.local",
"$HOME/.config",
"/run",
"/tmp",
"${XDG_CACHE_DIR}",
"${XDG_DATA_DIR}",
"${XDG_CONFIG_DIR}",
"${XDG_RUNTIME_DIR}",
"${TMPDIR}"
]
}
1 change: 1 addition & 0 deletions zig/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Currently undergoing a re-write that will prioritize simplicity
139 changes: 20 additions & 119 deletions zig/build.zig
Original file line number Diff line number Diff line change
@@ -1,145 +1,46 @@
const std = @import("std");

pub const LinkOptions = struct {
enable_zstd: bool = true,
enable_lz4: bool = true,
enable_lzo: bool = false,
enable_zlib: bool = true,
enable_xz: bool = true,

enable_fuse: bool = true,
use_system_fuse: bool = true,

use_libdeflate: bool = true,
};

// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});

// Standard optimization options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});

const lib_options = b.addOptions();
lib_options.addOption(bool, "enable_xz", true);
//lib_options.addOption(bool, "enable_zlib", true);
//lib_options.addOption(bool, "use_libdeflate", false);
lib_options.addOption(bool, "enable_lzo", false);
lib_options.addOption(bool, "enable_lz4", true);
lib_options.addOption(bool, "enable_zstd", true);
lib_options.addOption(bool, "use_zig_zstd", false);

const lib = b.addStaticLibrary(.{
.name = "aisap",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = b.path("lib/c_api.zig"),
.target = target,
.optimize = optimize,
});

lib.addIncludePath(b.path("../include"));

// const known_folders_module = b.addModule("known-folders", .{
// .root_source_file = b.path("known-folders/known-folders.zig"),
// });

const squashfuse_dep = b.dependency("squashfuse", .{
.target = target,
.optimize = optimize,

// These options will be renamed in the future
.@"enable-fuse" = true,
.@"enable-zlib" = true,
//.@"use-zig-zlib" = true,
.@"use-libdeflate" = true,
.@"enable-xz" = true,
.@"enable-lzma" = true,
.@"enable-lzo" = false,
.@"enable-lz4" = true,
.@"enable-zstd" = true,
});

const fuse_dep = b.dependency("fuse", .{
.target = target,
.optimize = optimize,
});

const known_folders_dep = b.dependency("known_folders", .{
.target = target,
.optimize = optimize,
.zlib_decompressor = .libdeflate_static,
.zstd_decompressor = .libzstd_static,
.lz4_decompressor = .liblz4_static,
.xz_decompressor = .liblzma_static,
});

lib.root_module.addImport(
"squashfuse",
squashfuse_dep.module("squashfuse"),
);

lib.root_module.addImport(
"known-folders",
known_folders_dep.module("known-folders"),
);

_ = b.addModule("aisap", .{
.root_source_file = b.path("lib.zig"),
const aisap_module = b.addModule("aisap", .{
.root_source_file = b.path("lib/AppImage.zig"),
.imports = &.{
.{
.name = "squashfuse",
.module = squashfuse_dep.module("squashfuse"),
},
.{
.name = "known-folders",
.module = known_folders_dep.module("known-folders"),
},
.{
.name = "fuse",
.module = fuse_dep.module("fuse"),
},
},
});

lib.root_module.addImport(
"fuse",
fuse_dep.module("fuse"),
);

// lib.root_module.addImport("known-folders", known_folders_module);

// const pie = b.option(bool, "pie", "build as a PIE (position independent executable)") orelse true;
// lib.pie = pie;

lib.linkLibC();

// This declares intent for the library to be installed into the standard
// location when the user invokes the "install" step (the default step when
// running `zig build`).
b.installArtifact(lib);
b.installArtifact(squashfuse_dep.artifact("deflate"));
b.installArtifact(squashfuse_dep.artifact("zstd"));
b.installArtifact(squashfuse_dep.artifact("lz4"));
b.installArtifact(fuse_dep.artifact("fuse"));

// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const main_tests = b.addTest(.{
.root_source_file = b.path("lib.zig"),
const exe = b.addExecutable(.{
.name = "aisap",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});

const run_main_tests = b.addRunArtifact(main_tests);
exe.linkLibC();

exe.root_module.addImport(
"aisap",
aisap_module,
);

exe.linkLibrary(squashfuse_dep.artifact("zstd"));
exe.linkLibrary(squashfuse_dep.artifact("deflate"));
//exe.linkLibrary(squashfuse_dep.artifact("deflate"));

// This creates a build step. It will be visible in the `zig build --help` menu,
// and can be selected like this: `zig build test`
// This will evaluate the `test` step rather than the default, which is "install".
const test_step = b.step("test", "Run library tests");
test_step.dependOn(&run_main_tests.step);
b.installArtifact(exe);
}
23 changes: 12 additions & 11 deletions zig/build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
.{
.name = "aisap",
.version = "0.10.2-alpha",
.paths = [][]const u8 {""},
.version = "0.10.3-alpha",
.minimum_zig_version = "0.13.0",

.dependencies = .{
.squashfuse = .{
.url = "https://github.com/mgord9518/squashfuse-zig/archive/refs/tags/continuous.tar.gz",
.hash = "12209f047e1b7dcaaa3335cb2ae4167b1062f308c409d8be24ce99edd17e1a0fc7d1",
},
.fuse = .{
.url = "https://github.com/mgord9518/libfuse-zig/archive/refs/tags/continuous.tar.gz",
.hash = "12205592f7dc4b4c7256abd657a50bd9784459a0e9b8bfe8b0d1bbcc153a6d0f650a",
},
.known_folders = .{
.url = "https://github.com/ziglibs/known-folders/archive/cdcc6137ed2e92096b27d394db917d1861f156b3.tar.gz",
.hash = "1220863f0fc3e97cfd47a8edb28c7a3d109c42143235042fb513207b5c5a032fb93f",
.hash = "1220e783b731a8fb6825fc1e2652ccd56890b8d7451d668064ed85b2fbddb790f8fa",
},
},

.paths = .{
"build.zig",
"build.zig.zon",
"src",
"lib",
"README.md",
},
}
42 changes: 42 additions & 0 deletions zig/lib/AppImage.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const std = @import("std");
const testing = std.testing;
const squashfuse = @import("squashfuse");
const SquashFs = squashfuse.SquashFs;

pub const AppImage = @This();

sqfs: SquashFs,
kind: Kind,
allocator: std.mem.Allocator,

pub const Kind = enum {
shimg,
type1,
type2,
};

pub fn open(allocator: std.mem.Allocator, path: []const u8) !AppImage {
const cwd = std.fs.cwd();
const file = try cwd.openFile(path, .{});

std.debug.print("offset {d}\n", .{try offsetFromElf(file)});

return .{
.sqfs = undefined,
.kind = undefined,
.allocator = allocator,
};
}

pub fn close(appimage: *AppImage) void {
_ = appimage;
return;
}

fn offsetFromElf(file: std.fs.File) !u64 {
const header = try std.elf.Header.read(file);

return header.shoff + (header.shentsize * header.shnum);
}

//fn offsetFromShimg(path: []const u8) u64 {}
Loading

0 comments on commit d029b09

Please sign in to comment.