summaryrefslogtreecommitdiff
path: root/stage
blob: ecca993045f5824d9d8201d105b51305501cd9fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#! /usr/bin/env bash

# Stage (or queue) build2 packages and distributions.
#
# -t
#    Toolchain only, no brep.
# -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 -e 's/^\(.*\)\.\(.*\)\.\([^-]*\).*$/\1.\2.\3/')" # Final.

if [ -z "$v" -o -z "$vf" ]; then
  error "unable to extract version from `cat build2-toolchain/version`"
fi

toolchain="libbutl build2 libbpkg bpkg"
extras="brep"
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
    -t)
      extras=
      shift
      ;;
    -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

tools="$toolchain $extras"

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

# 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"

# Dist individual packages into the repository.
#
function dist() # <dir> <category>
{
  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

# Regenerate the repository.
#
info "Insert $repo_name signing key and press Enter"
read
etc/rep-update "$repo_dir/" \
 --openssl openssl-1.0.2 \
 --openssl-option -engine --openssl-option pkcs11 \
 --openssl-option -keyform --openssl-option engine \
 --key "label_SIGN key"

# Sync repository and distribution.
#
etc/rep-publish "$repo_dir/" "$repo_host1/" $rsync_ops

if [ -n "$repo_host2" ]; then
  etc/rep-publish "$repo_dir/" "$repo_host2/" $rsync_ops
fi

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/