| 1 | #!/bin/bash -e |
|---|
| 2 | # |
|---|
| 3 | # Run daily fink build |
|---|
| 4 | # |
|---|
| 5 | |
|---|
| 6 | # Daily orange packages to build |
|---|
| 7 | DAILY_PACKAGES="orange-hg-py26 orange-gui-hg-py26 orange-bioinformatics-hg-py26 orange-bioinformatics-gui-hg-py26 orange-text-hg-py26 orange-text-gui-hg-py26 orange-hg-py27 orange-gui-hg-py27 orange-bioinformatics-hg-py27 orange-bioinformatics-gui-hg-py27 orange-text-hg-py27 orange-text-gui-hg-py27" |
|---|
| 8 | |
|---|
| 9 | # Packages which, when installing, want special confirmation from the user |
|---|
| 10 | # We keep those packages installed all the time |
|---|
| 11 | SPECIAL_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 |
|---|
| 17 | OTHER_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 |
|---|
| 21 | EXTRA_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 | |
|---|
| 23 | FINK_ARGS="--yes --build-as-nobody" |
|---|
| 24 | FINK_SELFUPDATE_ARGS="--yes" |
|---|
| 25 | APT_ARGS="--assume-yes" |
|---|
| 26 | |
|---|
| 27 | # Path to Fink root |
|---|
| 28 | FINK_ROOT=/sw |
|---|
| 29 | |
|---|
| 30 | # Repo dir |
|---|
| 31 | REPO_DIR=/private/tmp/repos |
|---|
| 32 | |
|---|
| 33 | ARCH=`perl -MFink::FinkVersion -e 'print Fink::FinkVersion::get_arch'` |
|---|
| 34 | |
|---|
| 35 | # Sets error handler |
|---|
| 36 | trap "echo \"Script failed\"" ERR |
|---|
| 37 | |
|---|
| 38 | ((`id -u` == 0)) || { echo "Must run as root user (use sudo)."; exit 1; } |
|---|
| 39 | |
|---|
| 40 | test -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 | |
|---|
| 47 | if ! 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 |
|---|
| 50 | fi |
|---|
| 51 | |
|---|
| 52 | if [ ! -x /usr/bin/xcodebuild ]; then |
|---|
| 53 | echo "It seems Xcode is not installed on a system." |
|---|
| 54 | exit 6 |
|---|
| 55 | fi |
|---|
| 56 | |
|---|
| 57 | MAC_VERSION=`sw_vers -productVersion | cut -d '.' -f 2` |
|---|
| 58 | if [[ "$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 |
|---|
| 61 | fi |
|---|
| 62 | |
|---|
| 63 | if [ ! "`/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 |
|---|
| 66 | fi |
|---|
| 67 | |
|---|
| 68 | echo "Preparing local biolab Fink info files repository." |
|---|
| 69 | mkdir -p $FINK_ROOT/fink/dists/biolab/main/finkinfo/ |
|---|
| 70 | rm -f $FINK_ROOT/fink/dists/biolab/main/finkinfo/* |
|---|
| 71 | |
|---|
| 72 | echo "Updating local biolab Fink info files repository." |
|---|
| 73 | curl "http://orange.biolab.si/fink/dists/10.$MAC_VERSION/main/finkinfo/all.tgz" --output $FINK_ROOT/fink/dists/biolab/main/finkinfo/all.tgz |
|---|
| 74 | tar -xzf $FINK_ROOT/fink/dists/biolab/main/finkinfo/all.tgz -C $FINK_ROOT/fink/dists/biolab/main/finkinfo/ |
|---|
| 75 | rm -f $FINK_ROOT/fink/dists/biolab/main/finkinfo/all.tgz |
|---|
| 76 | |
|---|
| 77 | # Move info files from local/main/finkinfo (put there by dailyru[-finkonly].sh |
|---|
| 78 | echo "Updating new fink info files." |
|---|
| 79 | mv $FINK_ROOT/fink/dists/local/main/finkinfo/*.info $FINK_ROOT/fink/dists/biolab/main/finkinfo/ |
|---|
| 80 | |
|---|
| 81 | if ! grep '^Trees:' $FINK_ROOT/etc/fink.conf | grep -q 'biolab/main'; then |
|---|
| 82 | echo "Adding local biolab Fink info files repository to Fink configuration." |
|---|
| 83 | perl -p -i -l -e '$_ = "$_ biolab/main" if /^Trees/' $FINK_ROOT/etc/fink.conf |
|---|
| 84 | fi |
|---|
| 85 | |
|---|
| 86 | # Adds our binary repository to local Fink (APT) configuration |
|---|
| 87 | if ! grep -q "deb http://orange.biolab.si/fink 10.$MAC_VERSION main" $FINK_ROOT/etc/apt/sources.list; then |
|---|
| 88 | echo "Adding biolab Fink binary packages repository to Fink configuration." |
|---|
| 89 | echo "deb http://orange.biolab.si/fink 10.$MAC_VERSION main" >> $FINK_ROOT/etc/apt/sources.list |
|---|
| 90 | fi |
|---|
| 91 | |
|---|
| 92 | if [ ! -e $FINK_ROOT/etc/apt/apt.conf.d/daily-build ]; then |
|---|
| 93 | echo "Configuring apt-get to assume yes to all questions." |
|---|
| 94 | echo 'APT::Get::Assume-Yes "true";' > $FINK_ROOT/etc/apt/apt.conf.d/daily-build |
|---|
| 95 | fi |
|---|
| 96 | |
|---|
| 97 | # Configures any pending packages from possible interrupted past sessions |
|---|
| 98 | dpkg --configure -a |
|---|
| 99 | |
|---|
| 100 | # Gets all official Fink package info files |
|---|
| 101 | echo "Updating installed Fink packages." |
|---|
| 102 | fink $FINK_SELFUPDATE_ARGS selfupdate --method=rsync |
|---|
| 103 | fink $FINK_ARGS scanpackages |
|---|
| 104 | |
|---|
| 105 | # Updates everything (probably by compiling new packages) |
|---|
| 106 | fink $FINK_ARGS update-all |
|---|
| 107 | |
|---|
| 108 | # Installs special packages (if they are not already installed) |
|---|
| 109 | yes | fink $FINK_ARGS install $SPECIAL_PACKAGES |
|---|
| 110 | |
|---|
| 111 | # Removes possiblly installed packages which we want built |
|---|
| 112 | fink $FINK_ARGS purge --recursive $DAILY_PACKAGES $OTHER_PACKAGES $EXTRA_PACKAGES |
|---|
| 113 | # Sometimes Fink and APT are not in sync so we remove packages also directly |
|---|
| 114 | for package in $DAILY_PACKAGES $OTHER_PACKAGES $EXTRA_PACKAGES ; do |
|---|
| 115 | echo $package "purge" | dpkg --set-selections |
|---|
| 116 | done |
|---|
| 117 | apt-get $APT_ARGS dselect-upgrade |
|---|
| 118 | |
|---|
| 119 | # Stores current packages status |
|---|
| 120 | dpkg --get-selections '*' > /tmp/dpkg-selections.list |
|---|
| 121 | |
|---|
| 122 | for package in $OTHER_PACKAGES ; do |
|---|
| 123 | # Restores intitial packages status |
|---|
| 124 | dpkg --get-selections '*' | cut -f 1 | xargs -n 1 -J % echo % purge | dpkg --set-selections |
|---|
| 125 | dpkg --set-selections < /tmp/dpkg-selections.list |
|---|
| 126 | apt-get $APT_ARGS dselect-upgrade |
|---|
| 127 | |
|---|
| 128 | # Builds a package if it has not been rebuilt already (for example, as a dependency) |
|---|
| 129 | # We install it and not just build it because installation does not build package if it already exists as a binary package |
|---|
| 130 | echo "Specially building package $package." |
|---|
| 131 | fink $FINK_ARGS install $package |
|---|
| 132 | done |
|---|
| 133 | |
|---|
| 134 | for package in $EXTRA_PACKAGES ; do |
|---|
| 135 | if fink $FINK_ARGS describe $package > /dev/null ; then |
|---|
| 136 | # Restores intitial packages status |
|---|
| 137 | dpkg --get-selections '*' | cut -f 1 | xargs -n 1 -J % echo % purge | dpkg --set-selections |
|---|
| 138 | dpkg --set-selections < /tmp/dpkg-selections.list |
|---|
| 139 | apt-get $APT_ARGS dselect-upgrade |
|---|
| 140 | |
|---|
| 141 | # Builds a package if it has not been rebuilt already (for example, as a dependency) |
|---|
| 142 | # We install it and not just build it because installation does not build package if it already exists as a binary package |
|---|
| 143 | echo "Specially building extra package $package." |
|---|
| 144 | fink $FINK_ARGS install $package |
|---|
| 145 | else |
|---|
| 146 | echo "Not building extra package $package." |
|---|
| 147 | fi |
|---|
| 148 | done |
|---|
| 149 | |
|---|
| 150 | # We build our packages in "maintainer" mode - Fink makes tests and validates packages |
|---|
| 151 | for package in $DAILY_PACKAGES ; do |
|---|
| 152 | 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)};"` |
|---|
| 153 | |
|---|
| 154 | # First builds all dependencies normally (so that we are not checking for others' errors) |
|---|
| 155 | for deps in $DEPS ; do |
|---|
| 156 | # Restores intitial packages status |
|---|
| 157 | dpkg --get-selections '*' | cut -f 1 | xargs -n 1 -J % echo % purge | dpkg --set-selections |
|---|
| 158 | dpkg --set-selections < /tmp/dpkg-selections.list |
|---|
| 159 | apt-get $APT_ARGS dselect-upgrade |
|---|
| 160 | |
|---|
| 161 | # We install it and not just build it because installation does not build package if it already exists as a binary package |
|---|
| 162 | echo "Specially building package $package dependency $deps." |
|---|
| 163 | fink $FINK_ARGS install $deps |
|---|
| 164 | done |
|---|
| 165 | |
|---|
| 166 | # Restores intitial packages status |
|---|
| 167 | dpkg --get-selections '*' | cut -f 1 | xargs -n 1 -J % echo % purge | dpkg --set-selections |
|---|
| 168 | dpkg --set-selections < /tmp/dpkg-selections.list |
|---|
| 169 | apt-get $APT_ARGS dselect-upgrade |
|---|
| 170 | |
|---|
| 171 | # Then builds a package |
|---|
| 172 | # We can just build it as our packages have been probably cached if they have been already built |
|---|
| 173 | echo "Specially building, testing and validating package $package." |
|---|
| 174 | fink $FINK_ARGS --maintainer build $package |
|---|
| 175 | done |
|---|
| 176 | |
|---|
| 177 | echo "Restoring initial packages status." |
|---|
| 178 | dpkg --get-selections '*' | cut -f 1 | xargs -n 1 -J % echo % purge | dpkg --set-selections |
|---|
| 179 | dpkg --set-selections < /tmp/dpkg-selections.list |
|---|
| 180 | apt-get $APT_ARGS dselect-upgrade |
|---|
| 181 | rm -f /tmp/dpkg-selections.list |
|---|
| 182 | |
|---|
| 183 | # Cleans unncessary files (we cache them anyway in public repository) |
|---|
| 184 | echo "Cleaning." |
|---|
| 185 | fink $FINK_ARGS cleanup --all |
|---|
| 186 | |
|---|
| 187 | # TODO: Should be called only on a daily build server and not if building locally |
|---|
| 188 | /Users/ailabc/mount-dirs.sh |
|---|
| 189 | |
|---|
| 190 | echo "Preparing public biolab Fink info and binary files repository." |
|---|
| 191 | mkdir -p /Volumes/fink/dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/ |
|---|
| 192 | chmod +rx /Volumes/fink/dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/ |
|---|
| 193 | mkdir -p /Volumes/fink/dists/10.$MAC_VERSION/main/finkinfo/ |
|---|
| 194 | chmod +rx /Volumes/fink/dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/ |
|---|
| 195 | |
|---|
| 196 | echo "Copying to repository all binary packages." |
|---|
| 197 | cp $FINK_ROOT/fink/debs/*.deb /Volumes/fink/dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/ |
|---|
| 198 | if (shopt -s nullglob; f=($FINK_ROOT/var/cache/apt/archives/*.deb); ((${#f[@]}))); then |
|---|
| 199 | # We have to test if there are any deb files available as otherwise cp fails |
|---|
| 200 | cp $FINK_ROOT/var/cache/apt/archives/*.deb /Volumes/fink/dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/ |
|---|
| 201 | fi |
|---|
| 202 | |
|---|
| 203 | cd /Volumes/fink/dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/ |
|---|
| 204 | |
|---|
| 205 | echo "Fixing possible problems with binary packages filenames." |
|---|
| 206 | # Some packages include Fink epoch which uses colon as a delimiter and breaks package retrieval from the repository web server |
|---|
| 207 | # We remove epoch as it should not be there in the first place |
|---|
| 208 | perl -e ' |
|---|
| 209 | for (<*.deb>) { |
|---|
| 210 | if (m/^(.+)_\d+%3a(.+)$/) { |
|---|
| 211 | rename $_, "$1_$2"; |
|---|
| 212 | } |
|---|
| 213 | } |
|---|
| 214 | ' |
|---|
| 215 | |
|---|
| 216 | echo "Removing old binary packages." |
|---|
| 217 | # (Versions of packages which have more then 5 versions and those old versions are more than one month old.) |
|---|
| 218 | perl -e ' |
|---|
| 219 | for (<*.deb>) { |
|---|
| 220 | m/(.*?)_/; |
|---|
| 221 | $fs{$1}++; |
|---|
| 222 | } |
|---|
| 223 | while (($f,$n) = each(%fs)) { |
|---|
| 224 | next if $n <= 5; |
|---|
| 225 | unlink for grep {-M > 30} <$f_*.deb>; |
|---|
| 226 | } |
|---|
| 227 | ' |
|---|
| 228 | |
|---|
| 229 | echo "Making packages list." |
|---|
| 230 | cd /Volumes/fink/ |
|---|
| 231 | perl -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 |
|---|
| 232 | |
|---|
| 233 | echo "Copying to repository all info files." |
|---|
| 234 | rm -f /Volumes/fink/dists/10.$MAC_VERSION/main/finkinfo/* |
|---|
| 235 | cp $FINK_ROOT/fink/dists/biolab/main/finkinfo/* /Volumes/fink/dists/10.$MAC_VERSION/main/finkinfo/ |
|---|
| 236 | |
|---|
| 237 | echo "Making an archive of all info files." |
|---|
| 238 | cd $FINK_ROOT/fink/dists/biolab/main/finkinfo/ |
|---|
| 239 | tar -czf /Volumes/fink/dists/10.$MAC_VERSION/main/finkinfo/all.tgz * |
|---|
| 240 | |
|---|
| 241 | echo "Setting permissions." |
|---|
| 242 | chmod -R +r /Volumes/fink/dists/10.$MAC_VERSION/main/finkinfo/ |
|---|
| 243 | |
|---|
| 244 | echo "Removing unnecessary source archives." |
|---|
| 245 | perl -e " |
|---|
| 246 | for (</Volumes/fink/dists/10.$MAC_VERSION/main/binary-darwin-$ARCH/orange-*.deb>) { |
|---|
| 247 | m/_(.+)-\\d+_darwin-$ARCH\\.deb/; |
|---|
| 248 | \$versions{\$1} = 1; |
|---|
| 249 | } |
|---|
| 250 | for (</Volumes/fink/dists/10.$MAC_VERSION/main/source/*.tgz>) { |
|---|
| 251 | m/.+-(.+)\\.tgz/; |
|---|
| 252 | next if \$versions{\$1} or -M() < 30; |
|---|
| 253 | unlink; |
|---|
| 254 | } |
|---|
| 255 | " |
|---|
| 256 | |
|---|