3 # Script for nightly builds of conkeror .debs
5 # Inspired by an idea of Nicholas A. Zigarovich <nick@servo.cc>
6 # Code by Axel Beckert <abe@deuxchevaux.org>
8 # Copyright (C) 2009-2011, 2014 Axel Beckert <abe@deuxchevaux.org>
10 # Needs the following Debian packages and their dependencies installed
11 # (besides "required" packages like coreutils and conkeror build
12 # dependencies) to work: devscripts, git
14 # If you want to use all features of this script, you need also the
15 # following packages: gnupg, openssh-client, dctrl-tools, gzip, bzip2
17 # And on the machine hosting the APT repository, you'll need the
18 # package reprepro. Configure all distributions with "AlsoAcceptFor:
19 # UNRELEASED experimental unstable sid".
21 # If you do only binary rebuilds for other architectures, you do _not_
22 # need to have the nightly builds APT repository in your
23 # /etc/apt/sources.list since we fetch the Sources list manually,
24 # parse it with grep-dctrl and fetch the source package with dget.
29 # Create the file ~/.conkeror-nightlybuildrc and write at least two
30 # lines like the following into it:
32 # WORKDIR=/path/to/the/directory/where/the/builds/should/happen
33 # CONTACT=you@example.com
35 # Example ~/.conkeror-nightlybuildrc similar to the one used for the
36 # initial builds on http://noone.org/conkeror-nightly-debs/:
39 # WORKDIR=$HOME/conkeror.nightly
40 # CONTACT=abe+conkeror-nightly@noone.org
43 # UPLOAD_SSH_KEY=~/.ssh/id_rsa.conkeror-nightly
44 # UPLOAD_SSH_HOST=noone.org
46 # UPLOAD_SSH_DIR=http/htdocs/conkeror-nightly
49 # Example ~/.conkeror-nightlybuildrc similar to the one used for
50 # binary-only builds of conkeror-spawn-process-helper on
51 # http://noone.org/conkeror-nightly-debs/:
54 # WORKDIR=$HOME/conkeror.nightly
55 # CONTACT=abe+conkeror-nightly@noone.org
58 # UPLOAD_SSH_KEY=~/.ssh/id_rsa.conkeror-nightly
59 # UPLOAD_SSH_HOST=noone.org
61 # UPLOAD_SSH_DIR=http/htdocs/conkeror-nightly
63 # REPREPRO_DISTS="lenny squeeze sid"
64 # BINARY_ONLY_BUILD=yes
65 # SOURCES_LIST_URL=http://noone.org/conkeror-nightly-debs/dists/lenny/main/source/Sources.gz
67 # I think the remaining variable names are quite self-explaining. If
68 # not, look at this script's source code (you're doing that already
69 # ;-) and see where they're used. It's not too hard, the script is
70 # fairly small and straight forward. ;-)
72 # Bail out on any error.
75 # Check for the the config file and read it
76 RCFILE
=$HOME/.conkeror-nightlybuildrc
77 if [ ! -s $RCFILE ]; then
78 echo "$RCFILE does not exist or is empty"
83 # Check if a working directory is defined. Bail out if not.
84 if [ -z "$WORKDIR" ]; then
85 echo '$WORKDIR must be defined in '$RCFILE
89 # Check if a contact is defined. Set a dummy value if not.
90 if [ -z "$CONTACT" ]; then
91 CONTACT
=package-builder-has-not-set-contact-address@example.com
94 # Check if $WORKDIR exists, otherwise create it.
95 if [ ! -d "$WORKDIR" ]; then
99 # Define places and version number
100 MASTERDIR
=$WORKDIR/MASTER
101 BUILDDIR
=$WORKDIR/BUILD
103 ZULUTIME
=`date -u +%y%m%d+%H%M`
111 # If we just rebuild a nightly snapshot for a new architecture, we
112 # fetch the list of source packages, extract the file name of the
113 # conkeror package out of it and download the appropriate conkeror
114 # source package with dget.
115 if [ "$BINARY_ONLY_BUILD" = "yes" ]; then
118 # Download Sources file
119 SOURCEENC
="${SOURCES_LIST_URL##*.}"
120 if [ -n "$SOURCEENC" ]; then
121 SOURCESTMPENC
=`mktemp`
122 wget
-O $SOURCESTMPENC "$SOURCES_LIST_URL";
123 if [ "$SOURCEENC" = "gz" ]; then
124 zcat
$SOURCESTMPENC > $SOURCESTMP
125 elif [ "$SOURCEENC" = "bz2" ]; then
126 bzcat
$SOURCESTMPENC > $SOURCESTMP
128 echo Unsupported suffix
$SOURCEENC in "$SOURCES_LIST_URL" 1>&2
131 rm -vf $SOURCESTMPENC
133 wget
-O $SOURCESTMP "$SOURCES_LIST_URL";
136 # Find package in Sources file
138 grep-dctrl
-S conkeror
$SOURCESTMP | sort-dctrl
-k Version
:v
- | \
139 grep-dctrl
-s Checksums-Sha256
,Directory conkeror
- > $INFOTMP
142 # Calculate source package URL
143 BASE_URL
="`echo \"$SOURCES_LIST_URL\" | sed -e 's:/dists/.*$::'`"
144 POOL_DIR
="`grep '^Directory:' $INFOTMP | awk '{print $2}'`"
145 DSC
="${BASE_URL}/${POOL_DIR}/`grep '\.dsc$' $INFOTMP | awk '{print $3}'`"
147 # Download source package
151 # Determine the correct version
152 RELEASE
="`gpg < \"${DSC##*/}\" 2>&1 | grep-dctrl -s Version conkeror - | \
154 VERSION
="`echo \"$RELEASE\" | sed -e 's/-.*$//'`"
155 DATEDIR
="$BUILDDIR/conkeror-$VERSION"
159 # Check if MASTER directory exists, if not, create it (untested code!)
161 if [ ! -d $MASTERDIR ]; then
162 git clone git
://repo.or.cz
/conkeror.git
$MASTERDIR
165 # Set the right options for debuild (signed vs unsigned packages)
166 DEBUILDOPTIONS
='-uc -us'
167 if [ ! -z "$SIGNKEY" ]; then
168 DEBUILDOPTIONS
="-k$SIGNKEY"
173 PULLOUTPUT
=`git pull`
175 # Only build if something changed
176 if echo "$PULLOUTPUT" | fgrep
-q 'Already up-to-date.'; then
181 # Determine the correct version
182 VERSION
=`grep ^Version= $MASTERDIR/application.ini | \
183 sed -e 's/^Version=//;s/\(pre\)\([0-9]\)/~~\1-\2/;s/\(pre[^-]\)/~~\1/;s/\(rc\|b\|a\)/~\1/'`+git
$ZULUTIME
184 RELEASE
="$VERSION-~nightly1"
185 DATEDIR
="$BUILDDIR/conkeror-$VERSION"
187 # Copy tree into build environment
188 cp -priv $MASTERDIR $DATEDIR
192 tar cvzf conkeror_
$VERSION.orig.
tar.gz
--exclude=.git conkeror-
$VERSION
194 # Add an appropriate changelog entry
196 mv changelog changelog.tmp
198 echo "conkeror ($RELEASE) UNRELEASED; urgency=low
200 * Automatically built package based on the state of
201 http://repo.or.cz/w/conkeror.git at $DATE
203 -- Conkeror Nightly Build <$CONTACT> $DATE
205 cat changelog.tmp
>> changelog
209 # Set the right options for debuild (signed vs unsigned packages)
210 DEBUILDOPTIONS
='-uc -us'
211 if [ ! -z "$SIGNKEY" ]; then
212 DEBUILDOPTIONS
="-k$SIGNKEY"
217 debuild
$DEBUILDOPTIONS $WHATTOBUILD -i'(?:^|/).*~$|(?:^|/)\.#.*$|(?:^|/)\..*\.swp$|(?:^|/),,.*(?:$|/.*$)|(?:^|/)(?:DEADJOE|\.cvsignore|\.arch-inventory|\.bzrignore|\.gitignore|\.hgignore)$|(?:^|/)(?:CVS|RCS|\.deps|\{arch\}|\.arch-ids|\.svn|\.hg|_darcs|\.git|\.shelf|_MTN|\.bzr(?:\.backup|tags)|update\.sh)(?:$|/.*$)'
222 if [ "$UPLOAD" = "yes" ]; then
223 if [ "$BINARY_ONLY_BUILD" = "yes" ]; then
224 scp
-i $UPLOAD_SSH_KEY -p *build
*deb
*changes \
225 $UPLOAD_SSH_USER@
$UPLOAD_SSH_HOST:$UPLOAD_SSH_DIR
226 if [ "$USE_REPREPRO" = "yes" ]; then
227 ssh -i $UPLOAD_SSH_KEY $UPLOAD_SSH_USER@
$UPLOAD_SSH_HOST \
228 "cd $UPLOAD_SSH_DIR; for i in $REPREPRO_DISTS; do reprepro -v includedeb" '$i' *.deb
"; done"
231 scp
-i $UPLOAD_SSH_KEY -p *build
*deb
*changes
*dsc
*gz
*xz \
232 $UPLOAD_SSH_USER@
$UPLOAD_SSH_HOST:$UPLOAD_SSH_DIR
234 if [ "$USE_REPREPRO" = "yes" ]; then
235 ssh -i $UPLOAD_SSH_KEY $UPLOAD_SSH_USER@
$UPLOAD_SSH_HOST \
236 "cd $UPLOAD_SSH_DIR; for i in $REPREPRO_DISTS; do reprepro -v include" '$i' *.changes
"; done"