slitaz-modular view mkiso.sh @ rev 173

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