File: build-gis-live

package info (click to toggle)
debian-gis 0.0.20
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 292 kB
  • sloc: sh: 164; makefile: 2
file content (201 lines) | stat: -rwxr-xr-x 5,138 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/sh
#
# (c) 2006, 2007	Holger Levsen <debian@layer-acht.org>
# (c) 2007 		    Petter Reinholdtsen <pere@hungry.com>
# (c) 2007, 2008    Andreas Putzo <andreas@putzo.net>
#
# Licended under GPL2
#
# Build script for Debian Gis Live CD.
# Based on build script for Debian Edu live CD.
#
# Build depends: live-helper tasksel
#
# Tested using live-helper version 1.0.0-2
#
##############################################################################

# Exit on errors
set -e

# Config options. See also lh_config call below.
verbose=1
build_dir=build
publish_dir=$(pwd)/pub
logfile=`mktemp`
today="`date +%Y%m%d%H%M`"
lockfile="/var/lock/gislive-build"
mirror=http://ftp.de.debian.org/debian
dist=lenny
# package (-lists) to install
package_list_dir=$(pwd)/packages
# scripts to execute in the chroot
hook_dir=$(pwd)/hooks
# Files to copy into the chroot to /
misc_files_dir=$(pwd)/files
publisher="Debian GIS Project"
live_username="gis"
live_hostname="Debian-GIS"
# CD boot image
#splashpng=foo.png

export LH_PACKAGES_LISTS="kde debian-gis base base2"

# helper functions
msg_info() {
  echo info: $@
}

msg_error() {
  echo error: $@
}

at_exit() {
    rm $lockfile
    if [ -f $logfile ] ; then
    	grep -v ^
 $logfile > $publish_dir/gislive-${today}.log
	    chmod 644 $publish_dir/gislive-${today}.log
    	rm $logfile
    fi
    cd -
}

####
trap at_exit EXIT
if [ "$verbose" ]; then
    tail -f $logfile &
fi    

# Some steps need to run as root. Use sudo unless already root
if [ root != "$(whoami)" ] ; then
    SUDO=sudo
fi

# check lockfile
if [ -f "$lockfile" ] ; then
	echo $lockfile exists, aborting
	exit 1
fi
$SUDO echo $$ > $lockfile

# check publishdir
if [ ! -d "$publish_dir" ] ; then
    msg_error "$publish_dir does not exist, aborting."
    exit 1
fi

# cleanup from previous builds
[ -d "$build_dir" ] || mkdir -p $build_dir
cd $build_dir
if lh_clean --all; then
    msg_info cleaning old build dir succeeded
    rm -rf config
else
    msg_error generating configuration failed
#    exit 1
fi

# configure live-helper
# Rewrite volume name to get it short enought when dist=squeeze.
export LH_BOOTAPPEND_LIVE="quiet splash"
if /usr/bin/lh_config \
    --apt aptitude \
    --bootappend "quiet splash" \
    --mirror-bootstrap "$mirror" \
    --mirror-binary "$mirror" \
    --distribution "$dist" \
    --categories 'main' \
    --apt-recommends disabled \
    --union-filesystem aufs \
    --linux-packages 'linux-image-2.6 aufs-modules-2.6 squashfs-modules-2.6' \
    --iso-publisher "$publisher" \
    --iso-volume "DebGisLive $dist (DATE)" \
    --username "$live_username" \
    --hostname "$live_hostname" \
    --verbose

#    --keyring-packages debian-archive-keyring \
then
  msg_info generating configuration succeeded
else
  msg_error generating configuration failed
  exit 1
fi

# copy hooks
if [ -d "$hook_dir" ]; then
    for hook in $(ls "$hook_dir"); do
        cp -v $hook_dir/$hook config/chroot_local-hooks
    done
fi

# copy package lists
if [ -d "$package_list_dir" ]; then
    for list in $(ls "$package_list_dir"); do
        cp -v $package_list_dir/$list config/chroot_local-packageslists
    done
fi

# copy misc files 
if [ -d "$misc_files_dir" ]; then
    ( cd "$misc_files_dir" && find . ! \( -type d -a -name ".svn" -prune \) ) | while read file; do
        if [ -d "$misc_files_dir/$file" ]; then
            mkdir -p config/chroot_local-includes/$file
        elif [ -f "$misc_files_dir/$file" ]; then
            cp -v $misc_files_dir/$file config/chroot_local-includes/$file
        fi            
    done
fi

# prepare chroot
if $SUDO /usr/bin/lh_bootstrap >> $logfile 2>&1; then
    msg_info "bootstrap succeeded."
else
    msg_error "bootstrap failed."
    exit 1
fi

if $SUDO /usr/bin/lh_chroot >> $logfile 2>&1; then
    msg_info "creating chroot succeeded."
else
    msg_error "creating chroot failed."
    exit 1
fi    

# Generate RLE from a splash image PNG
# Color index 0 is background, and index 7 is foreground.  Set to
# black and white respecively
if [ -f "$splashpng" ] ; then
    pngtopnm < $splashpng | ppmquant 16 2>/dev/null | \
	ppmtolss16 "#ffffff=7" "#000000=0"  2>/dev/null \
	> config/binary_syslinux/splash.rle
fi

# call lh_binary to build the iso image and publish the result
if $SUDO /usr/bin/lh_binary >> $logfile 2>&1; then
  msg_info "build succeeded."
else
  msg_error "build failed."
  exit 1
fi
if [ -f binary.iso ] ; then
  mv binary.iso $publish_dir/gislive-${dist}-${today}.iso
  md5sum $publish_dir/gislive-${dist}-${today}.iso > $publish_dir/gislive-${dist}-${today}.md5sum
  msg_info successfully build live-cd.
else 
  echo "#########################################################"
  echo 
  echo "An error occured, .iso was not created :-("
  echo 
  if [ ! "$verbose" ]; then
      echo "30 last lines of the make-live output:"
      echo
      tail -30 $logfile
  fi          
fi 

# cleanup old images and logs
find $publish_dir -mtime +1 !  -name "gislive-*00.???" -exec rm {} \;
find $publish_dir -mtime +2 !  -name "gislive-1600.???" -exec rm {} \;
find $publish_dir -mtime +14 ! -name "gislive-0400.???" -exec rm {} \;