pthbs_genpkgpy

Template engine for producing packages for pthbs written using Python and Jinja
git clone https://ccx.te2000.cz/git/pthbs_genpkgpy
Log | Files | Refs | Submodules | README

commit de1b2787ee38de63b6ed7b2a8d91d0c943f93161
parent 6ebe9b547ece64b464f1a368024236c8c2602e1f
Author: Jan Pobříslo <ccx@te2000.cz>
Date:   Fri, 23 Feb 2024 19:00:57 +0100

Replace pthbs-enter package with in-make generator call

Diffstat:
Acommand/pthbs-enter-gen | 30++++++++++++++++++++++++++++++
Mcommand/pthbs-makegen | 2+-
Mpackages/default.environment | 1-
Dpackages/pthbs-enter | 81-------------------------------------------------------------------------------
Mpackages/userspace.environment | 1-
Dtemplates/pkg/pthbs-enter | 33---------------------------------
Mtemplates/pkg/userspace.environment | 1-
7 files changed, 31 insertions(+), 118 deletions(-)

diff --git a/command/pthbs-enter-gen b/command/pthbs-enter-gen @@ -0,0 +1,30 @@ +#!/bin/sh -e +if test $# != 1; then + printf >2 'usage: %s\n' "pthbs-enter-gen /path/to/env.hash" + printf >2 'Error: expected 1 argument, got%s\n' "$#" + exit 2 +fi +envtop=$1 +envcommand=$1/command +envdir=$envtop/env +exe=$envcommand/command/pthbs-enter + +case $(dirname "$envtop") in + (env.*) ;; + (*) + printf >&2 "Error: '%s' doesn't look like environment path!\n" "$envtop" + exit 1;; +esac + +if ! test -e "$envcommand"; then + printf >&2 "Error: '%s' doesn't exist!\n" "$envcommand" +fi +mkdir -p "$envdir" +printf '%s\n' "$envcommand" >"$envdir/PATH" + +cat >"$exe"-enter <<EOF +#!$envcommand/execlineb -S0 +"$envcommand/s6-envdir" "$envdir" "$envcommand/exec" \$@ +EOF +chmod +x "$exe" +./"$exe" true diff --git a/command/pthbs-makegen b/command/pthbs-makegen @@ -84,7 +84,7 @@ function make_envfile( n, envfile, envhash) { printf "\n\t@%s", "printf "q("Creating environment for %s => %s\\n")" "q(FILENAME)" "q("$(VERSIONS)/env."envhash) printf "\n\t%s", "if test -e "q("$(VERSIONS)/env."envhash)"; then rm -r "q("$(VERSIONS)/env."envhash)"; fi" printf "\n\t%s", "mkdir -p "q("$(VERSIONS)/env."envhash"/env") - printf "\n\t%s", "printf \"%s\\n\" >"q("$(VERSIONS)/env."envhash"/env/PATH")" "q("$(VERSIONS)/env."envhash"/command") + printf "\n\t%s", "pthbs-enter-gen "q("$(VERSIONS)/env."envhash) for(n=1; n<=env_count; n++) { printf "\n\t%s", "pthbs-link "q("$(VERSIONS)/"env[n])" "q("$(VERSIONS)/env."envhash) } diff --git a/packages/default.environment b/packages/default.environment @@ -18,7 +18,6 @@ #+s6-networking.d30d0310f70a9af097cc2d98e7a97e329a626b005cb0b49247ce6cdaec251956 #+zsh.841d7010e0fe14991eb6173c03fd35eecda23c9693da65d121af20615e0dc5a0 #+pthbs-banginstall.849e1bc924bc7d9eff0c2ce1c3a44bf38afbf6b2a5f1dfbea7c077f886646e7b -#+pthbs-enter.eb57ee4bac604d6af16e14c173e06f340008989ff6f68874cd7039e260fbf4ef #+aat.9da7c8dd0936f2dcfd534a0473da1b730e29946cdd4db133659a1a35f0b53144 #+confz.4d0086594f647e7ab869714ca88253442d1b40f5f66312579521708a9e7cf24e #+containers.b5344393dbacc75ea943cf9119959cad0fc7c7272f7760b99ca67f3d48f7cf09 diff --git a/packages/pthbs-enter b/packages/pthbs-enter @@ -1,81 +0,0 @@ -#!/usr/bin/env pthbs-build -#+busybox.62e4b1201b20ef0faf051b0e9b3ad1d3fbf4d498b8a0910ce4845a9017323f62 -#+s6.be82395a9f4e8e0e08dc9900d7b4959e46db9d13d68355a6c5afebaf9237beb4 -#+execline.09706e0446392c1dc9f3d83c47704aadb8ec15c063317d139d0143cf59349b0f - -envpath=${PATH%%:*} -case "$envpath" in - (*/env.*/command) ;; - (*) - printf "Error: '%s' doesn't look like environment path!\n" "$envpath" - printf "PATH='%s'\n" "$PATH" - exit 2;; -esac -test -x "$envpath/execlineb" || exit $? -test -x "$envpath/s6-envdir" || exit $? -envdir=$(dirname "$envpath")/env -test -f "$envdir/PATH" - -cat >pthbs-enter <<EOF -#!$envpath/execlineb -S0 -"$envpath/s6-envdir" "$envdir" "$envpath/exec" \$@ -EOF -chmod +x pthbs-enter -./pthbs-enter true - -installdir="$pthbs_destdir//home/ccx/versions/$pthbs_package" -mkdir -p "$installdir/command" -mv pthbs-enter "$installdir/command/" - -cd "$pthbs_destdir/home/ccx/versions/$pthbs_package" -find -type d -o -print | awk -F/ ' -BEGIN { - x["./command/pthbs-enter"]=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 @@ -18,7 +18,6 @@ #+s6-networking.d30d0310f70a9af097cc2d98e7a97e329a626b005cb0b49247ce6cdaec251956 #+zsh.841d7010e0fe14991eb6173c03fd35eecda23c9693da65d121af20615e0dc5a0 #+pthbs-banginstall.849e1bc924bc7d9eff0c2ce1c3a44bf38afbf6b2a5f1dfbea7c077f886646e7b -#+pthbs-enter.eb57ee4bac604d6af16e14c173e06f340008989ff6f68874cd7039e260fbf4ef #+aat.9da7c8dd0936f2dcfd534a0473da1b730e29946cdd4db133659a1a35f0b53144 #+confz.4d0086594f647e7ab869714ca88253442d1b40f5f66312579521708a9e7cf24e #+containers.b5344393dbacc75ea943cf9119959cad0fc7c7272f7760b99ca67f3d48f7cf09 diff --git a/templates/pkg/pthbs-enter b/templates/pkg/pthbs-enter @@ -1,33 +0,0 @@ -{% extends "genlinks" %} -{%- block script %} -#+{{pkg_install_name("busybox")}} -#+{{pkg_install_name("s6")}} -#+{{pkg_install_name("execline")}} - -envpath=${PATH%%:*} -case "$envpath" in - (*/env.*/command) ;; - (*) - printf "Error: '%s' doesn't look like environment path!\n" "$envpath" - printf "PATH='%s'\n" "$PATH" - exit 2;; -esac -test -x "$envpath/execlineb" || exit $? -test -x "$envpath/s6-envdir" || exit $? -envdir=$(dirname "$envpath")/env -test -f "$envdir/PATH" - -cat >pthbs-enter <<EOF -#!$envpath/execlineb -S0 -"$envpath/s6-envdir" "$envdir" "$envpath/exec" \$@ -EOF -chmod +x pthbs-enter -./pthbs-enter true - -installdir="$pthbs_destdir/{{versions}}/$pthbs_package" -mkdir -p "$installdir/command" -mv pthbs-enter "$installdir/command/" -{% endblock %} -{% block genlinks_begin %} - x["./command/pthbs-enter"]=1 -{% endblock %} diff --git a/templates/pkg/userspace.environment b/templates/pkg/userspace.environment @@ -18,7 +18,6 @@ #+{{pkg_install_name("s6-networking")}} #+{{pkg_install_name("zsh")}} #+{{pkg_install_name("pthbs-banginstall")}} -#+{{pkg_install_name("pthbs-enter")}} #+{{pkg_install_name("aat")}} #+{{pkg_install_name("confz")}} #+{{pkg_install_name("containers")}}