commit 17fb07f32e087c47d15dba48359d107779c36dda
parent 67bf92501ba4303fdea27f8bea9f879a7ecc8e4c
Author: ccx <root@dorje.wpr.cz>
Date: Fri, 18 Feb 2022 18:08:54 +0100
Work on bzr support
Diffstat:
2 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/install b/install
@@ -6,11 +6,22 @@ zmodload zsh/zutil || exit $?
cd $0:h || exit $?
+die_ret() {
+ local ret
+ ret=$1
+ shift
+ echo >&2 "$@"
+ exit $ret
+}
+die() {
+ die_ret 1 "$@"
+}
+
require() {
if ! check_$1; then
make_$1
if ! check_$1; then
- echo "ERROR: check_$1 failed after make_$1"
+ die "ERROR: check_$1 failed after make_$1"
fi
fi
}
@@ -76,6 +87,7 @@ install_dot() {
done
s6-mkdir -p ${sm_dst[.]}/command || exit $?
+ install_bzr_repos
cd ${sm_dst[.]} || exit $?
ln_from_sub package package package
ln_sub_command package
@@ -143,6 +155,41 @@ submodule() {
}
#typeset -f -t submodule
+check_bzr_export() {
+ [[ -d ${bzr_dst} ]]
+}
+make_bzr_export() {
+ local tmp=$bzr_dst:h/.new.$bzr_dst:t
+ brz export --format=dir --revision=revid:$bzr_revid -d "$bzr_src" $tmp/ || exit $?
+ mv $tmp $bzr_dst
+}
+
+install_bzr_repo(){
+ typeset -g bzr_dst bzr_revid bzr_src
+ bzr_dst=/versions/$1.$2
+ bzr_revid=$2
+ bzr_src=$3
+
+ local cmd
+ for cmd in $bzr_dest/{command,bin,sbin}/*(N); do
+ s6-ln -s ../$cmd $sm_dst[.]/command/ || exit $?
+ done
+}
+install_bzr_repos(){
+ local name url revid
+ local -A repo_sources
+ <./bzr/sources while IFS=$'\t' read name url; do
+ [[ -n "$name" && -n "$url" ]] || die "Malformed bzr/sources file"
+ (( $+repo_sources[$name] )) && die "Duplicate repo name: ${(qqq)name}"
+ repo_sources[$name]=$url
+ repos+=( $name )
+ done
+ <./bzr/revisions while IFS=$'\t' read name revid; do
+ [[ -n "$name" && -n "$revid" ]] || die "Malformed revisions file"
+ install_bzr_repo "$name" "$revid" "$repo_sources[$name]"
+ done
+}
+
# End of functions, now install things in right order
typeset -g submodule
diff --git a/update-bzr b/update-bzr
@@ -135,9 +135,9 @@ prompt_commit() {
"Changed: "$^repos_modified
"Deleted: "$^repos_deleted
)
- pretend mv -v ./bzr/revisions.new ./bzr/revisions || exit $?
- pretend git add ./bzr/revisions || exit $?
- pretend git commit -m "${(F)msg}" ./bzr/revisions || exit $?
+ mv -v ./bzr/revisions.new ./bzr/revisions || exit $?
+ git add ./bzr/revisions || exit $?
+ git commit -m "${(F)msg}" ./bzr/revisions || exit $?
}
main() {