new-tabs: fix bug in tab_bar_kill_buffer
[conkeror.git] / contrib / debian / nightlybuild.sh
blobc9347f98cf15c651604dca951c97daf40c5e1ef0
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, 2010 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.
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.
26 # How to use:
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/:
37 # # -*- sh -*-
38 # WORKDIR=$HOME/conkeror.nightly
39 # CONTACT=abe+conkeror-nightly@noone.org
40 # SIGNKEY=373B76B4
41 # UPLOAD=yes
42 # UPLOAD_SSH_KEY=~/.ssh/id_rsa.conkeror-nightly
43 # UPLOAD_SSH_HOST=noone.org
44 # UPLOAD_SSH_USER=abe
45 # UPLOAD_SSH_DIR=http/htdocs/conkeror-nightly
46 # USE_REPREPRO=yes
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/:
52 # # -*- sh -*-
53 # WORKDIR=$HOME/conkeror.nightly
54 # CONTACT=abe+conkeror-nightly@noone.org
55 # SIGNKEY=373B76B4
56 # UPLOAD=yes
57 # UPLOAD_SSH_KEY=~/.ssh/id_rsa.conkeror-nightly
58 # UPLOAD_SSH_HOST=noone.org
59 # UPLOAD_SSH_USER=abe
60 # UPLOAD_SSH_DIR=http/htdocs/conkeror-nightly
61 # USE_REPREPRO=yes
62 # BINARY_ONLY_BUILD=yes
63 # SOURCES_LIST_URL=http://noone.org/conkeror-nightly-debs/dists/lenny/main/source/Sources.gz
65 # I think the remaining variable names are quite self-explaining. If
66 # not, look at this script's source code (you're doing that already
67 # ;-) and see where they're used. It's not too hard, the script is
68 # fairly small and straight forward. ;-)
70 # Bail out on any error.
71 set -e
73 # Check for the the config file and read it
74 RCFILE=$HOME/.conkeror-nightlybuildrc
75 if [ ! -s $RCFILE ]; then
76 echo "$RCFILE does not exist or is empty"
77 exit 1
79 . $RCFILE
81 # Check if a working directory is defined. Bail out if not.
82 if [ -z "$WORKDIR" ]; then
83 echo '$WORKDIR must be defined in '$RCFILE
84 exit 2
87 # Check if a contact is defined. Set a dummy value if not.
88 if [ -z "$CONTACT" ]; then
89 CONTACT=package-builder-has-not-set-contact-address@example.com
92 # Check if $WORKDIR exists, otherwise create it.
93 if [ ! -d "$WORKDIR" ]; then
94 mkdir -p "$WORKDIR"
97 # Define places and version number
98 MASTERDIR=$WORKDIR/MASTER
99 BUILDDIR=$WORKDIR/BUILD
100 UNIXTIME=`date +%s`
101 DATE=`date -R`
103 # Create build dir
104 mkdir -p $BUILDDIR
106 # Remove old builds
107 rm -rf $BUILDDIR/*
109 # If we just rebuild a nightly snapshot for a new architecture, we
110 # fetch the list of source packages, extract the file name of the
111 # conkeror package out of it and download the appropriate conkeror
112 # source package with dget.
113 if [ "$BINARY_ONLY_BUILD" = "yes" ]; then
114 SOURCESTMP=`mktemp`
116 # Download Sources file
117 SOURCEENC="${SOURCES_LIST_URL##*.}"
118 if [ -n "$SOURCEENC" ]; then
119 SOURCESTMPENC=`mktemp`
120 wget -O $SOURCESTMPENC "$SOURCES_LIST_URL";
121 if [ "$SOURCEENC" = "gz" ]; then
122 zcat $SOURCESTMPENC > $SOURCESTMP
123 elif [ "$SOURCEENC" = "bz2" ]; then
124 bzcat $SOURCESTMPENC > $SOURCESTMP
125 else
126 echo Unsupported suffix $SOURCEENC in "$SOURCES_LIST_URL" 1>&2
127 exit 1;
129 rm -vf $SOURCESTMPENC
130 else
131 wget -O $SOURCESTMP "$SOURCES_LIST_URL";
134 # Find package in Sources file
135 INFOTMP=`mktemp`
136 grep-dctrl -S conkeror $SOURCESTMP | sort-dctrl -k Version:v - | \
137 grep-dctrl -s Checksums-Sha256,Directory conkeror - > $INFOTMP
138 rm -vf $SOURCESTMP
140 # Calculate source package URL
141 BASE_URL="`echo \"$SOURCES_LIST_URL\" | sed -e 's:/dists/.*$::'`"
142 POOL_DIR="`grep '^Directory:' $INFOTMP | awk '{print $2}'`"
143 DSC="${BASE_URL}/${POOL_DIR}/`grep '\.dsc$' $INFOTMP | awk '{print $3}'`"
145 # Download source package
146 cd "$BUILDDIR"
147 dget -u "$DSC"
149 # Determine the correct version
150 RELEASE="`gpg < \"${DSC##*/}\" 2>&1 | grep-dctrl -s Version conkeror - | \
151 awk '{print $2}'`"
152 VERSION="`echo \"$RELEASE\" | sed -e 's/-.*$//'`"
153 DATEDIR="$BUILDDIR/conkeror-$VERSION"
155 WHATTOBUILD=-B
156 else
157 # Check if MASTER directory exists, if not, create it (untested code!)
158 cd $WORKDIR
159 if [ ! -d $MASTERDIR ]; then
160 git clone git://repo.or.cz/conkeror.git $MASTERDIR
163 # Update master copy
164 cd $MASTERDIR
165 git pull
167 # Determine the correct version
168 VERSION=`grep ^Version= $MASTERDIR/application.ini | \
169 sed -e 's/^Version=//'`+git`date +%y%m%d`
170 RELEASE="$VERSION-~nightlybuild$UNIXTIME"
171 DATEDIR="$BUILDDIR/conkeror-$VERSION"
173 # Copy tree into build environment
174 cp -priv $MASTERDIR $DATEDIR
176 # Build orig.tar.gz
177 cd $BUILDDIR
178 tar cvzf conkeror_$VERSION.orig.tar.gz --exclude=.git conkeror-$VERSION
180 # Add an appropriate changelog entry
181 cd $DATEDIR/debian
182 mv changelog changelog.tmp
184 echo "conkeror ($RELEASE) UNRELEASED; urgency=low
186 * Automatically built package based on the state of
187 http://repo.or.cz/w/conkeror.git at $DATE
189 -- Conkeror Nightly Build <$CONTACT> $DATE
190 " > changelog
191 cat changelog.tmp >> changelog
192 rm changelog.tmp
195 # Set the right options for debuild (signed vs unsigned packages)
196 DEBUILDOPTIONS='-uc -us'
197 if [ ! -z "$SIGNKEY" ]; then
198 DEBUILDOPTIONS="-k$SIGNKEY"
201 # Build the package
202 cd $DATEDIR
203 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)(?:$|/.*$)'
205 # Upload the files
206 cd ..
208 if [ "$UPLOAD" = "yes" ]; then
209 if [ "$BINARY_ONLY_BUILD" = "yes" ]; then
210 scp -i $UPLOAD_SSH_KEY -p *build *deb *changes \
211 $UPLOAD_SSH_USER@$UPLOAD_SSH_HOST:$UPLOAD_SSH_DIR
212 if [ "$USE_REPREPRO" = "yes" ]; then
213 ssh -i $UPLOAD_SSH_KEY $UPLOAD_SSH_USER@$UPLOAD_SSH_HOST \
214 "cd $UPLOAD_SSH_DIR; reprepro -v includedeb lenny" *.deb "; reprepro -v includedeb sid" *.deb ";"
216 else
217 scp -i $UPLOAD_SSH_KEY -p *build *deb *changes *dsc *gz \
218 $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; reprepro -v includedeb lenny" *.deb "; reprepro -v includedeb sid" *.deb "; reprepro -v includedsc lenny " *.dsc "; reprepro -v includedsc sid " *.dsc ";"