source: orange/install-scripts/debian/debian-daily-build.sh @ 9174:19e3b0e3c832

Revision 9174:19e3b0e3c832, 5.0 KB checked in by mitar, 2 years ago (diff)

Update Debian packaging files when building Debian packages.

  • Property exe set to *
Line 
1#!/bin/bash -e
2#
3# Should be run as: sudo ./debian-daily-build.sh [daily revision]
4#
5
6APT_ARGS="--assume-yes"
7APTITUDE_ARGS="--assume-yes"
8BUILD_DIR="/tmp/orange-build"
9
10ARCH=`dpkg --print-architecture`
11DISTRIBUTION=`lsb_release -c -s`
12
13# Sets error handler
14trap "echo \"Script failed\"" ERR
15
16((`id -u` == 0)) || { echo "Must run as root user (use sudo)."; exit 1; }
17
18[ -e /mnt/debian/ ] || { echo "/mnt/debian/ not mounted."; exit 2; }
19
20# Default is current latest revision in trunk
21DAILY_REVISION=${1:-`svn info --non-interactive http://orange.biolab.si/svn/orange/trunk/ | grep 'Last Changed Rev:' | cut -d ' ' -f 4`}
22# svn info does not return proper exit status on an error so we check it this way
23[ "$DAILY_REVISION" ] || exit 3
24
25# Adds our repository to APT configuration
26if ! grep -q "deb http://orange.biolab.si/debian $DISTRIBUTION main" /etc/apt/sources.list; then
27    echo "Adding biolab packages repository to APT configuration."
28    echo "deb http://orange.biolab.si/debian $DISTRIBUTION main" >> /etc/apt/sources.list
29    echo "deb-src http://orange.biolab.si/debian $DISTRIBUTION main" >> /etc/apt/sources.list
30fi
31
32# We are checking only for -1 debian revision as those are those made by uupdate
33if [ -e "/mnt/debian/dists/$DISTRIBUTION/main/binary-$ARCH/python-orange_0.0.$DAILY_REVISION~svn-1_$ARCH.deb" ]; then
34    echo "Package for $DAILY_REVISION revision already exists."
35    exit 0
36fi
37
38aptitude $APTITUDE_ARGS update
39aptitude $APTITUDE_ARGS install devscripts build-essential
40aptitude $APTITUDE_ARGS build-depends python-orange
41
42rm -rf "$BUILD_DIR"
43mkdir -p "$BUILD_DIR"
44cd "$BUILD_DIR"
45
46apt-get $APT_ARGS source python-orange
47
48if [ -e "python-orange-0.0.$DAILY_REVISION~svn" ]; then
49    echo "Package for $DAILY_REVISION revision already exists, just building it."
50else
51    echo "Making source archive python-orange-0.0.$DAILY_REVISION~svn."
52    svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/trunk/orange/ python-orange-0.0.$DAILY_REVISION~svn/
53    svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/trunk/source/ python-orange-0.0.$DAILY_REVISION~svn/source/
54    svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/trunk/add-ons/orngCRS/src/ python-orange-0.0.$DAILY_REVISION~svn/source/crs/
55    svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/trunk/COPYING python-orange-0.0.$DAILY_REVISION~svn/COPYING
56    svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/trunk/LICENSES python-orange-0.0.$DAILY_REVISION~svn/LICENSES
57   
58    [ -e python-orange-0.0.$DAILY_REVISION~svn/doc/COPYING ] && mv python-orange-0.0.$DAILY_REVISION~svn/doc/COPYING python-orange-0.0.$DAILY_REVISION~svn/
59    [ -e python-orange-0.0.$DAILY_REVISION~svn/doc/LICENSES ] && mv python-orange-0.0.$DAILY_REVISION~svn/doc/LICENSES python-orange-0.0.$DAILY_REVISION~svn/
60   
61    tar -czf python-orange-0.0.$DAILY_REVISION~svn.tar.gz python-orange-0.0.$DAILY_REVISION~svn
62    rm -rf python-orange-0.0.$DAILY_REVISION~svn/
63   
64    echo "Updating packages."
65    cd python-orange-0.0.*/
66    export DEBFULLNAME="Mitar"
67    export DEBEMAIL="mitar@tnode.com"
68    uupdate --upstream-version 0.0.$DAILY_REVISION~svn --no-symlink python-orange-0.0.$DAILY_REVISION~svn.tar.gz
69    cd ..
70    rm -rf python-orange-0.0.$DAILY_REVISION~svn.orig/ python-orange-0.0.$DAILY_REVISION~svn.tar.gz
71   
72    echo "Updating Debian packaging files."
73    cd python-orange-0.0.$DAILY_REVISION~svn/debian/
74    svn export --non-interactive --revision $DAILY_REVISION http://orange.biolab.si/svn/orange/trunk/install-scripts/debian/control-files
75    cd control-files
76    rm -f changelog
77    mv -f * ../
78    cd ../
79    rm -rf control-files
80    cd ../../
81   
82    echo "Building new packages."
83fi
84
85cd python-orange-0.0.$DAILY_REVISION~svn/
86dpkg-buildpackage -D -sa -us -uc
87
88echo "Preparing public biolab Debian repository."
89mkdir -p /mnt/debian/dists/$DISTRIBUTION/main/binary-$ARCH/
90mkdir -p /mnt/debian/dists/$DISTRIBUTION/main/source/
91
92echo "Copying to repository new packages."
93cd ..
94rm -rf python-orange-0.0.$DAILY_REVISION~svn/
95mv *$DAILY_REVISION*.deb /mnt/debian/dists/$DISTRIBUTION/main/binary-$ARCH/
96mv *$DAILY_REVISION* /mnt/debian/dists/$DISTRIBUTION/main/source/
97
98echo "Cleaning temporary build directory."
99cd /mnt/debian/dists/
100rm -rf "$BUILD_DIR"
101
102echo "Removing old packages."
103# (Versions of packages which have more then 5 versions and those old versions are more than one month old.)
104perl -e "
105for (<$DISTRIBUTION/main/binary-$ARCH/*.deb>) {
106    m!.*/(.*?)_!;
107    \$fs{\$1}++;
108}
109while ((\$f,\$n) = each(%fs)) {
110    next if \$n <= 5;
111    unlink for grep {-M > 30} <$DISTRIBUTION/main/binary-$ARCH/\$f_*.deb>;
112    unlink for grep {-M > 30} <$DISTRIBUTION/main/source/\$f_*>;
113}
114"
115
116echo "Making packages list."
117dpkg-scanpackages --multiversion $DISTRIBUTION/main/binary-$ARCH /dev/null dists/ | gzip - > $DISTRIBUTION/main/binary-$ARCH/Packages.gz
118dpkg-scansources $DISTRIBUTION/main/source /dev/null dists/ | gzip - > $DISTRIBUTION/main/source/Sources.gz
119
120echo "Setting permissions."
121chmod 644 $DISTRIBUTION/main/binary-$ARCH/* $DISTRIBUTION/main/source/*
Note: See TracBrowser for help on using the repository browser.