commit c6abeb3ac27bdaa4ca17ab49f422a9318860c754
parent 5c9723e3378ec351a025cbad714b55061d50f535
Author: Jan Pobříslo <ccx@te2000.cz>
Date: Wed, 31 May 2023 13:38:31 +0200
Preliminary support for default environment
Diffstat:
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,6 +1,12 @@
VERSIONS:=$(HOME)/versions
+CURRENT:=$(HOME)/current
+CURRENT_ENV:=$(shell pthbs-getenvhash environments/current)
-test: /home/ccx/versions/environment.12345678990/.env
+current: $(VERSIONS)/env.$(CURRENT_ENV)/.pthbs-env
+ @if cmp -s '$(VERSIONS)/env.$(CURRENT_ENV)/.pthbs-env' '$(CURRENT)/.pthbs-env'; then echo "Already installed!"; else \
+ ln -vTsf '$(VERSIONS)/env.$(CURRENT_ENV)' '$(CURRENT)' && \
+ cp -va environments/current "environments/installed.$(date +%s)" \
+ fi
$(VERSIONS)/environment.%/.env:
@echo mkdir "$$(dirname '$@')"
@@ -13,5 +19,6 @@ make/package.%.mk: packages/%
pkg_files=$(wildcard packages/*)
+env_files=$(wildcard environments/*)
mk_files=$(patsubst packages/%,make/package.%.mk,$(pkg_files))
include $(mk_files)
diff --git a/command/pthbs-install b/command/pthbs-install
@@ -1,7 +1,6 @@
#!/bin/sh -e
set -x
pthbs_versions=/home/ccx/versions
-pthbs_linkdir=$pthbs_versions/all.unversioned
test "$#" -eq 2 || exit 2
@@ -20,9 +19,8 @@ if test -e "$pthbs_versions/$pthbs_package"; then
done
echo >&2 "INFO: replacing previous package"
mv "$pthbs_versions/$pthbs_package" "$pthbs_versions/$pthbs_package.$N"
+ # remove dangling links
+ find "$pthbs_versions" -type l ! -exec test -e {} \; -exec rm -v {} +
fi
-# remove dangling links
-find "$pthbs_versions" -type l ! -exec test -e {} \; -exec rm -v {} +
mv "$pthbs_destdir/${pthbs_versions%/}/$pthbs_package" "$pthbs_versions/$pthbs_package"
-exec pthbs-link "$pthbs_versions/$pthbs_package" "$pthbs_linkdir"
diff --git a/command/pthbs-makegen b/command/pthbs-makegen
@@ -104,7 +104,7 @@ function have_envdep(package) {
for(n=1; n<=env_count; n++) {
printf "\n\t%s", "pthbs-link "q("$(VERSIONS)/"env[n])" "q("$(VERSIONS)/env."envhash)
}
- printf "\n\t%s\n\n", "touch "q("$@")
+ printf "\n\t%s\n\n", "sort -u <"q(envfile)" >"q("$@")
}
if(dep_count) {
@@ -112,7 +112,7 @@ function have_envdep(package) {
for(n=1; n<=dep_count; n++) {
printf " %s", dep[n]
}
- printf "\n\t%s\n\n", "pthbs-build "q(ENVIRON["script"])
+ printf "\n\t%s\n", "pthbs-build "q(ENVIRON["script"])
}
exit 0
}