Skip to content

Commit

Permalink
Merge pull request #12 from onekey-sec/sasquatch-patches-rebase
Browse files Browse the repository at this point in the history
Rebase on top of squashfs-tools-4.5.1
  • Loading branch information
qkaiser authored Mar 2, 2023
2 parents afdd63f + aa648c4 commit 4f75d70
Show file tree
Hide file tree
Showing 288 changed files with 37,542 additions and 73 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build-nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "Nix"
on:
pull_request:
push:
branches:
- main
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
arch: x86_64-linux
- os: ubuntu-latest
arch: aarch64-linux
- os: macos-latest
arch: x86_64-darwin
name: Build Nix - ${{ matrix.arch }}.${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v19
with:
install_url: https://releases.nixos.org/nix/nix-2.13.3/install
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Setup emulation
if: ${{ matrix.arch == 'aarch64-linux' }}
run: |
sudo apt install -q -y qemu-system-aarch64 qemu-efi binfmt-support qemu-user-static
mkdir -p ~/.config/nix
echo "system-features = aarch64-linux arm-linux" | sudo tee -a /etc/nix/nix.conf
- uses: cachix/cachix-action@v12
with:
name: unblob
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- run: |
nix flake check -L --option system ${{ matrix.arch }} --extra-platforms ${{ matrix.arch }}
- run: |
nix build -L --option system ${{ matrix.arch }} --extra-platforms ${{ matrix.arch }}
58 changes: 58 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This is a basic workflow to help you get started with Actions

name: Build

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the sasquatch branch
push:
branches:
- sasquatch
pull_request:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build_amd64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Debian package (AMD64)
uses: dawidd6/action-debian-package@v1.4.4
with:
os_distribution: bullseye
cpu_architecture: amd64
- name: Upload DEB artifacts
uses: actions/upload-artifact@v2
with:
path: ${{ github.workspace }}/*.deb
build_arm64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Debian package (AARCH64)
uses: dawidd6/action-debian-package@v1.4.4
with:
os_distribution: bullseye
cpu_architecture: arm64
- name: Upload DEB artifacts
uses: actions/upload-artifact@v2
with:
path: ${{ github.workspace }}/*.deb
if-no-files-found: error
build_arm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Debian package (ARM32)
uses: dawidd6/action-debian-package@v1.4.4
with:
os_distribution: bullseye
cpu_architecture: arm
- name: Upload DEB artifacts
uses: actions/upload-artifact@v2
with:
path: ${{ github.workspace }}/*.deb
if-no-files-found: error
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release

on:
push:
tags:
- "sasquatch-v*"

jobs:
build_amd64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Debian package (AMD64)
uses: dawidd6/action-debian-package@v1.4.4
with:
os_distribution: bullseye
cpu_architecture: amd64
- name: Release
uses: softprops/action-gh-release@v1
with:
files: ${{ github.workspace }}/*.deb
build_arm64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Debian package (AARCH64)
uses: dawidd6/action-debian-package@v1.4.4
with:
os_distribution: bullseye
cpu_architecture: arm64
- name: Release
uses: softprops/action-gh-release@v1
with:
files: ${{ github.workspace }}/*.deb
build_arm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Debian package (ARM32)
uses: dawidd6/action-debian-package@v1.4.4
with:
os_distribution: bullseye
cpu_architecture: arm
- name: Release
uses: softprops/action-gh-release@v1
with:
files: ${{ github.workspace }}/*.deb
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.o
*.a
*.swp
.vscode

squashfs-tools/sasquatch
squashfs-tools/sasquatch-v4be
5 changes: 5 additions & 0 deletions debian/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sasquatch/
debhelper-*-stamp
sasquatch.debhelper.log
sasquatch.substvars
files
6 changes: 6 additions & 0 deletions debian/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The Debian Package sasquatch
----------------------------

Comments regarding the Package

-- Marton Illes <marton.illes@iot-inspector.com> Sat, 26 Feb 2022 18:38:11 +0100
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sasquatch (1.0) unstable; urgency=medium

* Initial Release.

-- Marton Illes <marton.illes@iot-inspector.com> Sat, 26 Feb 2022 18:38:11 +0100
15 changes: 15 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Source: sasquatch
Section: misc
Priority: optional
Maintainer: Marton Illes <marton.illes@iot-inspector.com>
Build-Depends: debhelper-compat (= 13), liblzo2-dev, zlib1g-dev, liblz4-dev, liblzma-dev, libzstd-dev
Standards-Version: 4.5.1
Homepage: https://github.com/IoT-Inspector/sasquatch
#Vcs-Browser: https://salsa.debian.org/debian/sasquatch
#Vcs-Git: https://salsa.debian.org/debian/sasquatch.git
Rules-Requires-Root: no

Package: sasquatch
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Tool to extract vendor specific SquashFS images
39 changes: 39 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: sasquatch
Upstream-Contact: <preferred name and address to reach the upstream project>
Source: <url://example.com>

Files: *
Copyright: <years> <put author's name and email here>
<years> <likewise for another author>
License: GPL-2.0+

Files: debian/*
Copyright: 2022 Marton Illes <marton.illes@iot-inspector.com>
License: GPL-2.0+

License: GPL-2.0+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
.
On Debian systems, the complete text of the GNU General
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".

# Please also look if there are files or directories which have a
# different copyright/license attached and list them here.
# Please avoid picking licenses with terms that are more restrictive than the
# packaged work, as it may make Debian's contributions unacceptable upstream.
#
# If you need, there are some extra license texts available in two places:
# /usr/share/debhelper/dh_make/licenses/
# /usr/share/common-licenses/
23 changes: 23 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

override_dh_auto_configure:
dh_auto_configure -- $(shell dpkg-buildflags --export=cmdline)

override_dh_auto_build:


override_dh_auto_install:
dh_auto_clean
dh_auto_build
dh_auto_install -- INSTALL_DIR=$(CURDIR)/debian/sasquatch/usr/bin
dh_auto_clean
CFLAGS=-DFIX_BE dh_auto_build
cp $(CURDIR)/squashfs-tools/sasquatch $(CURDIR)/debian/sasquatch/usr/bin/sasquatch-v4be

%:
dh ${@} --sourcedirectory=squashfs-tools/

.PHONY: override_dh_auto_build override_dh_auto_install
1 change: 1 addition & 0 deletions debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (native)
26 changes: 26 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
description = ''
Set of patches to the standard unsquashfs utility (part of
squashfs-tools) that attempts to add support for as many hacked-up
vendor-specific SquashFS implementations as possible
'';

inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable";

outputs = { self, nixpkgs }:
let
# Generate a user-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;

# System types to support.
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];

# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;

# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = builtins.attrValues self.overlays; });
in
{
overlays.default = final: prev: {
sasquatch-le = final.squashfsTools.overrideAttrs (_: {
pname = "sasquatch-le";
inherit version;

src = ./.;
});

sasquatch-be = final.sasquatch-le.overrideAttrs (super: {
pname = "sasquatch-be";
preConfigure = (super.preConfigure or "") + ''
export CFLAGS="-DFIX_BE"
'';
postInstall = (super.postInstall or "") + ''
mv $out/bin/sasquatch{,-v4be}
'';
});

sasquatch = final.buildEnv {
name = "sasquatch";
paths = with final; [
sasquatch-be
sasquatch-le
];
};
};
packages = forAllSystems (system: rec {
inherit (nixpkgsFor.${system}) sasquatch sasquatch-be sasquatch-le;
default = sasquatch;
});
devShells = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
in
{
default = pkgs.mkShell {
inputsFrom = [ pkgs.sasquatch-le ];
};
});
};
}
Loading

0 comments on commit 4f75d70

Please sign in to comment.