pthbs

Packaging Through Hashed Build Scripts
git clone https://ccx.te2000.cz/git/pthbs
Log | Files | Refs | Submodules | README

commit c56fb517f5dc9e59e7edd056e407ea7c37616344
parent 3403c81bd5882cd13046ec9c11924146c56bee8a
Author: Jan Pobříslo <ccx@te2000.cz>
Date:   Thu,  7 Dec 2023 23:03:11 +0100

Add script to set shebang, submodules for bzr repos

Diffstat:
M.gitmodules | 18++++++++++++++++++
Afiles/pthbs-banginstall | 32++++++++++++++++++++++++++++++++
Mpackages/default.environment | 1+
Apackages/pthbs-banginstall | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpackages/userspace.environment | 5+++--
Asources/aat | 1+
Asources/confz | 1+
Asources/containers | 1+
Asources/fileset | 1+
Asources/logincaps | 1+
Asources/snaprep | 1+
Atemplates/pkg/pthbs-banginstall | 15+++++++++++++++
Mtemplates/pkg/userspace.environment | 1+
13 files changed, 139 insertions(+), 2 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -62,3 +62,21 @@ [submodule "sources/libcap"] path = sources/libcap url = https://git.kernel.org/pub/scm/libs/libcap/libcap.git +[submodule "sources/aat"] + path = sources/aat + url = /home/ccx/git/bzr-mirror/aat.git/ +[submodule "sources/confz"] + path = sources/confz + url = /home/ccx/git/bzr-mirror/confz.git/ +[submodule "sources/containers"] + path = sources/containers + url = /home/ccx/git/bzr-mirror/containers.git/ +[submodule "sources/fileset"] + path = sources/fileset + url = /home/ccx/git/bzr-mirror/fileset.git/ +[submodule "sources/logincaps"] + path = sources/logincaps + url = /home/ccx/git/bzr-mirror/logincaps.git/ +[submodule "sources/snaprep"] + path = sources/snaprep + url = /home/ccx/git/bzr-mirror/snaprep.git/ diff --git a/files/pthbs-banginstall b/files/pthbs-banginstall @@ -0,0 +1,32 @@ +#!/command/zsh +setopt no_unset extended_glob + +main() { + typeset -g pkg_dir + pkg_dir="$@[-1]" + [[ -d $pkg_dir ]] || exit 1 + local cmd + for cmd in "$@[1,-2]"; do + write_command $cmd + done +} + +write_command() { + (( $# == 1 )) || exit 2 + local script_file shebang interpreter rest + script_file=$1 + [[ -x $script_file ]] || exit 1 + read <$script_file shebang rest + [[ $shebang == '#!/'* ]] || exit 1 + interpreter=${commands[${shebang:t}]:P} + mkdir -p $pkg_dir/command $pkg_dir/deps/command || exit $? + ln -sf $interpreter $pkg_dir/deps/command/${shebang:t} || exit $? + [[ -e $pkg_dir/command/${script_file:t} ]] && exit 1 + cp -a $script_file $pkg_dir/command/${script_file:t} || exit $? + new_sb='#!'${pkg_dir:P}/deps/command/${shebang:t} awk ' + NR==1 { sub("^[^ \t]+", ENVIRON["new_sb"]) } + 1 + ' >$pkg_dir/command/${script_file:t} <$script_file +} + +main "$@" diff --git a/packages/default.environment b/packages/default.environment @@ -16,4 +16,5 @@ #+s6-dns.1fc33e454e4223762ec3ecb16a57fa087dfb77c41ef9a2192fe6374e275b437a #+s6-networking.e4d23d3b419702d6796f46ffe4e07604efe95f9a0ccb3ca3bfa958da368b3a96 #+zsh.8f959a5600b3c3032d95e369169334cdcb92e39be6d1bf9f481bd04b346025f1 +#+pthbs-banginstall.e93c990b3f00675976f37cd063fe0db1f81fb74e856bfb7d76bbf81275a9dc7c #+linux.8eedd5ac58030045509e8362bc29f7ed41dd467d3994202f933726cef5800bbc \ No newline at end of file diff --git a/packages/pthbs-banginstall b/packages/pthbs-banginstall @@ -0,0 +1,63 @@ +#!/usr/bin/env pthbs-build +#+* +#+busybox.74796beee7ee14b0d53a5576d0ec2e2938b951dd9864c233dbc5eb299e47330f +#+zsh.8f959a5600b3c3032d95e369169334cdcb92e39be6d1bf9f481bd04b346025f1 +#@sha256:979284d53c1653d0fbeb96bbf587f66de47d381b852baea2cbccdc75b7ec6fea:pthbs-banginstall + +installdir="$pthbs_destdir//home/ccx/versions/$pthbs_package" +mkdir -p "$installdir/command" +chmod +x pthbs-banginstall +zsh -x pthbs-banginstall pthbs-banginstall "$installdir" + +cd "$pthbs_destdir/home/ccx/versions/$pthbs_package" +find -type d -o -print | awk -F/ ' +BEGIN { + x["./command/pthbs-banginstall"]=1 +} + +function r1(s) { + sub("^[.]/[^/]*", ".", s) + return s +} +function s1(repl, s) { + sub("^[.]/[^/]*", "./"repl, s) + return s +} +function link(src) { + x[$0]=0 + printf "%s\t%s\n", $0, src + printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" +} +$1!="."{exit 1} + + +$2 == "command" { link($0); next } +$2 == "bin" { link(s1("command", $0)); next } + +$2 == "library.so" { link($0); next } +$2 == "library" { link($0); next } +$2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } +$2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next } + +$2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next } + +$2 == "man" { link($0); next } +$2 == "info" { link($0); next } +$2 == "doc" { link($0); next } +$2 == "icons" { link($0); next } +$2 == "terminfo" { link($0); next } + +$2 == "include" { link($0); next } + +{ printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } + +END { + for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } + for(fname in x) { + if(x[fname]) { + printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" + exit 3 + } + } +}' >.install-links.new +mv .install-links.new .install-links diff --git a/packages/userspace.environment b/packages/userspace.environment @@ -15,4 +15,5 @@ #+mdevd.b8212bebb9cb2b009f10357b358501789c2b33f5917f544391ec3e425e3e9716 #+s6-dns.1fc33e454e4223762ec3ecb16a57fa087dfb77c41ef9a2192fe6374e275b437a #+s6-networking.e4d23d3b419702d6796f46ffe4e07604efe95f9a0ccb3ca3bfa958da368b3a96 -#+zsh.8f959a5600b3c3032d95e369169334cdcb92e39be6d1bf9f481bd04b346025f1- \ No newline at end of file +#+zsh.8f959a5600b3c3032d95e369169334cdcb92e39be6d1bf9f481bd04b346025f1 +#+pthbs-banginstall.e93c990b3f00675976f37cd063fe0db1f81fb74e856bfb7d76bbf81275a9dc7c+ \ No newline at end of file diff --git a/sources/aat b/sources/aat @@ -0,0 +1 @@ +Subproject commit 5ce6a6a1224101ce5b0dfec1544a98c94d233ae0 diff --git a/sources/confz b/sources/confz @@ -0,0 +1 @@ +Subproject commit c6aef8098d37a1773439117a5674bfc8662ef62b diff --git a/sources/containers b/sources/containers @@ -0,0 +1 @@ +Subproject commit e1e16c08f53d80d08f0ce9e405115fd650270e6b diff --git a/sources/fileset b/sources/fileset @@ -0,0 +1 @@ +Subproject commit 4cced2cb91b19ebb648b803cfdcc936148cd6f94 diff --git a/sources/logincaps b/sources/logincaps @@ -0,0 +1 @@ +Subproject commit 1e042d5e1ab2b75e28d612b1fd053d92a79bd762 diff --git a/sources/snaprep b/sources/snaprep @@ -0,0 +1 @@ +Subproject commit e9d8af262eb5e25536ea9778e3ed57aebb55488c diff --git a/templates/pkg/pthbs-banginstall b/templates/pkg/pthbs-banginstall @@ -0,0 +1,15 @@ +{% extends "genlinks" %} +{%- block script %} +#+* +#+{{pkg_install_name("busybox")}} +#+{{pkg_install_name("zsh")}} +#@sha256:{{files["pthbs-banginstall"]}}:pthbs-banginstall + +installdir="$pthbs_destdir/{{versions}}/$pthbs_package" +mkdir -p "$installdir/command" +chmod +x pthbs-banginstall +zsh -x pthbs-banginstall pthbs-banginstall "$installdir" +{% endblock %} +{% block genlinks_begin %} + x["./command/pthbs-banginstall"]=1 +{% endblock %} diff --git a/templates/pkg/userspace.environment b/templates/pkg/userspace.environment @@ -16,3 +16,4 @@ #+{{pkg_install_name("s6-dns")}} #+{{pkg_install_name("s6-networking")}} #+{{pkg_install_name("zsh")}} +#+{{pkg_install_name("pthbs-banginstall")}}