Adding a ~ to the Debian release number of the nightly builds
[conkeror/arlinius.git] / contrib / debian / nightlybuild.sh
blob5bac86fd121ec7a829193f48da66cf503c84623a
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 VERSION=0.9~git`date +%y%m%d`
72 RELEASE=$VERSION-~nightlybuild$UNIXTIME
73 DATEDIR=$BUILDDIR/conkeror-$VERSION
74 DATE=`date -R`
76 # Check if MASTER directory exists, if not, create it (untested code!)
77 cd $WORKDIR
78 if [ ! -d $MASTERDIR ]; then
79 git clone git://repo.or.cz/conkeror.git $MASTERDIR
82 # Set the right options for debuild (signed vs unsigned packages)
83 DEBUILDOPTIONS='-uc -us'
84 if [ ! -z "$SIGNKEY" ]; then
85 DEBUILDOPTIONS="-k$SIGNKEY"
88 # Create build dir
89 mkdir -p $BUILDDIR
91 # Remove old builds
92 rm -rf $BUILDDIR/*
94 # Update master copy
95 cd $MASTERDIR
96 git pull
98 # Copy tree into build environment
99 cp -priv $MASTERDIR $DATEDIR
101 # Build orig.tar.gz
102 cd $BUILDDIR
103 tar cvzf conkeror_$VERSION.orig.tar.gz --exclude=.git conkeror-$VERSION
105 # Add an appropriate commit.id (probably obsolete soon)
106 cd $DATEDIR
107 git log | head -1 | awk '{print $2}' > debian/commit.id
109 # Add an appropriate changelog entry
110 cd debian
111 mv changelog changelog.tmp
112 echo "conkeror ($RELEASE) UNRELEASED; urgency=low
114 * Automatically built package based on the state of
115 http://repo.or.cz/w/conkeror.git at $DATE
117 -- Conkeror Nightly Build <abe+conkeror-nightly@deuxchevaux.org> $DATE
118 " > changelog
119 cat changelog.tmp >> changelog
120 rm changelog.tmp
122 # Build the package
123 cd ..
124 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)(?:$|/.*$)'
126 # Upload the files
127 cd ..
129 if [ "$UPLOAD" = "yes" ]; then
130 scp -i $UPLOAD_SSH_KEY -p *build *deb *changes *dsc *gz \
131 $UPLOAD_SSH_USER@$UPLOAD_SSH_HOST:$UPLOAD_SSH_DIR
133 if [ "$USE_REPREPRO" = "yes" ]; then
134 ssh -i $UPLOAD_SSH_KEY $UPLOAD_SSH_USER@$UPLOAD_SSH_HOST \
135 "cd $UPLOAD_SSH_DIR; reprepro -v includedeb lenny" *.deb "; reprepro -v includedeb sid" *.deb "; reprepro -v includedsc lenny " *.dsc "; reprepro -v includedsc sid " *.dsc ";"