slitaz-modular view mkiso.sh @ rev 152

mkiso.sh: Make sure varibles made in backup_pkg and backup_src are local.
author Christopher Rogers <slaxemulator@gmail.com>
date Sat Dec 24 16:21:25 2011 +0000 (2011-12-24)
parents 74ae03ca4c23
children b8a5e6854be8
line source
1 #!/bin/bash
3 . /etc/slitaz/slitaz.conf
4 . /etc/slitaz/cook.conf
6 QUIET="y"
7 FORCE="y"
8 PUBLISHER="Slitaz"
9 APPLICATION="Slitaz"
10 CREATE_DEFAULT="n"
11 BASEDIR="$(pwd)"
12 PROFILE="$BASEDIR/$1"
13 export LABEL="slitaz_$1_$(date +%F)"
14 VOLUME_ID="$LABEL"
15 ver=""
16 CDNAME="slitaz"
17 RMSTUFF=n
18 MVSTUFF=n
19 UNGZIP=n
20 EXT="xz"
21 COMPRESSION="xz -Xbcj x86"
22 MKOPTION="-b 256k"
23 BASE_MODULES=""
24 MODULES=""
25 UNION_MODULES=""
26 WORKING="$PROFILE/working"
27 INITRAMFS="$WORKING/initramfs"
28 UNION="$WORKING/union"
29 LOG="$WORKING/log"
30 ISODIR="$WORKING/iso"
31 IMGNAME="$PROFILE/$CDNAME-$1-$(date +%F).iso"
32 IMGMD5NAME="$IMGNAME.md5"
33 LASTBR="$INITRAMFS"
34 SGNFILE="$ISODIR/$CDNAME/livecd.sgn"
35 MODULES_DIR="$WORKING/modules"
36 HG_DIR="$WORKING/hg"
37 HG_URL="http://hg.slitaz.org"
38 HG_PATH="repos"
39 COPY_HG="no"
40 UPDATE_HG="no"
41 BACKUP_SOURCES="no"
42 BACKUP_PACKAGES="no"
43 MIRROR_DIR="mirror"
44 PKGISO_DIR="$ISODIR/$MIRROR_DIR/packages"
45 SRCISO_DIR="$ISODIR/$MIRROR_DIR/src"
46 BACKUP_ALL="no"
47 KEY_FILES="init liblinuxlive linuxrc"
48 CLEAN_MODULES_DIR="no"
49 CLEAN_INITRAMFS="no"
50 LOCAL_REPOSITORY="$SLITAZ"
51 PACKAGES_REPOSITORY="$PKGS"
52 INCOMING_REPOSITORY="$INCOMING"
53 SOURCES_REPOSITORY="$SRC"
54 HG_LIST="cookutils flavors flavors-stable slitaz-base-files slitaz-configs slitaz-dev-tools slitaz-doc slitaz-forge slitaz-modular slitaz-pizza slitaz-tools slitaz-vz ssfs tazlito tazpanel tazpkg tazusb tazweb tazwok website wok wok-stable wok-tiny wok-undigest"
55 MY_HG_LIST="slitaz-doc-wiki-data slitaz-boot-scripts my-cookutils wok-tank"
56 MY_HG_URL="https://bitbucket.org/godane"
58 error () { echo -e "\033[1;31;40m!!! \033[1;37;40m$@\033[1;0m"; }
59 warn () { echo -e "\033[1;33;40m*** \033[1;37;40m$@\033[1;0m"; }
60 info () { echo -e "\033[1;32;40m>>> \033[1;37;40m$@\033[1;0m"; }
62 # do UID checking here so someone can at least get usage instructions
63 #if [ "$EUID" != "0" ]; then
64 # error "error: This script must be run as root."
65 # exit 1
66 #fi
67 if [ ! -d $PROFILE -o "$1" = "" ]; then
68 echo "$0 profile-name"
69 echo "ex $0 core"
70 exit 1
71 fi
73 ROOT_MOD="$(ls -1 ${PROFILE}/list | head -1)"
74 INST_ROOT="${MODULES_DIR}/$(basename ${ROOT_MOD} .list)"
76 if [ -f ${PROFILE}/config ]; then
77 source ${PROFILE}/config
78 fi
80 _overlay()
81 {
82 if [ -d ${MODULES_DIR}/overlay ]; then
83 rm -rf ${MODULES_DIR}/overlay
84 cp -rf ${PROFILE}/overlay ${MODULES_DIR}
85 cp -af ${BASEDIR}/initramfs/* ${MODULES_DIR}/overlay
86 else
87 cp -rf ${PROFILE}/overlay ${MODULES_DIR}
88 cp -af ${BASEDIR}/initramfs/* ${MODULES_DIR}/overlay
89 fi
91 if [ -f ${MODULES_DIR}/overlay/etc/local-mirror.conf ]; then
92 sed -i "s|^#PKGDIR|PKGDIR=/packages|g" ${MODULES_DIR}/overlay/etc/local-mirror.conf
93 sed -i "s|^#SRCDIR|SRCDIR=/src|g" ${MODULES_DIR}/overlay/etc/local-mirror.conf
94 fi
96 if [ "${QUIET}" = "y" ]; then
97 mksquashfs "${MODULES_DIR}/overlay" "${ISODIR}/${CDNAME}/modules/zzz.overlay.${EXT}" -comp ${COMPRESSION} -noappend ${MKOPTION} >/dev/null
98 else
99 mksquashfs "${MODULES_DIR}/overlay" "${ISODIR}/${CDNAME}/modules/zzz.overlay.${EXT}" -comp ${COMPRESSION} -noappend ${MKOPTION}
100 fi
101 }
103 lzma_switches()
104 {
105 echo "-d$(echo 24) -mt$(grep ^processor < /proc/cpuinfo | wc -l)"
106 }
108 # Pack rootfs
109 pack_rootfs()
110 {
111 ( cd $1 ; find . -print | cpio -o -H newc ) | \
112 if [ -x /usr/bin/lzma ]; then
113 info "Generating lzma'ed initramfs... "
114 lzma e -si -so $(lzma_switches $1) > $2
115 else
116 info "Generating gziped initramfs... "
117 gzip -9 > $2
118 fi
119 echo 1 > /tmp/rootfs
120 }
122 download()
123 {
124 for file in $@; do
125 wget -q $file && break
126 done
127 }
129 initramfs () {
131 if [ ! -e "$BASEDIR/initramfs/initramfs.list" ]; then
132 error "error: $BASEDIR/initramfs/initramfs.list doesn't exist, aborting."
133 exit 1
134 fi
136 if [ "$CLEAN_INITRAMFS" = "yes" ]; then
137 if [ -d ${INITRAMFS} ]; then
138 rm -Rf ${INITRAMFS}
139 fi
140 fi
142 if [ ! -d ${INITRAMFS} ]; then
143 mkdir -p $INITRAMFS
144 fi
146 info "Making bootable image"
147 [ -f $LOG/initramfs.log ] && rm -f $LOG/initramfs.log
148 cat "$BASEDIR/initramfs/initramfs.list" | grep -v "^#" | while read pkgname; do
149 if [ ! -f ${INITRAMFS}${INSTALLED}/${pkgname}/files.list ]; then
150 tazpkg get-install $pkgname --root=$INITRAMFS 2>&1 | tee -a $LOG/initramfs.log
151 sleep 1
152 else
153 info "${pkgname} installed" | tee -a $LOG/initramfs.log
154 fi
155 done
157 if [ ! -d $ISODIR/boot ]; then
158 mkdir -p $ISODIR/boot
159 fi
161 #if [ ! -f $ISODIR/boot/bzImage ]; then
162 if [ -f $INITRAMFS/boot/vmlinuz* ]; then
163 cp -a $INITRAMFS/boot/vmlinuz* $ISODIR/boot/bzImage
164 rm -f $INITRAMFS/boot/vmlinuz*
165 fi
167 if [ -f $INITRAMFS/boot/gpxe ]; then
168 cp -a $INITRAMFS/boot/gpxe $ISODIR/boot/gpxe
169 rm -f $INITRAMFS/boot/gpxe
170 fi
172 if [ -d $BASEDIR/initramfs ]; then
173 for i in $KEY_FILES; do
174 if [ -f $BASEDIR/initramfs/$i ]; then
175 cp -af $BASEDIR/initramfs/$i $INITRAMFS
176 fi
177 done
178 fi
180 if [ -f $INITRAMFS/liblinuxlive ]; then
181 sed -i "s|^#MIRROR|MIRROR=$MIRROR_DIR|g" $INITRAMFS/liblinuxlive
182 fi
184 }
186 copy_hg() {
187 if [ ! -d ${HG_DIR}/${1}/${HG_PATH}/${1} ]; then
188 info "Cloning $1 repo ..."
189 hg clone $HG_URL/${1} ${HG_DIR}/${1}/${HG_PATH}/${1}
190 if [ $(grep -l "^HG_URL=$HG_URL" $PROFILE/config) ]; then
191 if [ ! $(grep -l "$HG_URL" ${HG_DIR}/${1}/${HG_PATH}/${1}/.hg/hgrc) ]; then
192 echo "mirror = $HG_URL/$1" >> ${HG_DIR}/${1}/${HG_PATH}/${1}/.hg/hgrc
193 fi
194 fi
195 elif [ -d ${HG_DIR}/${1}/${HG_PATH}/${1} -a ${UPDATE_HG} = "yes" ]; then
196 info "Updating $1 repo ..."
197 cd ${HG_DIR}/${1}/${HG_PATH}/${1}
198 hg pull $HG_URL/${1} -u
199 if [ $(grep -l "^HG_URL=$HG_URL" $PROFILE/config) ]; then
200 if [ ! $(grep -l "$HG_URL" ${HG_DIR}/${1}/${HG_PATH}/${1}/.hg/hgrc) ]; then
201 echo "mirror = $HG_URL/$1" >> ${HG_DIR}/${1}/${HG_PATH}/${1}/.hg/hgrc
202 fi
203 fi
204 cd $PROFILE
205 fi
206 }
208 squashfs_hg() {
209 if [ ! -d "$ISODIR/$CDNAME/modules/hg" ]; then
210 mkdir -p "$ISODIR/$CDNAME/modules/hg"
211 fi
212 if [ -d ${HG_DIR}/${1}/ ]; then
213 _mksquash ${HG_DIR}/${1} "$ISODIR/$CDNAME/modules/hg/" /${HG_PATH}/${1}
214 fi
215 }
217 slitaz_union () {
219 if [ -d ${MODULES_DIR}/${mod}${INSTALLED} ]; then
220 echo "${mod} module exist. Moving on."
221 elif [ ! -d ${MODULES_DIR}/${mod}${INSTALLED} ]; then
222 if [ -f "$PROFILE/list/${mod}.list" ]; then
223 [ -f ${LOG}/${mod}-current.log ] && rm -f ${LOG}/${mod}-current.log
224 cat "$PROFILE/list/${mod}.list" | grep -v "^#" | while read pkgname; do
225 if [ ! -f ${UNION}${INSTALLED}/${pkgname}/files.list ]; then
226 tazpkg get-install $pkgname --root=${UNION} 2>&1 | tee -a ${LOG}/${mod}-current.log
227 sleep 1
228 else
229 info "${pkgname} installed" | tee -a ${LOG}/${mod}-current.log
230 fi
231 done
232 fi
234 if [ -f $PROFILE/list/${mod}.removelist ]; then
235 [ -f ${LOG}/${mod}-current-removelist.log ] && rm -f ${LOG}/${mod}-current-removelist.log
236 cat "$PROFILE/list/${mod}.removelist" | grep -v "^#" | while read pkgname; do
237 if [ -f ${UNION}${INSTALLED}/${pkgname}/files.list ]; then
238 echo "y" | tazpkg remove ${pkgname} --root=${UNION} 2>&1 | tee -a ${LOG}/${mod}-current-removelist.log
239 sleep 1
240 else
241 info "${pkgname} removed"
242 fi
243 done
244 fi
245 fi
246 }
248 union () {
249 if [ "$BASE_MODULES" != "" ]; then
250 UNION_MODULES="$BASE_MODULES $MODULES"
251 elif [ "$MODULES" != "" ]; then
252 UNION_MODULES="$MODULES"
253 else
254 error "Error: no modules assigned in config for profile."
255 exit 1
256 fi
258 mkdir -p $WORKING
259 mkdir -p $UNION
260 mkdir -p $LOG
261 mkdir -p $ISODIR/${CDNAME}/base
262 mkdir -p $ISODIR/${CDNAME}/modules
263 mkdir -p $ISODIR/${CDNAME}/optional
264 mkdir -p $ISODIR/${CDNAME}/rootcopy
265 mkdir -p $ISODIR/${CDNAME}/tmp
266 mkdir -p $LASTBR
268 touch $SGNFILE
270 modprobe aufs
271 if [ $? -ne 0 ]; then
272 error "Error loading Union filesystem module. (aufs)"
273 exit 1
274 fi
276 # $INITRAMFS is now $LASTBR
277 # This will be copyed to /mnt/memory/changes on boot
278 initramfs
280 mount -t aufs -o br:${LASTBR}=rw aufs ${UNION}
281 if [ $? -ne 0 ]; then
282 error "Error mounting $union."
283 exit 1
284 fi
286 info "====> Installing packages to '$UNION'"
287 for mod in $UNION_MODULES; do
289 if [ "$CLEAN_MODULES_DIR" = "yes" ]; then
290 if [ -d $MODULES_DIR/$mod ]; then
291 rm -Rf $MODULES_DIR/$mod
292 fi
293 fi
295 if [ ! -d $MODULES_DIR/$mod ]; then
296 mkdir -p $MODULES_DIR/$mod
297 fi
298 info "Adding $MODULES_DIR/$mod as top branch of union."
299 mount -t aufs -o remount,add:0:${MODULES_DIR}/${mod}=rw aufs $UNION
300 info "Adding $LASTBR as lower branch of union."
301 mount -t aufs -o remount,mod:${LASTBR}=rr+wh aufs $UNION
302 LASTBR="$MODULES_DIR/${mod}"
304 slitaz_union
305 done
307 if [ -d ${UNION}/${INSTALLED} ]; then
308 ls ${UNION}/${INSTALLED} | sort > $ISODIR/packages-installed.list
309 fi
311 info "Unmounting union"
312 umount -l "${UNION}"
314 info "Removing unionfs .wh. files."
315 find ${MODULES_DIR} -type f -name ".wh.*" -exec rm {} \;
316 find ${MODULES_DIR} -type d -name ".wh.*" -exec rm -rf {} \;
317 }
319 backup_pkg() {
320 if [ "${BACKUP_PACKAGES}" = "yes" ]; then
321 [ -d $PKGISO_DIR ] && rm -r $PKGISO_DIR
322 [ -f $LOG/backup_pkg.log ] && rm -rf $LOG/backup_pkg.log
323 mkdir -p $PKGISO_DIR
324 info "Making cooking list based installed packages in union"
325 # this is to filter out packages build by get-
326 # packages that don't exist in repo or wok
327 cat $ISODIR/packages-installed.list | while read pkg; do
328 if [ ! -f $WOK/$pkg/receipt ]; then
329 sed -i "s|$pkg||g" $ISODIR/packages-installed.list
330 fi
331 done
332 local pkg wanted rwanted pkg_VERSION incoming_pkg_VERSION cache_pkg_VERSION
333 cook gen-cooklist $ISODIR/packages-installed.list > $ISODIR/cookorder.list
334 [ -f $PKGS/fullco.txt ] || cook gen-wok-db $WOKHG
335 cookorder=$ISODIR/cookorder.list
336 [ "$BACKUP_ALL" = "yes" ] && cookorder=$PKGS/fullco.txt
337 [ "$BACKUP_ALL" = "yes" ] && cp -a $cookorder $PKGISO_DIR/fullco.txt
338 CACHE_REPOSITORY="$CACHE_DIR/$(cat /etc/slitaz-release)/packages"
339 [ -f $PROFILE/list/backupall.banned ] && cp -a $PROFILE/list/backupall.banned $ISODIR/blocked
341 cat $cookorder | grep -v "^#" | while read pkg; do
342 [ -f "$WOK/$pkg/receipt" ] || continue
343 unset rwanted pkg_VERSION incoming_pkg_VERSION cache_pkg_VERSION
344 rwanted=$(grep $'\t'$pkg$ $PKGS/wanted.txt | cut -f 1)
345 pkg_VERSION="$(grep -m1 -A1 ^$pkg$ $PACKAGES_REPOSITORY/packages.txt | \
346 tail -1 | sed 's/ *//')"
347 incoming_pkg_VERSION="$(grep -m1 -A1 ^$pkg$ $INCOMING_REPOSITORY/packages.txt | \
348 tail -1 | sed 's/ *//')"
349 cache_pkg_VERSION="$(grep -m1 -A1 ^$pkg$ $LOCALSTATE/packages.txt | \
350 tail -1 | sed 's/ *//')"
351 for wanted in $rwanted; do
352 if [ -f $PROFILE/list/backupall.banned ]; then
353 if [ "$BACKUP_ALL" = "yes" ]; then
354 [ $(grep -l "^$wanted$" $PROFILE/list/backupall.banned) ] && continue
355 fi
356 fi
358 if [ -f $INCOMING_REPOSITORY/$wanted-$incoming_pkg_VERSION.tazpkg ]; then
359 info "Backing up $INCOMING_REPOSITORY/$wanted-$incoming_pkg_VERSION.tazpkg" | tee -a $LOG/backup_pkg.log
360 ln -sf $INCOMING_REPOSITORY/$wanted-$incoming_pkg_VERSION.tazpkg $PKGISO_DIR/$wanted-$incoming_pkg_VERSION.tazpkg
361 elif [ -f $PACKAGES_REPOSITORY/$wanted-$pkg_VERSION.tazpkg ]; then
362 info "Backing up $PACKAGES_REPOSITORY/$wanted-$pkg_VERSION.tazpkg" | tee -a $LOG/backup_pkg.log
363 ln -sf $PACKAGES_REPOSITORY/$wanted-$pkg_VERSION.tazpkg $PKGISO_DIR/$wanted-$pkg_VERSION.tazpkg
364 elif [ -f $CACHE_REPOSITORY/$Wanted-$cache_pkg_VERSION.tazpkg ]; then
365 info "Backing up $CACHE_REPOSITORY/$wanted-$cache_pkg_VERSION.tazpkg" | tee -a $LOG/backup_pkg.log
366 ln -sf $CACHE_REPOSITORY/$wanted-$cache_pkg_VERSION.tazpkg $PKGISO_DIR/$wanted-$cache_pkg_VERSION.tazpkg
367 fi
368 done
370 if [ -f $PROFILE/list/backupall.banned ]; then
371 if [ "$BACKUP_ALL" = "yes" ]; then
372 [ $(grep -l "^$pkg$" $PROFILE/list/backupall.banned) ] && continue
373 fi
374 fi
376 if [ -f $INCOMING_REPOSITORY/$pkg-$incoming_pkg_VERSION.tazpkg ]; then
377 info "Backing up $INCOMING_REPOSITORY/$pkg-$incoming_pkg_VERSION.tazpkg" | tee -a $LOG/backup_pkg.log
378 ln -sf $INCOMING_REPOSITORY/$pkg-$incoming_pkg_VERSION.tazpkg $PKGISO_DIR/$pkg-$incoming_pkg_VERSION.tazpkg
379 elif [ -f $PACKAGES_REPOSITORY/$pkg-$pkg_VERSION.tazpkg ]; then
380 info "Backing up $PACKAGES_REPOSITORY/$pkg-$pkg_VERSION.tazpkg" | tee -a $LOG/backup_pkg.log
381 ln -sf $PACKAGES_REPOSITORY/$pkg-$pkg_VERSION.tazpkg $PKGISO_DIR/$pkg-$pkg_VERSION.tazpkg
382 elif [ -f $CACHE_REPOSITORY/$pkg-$cache_pkg_VERSION.tazpkg ]; then
383 info "Backing up $CACHE_REPOSITORY/$pkg-$cache_pkg_VERSION.tazpkg" | tee -a $LOG/backup_pkg.log
384 ln -sf $CACHE_REPOSITORY/$pkg-$cache_pkg_VERSION.tazpkg $PKGISO_DIR/$pkg-$cache_pkg_VERSION.tazpkg
385 fi
386 done
388 if [ "$SRC_PKG" = "yes" ]; then
389 cat $cookorder | grep -v "^#" | while read pkg; do
390 [ -f "$WOK/$pkg/receipt" ] || continue
391 [ $(grep ^$pkg$ $PROFILE/list/srcpkg.banned) ] && continue
392 for i in $(grep -l "^SOURCE=\"$pkg\"" $WOK/*/receipt); do
393 unset SOURCE TARBALL WANTED PACKAGE VERSION COOK_OPT WGET_URL
394 unset pkg_VERSION incoming_pkg_VERSION cache_pkg_VERSION src_pkg src_ver
395 #source $i
396 src_pkg=$(grep ^PACKAGE= $WOK/$pkg/receipt | cut -d "=" -f 2 | sed -e 's/"//g')
397 src_ver=$(grep ^VERSION= $WOK/$pkg/receipt | cut -d "=" -f 2 | sed -e 's/"//g')
398 [ "$VERSION" = "$src_ver" ] || continue
399 pkg_VERSION="$(grep -m1 -A1 ^$src_pkg$ $PACKAGES_REPOSITORY/packages.txt | \
400 tail -1 | sed 's/ *//')"
401 incoming_pkg_VERSION="$(grep -m1 -A1 ^$src_pkg$ $INCOMING_REPOSITORY/packages.txt | \
402 tail -1 | sed 's/ *//')"
403 cache_pkg_VERSION="$(grep -m1 -A1 ^$src_pkg$ $LOCALSTATE/packages.txt | \
404 tail -1 | sed 's/ *//')"
405 rwanted=$(grep $'\t'$src_pkg$ $PKGS/wanted.txt | cut -f 1)
407 for wanted in $rwanted; do
408 if [ -f $INCOMING_REPOSITORY/$wanted-$incoming_pkg_VERSION.tazpkg ]; then
409 ln -sf $INCOMING_REPOSITORY/$wanted-$incoming_pkg_VERSION.tazpkg $PKGISO_DIR/$wanted-$incoming_pkg_VERSION.tazpkg
410 elif [ -f $PACKAGES_REPOSITORY/$wanted-$pkg_VERSION.tazpkg ]; then
411 ln -sf $PACKAGES_REPOSITORY/$wanted-$pkg_VERSION.tazpkg $PKGISO_DIR/$wanted-$pkg_VERSION.tazpkg
412 elif [ -f $CACHE_REPOSITORY/$Wanted-$pkg_VERSION.tazpkg ]; then
413 ln -sf $CACHE_REPOSITORY/$wanted-$pkg_VERSION.tazpkg $PKGISO_DIR/$wanted-$pkg_VERSION.tazpkg
414 fi
415 done
417 if [ -f $INCOMING_REPOSITORY/$PACKAGE-$incoming_pkg_VERSION.tazpkg ]; then
418 ln -sf $INCOMING_REPOSITORY/$PACKAGE-$incoming_pkg_VERSION.tazpkg $PKGISO_DIR/$PACKAGE-$incoming_pkg_VERSION.tazpkg
419 elif [ -f $PACKAGES_REPOSITORY/$PACKAGE-$pkg_VERSION.tazpkg ]; then
420 ln -sf $PACKAGES_REPOSITORY/$PACKAGE-$pkg_VERSION.tazpkg $PKGISO_DIR/$PACKAGE-$pkg_VERSION.tazpkg
421 elif [ -f $CACHE_REPOSITORY/$PACKAGE-$cache_pkg_VERSION.tazpkg ]; then
422 ln -sf $CACHE_REPOSITORY/$PACKAGE-$cache_pkg_VERSION.tazpkg $PKGISO_DIR/$PACKAGE-$cache_pkg_VERSION.tazpkg
423 fi
424 done
425 done
426 fi
428 [ -f $LOG/packages-gen-list.log ] && rm -f $LOG/packages-gen-list.log
429 [ -d $PKGISO_DIR ] && cook pkgdb $PKGISO_DIR | tee -a $LOG/packages-gen-list.log
430 fi
432 }
434 backup_src() {
436 if [ "${BACKUP_PACKAGES}" = "yes" -a "${BACKUP_SOURCES}" = "yes" ]; then
437 [ -d $SOURCES_REPOSITORY ] || mkdir -p $SOURCES_REPOSITORY
438 [ -d $SRCISO_DIR ] && rm -r $SRCISO_DIR
439 mkdir -p $SRCISO_DIR
440 local pkg cookorder pkg_VERSION
441 cookorder=$ISODIR/cookorder.list
442 [ "$BACKUP_ALL" = "yes" ] && cookorder=$PKGS/fullco.txt
443 [ -f $LOG/cook-getsrc.log ] && rm -rf $LOG/cook-getsrc.log
444 [ -f $LOG/backup_src.log ] && rm -rf $LOG/backup_src.log
445 cat $cookorder | grep -v "^#" | while read pkg; do
446 if [ -f $PROFILE/list/backupall.banned ]; then
447 if [ "$BACKUP_ALL" = "yes" ]; then
448 [ $(grep -l "^$pkg$" $PROFILE/list/backupall.banned) ] && continue
449 fi
450 fi
451 unset PATCH SOURCE TARBALL WANTED PACKAGE VERSION COOK_OPT WGET_URL KBASEVER
452 unset pkg_VERSION
453 [ -f $WOK/$pkg/receipt ] || continue
454 source $WOK/$pkg/receipt
455 [ "$WGET_URL" ] || continue
456 [ "$TARBALL" ] || continue
457 pkg_VERSION="$(grep -m1 -A1 ^$pkg$ $PKGISO_DIR/packages.txt | \
458 tail -1 | sed 's/ *//')"
459 [ -f "$PKGISO_DIR/$PACKAGE-$pkg_VERSION.tazpkg" ] || continue
460 #{ [ ! "$TARBALL" ] || [ ! "$WGET_URL" ] ; } && continue
461 LZMA_TARBALL="${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma"
462 if [ "$PATCH" ]; then
463 if [ -f "$SOURCES_REPOSITORY/$(basename $PATCH)" ]; then
464 info "Backing up $SOURCES_REPOSITORY/$(basename $PATCH)" | tee -a $LOG/backup_src.log
465 ln -sf $SOURCES_REPOSITORY/$(basename $PATCH) $SRCISO_DIR/$(basename $PATCH)
466 else
467 cook $PACKAGE --getsrc | tee -a $LOG/cook-getsrc.log
468 if [ -f "$SOURCES_REPOSITORY/$(basename $PATCH)" ]; then
469 info "Backing up $SOURCES_REPOSITORY/$(basename $PATCH)" | tee -a $LOG/backup_src.log
470 ln -sf $SOURCES_REPOSITORY/$(basename $PATCH) $SRCISO_DIR/$(basename $PATCH)
471 fi
472 fi
473 fi
474 if [ -f "$SOURCES_REPOSITORY/$LZMA_TARBALL" ]; then
475 info "Backing up $SOURCES_REPOSITORY/$LZMA_TARBALL" | tee -a $LOG/backup_src.log
476 ln -sf $SOURCES_REPOSITORY/$LZMA_TARBALL $SRCISO_DIR/$LZMA_TARBALL
477 elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
478 info "Backing up $SOURCES_REPOSITORY/$TARBALL" | tee -a $LOG/backup_src.log
479 ln -sf $SOURCES_REPOSITORY/$TARBALL $SRCISO_DIR/$TARBALL
480 else
481 cook $PACKAGE --getsrc | tee -a $LOG/cook-getsrc.log
482 if [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
483 info "Backing up $SOURCES_REPOSITORY/$TARBALL" | tee -a $LOG/backup_src.log
484 ln -sf $SOURCES_REPOSITORY/$TARBALL $SRCISO_DIR/$TARBALL
485 elif [ -f "$SOURCES_REPOSITORY/$LZMA_TARBALL" ]; then
486 info "Backing up $SOURCES_REPOSITORY/$LZMA_TARBALL" | tee -a $LOG/backup_src.log
487 ln -sf $SOURCES_REPOSITORY/$LZMA_TARBALL $SRCISO_DIR/$LZMA_TARBALL
488 fi
489 fi
490 done
491 cd $SRCISO_DIR
492 info "Make md5sum file for sources"
493 find * -not -type d | grep -v md5sum | xargs md5sum > md5sum
494 cd $WORKING
495 fi
497 }
499 # _mksquash dirname
500 _mksquash () {
501 if [ ! -d "$1" ]; then
502 error "Error: '$1' is not a directory"
503 return 1
504 fi
506 if [ ! -d "$2" ]; then
507 error "Error: '$2' is not a directory"
508 return 1
509 fi
511 if [ ! -d "${1}${3}" ]; then
512 error "Error: '${1}${3}' is not a directory"
513 return 1
514 fi
516 time_dir="${3}"
517 sqimg="${2}/$(basename ${1}).${EXT}"
518 info "====> Generating SquashFS image for '${1}'"
519 if [ -e "${sqimg}" ]; then
520 dirhaschanged=$(find ${1}${time_dir} -newer ${sqimg})
521 if [ "${dirhaschanged}" != "" ]; then
522 info "SquashFS image '${sqimg}' is not up to date, rebuilding..."
523 rm "${sqimg}"
524 else
525 info "SquashFS image '${sqimg}' is up to date, skipping."
526 return
527 fi
528 fi
530 info "Creating SquashFS image. This may take some time..."
531 start=$(date +%s)
532 if [ "${QUIET}" = "y" ]; then
533 mksquashfs "${1}" "${sqimg}" -noappend ${MKOPTION} -comp ${COMPRESSION} >/dev/null
534 else
535 mksquashfs "${1}" "${sqimg}" -noappend ${MKOPTION} -comp ${COMPRESSION}
536 fi
537 minutes=$(echo $start $(date +%s) | awk '{ printf "%0.2f",($2-$1)/60 }')
538 info "Image creation done in $minutes minutes."
539 }
541 imgcommon () {
542 for MOD in ${BASE_MODULES}; do
543 if [ -d "${MODULES_DIR}/${MOD}" ]; then
544 _mksquash "${MODULES_DIR}/${MOD}" "$ISODIR/$CDNAME/base" $INSTALLED
545 fi
546 done
548 if [ "${MODULES}" != "" ]; then
549 for MOD in ${MODULES}; do
550 if [ -d "${MODULES_DIR}/${MOD}" ]; then
551 _mksquash "${MODULES_DIR}/${MOD}" "$ISODIR/$CDNAME/modules" $INSTALLED
552 fi
553 done
554 fi
556 if [ "$HG_LIST" != "" ]; then
557 if [ "$COPY_HG" = "yes" ]; then
558 for hg in $HG_LIST; do
559 copy_hg $hg
560 squashfs_hg $hg
561 done
562 fi
563 fi
565 if [ "$MY_HG_LIST" != "" ]; then
566 if [ "$COPY_HG" = "yes" ]; then
567 for my_hg in $MY_HG_LIST; do
568 HG_URL="$MY_HG_URL"
569 copy_hg $my_hg
570 WOK=${HG_DIR}/wok-tank/repos/wok-tank
571 if [ -d $WOK/.hg ]; then
572 cd $WOK
573 if [ "$(hg branch)" != "cooking" ]; then
574 hg update cooking
575 fi
576 cd $PROFILE
577 fi
578 squashfs_hg $my_hg
579 done
580 fi
581 fi
583 [ -d $SRCISO_DIR ] && rm -r $SRCISO_DIR
584 [ -d $PKGISO_DIR ] && rm -r $PKGISO_DIR
586 if [ -d ${HG_DIR}/wok-tank/repos/wok-tank/.hg ]; then
587 WOK=${HG_DIR}/wok-tank/repos/wok-tank
588 backup_pkg
589 backup_src
590 elif [ -d ${HG_DIR}/wok/repos/wok/.hg ]; then
591 WOK=${HG_DIR}/wok/repos/wok
592 backup_pkg
593 backup_src
594 fi
596 info "====> Making bootable image"
598 # Sanity checks
599 if [ ! -d "${ISODIR}" ]; then
600 error "Error: '${ISODIR}' doesn't exist. What did you do?!"
601 exit 1
602 fi
604 if [ ! -f "${SGNFILE}" ]; then
605 error "Error: the ${SGNFILE} file doesn't exist. This image won't do anything"
606 error " Protecting you from yourself and erroring out here..."
607 exit 1
608 fi
611 if [ -e "${IMGNAME}" ]; then
612 if [ "${FORCE}" = "y" ]; then
613 info "Removing existing bootable image..."
614 rm -rf "${IMGNAME}"
615 else
616 error "Error: Image '${IMGNAME}' already exists, aborting."
617 exit 1
618 fi
619 fi
621 }
623 make_iso () {
624 imgcommon
626 info "Creating rootfs.gz"
627 pack_rootfs $INITRAMFS $ISODIR/boot/rootfs.gz
629 if [ -d $PROFILE/rootcd ]; then
630 cp -af $PROFILE/rootcd/* $ISODIR/
631 fi
633 info "Copying isolinux files..."
634 if [ -d $INITRAMFS/boot/isolinux ]; then
635 cp -a $INITRAMFS/boot/isolinux $ISODIR/boot
636 fi
638 if [ -d ${PROFILE}/overlay ]; then
639 _overlay
640 fi
642 info "Creating ISO image..."
643 genisoimage -R -l -f -V $VOLUME_ID -o $IMGNAME -b boot/isolinux/isolinux.bin \
644 -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
645 -uid 0 -gid 0 \
646 -udf -allow-limited-size -iso-level 3 \
647 -P $PUBLISHER -input-charset utf-8 -boot-info-table $ISODIR
648 if [ -x /usr/bin/isohybrid ]; then
649 info "Creating hybrid ISO..."
650 isohybrid "${IMGNAME}"
651 fi
652 md5sum "$IMGNAME" > $IMGMD5NAME
653 sed -i "s|$PROFILE/||g" $IMGMD5NAME
654 }
656 if [ "$BASE_MODULES" != "" ]; then
657 union
658 else
659 error "BASE_MODULES was empty. exiting."
660 exit 1
661 fi
663 make_iso