.deb nightlybuild script: No more warning about using --ignore=wrongdistribution
[conkeror.git] / contrib / debian / nightlybuild.sh
blob54902e75d63ffa98cde9d3c4a3d7a76b5f8828b2
1 #!/bin/sh
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
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.
27 # How to use:
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/:
38 # # -*- sh -*-
39 # WORKDIR=$HOME/conkeror.nightly
40 # CONTACT=abe+conkeror-nightly@noone.org
41 # SIGNKEY=373B76B4
42 # UPLOAD=yes
43 # UPLOAD_SSH_KEY=~/.ssh/id_rsa.conkeror-nightly
44 # UPLOAD_SSH_HOST=noone.org
45 # UPLOAD_SSH_USER=abe
46 # UPLOAD_SSH_DIR=http/htdocs/conkeror-nightly
47 # USE_REPREPRO=yes
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/:
53 # # -*- sh -*-
54 # WORKDIR=$HOME/conkeror.nightly
55 # CONTACT=abe+conkeror-nightly@noone.org
56 # SIGNKEY=373B76B4
57 # UPLOAD=yes
58 # UPLOAD_SSH_KEY=~/.ssh/id_rsa.conkeror-nightly
59 # UPLOAD_SSH_HOST=noone.org
60 # UPLOAD_SSH_USER=abe
61 # UPLOAD_SSH_DIR=http/htdocs/conkeror-nightly
62 # USE_REPREPRO=yes
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.
73 set -e
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"
79 exit 1
81 . $RCFILE
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
86 exit 2
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
96 mkdir -p "$WORKDIR"
99 # Define places and version number
100 MASTERDIR=$WORKDIR/MASTER
101 BUILDDIR=$WORKDIR/BUILD
102 DATE=`date -R`
103 ZULUTIME=`date -u +%y%m%d%H%M`
105 # Create build dir
106 mkdir -p $BUILDDIR
108 # Remove old builds
109 rm -rf $BUILDDIR/*
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
116 SOURCESTMP=`mktemp`
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
127 else
128 echo Unsupported suffix $SOURCEENC in "$SOURCES_LIST_URL" 1>&2
129 exit 1;
131 rm -vf $SOURCESTMPENC
132 else
133 wget -O $SOURCESTMP "$SOURCES_LIST_URL";
136 # Find package in Sources file
137 INFOTMP=`mktemp`
138 grep-dctrl -S conkeror $SOURCESTMP | sort-dctrl -k Version:v - | \
139 grep-dctrl -s Checksums-Sha256,Directory conkeror - > $INFOTMP
140 rm -vf $SOURCESTMP
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
148 cd "$BUILDDIR"
149 dget -u "$DSC"
151 # Determine the correct version
152 RELEASE="`gpg < \"${DSC##*/}\" 2>&1 | grep-dctrl -s Version conkeror - | \
153 awk '{print $2}'`"
154 VERSION="`echo \"$RELEASE\" | sed -e 's/-.*$//'`"
155 DATEDIR="$BUILDDIR/conkeror-$VERSION"
157 WHATTOBUILD=-B
158 else
159 # Check if MASTER directory exists, if not, create it (untested code!)
160 cd $WORKDIR
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"
171 # Update master copy
172 cd $MASTERDIR
173 git pull
175 # Determine the correct version
176 VERSION=`grep ^Version= $MASTERDIR/application.ini | \
177 sed -e 's/^Version=//;s/\(pre\)/~~\1/;s/\(rc\|b\|a\)/~\1/'`+git$ZULUTIME
178 RELEASE="$VERSION-~nightly1"
179 DATEDIR="$BUILDDIR/conkeror-$VERSION"
181 # Copy tree into build environment
182 cp -priv $MASTERDIR $DATEDIR
184 # Build orig.tar.gz
185 cd $BUILDDIR
186 tar cvzf conkeror_$VERSION.orig.tar.gz --exclude=.git conkeror-$VERSION
188 # Add an appropriate changelog entry
189 cd $DATEDIR/debian
190 mv changelog changelog.tmp
192 echo "conkeror ($RELEASE) UNRELEASED; urgency=low
194 * Automatically built package based on the state of
195 http://repo.or.cz/w/conkeror.git at $DATE
197 -- Conkeror Nightly Build <$CONTACT> $DATE
198 " > changelog
199 cat changelog.tmp >> changelog
200 rm changelog.tmp
203 # Set the right options for debuild (signed vs unsigned packages)
204 DEBUILDOPTIONS='-uc -us'
205 if [ ! -z "$SIGNKEY" ]; then
206 DEBUILDOPTIONS="-k$SIGNKEY"
209 # Build the package
210 cd $DATEDIR
211 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)(?:$|/.*$)'
213 # Upload the files
214 cd ..
216 if [ "$UPLOAD" = "yes" ]; then
217 if [ "$BINARY_ONLY_BUILD" = "yes" ]; then
218 scp -i $UPLOAD_SSH_KEY -p *build *deb *changes \
219 $UPLOAD_SSH_USER@$UPLOAD_SSH_HOST:$UPLOAD_SSH_DIR
220 if [ "$USE_REPREPRO" = "yes" ]; then
221 ssh -i $UPLOAD_SSH_KEY $UPLOAD_SSH_USER@$UPLOAD_SSH_HOST \
222 "cd $UPLOAD_SSH_DIR; for i in $REPREPRO_DISTS; do reprepro -v includedeb" '$i' *.deb "; done"
224 else
225 scp -i $UPLOAD_SSH_KEY -p *build *deb *changes *dsc *gz \
226 $UPLOAD_SSH_USER@$UPLOAD_SSH_HOST:$UPLOAD_SSH_DIR
228 if [ "$USE_REPREPRO" = "yes" ]; then
229 ssh -i $UPLOAD_SSH_KEY $UPLOAD_SSH_USER@$UPLOAD_SSH_HOST \
230 "cd $UPLOAD_SSH_DIR; for i in $REPREPRO_DISTS; do reprepro -v include" '$i' *.changes "; done"