deblob.1 (4137B)
- .\" SPDX-FileCopyrightText: 2019 deblob Authors <https://hacktivis.me/projects/deblob>
 - .\" SPDX-License-Identifier: BSD-3-Clause
 - .Dd 2024-11-16
 - .Dt DEBLOB 1
 - .Os
 - .Sh NAME
 - .Nm deblob
 - .Nd remove binary executables ("blobs") from a directory
 - .Sh SYNOPSIS
 - .Nm
 - .Op Fl cn
 - .Op Fl d Ar workdir
 - .Op Fl e Ar excluded path ...
 - .Op Fl j Ar file
 - .Sh DESCRIPTION
 - The
 - .Nm
 - utility cleans a directory from binary executables ("blobs").
 - Useful to clean a source tree to make sure it fully builds from source.
 - .Pp
 - Scanning for blobs inside source files is considered to be out-of-scope as
 - .Lk https://www.fsfla.org/svn/fsfla/software/linux-libre/scripts/ linux-libre deblob script
 - already exists.
 - .Pp
 - The options are as follows:
 - .Bl -tag -width Ds
 - .It Fl c
 - Return error if any non-excluded blobs were found.
 - .It Fl d Ar workdir
 - Directory to be scanned rather than the current working directory on execution.
 - .It Fl e Ar excluded path
 - Paths to be excluded from removal, accepts shell-style globbing.
 - Pass the option multiple times to do multiple exclusions.
 - .It Fl j Ar file
 - JSON file to log actions taken and metadata into.
 - See
 - .Sx JSON OUTPUT FORMAT
 - section.
 - .It Fl n
 - Scan the files but do not actually delete them.
 - .El
 - .Sh EXIT STATUS
 - The
 - .Nm
 - utility exits with the following statuses:
 - .Bl -tag -width _
 - .It 0
 - No errors happened and if
 - .Fl c
 - was passed, no matching blobs were found.
 - .It 1
 - Failed scanning for blobs, for example due to an I/O error.
 - .It 2
 - Option
 - .Fl c
 - passed and matching blobs were found.
 - .El
 - .Sh JSON OUTPUT FORMAT
 - When the
 - .Fl j Ar file
 - option is set,
 - .Nm
 - writes a JSON list of objects containing the following keys:
 - .Bl -tag -width format
 - .It action
 - Action which
 - .Nm
 - took.
 - For example: "ignoring", "detected", "removing".
 - .It format
 - Short description of the detected format, intended for humans.
 - No stability guarantees.
 - .It path
 - Path of the matched file, relative to the working directory, as changed by
 - .Cm cd
 - and
 - .Fl d Ar workdir .
 - .El
 - .Sh SUPPORTED FORMATS
 - Blobs scanned against are the following:
 - .Bl -dash -compact
 - .It
 - Executable and Linking Format (ELF) files
 - .It
 - Unix
 - .Xr ar 1
 - files
 - .It
 - x86 IBM PC BIOS Option Rom
 - .It
 - Erlang BEAM files and BEAM/PKZIP-based escripts
 - .It
 - Java Class files and Archives (JAR)
 - .It
 - Mach-O executables
 - .It
 - Python 2.7, and 3.8 to 3.14 bytecode files, typically
 - .Sq *.pyc
 - .It
 - Python pickle files, used to serialize Python objects
 - .It
 - Portable Executable files, typically
 - .Sq *.exe
 - and
 - .Sq *.dll .
 - .It
 - Lua bytecode
 - .It
 - WASM (Web Assembly)
 - .It
 - Apple Preferred Executable Format
 - .It
 - MoarVM bytecode
 - .It
 - Parrot bytecode
 - .It
 - Perl Storable data (v0.6 and v0.7)
 - .It
 - Device Tree Blob, typically
 - .Sq *.dtb
 - .It
 - Chez Scheme bytecode
 - .It
 - NekoVM bytecode
 - .It
 - OCaml bytecode and native binaries
 - .It
 - Racket bytecode
 - .It
 - Emacs Lisp Bytecode
 - .It
 - Ren'Py Archives v1/v2/v3
 - .It
 - Squirrel bytecode
 - .It
 - Pre-Compiled Headers: Clang, GCC
 - .It
 - GCC Rust Metadata, typically
 - .It
 - Dart Kernel and JIT snapshots
 - .Sq *.rox
 - .El
 - .Sh EXAMPLES
 - The following code block shows how it can be used in Gentoo's
 - .Pa /etc/portage/bashrc :
 - .Bd -literal
 - # Will be ran before configure phase, allowing ebuilds to delete blobs themselves in the prepare phase
 - if [ "${EBUILD_PHASE}" == "configure" ]; then
 - if grep -q -- '-bin$' <<<"${PN}"; then
 - echo ":: *-bin package, not deblobbing"
 - elif grep -q -- "${PN}" /etc/portage/deblob.reject; then
 - echo ":: package is in /etc/portage/deblob.reject, no removals"
 - time deblob -n -e 'test*' -e '*/test*' -d "${WORKDIR}"
 - else
 - time deblob -e 'test*' -e '*/test*' -d "${WORKDIR}"
 - fi
 - fi
 - .Ed
 - .Sh HISTORY
 - This tool was originally implemented in Go as "go-deblob" and got rewritten
 - to hare as "deblob".
 - .Sh AUTHORS
 - .An Haelwenn (lanodan) Monnier Aq Mt contact+deblob-mdoc@hacktivis.me
 - .Sh CAVEATS
 - .Ss Out of scope formats
 - .Bl -dash -compact
 - .It
 - Generic formats and executables based on them:
 - .Bl -dash -compact
 - .It
 - Generic Archives: Tarballs, Distro Packages, ZIP, Cabinet (CAB), Microsoft Compound File (including MSI), …
 - .It
 - Filesystems, disk dumps, databases
 - .El
 - .It
 - Obscure proprietary formats, like executables/firmware where no libre implementation exists for either execution or compilation
 - .El