#! /usr/bin/env bash # Stage or queue build2 packages and distributions. # # -p # Packages only, no baseutils/mingw. # -q # Put packages into the queue instead of staging (distributions still go to # staging). # usage="usage: etc/stage" rsync_ops="--progress" owd=`pwd` trap "{ cd $owd; exit 1; }" ERR set -o errtrace # Trap in functions. function info () { echo "$*" 1>&2; } function error () { info "$*"; exit 1; } v="$(cat build2-toolchain/version)" vf="$(echo $v | sed -re 's/^([^.]*)\.([^.]*)\.([^-]*).*$/\1.\2.\3/')" # Final. if [ -z "$v" -o -z "$vf" ]; then error "unable to extract version from build2-toolchain/version" fi base="y" repo_name="STAGE.BUILD2.ORG" repo_dir="staging/repository/1" repo_host1="stage.build2.org:/var/bpkg/1" repo_host2= while [ $# -gt 0 ]; do case $1 in -p) base=n shift ;; -q) repo_name="CPPGET.ORG/QUEUE" repo_dir="cppget.org/repository/1/queue" repo_host1="cppget.org:/var/bpkg/1/queue" repo_host2="queue.cppget.org:/var/bpkg/1/queue" shift ;; *) error "unexpected $1" ;; esac done mkdir -p "staging/0/$v" # Generate baseutils if requested. # if [ "$base" = "y" ]; then cd private/baseutils echo "$v" >version ./pkdist -n baseutils -d "$vf" -p "$vf/list-i686" \ -c control -s ./pkpost \ -z "/tmp/build2-baseutils-$v-i686-windows" ./pkdist -n baseutils -d "$vf" -p "$vf/list-x86_64" \ -c control -s ./pkpost \ -z "/tmp/build2-baseutils-$v-x86_64-windows" ./pkdist -n mingw -d "mingw-$vf" -p "mingw-$vf/list-i686" \ -c ./control-mingw-i686 -s ./pkpost-mingw -u http://repo.msys2.org/mingw \ -x "/tmp/build2-mingw-$v-i686-windows" ./pkdist -n mingw -d "mingw-$vf" -p "mingw-$vf/list-x86_64" \ -c ./control-mingw-x86_64 -s ./pkpost-mingw -u http://repo.msys2.org/mingw \ -x "/tmp/build2-mingw-$v-x86_64-windows" cd ../.. mv "/tmp/build2-baseutils-$v-i686-windows.zip" "staging/0/$v/" mv "/tmp/build2-baseutils-$v-i686-windows.zip.sha256" "staging/0/$v/" mv "/tmp/build2-baseutils-$v-x86_64-windows.zip" "staging/0/$v/" mv "/tmp/build2-baseutils-$v-x86_64-windows.zip.sha256" "staging/0/$v/" mv "/tmp/build2-mingw-$v-i686-windows.tar.xz" "staging/0/$v/" mv "/tmp/build2-mingw-$v-i686-windows.tar.xz.sha256" "staging/0/$v/" mv "/tmp/build2-mingw-$v-x86_64-windows.tar.xz" "staging/0/$v/" mv "/tmp/build2-mingw-$v-x86_64-windows.tar.xz.sha256" "staging/0/$v/" fi mkdir -p /tmp/dist # Dist build2-toolchain. # # @@ .sha256 sums: make sure they don't contain full paths! b "dist(build2-toolchain-default/)" \ "config.dist.archives=$owd/staging/0/$v/tar.xz $owd/staging/0/$v/tar.gz" cd "$owd/staging/0/$v/" sha256sum -b "build2-toolchain-$v.tar.gz" >"build2-toolchain-$v.tar.gz.sha256" sha256sum -b "build2-toolchain-$v.tar.xz" >"build2-toolchain-$v.tar.xz.sha256" cd "$owd" # Prepare the toolchain.sha256 checksums file. # function checksum_line () # { local s s="$(sed -n -re 's/^([^ ]+) .+$/\1/p' "staging/0/$v/$1.sha256")" echo "$s *$v/$1" >>"staging/0/toolchain.sha256" } echo "# $v" >"staging/0/toolchain.sha256" checksum_line "build2-toolchain-$v.tar.xz" # Must be first. checksum_line "build2-baseutils-$v-x86_64-windows.zip" #checksum_line "build2-mingw-$v-x86_64-windows.tar.xz" #checksum_line "build2-baseutils-$v-i686-windows.zip" #checksum_line "build2-mingw-$v-i686-windows.tar.xz" # Dist individual packages into the repository. # function dist() # { local b="$(basename $1)" local o="$repo_dir/$2" # Clean up old packages. # mkdir -p "$o" rm -f "$o/$b"-* b "dist($1-default/)" "config.dist.archives=$owd/$o/tar.gz" } dist packaging/apr/libapr1 apr dist packaging/postgresql/libpq postgresql dist packaging/sqlite/libsqlite3 sqlite dist packaging/sqlite/sqlite3 sqlite dist ../studxml/libstudxml studxml dist ../odb/builds/default/libodb odb dist ../odb/builds/default/libodb-sqlite odb dist ../odb/builds/default/libodb-pgsql odb dist libbutl build2 dist build2 build2 dist libbpkg build2 dist bpkg build2 dist brep build2 dist libbbot build2 dist bbot build2 # Regenerate the repository. # info "Insert $repo_name signing key and press Enter" read etc/rep-update "$repo_dir/" \ --openssl-option -engine --openssl-option pkcs11 \ --openssl-option -keyform --openssl-option engine \ --key "label_SIGN key" # Sync repository and distribution. # # Note that we do the distribution first so that the toolchain changes are # visible before package changes. This is relied upon by the Build OS monitor. # rsync -v -rlpt -c --copy-unsafe-links --prune-empty-dirs --delete-after \ $rsync_ops staging/0/ stage.build2.org:/var/www/stage.build2.org/public/0/ etc/rep-publish "$repo_dir/" "$repo_host1/" $rsync_ops if [ -n "$repo_host2" ]; then etc/rep-publish "$repo_dir/" "$repo_host2/" $rsync_ops fi