logo

deblob

remove binary executables from a directory git clone https://hacktivis.me/git/deblob.git
commit: 3ddda26203054f1678a7a05ea4e15f4600156c97
parent 756b5431b338943c95dd2bff6ec9cf4681a25aca
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 16 Oct 2022 20:52:35 +0200

Add support for Device Tree Blob

Diffstat:

M.reuse/dep52+-
MMakefile6+++++-
Mdeblob.13+++
Mmain.ha7+++++--
Atest/fixtures/empty.dtb0
Atest/fixtures/empty.dts5+++++
6 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/.reuse/dep5 b/.reuse/dep5 @@ -3,6 +3,6 @@ Upstream-Name: deblob Upstream-Contact: deblob Authors <https://hacktivis.me/projects/deblob> Source: https://hacktivis.me/projects/deblob -Files: test/fixtures/pyc/*.pyc test/fixtures/hello.luac* test/fixtures/hello.class test/fixtures/hello.nqp.moarvm test/fixtures/hello.pir.pbc test/fixtures/perl_storage.pst test/fixtures/hello.beam +Files: test/fixtures/pyc/*.pyc test/fixtures/hello.luac* test/fixtures/hello.class test/fixtures/hello.nqp.moarvm test/fixtures/hello.pir.pbc test/fixtures/perl_storage.pst test/fixtures/hello.beam test/fixtures/empty.dtb Copyright: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob> License: BSD-3-Clause diff --git a/Makefile b/Makefile @@ -18,9 +18,10 @@ NQP ?= nqp PARROT ?= parrot PERL ?= perl ERLC ?= erlc +DTC ?= dtc EXE = deblob -TEST_BLOBS = test/fixtures/hello test/fixtures/hello.a test/fixtures/hello.o test/fixtures/hello.exe test/fixtures/hello.luac53 test/fixtures/hello.luac54 test/fixtures/hello.wasm test/fixtures/hello.class test/fixtures/hello.nqp.moarvm test/fixtures/hello.pir.pbc test/fixtures/perl_storage.pst test/fixtures/hello.beam +TEST_BLOBS = test/fixtures/hello test/fixtures/hello.a test/fixtures/hello.o test/fixtures/hello.exe test/fixtures/hello.luac53 test/fixtures/hello.luac54 test/fixtures/hello.wasm test/fixtures/hello.class test/fixtures/hello.nqp.moarvm test/fixtures/hello.pir.pbc test/fixtures/perl_storage.pst test/fixtures/hello.beam test/fixtures/empty.dtb all: $(EXE) @@ -67,6 +68,9 @@ test/fixtures/perl_storage.pst: test/fixtures/perl_storage.pm test/fixtures/hello.beam: test/fixtures/hello.erl $(ERLC) -o test/fixtures +deterministic test/fixtures/hello.erl +test/fixtures/empty.dtb: test/fixtures/empty.dts + $(DTC) -o $@ -O dtb test/fixtures/empty.dts + .PHONY: test test: all $(TEST_BLOBS) rm -fr test/check_dir-fixtures diff --git a/deblob.1 b/deblob.1 @@ -66,6 +66,9 @@ MoarVM bytecode Parrot bytecode .It Perl Storable data (v0.6 and v0.7) +.It +Device Tree Blob, typically +.Sq *.dtb .El .Sh EXAMPLES The following code block shows how it can be used in Gentoo's diff --git a/main.ha b/main.ha @@ -25,6 +25,7 @@ const magic: [_][]u8 = [ [0x1B, 'L', 'u', 'a'], // Lua bytecode [0x00, 'a', 's', 'm'], // WebAssembly ['J', 'o', 'y', '!', 'p', 'e', 'f', 'f'], // Apple Preferred Executable Format + [0xD0, 0x0D, 0xFE, 0xED], // Device Tree Blob (OpenFirmware, u-boot, …) // Python *.pyc bytecode magic numbers (defined in importlib/_bootstrap_external.py) [0x03, 0xF3, '\r', '\n'], // (62211i little-endian) Python 2.7 @@ -74,6 +75,7 @@ fn is_blob(filename: str) (bool | fs::error | io::error) = { @test fn is_blob() void = { const tests = [ (false, "test/fixtures/empty"), + (false, "test/fixtures/empty.dts"), (false, "test/fixtures/hello.1"), (false, "test/fixtures/hello.c"), (false, "test/fixtures/hello.cs"), @@ -85,6 +87,7 @@ fn is_blob(filename: str) (bool | fs::error | io::error) = { (false, "test/fixtures/hello.py"), (false, "test/fixtures/hello.wat"), (false, "test/fixtures/perl_storage.pm"), + (true, "test/fixtures/empty.dtb"), (true, "test/fixtures/hello"), (true, "test/fixtures/hello.a"), (true, "test/fixtures/hello.beam"), @@ -200,7 +203,7 @@ fn check_dir(dirname: str) (void | errors::invalid) = { case let e: fs::error => fmt::fatalf("os::readdir({}): {}", dirname, fs::strerror(e)); }; - assert(len(files_before) == 33); + assert(len(files_before) == 35); const ret = check_dir(dirname); assert(ret is void); @@ -211,7 +214,7 @@ fn check_dir(dirname: str) (void | errors::invalid) = { case let e: fs::error => fmt::fatalf("os::readdir({}): {}", dirname, fs::strerror(e)); }; - assert(len(files_after) == 19); + assert(len(files_after) == 20); }; export fn main() void = { diff --git a/test/fixtures/empty.dtb b/test/fixtures/empty.dtb Binary files differ. diff --git a/test/fixtures/empty.dts b/test/fixtures/empty.dts @@ -0,0 +1,5 @@ +/dts-v1/; +// SPDX-FileCopyrightText: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob> +// SPDX-License-Identifier: BSD-3-Clause +/ { +};