2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # T2 SDE: scripts/Create-ISO
4 # Copyright (C) 2004 - 2021 The T2 SDE Project
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2.
11 # --- T2-COPYRIGHT-NOTE-END ---
14 # Commands in isofs.txt files:
16 # EVERY from to Put this on every disk
17 # DISK1 from to Put this on the 1st disk
18 # SINGLE from to Put it on any disk
19 # SPLIT from to You may split it up over many disks
21 # BOOT boot-options Add this mkisofs options for 1st disk
23 # If you want to add multiple 'BOOT' lines, use the tag-name 'BOOTx' for
24 # the 2nd and all further lines.
26 # SCRIPT script-name args Run given script for each image
28 # Intended for image post-processing. The first argument is the CD
29 # number and the second the image file.
32 eval `grep sdever scripts/parse-config`
33 .
scripts
/functions.
in
38 echo "Usage: $0 [ -size MB ] [ -source ] [ -mkdebug ] [ -sha len ] ISO-Prefix \\"
39 echo " ${0//?/ } [ Config [ .. ] ]"
41 echo "E.g.: $0 mycdset system rescue"
47 dsize
=$
((1024 * 1024))
56 dsize
=$
(( $2 * 1024 )); shift; shift ;;
62 shalen
=$2; shift; shift ;;
73 [ $# -eq 0 ] && set -- 'default'
78 if [ ! -f config
/$cfg/config
]; then
79 echo "Not a valid config: $cfg"
83 [ $errno -ne 0 ] && exit 1
85 echo; date "+ [%X] Removing old files with same prefix ..."
86 [ "${isoprefix//\//}" == "${isoprefix}" ] && isoprefix
="$isoprefix"
87 rm -rvf ${isoprefix}[_.
]* ${isoprefix}.md5
89 date "+ [%X] Reading configs ..."
90 index
=`mktemp`; dat
=`mktemp`; pathspec
=`mktemp`
94 id
="`grep '^export SDECFG_ID=' config/$cfg/config |
95 cut -f2 -d\' 2> /dev/null`"
96 if ! cat build
/$id/TOOLCHAIN
/isofs.txt
>> $dat 2> /dev
/null
98 echo "Not a valid build: $cfg"
99 echo "build/$id/TOOLCHAIN/isofs.txt must exist."
100 rm -f $dat $index ${pathspec}_
*; exit 1
103 if test -f config
/$cfg/license-issue.ask
; then
104 if ! grep LICENSE-WARNING
$dat &> /dev
/null
; then
105 echo "EVERY misc/share/LICENSE-WARNING LICENSE-WARNING" >> $dat
108 cp -vf misc
/share
/LICENSE-WARNING build
/$id/TOOLCHAIN
/
109 echo "" >> build
/$id/TOOLCHAIN
/LICENSE-WARNING
110 echo "The following packages may have license restrictions:" >> build
/$id/TOOLCHAIN
/LICENSE-WARNING
111 cat config
/$cfg/license-issue.ask
>> build
/$id/TOOLCHAIN
/LICENSE-WARNING
113 if [ "`grep '^export SDECFG_LICENSE_ISSUE=' config/$cfg/config | cut -f2 -d\'`" = "0" ]; then
115 You have chosen to compile packages that are restricted
116 in their redistribution. Unless you accept this limitation
117 you cannot burn these packages.
119 Please rerun scripts/Config -cfg $cfg and check
120 'I have read and understood the licensing issues.'
123 #FIXME remove packages that have an issue instead of exiting
129 # function to add a given file $1 to the place $2 on the resulting ISO
132 local from
="$1" to
="$2" done=0
133 if [ ! -f "$from" -a ! -d "$from" ]; then
134 echo "No such file or directory: $from"
135 rm -f $dat $index ${pathspec}_
*; exit 1
138 files
="`find $from ! -type d | wc -l`"
139 size
="`du -s -b $from | cut -f1`"
140 size
=$
(( size
/ 1024 + files
* file_overhead
))
142 if [ $size -gt $
(( $dsize - $disk_0_size )) ]; then
143 echo "Chunk $from is too big!"
144 rm -f $dat $index ${pathspec}_
*; exit 1
148 ds
=disk_
${x}_size
; dd=disk_
${x}_data
149 if [ $
(( ${!ds} + $size )) -le \
150 $
(( $dsize - $disk_0_size )) ]; then
151 eval "$ds=$(( ${!ds} + $size ))"
152 echo "$to=$from" >> ${pathspec}_
${disk_nr}
157 if [ $done = 0 ]; then
159 ds
=disk_
${disk_nr}_size
; eval "$ds=$size"
161 # FIXME: if in a path-list files, mkisofs complains about
162 # missing isolinux. Should be a mkisofs bug!
163 if [ "$to" = "isolinux/" -o "$from" = "isolinux/" ]; then
164 echo "$to=$from" >> ${pathspec}_iso
166 echo "$to=$from" >> ${pathspec}_
${disk_nr}
168 disks
="$disks${disks:+ }$disk_nr"
174 while read tag data
; do
176 [ "$tag" ] ||
continue
177 if [ $tag = BOOT
]; then
178 if [ "$bootoptions" ]; then
179 echo "Multiple boot options found!"
180 rm -f $dat $index ${pathspec}_
*; exit 1
183 [[ $data == *-hfs* ]] && file_overhead
=12
185 elif [ $tag = SCRIPT
]; then
186 scripts
="$scripts $data"
189 while read tag data
; do
190 if [ "$tag" = BOOTx
]; then
191 bootoptions
="$bootoptions $data"
192 [[ $data == *-hfs* ]] && file_overhead
=12
196 echo "$spacer parsing for EVERY disk."
198 disks
="0"; disk_nr
=0; disk_0_size
=0
199 echo "index.txt=${isoprefix}_index.txt" >> ${pathspec}_0
200 while read type from to
; do
201 if [ "$type" = EVERY
]; then
203 if [ $disk_nr -gt 0 ]; then
204 echo "Every-disk data is too big!"
205 rm -f $dat $index ${pathspec}_
*; exit 1
210 echo "$spacer parsing for DISK1 disk."
213 while read type from to
; do
214 if [ "$type" = DISK1
]; then
216 if [ $disk_nr -gt 1 ]; then
217 echo "Disk 1 is too big!"
218 rm -f $dat $index ${pathspec}_
*; exit 1
223 echo "$spacer parsing for SINGLE disk."
225 while read type from to
; do
226 if [ "$type" = SINGLE
]; then
231 echo "$spacer parsing for SPLIT disk."
233 while read type from to
; do
234 if [ "$type" = SPLIT
]; then
235 find $from -type f
-printf '%P\n' |
sort > $index
242 if [ $src = 1 ]; then
243 date "+ [%X] Embedding source ..."
246 from
="`bz2filename $from`"
247 if [ -e $from ]; then
250 echo "WARNING: File $from is missing!"
252 done < <( scripts
/Download
-list |
sort -u )
255 date "+ [%X] Creating ISO index ..."
257 for x
in 0 $disks; do
259 for y
in ${!dd} `cat ${pathspec}_${x} 2> /dev
/null
`; do
260 to=${y%=*}; from=${y#*=}
261 if [ -e $from ]; then
262 find $from -printf "disk$x $to%P\\n" >> $index
264 echo "disk$x $to" >> $index
268 disk_0_size=$(( $disk_0_size + $( du -sk $index | cut -f1 ) ))
270 if [ -z "$bootoptions" ]; then
271 echo "WARNING: Disk1 is not bootable - no boot options defined."
276 for x in 0 $disks; do
278 total=$(( $total + ${!ds} ))
280 if [ $x = 0 ]; then y="Shared"
281 else y="`printf 'Disk%2d' $x`"; fi
283 z="$( grep "^disk$x " $index | wc -l )"
285 if [ -z "$bootoptions" -o $x != 1 ]; then
286 printf "%15s $y: %7s kB in %5d files\n" "" ${!ds} $z
288 printf "%15s $y: %7s kB in %5d files (boot)\n" "" ${!ds} $z
291 printf "%15s Total: %8s kB in %5d files\n" "" $total $( wc -l < $index )
294 date "+ [%X] Creating ${isoprefix}_index.txt ..."
295 sort -tk -n -k2 < $index > ${isoprefix}_index.txt
298 for x in xorrisofs genisoimage mkisofs; do
299 if [ "`type -p $x`" ]; then
300 if [ $x = "xorrisofs" ] && [[ "$bootoptions" = *-hfs* ]]; then
301 echo "$x does not yet support -hfs, ... skipped."
307 [ ! "$mkisofs" ] && echo 'No "mkisofs" found in path!' && exit 1
312 [ "${disks// /}" != "$disks" ] && isoname=${isoname}_$x
313 date "+ [%X] Creating $isoname ..."
314 echo "This is disc #$x." > $dat
315 # FIXME: current mkisofs does only accept one -path-list
316 sort -u ${pathspec}_${x} ${pathspec}_0 > ${pathspec}_current 2> /dev/null
317 $mkisofs -r -J -l -A "T2 SDE - Disc $x" \
318 -publisher 'T2 System Develop Environment - https://t2sde.org' \
319 -graft-points -path-list ${pathspec}_current \
320 $bootoptions disk$x.txt=$dat \
321 `cat ${pathspec}_iso
2>/dev
/null
` | tee $isoname.iso |
322 sha${shalen}sum | sed "s/ -/ `basename ${isoname}.iso`/" >> $isoname.sha${shalen}
323 rm -f ${pathspec}_iso
324 rm -f ${pathspec}_current
328 if [ "$scripts" ]; then
329 echo "$spacer Running post-processing scripts on image"
330 eval $scripts $x ${isoname}.iso
333 if [ "$mkdebug" = 1 ]; then
334 cat > ${isoprefix}_loop$x.sh << EOT
337 if [ "\$1" -a -z "\${1//[0-9]/}" ]; then
338 [ "\$2" ] && umount \$2 > /dev/null 2>&1
339 losetup -d /dev/loop\$1 > /dev/null 2>&1
340 losetup /dev/loop\$1 $isoname.iso
341 [ "\$2" ] && mount /dev/loop\$1 \$2
343 echo "Usage: \$0 loopback-dev-nr [ mount-point ]"
347 chmod +x ${isoprefix}_loop$x.sh
351 date "+ [%X] Done. Have fun!"
354 rm -f $index $dat ${pathspec}_*