slitaz-modular view mkiso.sh @ rev 146

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