debian/contrib/update.sh now accepts an upstream version as parameter
[conkeror.git] / contrib / debian / nightlybuild.sh
blob4db42969195d9411d199a3e189704ef40f8de2f8
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 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
17 # And on the machine hosting the APT repository, you'll need the
18 # package reprepro.
20 # How to use:
22 # Create the file ~/.conkeror-nightlybuildrc and write at least a line
23 # like the following into it:
25 # WORKDIR=/path/to/the/directory/where/the/builds/should/happen
27 # Example ~/.conkeror-nightlybuildrc similar to the one used for
28 # http://noone.org/conkeror-nightly-debs/:
30 # # -*- sh -*-
31 # WORKDIR=$HOME/conkeror.nightly
32 # SIGNKEY=373B76B4
33 # UPLOAD=yes
34 # UPLOAD_SSH_KEY=~/.ssh/id_rsa.conkeror-nightly
35 # UPLOAD_SSH_HOST=noone.org
36 # UPLOAD_SSH_USER=abe
37 # UPLOAD_SSH_DIR=http/htdocs/conkeror-nightly
38 # USE_REPREPRO=yes
40 # I think the remaining variable names are quite self-explaining. If
41 # not, look at this script's source code (you're doing that already
42 # ;-) and see where they're used. It's not too hard, the script is
43 # fairly small and straight forward. ;-)
45 # Bail out on any error.
46 set -e
48 # Check for the the config file and read it
49 RCFILE=$HOME/.conkeror-nightlybuildrc
50 if [ ! -s $RCFILE ]; then
51 echo "$RCFILE does not exist or is empty"
52 exit 1
54 . $RCFILE
56 # Check if a working directory is defined. Bail out if not.
57 if [ -z "$WORKDIR" ]; then
58 echo '$WORKDIR must be defined in '$RCFILE
59 exit 2
62 # Check if $WORKDIR exists, otherwise create it.
63 if [ ! -d "$WORKDIR" ]; then
64 mkdir -p "$WORKDIR"
67 # Define places and version number
68 MASTERDIR=$WORKDIR/MASTER
69 BUILDDIR=$WORKDIR/BUILD
70 UNIXTIME=`date +%s`
71 DATE=`date -R`
73 # Check if MASTER directory exists, if not, create it (untested code!)
74 cd $WORKDIR
75 if [ ! -d $MASTERDIR ]; then
76 git clone git://repo.or.cz/conkeror.git $MASTERDIR
79 # Set the right options for debuild (signed vs unsigned packages)
80 DEBUILDOPTIONS='-uc -us'
81 if [ ! -z "$SIGNKEY" ]; then
82 DEBUILDOPTIONS="-k$SIGNKEY"
85 # Update master copy
86 cd $MASTERDIR
87 git pull
89 # Determine the correct version
90 VERSION=`grep ^Version= $MASTERDIR/application.ini | \
91 sed -e 's/^Version=//'`+git`date +%y%m%d`
92 RELEASE=$VERSION-~nightlybuild$UNIXTIME
93 DATEDIR=$BUILDDIR/conkeror-$VERSION
95 # Create build dir
96 mkdir -p $BUILDDIR
98 # Remove old builds
99 rm -rf $BUILDDIR/*
101 # Copy tree into build environment
102 cp -priv $MASTERDIR $DATEDIR
104 # Build orig.tar.gz
105 cd $BUILDDIR
106 tar cvzf conkeror_$VERSION.orig.tar.gz --exclude=.git conkeror-$VERSION
108 # Add an appropriate changelog entry
109 cd $DATEDIR/debian
110 mv changelog changelog.tmp
111 echo "conkeror ($RELEASE) UNRELEASED; urgency=low
113 * Automatically built package based on the state of
114 http://repo.or.cz/w/conkeror.git at $DATE
116 -- Conkeror Nightly Build <abe+conkeror-nightly@deuxchevaux.org> $DATE
117 " > changelog
118 cat changelog.tmp >> changelog
119 rm changelog.tmp
121 # Build the package
122 cd ..
123 debuild $DEBUILDOPTIONS -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)(?:$|/.*$)'
125 # Upload the files
126 cd ..
128 if [ "$UPLOAD" = "yes" ]; then
129 scp -i $UPLOAD_SSH_KEY -p *build *deb *changes *dsc *gz \
130 $UPLOAD_SSH_USER@$UPLOAD_SSH_HOST:$UPLOAD_SSH_DIR
132 if [ "$USE_REPREPRO" = "yes" ]; then
133 ssh -i $UPLOAD_SSH_KEY $UPLOAD_SSH_USER@$UPLOAD_SSH_HOST \
134 "cd $UPLOAD_SSH_DIR; reprepro -v includedeb lenny" *.deb "; reprepro -v includedeb sid" *.deb "; reprepro -v includedsc lenny " *.dsc "; reprepro -v includedsc sid " *.dsc ";"