Skip to content

Instantly share code, notes, and snippets.

@noraj
Last active February 22, 2025 19:03
Show Gist options
  • Save noraj/5045be32490f1161161e16fc5820066c to your computer and use it in GitHub Desktop.
Save noraj/5045be32490f1161161e16fc5820066c to your computer and use it in GitHub Desktop.
BlackArch dev tips

Lexicon

  • BA: BlackArch
  • AL: ArchLinux
  • SO: StackOverflow

PKGBUILD

See PKGBUILD(5) § USING VCS SOURCES and VCS package guidelines#VCS sources for details on VCS specific options, such as targeting a specific Git branch or commit.

For license name, it now uses SPDX names: see /usr/share/licenses/spdx/ or https://spdx.org/licenses/.

Updating

To update pkgver automatically when there is a pkgver():

makepkg -o

pkgver() for non-VCS

Github release

curl -s "https://api.github.com/repos/<noraj>/<haiti>/releases/latest" | jq -r '.tag_name'

Ruby gem

gem list '^haiti-hash$' -r | grep -Po '\((.+)\)' | tr -d '()'
# or better
curl -s https://rubygems.org/api/v1/gems/<haiti-hash>.json | jq -r '.version'

Git

Remove ALL local branches that are not on remote (see on SO)

git fetch -p && git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D

Remove untracked files and git ignored files (dry run)

git clean -xn

Remove untracked files and git ignored files (force)

git clean -xf

Checking out pull requests locally

$ git fetch origin pull/ID/head:BRANCH_NAME
$ git checkout BRANCH_NAME

Remove all branches named pr-*

git branch | awk '{print $1}' | grep -P '^pr-\d+' | xargs git branch -D

git rebase --onto

https://womanonrails.com/git-rebase-onto

BA

List categories

$ pacman -Sg | grep blackarch
$ curl https://raw.githubusercontent.com/BlackArch/blackarch/master/lists/groups

Testing

Install pacman-contrib to get updpkgsums.

  • blackarch-devtools: https://github.com/Edu4rdSHL/blackarch-devtools
    • Update env: ba-dev -u
    • Build ba dev -b
    • Install and test: ba-dev -e 'cmd' -p package.tar.zst
    • Build package requiring files that aren't available in repos: ba-dev -I ../dep/package.pkg.tar.zst

Misc

Python packaging

Removing useless dependencies

cf. https://github.com/BlackArch/blackarch/pulls?q=is%3Apr+%22remove+useless+dependencies%22

Git bisect linux kernel (but fast)

  • Setup ccache for makepkg
  • Setup modprobed-db
  • Build official vinilla linux kernel git version and bisect:
    • Clone: git clone https://aur.archlinux.org/linux-git.git and cd
    • Download the source without building: makepkg -o --skippgpcheck (very big)
    • Go to kernel git root: cd src/linux-torvalds/
    • Bisect (AL) - Bisect (kernel.org)
      • Start bisecting: git bisect start
      • Tag last know version working and the first failing, e.g.: git bisect good v6.7 and git bisect bad v6.8
      • Go back to AUR git root: cd ../..
      • Use modprobed-db for building using the official Arch kernel PKGBUILD (edit PKGBUILD make localmodconfig)
      • Enable multi-threading compilation: edit PKGBUILD with make -j$(nproc) in build()
      • (Re)build the kernel: makepkg -efsi
      • Reboot and test
        • cd src/linux-torvalds/
        • If it was working: git bisect good
        • If it was failing: git bisect bad
        • Start again until bisecting ends
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment