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 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-core
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
20 # If you do only binary rebuilds for other architectures, you do _not_
21 # need to have the nightly builds APT repository in your
22 # /etc/apt/sources.list since we fetch the Sources list manually,
23 # parse it with grep-dctrl and fetch the source package with dget.
28 # Create the file ~/.conkeror-nightlybuildrc and write at least two
29 # lines like the following into it:
31 # WORKDIR=/path/to/the/directory/where/the/builds/should/happen
32 # CONTACT=you@example.com
34 # Example ~/.conkeror-nightlybuildrc similar to the one used for the
35 # initial builds on http://noone.org/conkeror-nightly-debs/:
38 # WORKDIR=$HOME/conkeror.nightly
39 # CONTACT=abe+conkeror-nightly@noone.org
42 # UPLOAD_SSH_KEY=~/.ssh/id_rsa.conkeror-nightly
43 # UPLOAD_SSH_HOST=noone.org
45 # UPLOAD_SSH_DIR=http/htdocs/conkeror-nightly
48 # Example ~/.conkeror-nightlybuildrc similar to the one used for
49 # binary-only builds of conkeror-spawn-process-helper on
50 # http://noone.org/conkeror-nightly-debs/:
53 # WORKDIR=$HOME/conkeror.nightly
54 # CONTACT=abe+conkeror-nightly@noone.org
57 # UPLOAD_SSH_KEY=~/.ssh/id_rsa.conkeror-nightly
58 # UPLOAD_SSH_HOST=noone.org
60 # UPLOAD_SSH_DIR=http/htdocs/conkeror-nightly
62 # REPREPRO_DISTS="lenny squeeze sid"
63 # BINARY_ONLY_BUILD=yes
64 # SOURCES_LIST_URL=http://noone.org/conkeror-nightly-debs/dists/lenny/main/source/Sources.gz
66 # I think the remaining variable names are quite self-explaining. If
67 # not, look at this script's source code (you're doing that already
68 # ;-) and see where they're used. It's not too hard, the script is
69 # fairly small and straight forward. ;-)
71 # Bail out on any error.
74 # Check for the the config file and read it
75 RCFILE
=$HOME/.conkeror-nightlybuildrc
76 if [ ! -s $RCFILE ]; then
77 echo "$RCFILE does not exist or is empty"
82 # Check if a working directory is defined. Bail out if not.
83 if [ -z "$WORKDIR" ]; then
84 echo '$WORKDIR must be defined in '$RCFILE
88 # Check if a contact is defined. Set a dummy value if not.
89 if [ -z "$CONTACT" ]; then
90 CONTACT
=package-builder-has-not-set-contact-address@example.com
93 # Check if $WORKDIR exists, otherwise create it.
94 if [ ! -d "$WORKDIR" ]; then
98 # Define places and version number
99 MASTERDIR
=$WORKDIR/MASTER
100 BUILDDIR
=$WORKDIR/BUILD
102 ZULUTIME
=`date -u +%y%m%d%H%M`
110 # If we just rebuild a nightly snapshot for a new architecture, we
111 # fetch the list of source packages, extract the file name of the
112 # conkeror package out of it and download the appropriate conkeror
113 # source package with dget.
114 if [ "$BINARY_ONLY_BUILD" = "yes" ]; then
117 # Download Sources file
118 SOURCEENC
="${SOURCES_LIST_URL##*.}"
119 if [ -n "$SOURCEENC" ]; then
120 SOURCESTMPENC
=`mktemp`
121 wget
-O $SOURCESTMPENC "$SOURCES_LIST_URL";
122 if [ "$SOURCEENC" = "gz" ]; then
123 zcat
$SOURCESTMPENC > $SOURCESTMP
124 elif [ "$SOURCEENC" = "bz2" ]; then
125 bzcat
$SOURCESTMPENC > $SOURCESTMP
127 echo Unsupported suffix
$SOURCEENC in "$SOURCES_LIST_URL" 1>&2
130 rm -vf $SOURCESTMPENC
132 wget
-O $SOURCESTMP "$SOURCES_LIST_URL";
135 # Find package in Sources file
137 grep-dctrl
-S conkeror
$SOURCESTMP | sort-dctrl
-k Version
:v
- | \
138 grep-dctrl
-s Checksums-Sha256
,Directory conkeror
- > $INFOTMP
141 # Calculate source package URL
142 BASE_URL
="`echo \"$SOURCES_LIST_URL\" | sed -e 's:/dists/.*$::'`"
143 POOL_DIR
="`grep '^Directory:' $INFOTMP | awk '{print $2}'`"
144 DSC
="${BASE_URL}/${POOL_DIR}/`grep '\.dsc$' $INFOTMP | awk '{print $3}'`"
146 # Download source package
150 # Determine the correct version
151 RELEASE
="`gpg < \"${DSC##*/}\" 2>&1 | grep-dctrl -s Version conkeror - | \
153 VERSION
="`echo \"$RELEASE\" | sed -e 's/-.*$//'`"
154 DATEDIR
="$BUILDDIR/conkeror-$VERSION"
158 # Check if MASTER directory exists, if not, create it (untested code!)
160 if [ ! -d $MASTERDIR ]; then
161 git clone git
://repo.or.cz
/conkeror.git
$MASTERDIR
164 # Set the right options for debuild (signed vs unsigned packages)
165 DEBUILDOPTIONS
='-uc -us'
166 if [ ! -z "$SIGNKEY" ]; then
167 DEBUILDOPTIONS
="-k$SIGNKEY"
174 # Determine the correct version
175 VERSION
=`grep ^Version= $MASTERDIR/application.ini | \
176 sed -e 's/^Version=//;s/\(pre\)/~~\1/;s/\(rc\|b\|a\)/~\1/'`+git
$ZULUTIME
177 RELEASE
="$VERSION-~nightly1"
178 DATEDIR
="$BUILDDIR/conkeror-$VERSION"
180 # Copy tree into build environment
181 cp -priv $MASTERDIR $DATEDIR
185 tar cvzf conkeror_
$VERSION.orig.
tar.gz
--exclude=.git conkeror-
$VERSION
187 # Add an appropriate changelog entry
189 mv changelog changelog.tmp
191 echo "conkeror ($RELEASE) UNRELEASED; urgency=low
193 * Automatically built package based on the state of
194 http://repo.or.cz/w/conkeror.git at $DATE
196 -- Conkeror Nightly Build <$CONTACT> $DATE
198 cat changelog.tmp
>> changelog
202 # Set the right options for debuild (signed vs unsigned packages)
203 DEBUILDOPTIONS
='-uc -us'
204 if [ ! -z "$SIGNKEY" ]; then
205 DEBUILDOPTIONS
="-k$SIGNKEY"
210 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)(?:$|/.*$)'
215 if [ "$UPLOAD" = "yes" ]; then
216 if [ "$BINARY_ONLY_BUILD" = "yes" ]; then
217 scp
-i $UPLOAD_SSH_KEY -p *build
*deb
*changes \
218 $UPLOAD_SSH_USER@
$UPLOAD_SSH_HOST:$UPLOAD_SSH_DIR
219 if [ "$USE_REPREPRO" = "yes" ]; then
220 ssh -i $UPLOAD_SSH_KEY $UPLOAD_SSH_USER@
$UPLOAD_SSH_HOST \
221 "cd $UPLOAD_SSH_DIR; for i in $REPREPRO_DISTS; do reprepro --ignore=wrongdistribution -v includedeb" '$i' *.deb
"; done"
224 scp
-i $UPLOAD_SSH_KEY -p *build
*deb
*changes
*dsc
*gz \
225 $UPLOAD_SSH_USER@
$UPLOAD_SSH_HOST:$UPLOAD_SSH_DIR
227 if [ "$USE_REPREPRO" = "yes" ]; then
228 ssh -i $UPLOAD_SSH_KEY $UPLOAD_SSH_USER@
$UPLOAD_SSH_HOST \
229 "cd $UPLOAD_SSH_DIR; for i in $REPREPRO_DISTS; do reprepro --ignore=wrongdistribution -v include" '$i' *.changes
"; done"