@@ -3,15 +3,15 @@ set -euo pipefail
33
44PATH=@path@
55
6- if [[ $# -ne 2 ]]; then
6+ if [[ $# -ne 2 ]] && [[ $# -ne 1 ]] ; then
77 cat >&2 << EOF
88
9- USAGE: nix run .#deploy -- <public_url> < rsync_target>
9+ USAGE: nix run .#deploy -- <public_url> [ rsync_target]
1010
1111Builds bootstrap zip ball and source code tar ball (for usage as a channel or
12- flake) and uploads it to the directory specified in <rsync_target>. The
13- contents of this directory should be reachable by the android device with
14- < public_url> .
12+ flake). If rsync_target is specified, uploads it to the directory specified
13+ in rsync_target. The contents of this directory should be reachable by the
14+ android device with public_url.
1515
1616Examples:
1717$ nix run .#deploy -- 'https://example.com/bootstrap/source.tar.gz' 'user@host:/path/to/bootstrap'
2222fi
2323
2424PUBLIC_URL=" $1 "
25- RSYNC_TARGET=" $2 "
25+ if [[ $# == 2 ]]; then
26+ RSYNC_TARGET=" $2 "
27+ else
28+ RSYNC_TARGET=" "
29+ fi
2630: ${ARCHES:= aarch64 x86_64}
2731
2832# this allows to run this script from every place in this git repo
@@ -51,27 +55,45 @@ if [[ "$PUBLIC_URL" =~ ^file:///(.*)/archive.tar.gz ]]; then
5155else
5256 export NIX_ON_DROID_FLAKE_URL=" $PUBLIC_URL "
5357fi
58+ export NIX_ON_DROID_BASE_URL=" ${PUBLIC_URL%/* } "
59+
5460log " NIX_ON_DROID_CHANNEL_URL=$NIX_ON_DROID_CHANNEL_URL "
5561log " NIX_ON_DROID_FLAKE_URL=$NIX_ON_DROID_FLAKE_URL "
62+ log " NIX_ON_DROID_BASE_URL=$NIX_ON_DROID_BASE_URL "
5663
57-
58- PROOT_HASH_FILE=" modules/environment/login/default.nix"
5964UPLOADS=()
6065for arch in $ARCHES ; do
6166 log " building $arch proot..."
6267 proot=" $( nix build --no-link --print-out-paths " .#prootTermux-${arch} " ) "
68+ proot_hash=" $( nix-hash --type sha256 --sri " $proot " /bin/proot-static) "
69+ attrs_file=" modules/environment/login/proot-attrs/$arch .nix"
70+ new_attrs_file=" $( mktemp) "
71+
72+ cat > $new_attrs_file << EOF
73+ # WARNING: This file is autogenerated by the deploy script. Any changes will be overridden
74+ {
75+ url = "$NIX_ON_DROID_BASE_URL /bootstrap-$arch .zip";
76+ hash = "$proot_hash ";
77+ }
78+ EOF
6379
64- if grep -q " $arch -linux = \" $proot \" ;" " $PROOT_HASH_FILE " ; then
65- log " keeping $arch proot path in $PROOT_HASH_FILE "
66- elif grep -q " $arch -linux = \" /nix/store/" " $PROOT_HASH_FILE " ; then
67- log " patching $arch proot path in $PROOT_HASH_FILE ..."
68- grep " $arch -linux = \" /nix/store/" " $PROOT_HASH_FILE "
69- sed -i " s|$arch -linux = \" /nix/store/.*\" ;|$arch -linux = \" $proot \" ;|" " $PROOT_HASH_FILE "
70- log " ->"
71- grep " $arch -linux = \" /nix/store/" " $PROOT_HASH_FILE "
80+ if [[ ! -f $attrs_file ]]; then
81+ log " warn: $attrs_file not present; creating"
82+ mv $new_attrs_file $attrs_file
83+ log " adding $attrs_file to git index"
84+ git add $attrs_file
85+ elif diff $attrs_file $new_attrs_file > /dev/null; then
86+ log " no changes needed to $attrs_file "
7287 else
73- log " no $arch proot hash found in $PROOT_HASH_FILE !"
74- exit 1
88+ log " updating contents of $attrs_file "
89+ echo " <<<<<<"
90+ cat $attrs_file
91+ echo " ======"
92+ mv $new_attrs_file $attrs_file
93+ cat $attrs_file
94+ echo " >>>>>>"
95+ log " adding $attrs_file to git index"
96+ git add $attrs_file
7597 fi
7698
7799 log " building $arch bootstrapZip..."
@@ -86,4 +108,8 @@ UPLOADS+=($SOURCE_FILE)
86108
87109
88110log " uploading artifacts..."
89- rsync --progress " ${UPLOADS[@]} " " $RSYNC_TARGET "
111+ if [[ -n " $RSYNC_TARGET " ]]; then
112+ rsync --progress " ${UPLOADS[@]} " " $RSYNC_TARGET "
113+ else
114+ echo " Would have uploaded ${UPLOADS[@]} "
115+ fi
0 commit comments