| 1 |
pere |
991 |
#!/bin/sh |
| 2 |
|
|
# |
| 3 |
|
|
# (c) 2006, 2007 Holger Levsen <debian@layer-acht.org> |
| 4 |
nd-guest |
1237 |
# (c) 2007 Petter Reinholdtsen <pere@hungry.com> |
| 5 |
|
|
# (c) 2007 Andreas Putzo <andreas@putzo.net> |
| 6 |
pere |
991 |
# |
| 7 |
|
|
# Licended under GPL2 |
| 8 |
|
|
# |
| 9 |
|
|
# Build script for Debian Gis Live CD. |
| 10 |
|
|
# Based on build script for Debian Edu live CD. |
| 11 |
|
|
# |
| 12 |
pere |
1002 |
# Build depends: live-helper tasksel |
| 13 |
pere |
991 |
# |
| 14 |
nd-guest |
1237 |
# Tested using live-helper version 1.0~a31-1 |
| 15 |
pere |
1021 |
# |
| 16 |
pere |
991 |
############################################################################## |
| 17 |
|
|
|
| 18 |
|
|
# Exit on errors |
| 19 |
|
|
set -e |
| 20 |
|
|
|
| 21 |
nd-guest |
1237 |
# Config options. See also lh_config call below. |
| 22 |
|
|
verbose=1 |
| 23 |
|
|
build_dir=build |
| 24 |
|
|
publish_dir=$(pwd)/pub |
| 25 |
|
|
logfile=`mktemp` |
| 26 |
|
|
today="`date +%Y%m%d%H%M`" |
| 27 |
|
|
lockfile="/var/lock/gislive-build" |
| 28 |
|
|
mirror=http://ftp.de.debian.org/debian |
| 29 |
|
|
dist=lenny |
| 30 |
|
|
# package (-lists) to install |
| 31 |
|
|
package_list_dir=$(pwd)/packages |
| 32 |
|
|
# scripts to execute in the chroot |
| 33 |
|
|
hook_dir=$(pwd)/hooks |
| 34 |
|
|
# Files to copy into the chroot to / |
| 35 |
|
|
misc_files_dir=$(pwd)/files |
| 36 |
|
|
publisher="Debian GIS Project" |
| 37 |
|
|
live_username="gis" |
| 38 |
|
|
live_hostname="Debian-GIS" |
| 39 |
pere |
991 |
# CD boot image |
| 40 |
nd-guest |
1237 |
#splashpng=foo.png |
| 41 |
pere |
991 |
|
| 42 |
|
|
|
| 43 |
nd-guest |
1237 |
# helper functions |
| 44 |
pere |
991 |
msg_info() { |
| 45 |
nd-guest |
1237 |
echo info: $@ |
| 46 |
pere |
991 |
} |
| 47 |
|
|
|
| 48 |
|
|
msg_error() { |
| 49 |
|
|
echo error: $@ |
| 50 |
|
|
} |
| 51 |
|
|
|
| 52 |
nd-guest |
1237 |
at_exit() { |
| 53 |
|
|
rm $lockfile |
| 54 |
|
|
if [ -f $logfile ] ; then |
| 55 |
|
|
cp $logfile $publish_dir/gislive-${today}.log |
| 56 |
|
|
chmod 644 $publish_dir/gislive-${today}.log |
| 57 |
|
|
rm $logfile |
| 58 |
|
|
fi |
| 59 |
|
|
cd - |
| 60 |
|
|
} |
| 61 |
pere |
991 |
|
| 62 |
nd-guest |
1237 |
#### |
| 63 |
|
|
trap at_exit EXIT |
| 64 |
|
|
if [ "$verbose" ]; then |
| 65 |
|
|
tail -f $logfile & |
| 66 |
|
|
fi |
| 67 |
pere |
991 |
|
| 68 |
nd-guest |
1237 |
# Some steps need to run as root. Use sudo unless already root |
| 69 |
|
|
if [ root != "$(whoami)" ] ; then |
| 70 |
|
|
SUDO=sudo |
| 71 |
pere |
1002 |
fi |
| 72 |
|
|
|
| 73 |
pere |
991 |
# check lockfile |
| 74 |
nd-guest |
1237 |
if [ -f "$lockfile" ] ; then |
| 75 |
|
|
echo $lockfile exists, aborting |
| 76 |
pere |
991 |
exit 1 |
| 77 |
|
|
fi |
| 78 |
nd-guest |
1237 |
$SUDO echo $$ > $lockfile |
| 79 |
pere |
991 |
|
| 80 |
nd-guest |
1237 |
# check publishdir |
| 81 |
|
|
if [ ! -d "$publish_dir" ] ; then |
| 82 |
|
|
msg_error "$publish_dir does not exist, aborting." |
| 83 |
|
|
exit 1 |
| 84 |
pere |
991 |
fi |
| 85 |
|
|
|
| 86 |
nd-guest |
1237 |
# cleanup from previous builds |
| 87 |
|
|
[ -d "$build_dir" ] || mkdir -p $build_dir |
| 88 |
|
|
cd $build_dir |
| 89 |
|
|
if lh_clean all; then |
| 90 |
|
|
msg_info cleaning old build dir succeeded |
| 91 |
|
|
rm -rf config |
| 92 |
|
|
else |
| 93 |
|
|
msg_error generating configuration failed |
| 94 |
|
|
exit 1 |
| 95 |
pere |
991 |
fi |
| 96 |
|
|
|
| 97 |
nd-guest |
1237 |
# configure live-helper |
| 98 |
|
|
export LH_BOOTAPPEND_LIVE="quiet splash" |
| 99 |
|
|
if /usr/bin/lh_config \ |
| 100 |
pere |
991 |
--bootappend "quiet splash" \ |
| 101 |
|
|
--keyring-packages debian-archive-keyring \ |
| 102 |
nd-guest |
1237 |
--mirror-bootstrap "$mirror" \ |
| 103 |
|
|
--distribution "$dist" \ |
| 104 |
pere |
991 |
--sections "main" \ |
| 105 |
|
|
--apt-recommends disabled \ |
| 106 |
nd-guest |
1237 |
--union-filesystem aufs \ |
| 107 |
|
|
--linux-packages 'linux-image-2.6 aufs-modules-2.6 squashfs-modules-2.6' \ |
| 108 |
|
|
--iso-publisher "$publisher" \ |
| 109 |
|
|
--username "$live_username" \ |
| 110 |
|
|
--hostname "$live_hostname" \ |
| 111 |
|
|
--verbose |
| 112 |
pere |
991 |
then |
| 113 |
|
|
msg_info generating configuration succeeded |
| 114 |
|
|
else |
| 115 |
|
|
msg_error generating configuration failed |
| 116 |
|
|
exit 1 |
| 117 |
|
|
fi |
| 118 |
|
|
|
| 119 |
nd-guest |
1237 |
# copy hooks |
| 120 |
|
|
if [ -d "$hook_dir" ]; then |
| 121 |
|
|
for hook in $(ls "$hook_dir"); do |
| 122 |
|
|
cp $hook_dir/$hook config/chroot_local-hooks |
| 123 |
|
|
done |
| 124 |
|
|
fi |
| 125 |
pere |
991 |
|
| 126 |
nd-guest |
1237 |
# copy package lists |
| 127 |
|
|
if [ -d "$package_list_dir" ]; then |
| 128 |
|
|
for list in $(ls "$package_list_dir"); do |
| 129 |
|
|
cp $package_list_dir/$list config/chroot_local-packageslists |
| 130 |
|
|
done |
| 131 |
|
|
fi |
| 132 |
pere |
991 |
|
| 133 |
nd-guest |
1237 |
# copy misc files |
| 134 |
|
|
if [ -d "$misc_files_dir" ]; then |
| 135 |
nd-guest |
1243 |
( cd "$misc_files_dir" && find . ! \( -type d -a -name ".svn" -prune \) ) | while read file; do |
| 136 |
|
|
if [ -d "$misc_files_dir/$file" ]; then |
| 137 |
|
|
mkdir -p config/chroot_local-includes/$file |
| 138 |
|
|
elif [ -f "$misc_files_dir/$file" ]; then |
| 139 |
|
|
cp -v $misc_files_dir/$file config/chroot_local-includes/$file |
| 140 |
|
|
fi |
| 141 |
nd-guest |
1237 |
done |
| 142 |
|
|
fi |
| 143 |
pere |
991 |
|
| 144 |
nd-guest |
1237 |
# prepare chroot |
| 145 |
|
|
if $SUDO /usr/bin/lh_bootstrap >> $logfile 2>&1; then |
| 146 |
|
|
msg_info "bootstrap succeeded." |
| 147 |
|
|
else |
| 148 |
|
|
msg_error "bootstrap failed." |
| 149 |
|
|
exit 1 |
| 150 |
|
|
fi |
| 151 |
|
|
|
| 152 |
|
|
if $SUDO /usr/bin/lh_chroot >> $logfile 2>&1; then |
| 153 |
|
|
msg_info "creating chroot succeeded." |
| 154 |
|
|
else |
| 155 |
|
|
msg_error "creating chroot failed." |
| 156 |
|
|
exit 1 |
| 157 |
|
|
fi |
| 158 |
|
|
|
| 159 |
pere |
992 |
# Generate RLE from a splash image PNG |
| 160 |
pere |
991 |
# Color index 0 is background, and index 7 is foreground. Set to |
| 161 |
|
|
# black and white respecively |
| 162 |
nd-guest |
1237 |
if [ -f "$splashpng" ] ; then |
| 163 |
|
|
pngtopnm < $splashpng | ppmquant 16 2>/dev/null | \ |
| 164 |
pere |
991 |
ppmtolss16 "#ffffff=7" "#000000=0" 2>/dev/null \ |
| 165 |
nd-guest |
1237 |
> config/binary_syslinux/splash.rle |
| 166 |
pere |
991 |
fi |
| 167 |
|
|
|
| 168 |
nd-guest |
1237 |
# call lh_binary to build the iso image and publish the result |
| 169 |
|
|
if $SUDO /usr/bin/lh_binary >> $logfile 2>&1; then |
| 170 |
pere |
991 |
msg_info "build succeeded." |
| 171 |
|
|
else |
| 172 |
|
|
msg_error "build failed." |
| 173 |
|
|
exit 1 |
| 174 |
|
|
fi |
| 175 |
nd-guest |
1237 |
if [ -f binary.iso ] ; then |
| 176 |
|
|
mv binary.iso $publish_dir/gislive-${today}.iso |
| 177 |
|
|
md5sum $publish_dir/gislive-${today}.iso > $publish_dir/gislive-${today}.md5sum |
| 178 |
|
|
msg_info successfully build live-cd. |
| 179 |
pere |
991 |
else |
| 180 |
|
|
echo "#########################################################" |
| 181 |
|
|
echo |
| 182 |
|
|
echo "An error occured, .iso was not created :-(" |
| 183 |
|
|
echo |
| 184 |
nd-guest |
1237 |
if [ ! "$verbose" ]; then |
| 185 |
|
|
echo "30 last lines of the make-live output:" |
| 186 |
|
|
echo |
| 187 |
|
|
tail -30 $logfile |
| 188 |
|
|
fi |
| 189 |
pere |
991 |
fi |
| 190 |
|
|
|
| 191 |
|
|
# cleanup old images and logs |
| 192 |
nd-guest |
1237 |
find $publish_dir -mtime +1 ! -name "gislive-*00.???" -exec rm {} \; |
| 193 |
|
|
find $publish_dir -mtime +2 ! -name "gislive-1600.???" -exec rm {} \; |
| 194 |
|
|
find $publish_dir -mtime +14 ! -name "gislive-0400.???" -exec rm {} \; |