slitaz-modular view initramfs/usr/bin/slitaz-modular @ rev 176

Tiny edits
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Mar 30 01:34:14 2016 +0300 (2016-03-30)
parents 87aa12b14afa
children
line source
1 #!/bin/sh
3 . /etc/slitaz/slitaz.conf
5 BASEDIR="$LOCAL_REPOSITORY/slitaz-modular"
6 PROFILE="$BASEDIR/$1"
7 WORKING="$PROFILE/working"
8 CDNAME="slitaz"
9 QUIET="y"
10 FORCE="y"
11 export LABEL="slitaz_$1_$(date +%F)"
12 VOLUME_ID="$LABEL"
13 PUBLISHER="SliTaz-$1"
14 APPLICATION="SliTaz-$1"
15 EXT="xz"
16 COMPRESSION="-comp xz -Xbcj x86"
17 WORKING="$PROFILE/working"
18 INITRAMFS="$WORKING/initramfs"
19 UNION="$WORKING/union"
20 LOG="$WORKING/log"
21 ISODIR="$WORKING/iso"
22 IMGNAME="$PROFILE/$CDNAME-$1-$(date +%F).iso"
23 IMGMD5NAME="$IMGNAME.md5"
24 SGNFILE="$ISODIR/$CDNAME/livecd.sgn"
25 MODULES_DIR="$WORKING/modules"
26 HG_DIR="$WORKING/hg"
27 HG_URL="http://hg.slitaz.org"
28 HG_PATH="home/slitaz/repos"
29 COPY_HG="no"
30 UPDATE_HG="no"
31 BACKUP_SOURCES="no"
32 BACKUP_PACKAGES="no"
33 MIRROR_DIR="mirror"
34 PKGISO_DIR="$ISODIR/$MIRROR_DIR/packages"
35 SRCISO_DIR="$ISODIR/$MIRROR_DIR/src"
36 BACKUP_ALL="no"
37 KEY_FILES="init liblinuxlive linuxrc"
38 INSTALL_FILES="files.list md5sum receipt volatile.cpio.gz"
39 CLEAN_MODULES_DIR="no"
40 CLEAN_INITRAMFS="no"
41 PACKAGES_REPOSITORY="$LOCAL_REPOSITORY/packages"
42 INCOMING_REPOSITORY="$LOCAL_REPOSITORY/packages-incoming"
43 SOURCES_REPOSITORY="$LOCAL_REPOSITORY/src"
44 HG_LIST="flavors flavors-stable slitaz-base-files slitaz-boot-scripts \
45 slitaz-configs slitaz-dev-tools slitaz-doc slitaz-doc-wiki-data slitaz-forge \
46 slitaz-modular slitaz-pizza slitaz-tools slitaz-vz ssfs tazlito tazpanel \
47 tazpkg tazusb tazweb tazwok tiny-slitaz website wok wok-stable \
48 wok-tiny wok-undigest"
50 error () { echo -e "\033[1;31;40m!!! \033[1;37;40m$@\033[1;0m"; }
51 warn () { echo -e "\033[1;33;40m*** \033[1;37;40m$@\033[1;0m"; }
52 info () { echo -e "\033[1;32;40m>>> \033[1;37;40m$@\033[1;0m"; }
55 if [ ! -f "$PROFILE/config" ]; then
56 echo "$PROFILE/config doesn't exist."
57 exit 1
58 fi
60 if [ -f ${PROFILE}/config ]; then
61 source ${PROFILE}/config
62 fi
64 cd $PROFILE
66 lzma_switches()
67 {
68 echo "-d$(echo 24) -mt$(grep ^processor < /proc/cpuinfo | wc -l)"
69 }
71 # Pack rootfs
72 pack_rootfs()
73 {
74 ( cd $1 ; find . -print | cpio -o -H newc ) | \
75 if [ -x /usr/bin/lzma ]; then
76 info "Generating lzma'ed initramfs... "
77 lzma e -si -so $(lzma_switches $1) > $2
78 else
79 info "Generating gziped initramfs... "
80 gzip -9 > $2
81 fi
82 echo 1 > /tmp/rootfs
83 }
85 look_for_dep()
86 {
87 grep -m1 ^$1$'\t' $INCOMING_REPOSITORY/depends.txt | \
88 cut -f 2 | sed 's|^[ \t]*||g' | sed 's| |\n|g' | sed '/^$/d'
89 }
91 _overlay()
92 {
93 if [ -d ${MODULES_DIR}/overlay ]; then
94 rm -rf ${MODULES_DIR}/overlay
95 cp -rf ${PROFILE}/overlay ${MODULES_DIR}
96 cp -af ${BASEDIR}/initramfs/* ${MODULES_DIR}/overlay
97 else
98 cp -rf ${PROFILE}/overlay ${MODULES_DIR}
99 cp -af ${BASEDIR}/initramfs/* ${MODULES_DIR}/overlay
100 fi
102 if [ -f ${MODULES_DIR}/overlay/etc/local-mirror.conf ]; then
103 sed -i "s|^#PKGDIR|PKGDIR=/packages|g" ${MODULES_DIR}/overlay/etc/local-mirror.conf
104 sed -i "s|^#SRCDIR|SRCDIR=/src|g" ${MODULES_DIR}/overlay/etc/local-mirror.conf
105 fi
106 create_module "${MODULES_DIR}/overlay" "${ISODIR}/${CDNAME}/modules/zzz.overlay.${EXT}" >/dev/null
107 }
109 initramfs () {
111 if [ ! -e "$BASEDIR/initramfs/initramfs.list" ]; then
112 error "error: $BASEDIR/initramfs/initramfs.list doesn't exist, aborting."
113 exit 1
114 fi
116 if [ ! -d ${INITRAMFS} ]; then
117 mkdir -p $INITRAMFS
118 fi
120 info "Making bootable image"
121 cat "$BASEDIR/initramfs/initramfs.list" | grep -v "^#" | while read pkgname; do
122 if [ ! -f ${INITRAMFS}${INSTALLED}/${pkgname}/files.list ]; then
123 tazpkg get-install $pkgname --root=$INITRAMFS | tee -a $LOG/initramfs.log
124 if [ ! $(grep -l "^${pkgname}$" $ISODIR/packages-order.txt) ]; then
125 echo "$pkgname" >> $ISODIR/packages-order.txt
126 fi
127 sleep 1
128 else
129 info "${pkgname} installed"
130 fi
131 done
133 if [ ! -d $ISODIR/boot ]; then
134 mkdir -p $ISODIR/boot
135 fi
137 #if [ ! -f $ISODIR/boot/bzImage ]; then
138 cp -a $INITRAMFS/boot/vmlinuz* $ISODIR/boot/bzImage
139 rm -f $INITRAMFS/boot/vmlinuz*
140 if [ -f $INITRAMFS/boot/gpxe ]; then
141 cp -a $INITRAMFS/boot/gpxe $ISODIR/boot/gpxe
142 rm -f $INITRAMFS/boot/gpxe
143 fi
144 #fi
145 if [ -d $BASEDIR/initramfs ]; then
146 for i in $KEY_FILES; do
147 if [ -f $BASEDIR/initramfs/$i ]; then
148 cp -af $BASEDIR/initramfs/$i $INITRAMFS
149 fi
150 done
151 fi
153 if [ -f $INITRAMFS/liblinuxlive ]; then
154 sed -i "s|^#MIRROR|MIRROR=$MIRROR_DIR|g" $INITRAMFS/liblinuxlive
155 fi
157 }
159 copy_hg() {
160 if [ ! -d ${HG_DIR}/${1}/${HG_PATH}/${1} ]; then
161 info "Cloning $1 repo ..."
162 hg clone $HG_URL/${1} ${HG_DIR}/${1}/${HG_PATH}/${1}
163 if [ $(grep -l "^HG_URL=$HG_URL" $PROFILE/config) ]; then
164 if [ ! $(grep -l "$HG_URL" ${HG_DIR}/${1}/${HG_PATH}/${1}/.hg/hgrc) ]; then
165 echo "mirror = $HG_URL/$1" >> ${HG_DIR}/${1}/${HG_PATH}/${1}/.hg/hgrc
166 fi
167 fi
168 elif [ -d ${HG_DIR}/${1}/${HG_PATH}/${1} -a ${UPDATE_HG} = "yes" ]; then
169 info "Updating $1 repo ..."
170 cd ${HG_DIR}/${1}/${HG_PATH}/${1}
171 hg pull $HG_URL/${1} -u
172 if [ $(grep -l "^HG_URL=$HG_URL" $PROFILE/config) ]; then
173 if [ ! $(grep -l "$HG_URL" ${HG_DIR}/${1}/${HG_PATH}/${1}/.hg/hgrc) ]; then
174 echo "mirror = $HG_URL/$1" >> ${HG_DIR}/${1}/${HG_PATH}/${1}/.hg/hgrc
175 fi
176 fi
177 cd $PROFILE
178 fi
179 }
181 mktaz2xz()
182 {
183 CUR_DIR="$2"
184 local i
186 tazpkg get $1 || exit 1
187 PACKAGE_FILE="$(find -name "$1*.tazpkg")"
188 if [ -f "$PACKAGE_FILE" ]; then
189 { cpio --quiet -i receipt > /dev/null 2>&1; } < $PACKAGE_FILE
190 unset PKGNAME PACKAGE VERSION EXTRAVERSION
191 source receipt || exit 1
192 PKGNAME="${PACKAGE}-${VERSION}${EXTRAVERSION}"
193 tazpkg extract $PKGNAME.tazpkg
194 for i in $INSTALL_FILES; do
195 if [ -f "$PKGNAME/$i" ]; then
196 mkdir -p $PKGNAME/fs/$INSTALLED/$PACKAGE
197 cp -a $PKGNAME/$i $PKGNAME/fs/$INSTALLED/$PACKAGE/$i
198 fi
199 done
200 [ -d $CUR_DIR ] || mkdir $CUR_DIR
201 md5sum $PKGNAME.tazpkg > $PKGNAME/fs/$INSTALLED/$PACKAGE/pkgmd5
202 create_module $PKGNAME/fs $CUR_DIR/$PKGNAME.$EXT $INSTALLED
203 fi
204 }
206 create_module()
207 {
208 if [ ! -d "$1" ]; then
209 error "Error: '$1' is not a directory"
210 return 1
211 fi
213 #if [ -d "${1}${3}" ]; then
214 # time_dir="${3}"
215 # sqimg="${2}/$(basename ${1}).${EXT}"
216 # info "====> Generating SquashFS image for '${1}'"
217 # if [ -e "${sqimg}" ]; then
218 # dirhaschanged=$(find ${1}${time_dir} -newer ${sqimg})
219 # if [ "${dirhaschanged}" != "" ]; then
220 # info "SquashFS image '${sqimg}' is not up to date, rebuilding..."
221 # rm -f "${sqimg}"
222 # else
223 # info "SquashFS image '${sqimg}' is up to date, skipping."
224 # return
225 # fi
226 # fi
227 #fi
228 [ -f "$2" ] && rm -f "$2" # overwrite, never append to existing file
229 mksquashfs "$1" "$2" -b 256K $COMPRESSION >/dev/null
230 if [ $? -ne 0 ]; then return 1; fi
231 chmod a-wx "$2" # remove execute and write attrib
232 chmod a+r "$2" # add read for everyone
233 }
235 squashfs_hg() {
236 if [ ! -d "$ISODIR/$CDNAME/modules/hg" ]; then
237 mkdir -p "$ISODIR/$CDNAME/modules/hg"
238 fi
239 if [ -d ${HG_DIR}/${1}/ ]; then
240 info "Making $ISODIR/$CDNAME/modules/hg/${1}.$EXT module"
241 create_module ${HG_DIR}/${1} $ISODIR/$CDNAME/modules/hg/${1}.$EXT
242 fi
243 }
245 pkg_flavors_modules()
246 {
247 local i
248 cat "$PROFILE/list/${flavors}.list" | grep -v "^#" | while read i; do
249 look_for_dep $i > /tmp/deps
250 if [ "$(cat /tmp/deps)" != "" ]; then
251 cat /tmp/deps | while read d; do
252 if [ ! $(grep "^$d$" $ISODIR/packages-order.txt) ]; then
253 [ -d $MODULES_DIR/$d ] || mkdir -p $MODULES_DIR/$d
254 [ -f $MODULES_DIR/$d/receipt ] && continue
255 if [ "$CLEAN_MODULES_DIR" = "yes" ]; then
256 if [ -d $MODULES_DIR/$d ]; then
257 rm -Rf $MODULES_DIR/$d
258 fi
259 [ -f $LOG/$d.log ] && rm -f $LOG/$d.log
260 fi
261 info "Make module of depend package $d" | tee -a $LOG/$d.log
262 echo "$d" >> $ISODIR/packages-order.txt
263 cd $MODULES_DIR/$d
264 mktaz2xz $d $ISODIR/$CDNAME/base/$flavors | tee -a $LOG/$d.log
265 cd $PROFILE
266 fi
267 done
268 fi
269 if [ ! $(grep "^$i$" $ISODIR/packages-order.txt) ]; then
270 [ -d $MODULES_DIR/$i ] || mkdir -p $MODULES_DIR/$i
271 [ -f $MODULES_DIR/$i/receipt ] && continue
272 if [ "$CLEAN_MODULES_DIR" = "yes" ]; then
273 if [ -d $MODULES_DIR/$i ]; then
274 rm -Rf $MODULES_DIR/$i
275 fi
276 [ -f $LOG/$i.log ] && rm -f $LOG/$i.log
277 fi
278 echo "$i" >> $ISODIR/packages-order.txt
279 info "Make module of main package $i"
280 cd $MODULES_DIR/$i
281 mktaz2xz $i $ISODIR/$CDNAME/base/$flavors
282 cd $PROFILE
283 fi
284 done
285 }
287 build_modules()
288 {
289 mkdir -p $WORKING
290 mkdir -p $LOG
291 mkdir -p $ISODIR/${CDNAME}/base
292 mkdir -p $ISODIR/${CDNAME}/modules
293 mkdir -p $ISODIR/${CDNAME}/optional
294 mkdir -p $ISODIR/${CDNAME}/rootcopy
295 mkdir -p $ISODIR/${CDNAME}/tmp
297 touch $SGNFILE
299 if [ "$CLEAN_MODULES_DIR" = "yes" ]; then
300 [ -f $ISODIR/packages-order.txt ] && rm -f $ISODIR/packages-order.txt
301 touch $ISODIR/packages-order.txt
302 fi
304 if [ "$CLEAN_INITRAMFS" = "yes" ]; then
305 if [ -d ${INITRAMFS} ]; then
306 rm -Rf ${INITRAMFS}
307 fi
308 fi
310 if [ ! -d $INITRAMFS ]; then
311 initramfs
312 fi
314 if [ ! -d $SLITAZ_DIR/repos/wok ]; then
315 hg clone $HG_URL/wok $SLITAZ_DIR/repos/wok
316 fi
318 [ -d $INCOMING_REPOSITORY ] || mkdir -p $INCOMING_REPOSITORY
319 cooker gen-wok-db $SLITAZ_DIR/repos/wok-tank
321 local i
322 for flavors in $FLAVORS_LIST; do
323 if [ -f "$PROFILE/list/${flavors}.list" ]; then
324 pkg_flavors_modules
325 fi
326 done
328 }
330 backup_pkg() {
331 if [ "${BACKUP_PACKAGES}" = "yes" ]; then
332 [ -d $PKGISO_DIR ] && rm -r $PKGISO_DIR
333 [ -f $LOG/backup_pkg.log ] && rm -rf $LOG/backup_pkg.log
334 mkdir -p $PKGISO_DIR
335 info "Making cooking list based installed packages in union"
336 # this is to filter out packages build by get-
337 # packages that don't exist in repo or wok
338 cat $ISODIR/packages-installed.list | while read pkg; do
339 if [ ! -f $WOK/$pkg/receipt ]; then
340 sed -i "s|$pkg||g" $ISODIR/packages-installed.list
341 fi
342 done
343 local pkg wanted rwanted pkg_VERSION incoming_pkg_VERSION cache_pkg_VERSION
344 cook gen-cooklist $ISODIR/packages-installed.list > $ISODIR/cookorder.list
345 [ -f $PKGS/fullco.txt ] || cook gen-wok-db $WOKHG
346 cookorder=$ISODIR/cookorder.list
347 [ "$BACKUP_ALL" = "yes" ] && cookorder=$PKGS/fullco.txt
348 [ "$BACKUP_ALL" = "yes" ] && cp -a $cookorder $PKGISO_DIR/fullco.txt
349 CACHE_REPOSITORY="$CACHE_DIR/$(cat /etc/slitaz-release)/packages"
350 [ -f $PROFILE/list/backupall.banned ] && cp -a $PROFILE/list/backupall.banned $ISODIR/blocked
352 cat $cookorder | grep -v "^#" | while read pkg; do
353 [ -f "$WOK/$pkg/receipt" ] || continue
354 unset rwanted pkg_VERSION incoming_pkg_VERSION cache_pkg_VERSION
355 rwanted=$(grep $'\t'$pkg$ $PKGS/wanted.txt | cut -f 1)
356 pkg_VERSION="$(grep -m1 -A1 ^$pkg$ $PACKAGES_REPOSITORY/packages.txt | \
357 tail -1 | sed 's/ *//')"
358 incoming_pkg_VERSION="$(grep -m1 -A1 ^$pkg$ $INCOMING_REPOSITORY/packages.txt | \
359 tail -1 | sed 's/ *//')"
360 cache_pkg_VERSION="$(grep -m1 -A1 ^$pkg$ $LOCALSTATE/packages.txt | \
361 tail -1 | sed 's/ *//')"
362 for wanted in $rwanted; do
363 if [ -f $PROFILE/list/backupall.banned ]; then
364 if [ "$BACKUP_ALL" = "yes" ]; then
365 [ $(grep -l "^$wanted$" $PROFILE/list/backupall.banned) ] && continue
366 fi
367 fi
369 if [ -f $INCOMING_REPOSITORY/$wanted-$incoming_pkg_VERSION.tazpkg ]; then
370 info "Backing up $INCOMING_REPOSITORY/$wanted-$incoming_pkg_VERSION.tazpkg" | tee -a $LOG/backup_pkg.log
371 ln -sf $INCOMING_REPOSITORY/$wanted-$incoming_pkg_VERSION.tazpkg $PKGISO_DIR/$wanted-$incoming_pkg_VERSION.tazpkg
372 elif [ -f $PACKAGES_REPOSITORY/$wanted-$pkg_VERSION.tazpkg ]; then
373 info "Backing up $PACKAGES_REPOSITORY/$wanted-$pkg_VERSION.tazpkg" | tee -a $LOG/backup_pkg.log
374 ln -sf $PACKAGES_REPOSITORY/$wanted-$pkg_VERSION.tazpkg $PKGISO_DIR/$wanted-$pkg_VERSION.tazpkg
375 elif [ -f $CACHE_REPOSITORY/$Wanted-$cache_pkg_VERSION.tazpkg ]; then
376 info "Backing up $CACHE_REPOSITORY/$wanted-$cache_pkg_VERSION.tazpkg" | tee -a $LOG/backup_pkg.log
377 ln -sf $CACHE_REPOSITORY/$wanted-$cache_pkg_VERSION.tazpkg $PKGISO_DIR/$wanted-$cache_pkg_VERSION.tazpkg
378 fi
379 done
381 if [ -f $PROFILE/list/backupall.banned ]; then
382 if [ "$BACKUP_ALL" = "yes" ]; then
383 [ $(grep -l "^$pkg$" $PROFILE/list/backupall.banned) ] && continue
384 fi
385 fi
387 if [ -f $INCOMING_REPOSITORY/$pkg-$incoming_pkg_VERSION.tazpkg ]; then
388 info "Backing up $INCOMING_REPOSITORY/$pkg-$incoming_pkg_VERSION.tazpkg" | tee -a $LOG/backup_pkg.log
389 ln -sf $INCOMING_REPOSITORY/$pkg-$incoming_pkg_VERSION.tazpkg $PKGISO_DIR/$pkg-$incoming_pkg_VERSION.tazpkg
390 elif [ -f $PACKAGES_REPOSITORY/$pkg-$pkg_VERSION.tazpkg ]; then
391 info "Backing up $PACKAGES_REPOSITORY/$pkg-$pkg_VERSION.tazpkg" | tee -a $LOG/backup_pkg.log
392 ln -sf $PACKAGES_REPOSITORY/$pkg-$pkg_VERSION.tazpkg $PKGISO_DIR/$pkg-$pkg_VERSION.tazpkg
393 elif [ -f $CACHE_REPOSITORY/$pkg-$cache_pkg_VERSION.tazpkg ]; then
394 info "Backing up $CACHE_REPOSITORY/$pkg-$cache_pkg_VERSION.tazpkg" | tee -a $LOG/backup_pkg.log
395 ln -sf $CACHE_REPOSITORY/$pkg-$cache_pkg_VERSION.tazpkg $PKGISO_DIR/$pkg-$cache_pkg_VERSION.tazpkg
396 fi
397 done
399 if [ "$SRC_PKG" = "yes" ]; then
400 cat $cookorder | grep -v "^#" | while read pkg; do
401 [ -f "$WOK/$pkg/receipt" ] || continue
402 [ $(grep ^$pkg$ $PROFILE/list/srcpkg.banned) ] && continue
403 for i in $(grep -l "^SOURCE=\"$pkg\"" $WOK/*/receipt); do
404 unset SOURCE TARBALL WANTED PACKAGE VERSION COOK_OPT WGET_URL
405 unset pkg_VERSION incoming_pkg_VERSION cache_pkg_VERSION src_pkg src_ver
406 #source $i
407 src_pkg=$(grep ^PACKAGE= $WOK/$pkg/receipt | cut -d "=" -f 2 | sed -e 's/"//g')
408 src_ver=$(grep ^VERSION= $WOK/$pkg/receipt | cut -d "=" -f 2 | sed -e 's/"//g')
409 [ "$VERSION" = "$src_ver" ] || continue
410 pkg_VERSION="$(grep -m1 -A1 ^$src_pkg$ $PACKAGES_REPOSITORY/packages.txt | \
411 tail -1 | sed 's/ *//')"
412 incoming_pkg_VERSION="$(grep -m1 -A1 ^$src_pkg$ $INCOMING_REPOSITORY/packages.txt | \
413 tail -1 | sed 's/ *//')"
414 cache_pkg_VERSION="$(grep -m1 -A1 ^$src_pkg$ $LOCALSTATE/packages.txt | \
415 tail -1 | sed 's/ *//')"
416 rwanted=$(grep $'\t'$src_pkg$ $PKGS/wanted.txt | cut -f 1)
418 for wanted in $rwanted; do
419 if [ -f $INCOMING_REPOSITORY/$wanted-$incoming_pkg_VERSION.tazpkg ]; then
420 ln -sf $INCOMING_REPOSITORY/$wanted-$incoming_pkg_VERSION.tazpkg $PKGISO_DIR/$wanted-$incoming_pkg_VERSION.tazpkg
421 elif [ -f $PACKAGES_REPOSITORY/$wanted-$pkg_VERSION.tazpkg ]; then
422 ln -sf $PACKAGES_REPOSITORY/$wanted-$pkg_VERSION.tazpkg $PKGISO_DIR/$wanted-$pkg_VERSION.tazpkg
423 elif [ -f $CACHE_REPOSITORY/$Wanted-$pkg_VERSION.tazpkg ]; then
424 ln -sf $CACHE_REPOSITORY/$wanted-$pkg_VERSION.tazpkg $PKGISO_DIR/$wanted-$pkg_VERSION.tazpkg
425 fi
426 done
428 if [ -f $INCOMING_REPOSITORY/$PACKAGE-$incoming_pkg_VERSION.tazpkg ]; then
429 ln -sf $INCOMING_REPOSITORY/$PACKAGE-$incoming_pkg_VERSION.tazpkg $PKGISO_DIR/$PACKAGE-$incoming_pkg_VERSION.tazpkg
430 elif [ -f $PACKAGES_REPOSITORY/$PACKAGE-$pkg_VERSION.tazpkg ]; then
431 ln -sf $PACKAGES_REPOSITORY/$PACKAGE-$pkg_VERSION.tazpkg $PKGISO_DIR/$PACKAGE-$pkg_VERSION.tazpkg
432 elif [ -f $CACHE_REPOSITORY/$PACKAGE-$cache_pkg_VERSION.tazpkg ]; then
433 ln -sf $CACHE_REPOSITORY/$PACKAGE-$cache_pkg_VERSION.tazpkg $PKGISO_DIR/$PACKAGE-$cache_pkg_VERSION.tazpkg
434 fi
435 done
436 done
437 fi
439 [ -f $LOG/packages-gen-list.log ] && rm -f $LOG/packages-gen-list.log
440 [ -d $PKGISO_DIR ] && cook pkgdb $PKGISO_DIR | tee -a $LOG/packages-gen-list.log
441 fi
443 }
445 backup_src() {
447 if [ "${BACKUP_PACKAGES}" = "yes" -a "${BACKUP_SOURCES}" = "yes" ]; then
448 [ -d $SOURCES_REPOSITORY ] || mkdir -p $SOURCES_REPOSITORY
449 [ -d $SRCISO_DIR ] && rm -r $SRCISO_DIR
450 mkdir -p $SRCISO_DIR
451 local pkg cookorder pkg_VERSION
452 cookorder=$ISODIR/cookorder.list
453 [ "$BACKUP_ALL" = "yes" ] && cookorder=$PKGS/fullco.txt
454 [ -f $LOG/cook-getsrc.log ] && rm -rf $LOG/cook-getsrc.log
455 [ -f $LOG/backup_src.log ] && rm -rf $LOG/backup_src.log
456 cat $cookorder | grep -v "^#" | while read pkg; do
457 if [ -f $PROFILE/list/backupall.banned ]; then
458 if [ "$BACKUP_ALL" = "yes" ]; then
459 [ $(grep -l "^$pkg$" $PROFILE/list/backupall.banned) ] && continue
460 fi
461 fi
462 unset PATCH SOURCE TARBALL WANTED PACKAGE VERSION COOK_OPT WGET_URL KBASEVER
463 unset pkg_VERSION
464 [ -f $WOK/$pkg/receipt ] || continue
465 source $WOK/$pkg/receipt
466 [ "$WGET_URL" ] || continue
467 [ "$TARBALL" ] || continue
468 pkg_VERSION="$(grep -m1 -A1 ^$pkg$ $PKGISO_DIR/packages.txt | \
469 tail -1 | sed 's/ *//')"
470 [ -f "$PKGISO_DIR/$PACKAGE-$pkg_VERSION.tazpkg" ] || continue
471 #{ [ ! "$TARBALL" ] || [ ! "$WGET_URL" ] ; } && continue
472 LZMA_TARBALL="${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma"
473 if [ "$PATCH" ]; then
474 if [ -f "$SOURCES_REPOSITORY/$(basename $PATCH)" ]; then
475 info "Backing up $SOURCES_REPOSITORY/$(basename $PATCH)" | tee -a $LOG/backup_src.log
476 ln -sf $SOURCES_REPOSITORY/$(basename $PATCH) $SRCISO_DIR/$(basename $PATCH)
477 else
478 cook $PACKAGE --getsrc | tee -a $LOG/cook-getsrc.log
479 if [ -f "$SOURCES_REPOSITORY/$(basename $PATCH)" ]; then
480 info "Backing up $SOURCES_REPOSITORY/$(basename $PATCH)" | tee -a $LOG/backup_src.log
481 ln -sf $SOURCES_REPOSITORY/$(basename $PATCH) $SRCISO_DIR/$(basename $PATCH)
482 fi
483 fi
484 fi
485 if [ -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 elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
489 info "Backing up $SOURCES_REPOSITORY/$TARBALL" | tee -a $LOG/backup_src.log
490 ln -sf $SOURCES_REPOSITORY/$TARBALL $SRCISO_DIR/$TARBALL
491 else
492 cook $PACKAGE --getsrc | tee -a $LOG/cook-getsrc.log
493 if [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
494 info "Backing up $SOURCES_REPOSITORY/$TARBALL" | tee -a $LOG/backup_src.log
495 ln -sf $SOURCES_REPOSITORY/$TARBALL $SRCISO_DIR/$TARBALL
496 elif [ -f "$SOURCES_REPOSITORY/$LZMA_TARBALL" ]; then
497 info "Backing up $SOURCES_REPOSITORY/$LZMA_TARBALL" | tee -a $LOG/backup_src.log
498 ln -sf $SOURCES_REPOSITORY/$LZMA_TARBALL $SRCISO_DIR/$LZMA_TARBALL
499 fi
500 fi
501 done
502 cd $SRCISO_DIR
503 info "Make md5sum file for sources"
504 find * -not -type d | grep -v md5sum | xargs md5sum > md5sum
505 cd $WORKING
506 fi
508 }
510 imgcommon () {
512 build_modules
514 if [ "$HG_LIST" != "" ]; then
515 if [ "$COPY_HG" = "yes" ]; then
516 for hg in $HG_LIST; do
517 copy_hg $hg
518 squashfs_hg $hg
519 done
520 fi
521 fi
523 if [ "$DONT_UPDATE_MIRROR" = "no" ]; then
524 [ -d $SRCISO_DIR ] && rm -r $SRCISO_DIR
525 [ -d $PKGISO_DIR ] && rm -r $PKGISO_DIR
526 if [ -d ${HG_DIR}/wok-tank/repos/wok-tank/.hg ]; then
527 WOK=${HG_DIR}/wok-tank/repos/wok-tank
528 backup_pkg
529 backup_src
530 elif [ -d ${HG_DIR}/wok/repos/wok/.hg ]; then
531 WOK=${HG_DIR}/wok/repos/wok
532 backup_pkg
533 backup_src
534 fi
535 fi
537 info "====> Making bootable image"
539 # Sanity checks
540 if [ ! -d "${ISODIR}" ]; then
541 error "Error: '${ISODIR}' doesn't exist. What did you do?!"
542 exit 1
543 fi
545 if [ ! -f "${SGNFILE}" ]; then
546 error "Error: the ${SGNFILE} file doesn't exist. This image won't do anything"
547 error " Protecting you from yourself and erroring out here..."
548 exit 1
549 fi
552 if [ -e "${IMGNAME}" ]; then
553 if [ "${FORCE}" = "y" ]; then
554 info "Removing existing bootable image..."
555 rm -rf "${IMGNAME}"
556 else
557 error "Error: Image '${IMGNAME}' already exists, aborting."
558 exit 1
559 fi
560 fi
562 }
564 make_iso () {
565 imgcommon
567 info "Creating rootfs.gz"
568 pack_rootfs $INITRAMFS $ISODIR/boot/rootfs.gz
570 if [ -d $PROFILE/rootcd ]; then
571 cp -af $PROFILE/rootcd/* $ISODIR/
572 fi
574 info "Copying isolinux files..."
575 if [ -d $INITRAMFS/boot/isolinux ]; then
576 cp -a $INITRAMFS/boot/isolinux $ISODIR/boot
577 rm -rf $INITRAMFS/boot/isolinux
578 fi
580 if [ -d ${PROFILE}/overlay ]; then
581 _overlay
582 fi
584 info "Creating ISO image..."
585 genisoimage -R -l -f -V $VOLUME_ID -o $IMGNAME -b boot/isolinux/isolinux.bin \
586 -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
587 -uid 0 -gid 0 \
588 -udf -allow-limited-size -iso-level 3 \
589 -P $PUBLISHER -input-charset utf-8 -boot-info-table $ISODIR
590 if [ -x /usr/bin/isohybrid ]; then
591 info "Creating hybrid ISO..."
592 isohybrid "${IMGNAME}"
593 fi
594 md5sum "$IMGNAME" > $IMGMD5NAME
595 sed -i "s|$PROFILE/||g" $IMGMD5NAME
596 }
598 make_iso