source: orange/install-scripts/mac/fink-daily-build-packages.sh @ 10702:cb5132258dab

Revision 10702:cb5132258dab, 10.7 KB checked in by Ales Erjavec <ales.erjavec@…>, 2 years ago (diff)

Fixes for daily build scripts.

  • Property exe set to *
Line 
1#!/bin/bash -e
2#
3# Run daily fink build
4#
5
6# Daily orange packages to build
7DAILY_PACKAGES="orange-dev-py26 orange-gui-dev-py26 orange-bioinformatics-dev-py26 orange-bioinformatics-gui-dev-py26 orange-text-dev-py26 orange-text-gui-dev-py26 orange-dev-py27 orange-gui-dev-py27 orange-bioinformatics-dev-py27 orange-bioinformatics-gui-dev-py27 orange-text-dev-py27 orange-text-gui-dev-py27"
8
9# Packages which, when installing, want special confirmation from the user
10# We keep those packages installed all the time
11SPECIAL_PACKAGES="passwd xinitrc"
12
13# A list of packages (dependencies) from which user can choose upon installing our packages
14# We would like to build all those so that it does not need to compile anything whichever packages he or she chooses
15# The problem is that they are often mutually conflicting so we cannot have them simply installed (so that update-all
16# would update them) but have to build them explicitly
17OTHER_PACKAGES="ghostscript ghostscript-esp ghostscript6 ghostscript-nox ghostscript6-nox gnuplot gnuplot-nox gnuplot-nogtk tetex-base tetex-nox-base texlive-nox-base texlive-base tetex-texmf texlive-texmf"
18
19
20# Miscellaneous extra packages which are maybe not really needed for Orange but are useful for CS research
21EXTRA_PACKAGES="fuse gcc42 gcc43 gcc44 gnuplot gnuplot-nox gnuplot-nogtk db48 db48-aes git imagemagick-nox rrdtool maxima nmap wireshark openssl pstree python26 python27 python3 rdiff-backup svn swi-prolog lynx links w3m elinks matplotlib-py26 matplotlib-py27 mercurial-py26 mercurial-py27"
22
23FINK_ARGS="--yes --build-as-nobody"
24FINK_SELFUPDATE_ARGS="--yes"
25APT_ARGS="--assume-yes"
26
27# Path to Fink root
28FINK_ROOT=/sw
29
30# Repo dir
31REPO_DIR=/private/tmp/repos
32
33ARCH=`perl -MFink::FinkVersion -e 'print Fink::FinkVersion::get_arch'`
34
35# Sets error handler
36trap "echo \"Script failed\"" ERR
37
38((`id -u` == 0)) || { echo "Must run as root user (use sudo)."; exit 1; }
39
40test -r $FINK_ROOT/bin/init.sh || { echo "Fink cannot be found." exit 2; }
41
42[ -e /Volumes/fink/ ] || { echo "/Volumes/fink/ not mounted."; exit 3; }
43
44# Configures environment for Fink
45. $FINK_ROOT/bin/init.sh
46
47if ! grep '^Trees:' $FINK_ROOT/etc/fink.conf | grep -q 'unstable/main' && grep '^SelfUpdateMethod:' $FINK_ROOT/etc/fink.conf | grep -q 'point'; then
48    echo "Fink does not seem to use unstable Fink packages tree with rsync or CVS updating."
49    exit 5
50fi
51
52if [ ! -x /usr/bin/xcodebuild ]; then
53    echo "It seems Xcode is not installed on a system."
54    exit 6
55fi
56
57MAC_VERSION=`sw_vers -productVersion | cut -d '.' -f 2`
58if [[ "$MAC_VERSION" -ne 5 && "$MAC_VERSION" -ne 6 ]]; then
59    echo "It seems system is not Mac OS X version 10.5 or 10.6."
60    exit 7
61fi
62
63if [ ! "`/usr/X11/bin/X -version 2>&1 | grep '^X.Org X Server' | grep -E -o '[0-9]+\.[0-9]+\.[0-9]+' | cut -d '.' -f 2`" -gt "3" ]; then
64    echo "It seems X11 version 2.3.0 or later is not installed on a system."
65    exit 8
66fi
67
68echo "Preparing local biolab Fink info files repository."
69mkdir -p $FINK_ROOT/fink/dists/biolab/main/finkinfo/
70rm -f $FINK_ROOT/fink/dists/biolab/main/finkinfo/*
71
72echo "Updating local biolab Fink info files repository."
73curl "http://orange.biolab.si/fink/dists/10.$MAC_VERSION/main/finkinfo/all.tgz" --output $FINK_ROOT/fink/dists/biolab/main/finkinfo/all.tgz
74tar -xzf $FINK_ROOT/fink/dists/biolab/main/finkinfo/all.tgz -C $FINK_ROOT/fink/dists/biolab/main/finkinfo/
75rm -f $FINK_ROOT/fink/dists/biolab/main/finkinfo/all.tgz
76
77# Move info files from local/main/finkinfo (put there by dailyrun[-finkonly].sh
78if [[ $(ls -A $FINK_ROOT/fink/dists/local/main/finkinfo/ | grep "\.info") ]]; then
79    echo "Updating new fink info files."
80    mv $FINK_ROOT/fink/dists/local/main/finkinfo/*.info $FINK_ROOT/fink/dists/biolab/main/finkinfo/
81fi
82
83if ! grep '^Trees:' $FINK_ROOT/etc/fink.conf | grep -q 'biolab/main'; then
84    echo "Adding local biolab Fink info files repository to Fink configuration."
85    perl -p -i -l -e '$_ = "$_ biolab/main" if /^Trees/' $FINK_ROOT/etc/fink.conf
86fi
87
88# Adds our binary repository to local Fink (APT) configuration
89if ! grep -q "deb http://orange.biolab.si/fink 10.$MAC_VERSION main" $FINK_ROOT/etc/apt/sources.list; then
90    echo "Adding biolab Fink binary packages repository to Fink configuration."
91    echo "deb http://orange.biolab.si/fink 10.$MAC_VERSION main" >> $FINK_ROOT/etc/apt/sources.list
92fi
93
94if [ ! -e $FINK_ROOT/etc/apt/apt.conf.d/daily-build ]; then
95    echo "Configuring apt-get to assume yes to all questions."
96    echo 'APT::Get::Assume-Yes "true";' > $FINK_ROOT/etc/apt/apt.conf.d/daily-build
97fi
98
99# Configures any pending packages from possible interrupted past sessions
100dpkg --configure -a
101
102# Gets all official Fink package info files
103echo "Updating installed Fink packages."
104fink $FINK_SELFUPDATE_ARGS selfupdate --method=rsync
105fink $FINK_ARGS scanpackages
106
107# Updates everything (probably by compiling new packages)
108fink $FINK_ARGS update-all
109
110# Installs special packages (if they are not already installed)
111yes | fink $FINK_ARGS install $SPECIAL_PACKAGES
112
113# Removes possiblly installed packages which we want built
114fink $FINK_ARGS purge --recursive $DAILY_PACKAGES $OTHER_PACKAGES $EXTRA_PACKAGES
115# Sometimes Fink and APT are not in sync so we remove packages also directly
116for package in $DAILY_PACKAGES $OTHER_PACKAGES $EXTRA_PACKAGES ; do
117    echo $package "purge" | dpkg --set-selections
118done
119apt-get $APT_ARGS dselect-upgrade
120
121# Stores current packages status
122dpkg --get-selections '*' > /tmp/dpkg-selections.list
123
124for package in $OTHER_PACKAGES ; do
125    # Restores intitial packages status
126    dpkg --get-selections '*' | cut -f 1 | xargs -n 1 -J % echo % purge | dpkg --set-selections
127    dpkg --set-selections < /tmp/dpkg-selections.list
128    apt-get $APT_ARGS dselect-upgrade
129   
130    # Builds a package if it has not been rebuilt already (for example, as a dependency)
131    # We install it and not just build it because installation does not build package if it already exists as a binary package
132    echo "Specially building package $package."
133    fink $FINK_ARGS install $package
134done
135
136for package in $EXTRA_PACKAGES ; do
137    if fink $FINK_ARGS describe $package > /dev/null ; then
138        # Restores intitial packages status
139        dpkg --get-selections '*' | cut -f 1 | xargs -n 1 -J % echo % purge | dpkg --set-selections
140        dpkg --set-selections < /tmp/dpkg-selections.list
141        apt-get $APT_ARGS dselect-upgrade
142       
143        # Builds a package if it has not been rebuilt already (for example, as a dependency)
144        # We install it and not just build it because installation does not build package if it already exists as a binary package
145        echo "Specially building extra package $package."
146        fink $FINK_ARGS install $package
147    else
148        echo "Not building extra package $package."
149    fi
150done
151
152# We build our packages in "maintainer" mode - Fink makes tests and validates packages
153for package in $DAILY_PACKAGES ; do
154    DEPS=`perl -MFink -MFink::PkgVersion -l -e "Fink::Package->require_packages(); map { map { /(\\S+)/; print \\$1 } @\\$_ } @{Fink::PkgVersion->match_package('$package')->get_depends(1, 0)};"`
155   
156    # First builds all dependencies normally (so that we are not checking for others' errors)
157    for deps in $DEPS ; do
158        # Restores intitial packages status
159        dpkg --get-selections '*' | cut -f 1 | xargs -n 1 -J % echo % purge | dpkg --set-selections
160        dpkg --set-selections < /tmp/dpkg-selections.list
161        apt-get $APT_ARGS dselect-upgrade
162       
163        # We install it and not just build it because installation does not build package if it already exists as a binary package
164        echo "Specially building package $package dependency $deps."
165        fink $FINK_ARGS install $deps
166    done
167   
168    # Restores intitial packages status
169    dpkg --get-selections '*' | cut -f 1 | xargs -n 1 -J % echo % purge | dpkg --set-selections
170    dpkg --set-selections < /tmp/dpkg-selections.list
171    apt-get $APT_ARGS dselect-upgrade
172   
173    # Then builds a package
174    # We can just build it as our packages have been probably cached if they have been already built
175    echo "Specially building, testing and validating package $package."
176    fink $FINK_ARGS --maintainer build $package
177done
178
179echo "Restoring initial packages status."
180dpkg --get-selections '*' | cut -f 1 | xargs -n 1 -J % echo % purge | dpkg --set-selections
181dpkg --set-selections < /tmp/dpkg-selections.list
182apt-get $APT_ARGS dselect-upgrade
183rm -f /tmp/dpkg-selections.list
184
185# Cleans unncessary files (we cache them anyway in public repository)
186echo "Cleaning."
187fink $FINK_ARGS cleanup --all
188
189# TODO: Should be called only on a daily build server and not if building locally
190/Users/ailabc/mount-dirs.sh
191
192echo "Preparing public biolab Fink info and binary files repository."
193mkdir -p /Volumes/fink/dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/
194chmod +rx /Volumes/fink/dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/
195mkdir -p /Volumes/fink/dists/10.$MAC_VERSION/main/finkinfo/
196chmod +rx /Volumes/fink/dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/
197
198echo "Copying to repository all binary packages."
199cp $FINK_ROOT/fink/debs/*.deb /Volumes/fink/dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/
200if (shopt -s nullglob; f=($FINK_ROOT/var/cache/apt/archives/*.deb); ((${#f[@]}))); then
201    # We have to test if there are any deb files available as otherwise cp fails
202    cp $FINK_ROOT/var/cache/apt/archives/*.deb /Volumes/fink/dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/
203fi
204
205cd /Volumes/fink/dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/
206
207echo "Fixing possible problems with binary packages filenames."
208# Some packages include Fink epoch which uses colon as a delimiter and breaks package retrieval from the repository web server
209# We remove epoch as it should not be there in the first place
210perl -e '
211for (<*.deb>) {
212    if (m/^(.+)_\d+%3a(.+)$/) {
213        rename $_, "$1_$2";
214    }
215}
216'
217
218echo "Removing old binary packages."
219# (Versions of packages which have more then 5 versions and those old versions are more than one month old.)
220perl -e '
221for (<*.deb>) {
222    m/(.*?)_/;
223    $fs{$1}++;
224}
225while (($f,$n) = each(%fs)) {
226    next if $n <= 5;
227    unlink for grep {-M > 30} <$f_*.deb>;
228}
229'
230
231echo "Making packages list."
232cd /Volumes/fink/
233perl -MFink::Scanpackages -e "Fink::Scanpackages->scan('dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/');" | gzip - > dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/Packages.gz
234
235echo "Copying to repository all info files."
236rm -f /Volumes/fink/dists/10.$MAC_VERSION/main/finkinfo/*
237cp $FINK_ROOT/fink/dists/biolab/main/finkinfo/* /Volumes/fink/dists/10.$MAC_VERSION/main/finkinfo/
238
239echo "Making an archive of all info files."
240cd $FINK_ROOT/fink/dists/biolab/main/finkinfo/
241tar -czf /Volumes/fink/dists/10.$MAC_VERSION/main/finkinfo/all.tgz *
242
243echo "Setting permissions."
244chmod -R +r /Volumes/fink/dists/10.$MAC_VERSION/main/finkinfo/
245
246echo "Removing unnecessary source archives."
247perl -e "
248for (</Volumes/fink/dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/orange-*.deb>) {
249    m/_(.+)-\\d+_darwin-$ARCH\\.deb/;
250    \$versions{\$1} = 1;
251}
252for (</Volumes/fink/dists/10.$MAC_VERSION/main/source/*.tgz>) {
253    m/.+-(.+)\\.tgz/;
254    next if \$versions{\$1} or -M() < 30;
255    unlink;
256}
257"
258
Note: See TracBrowser for help on using the repository browser.