2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by scripts/Create-CopyPatch.
5 # T2 SDE: scripts/Create-ISO
6 # Copyright (C) 2004 - 2021 The T2 SDE Project
8 # More information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
17 # Commands in isofs.txt files:
19 # EVERY from to Put this on every disk
20 # DISK1 from to Put this on the 1st disk
21 # SINGLE from to Put it on any disk
22 # SPLIT from to You may split it up over many disks
24 # BOOT boot-options Add this mkisofs options for 1st disk
26 # If you want to add multiple 'BOOT' lines, use the tag-name 'BOOTx' for
27 # the 2nd and all further lines.
29 # SCRIPT script-name args Run given script for each image
31 # Intended for image post-processing. The first argument is the CD
32 # number and the second the image file.
35 eval `grep sdever scripts/parse-config`
36 .
scripts
/functions.
in
41 echo "Usage: $0 [ -size MB ] [ -source ] [ -mkdebug ] [ -sha len ] ISO-Prefix \\"
42 echo " ${0//?/ } [ Config [ .. ] ]"
44 echo "E.g.: $0 mycdset system rescue"
50 dsize
=$
((1024 * 1024))
59 dsize
=$
(( $2 * 1024 )); shift; shift ;;
65 shalen
=$2; shift; shift ;;
76 [ $# -eq 0 ] && set -- 'default'
81 if [ ! -f config
/$cfg/config
]; then
82 echo "Not a valid config: $cfg"
86 [ $errno -ne 0 ] && exit 1
88 echo; date "+ [%X] Removing old files with same prefix ..."
89 [ "${isoprefix//\//}" == "${isoprefix}" ] && isoprefix
="$isoprefix"
90 rm -rvf ${isoprefix}[_.
]* ${isoprefix}.md5
92 date "+ [%X] Reading configs ..."
93 index
=`mktemp`; dat
=`mktemp`; pathspec
=`mktemp`
97 id
="`grep '^export SDECFG_ID=' config/$cfg/config |
98 cut -f2 -d\' 2> /dev/null`"
99 if ! cat build
/$id/TOOLCHAIN
/isofs.txt
>> $dat 2> /dev
/null
101 echo "Not a valid build: $cfg"
102 echo "build/$id/TOOLCHAIN/isofs.txt must exist."
103 rm -f $dat $index ${pathspec}_
*; exit 1
106 if test -f config
/$cfg/license-issue.ask
; then
107 if ! grep LICENSE-WARNING
$dat &> /dev
/null
; then
108 echo "EVERY misc/share/LICENSE-WARNING LICENSE-WARNING" >> $dat
111 cp -vf misc
/share
/LICENSE-WARNING build
/$id/TOOLCHAIN
/
112 echo "" >> build
/$id/TOOLCHAIN
/LICENSE-WARNING
113 echo "The following packages may have license restrictions:" >> build
/$id/TOOLCHAIN
/LICENSE-WARNING
114 cat config
/$cfg/license-issue.ask
>> build
/$id/TOOLCHAIN
/LICENSE-WARNING
116 if [ "`grep '^export SDECFG_LICENSE_ISSUE=' config/$cfg/config | cut -f2 -d\'`" = "0" ]; then
118 You have chosen to compile packages that are restricted
119 in their redistribution. Unless you accept this limitation
120 you cannot burn these packages.
122 Please rerun scripts/Config -cfg $cfg and check
123 'I have read and understood the licensing issues.'
126 #FIXME remove packages that have an issue instead of exiting
132 # function to add a given file $1 to the place $2 on the resulting ISO
135 local from
="$1" to
="$2" done=0
136 if [ ! -f "$from" -a ! -d "$from" ]; then
137 echo "No such file or directory: $from"
138 rm -f $dat $index ${pathspec}_
*; exit 1
141 files
="`find $from ! -type d | wc -l`"
142 size
="`du -s -b $from | cut -f1`"
143 size
=$
(( size
/ 1024 + files
* file_overhead
))
145 if [ $size -gt $
(( $dsize - $disk_0_size )) ]; then
146 echo "Chunk $from is too big!"
147 rm -f $dat $index ${pathspec}_
*; exit 1
151 ds
=disk_
${x}_size
; dd=disk_
${x}_data
152 if [ $
(( ${!ds} + $size )) -le \
153 $
(( $dsize - $disk_0_size )) ]; then
154 eval "$ds=$(( ${!ds} + $size ))"
155 echo "$to=$from" >> ${pathspec}_
${disk_nr}
160 if [ $done = 0 ]; then
162 ds
=disk_
${disk_nr}_size
; eval "$ds=$size"
164 # FIXME: if in a path-list files, mkisofs complains about
165 # missing isolinux. Should be a mkisofs bug!
166 if [ "$to" = "isolinux/" -o "$from" = "isolinux/" ]; then
167 echo "$to=$from" >> ${pathspec}_iso
169 echo "$to=$from" >> ${pathspec}_
${disk_nr}
171 disks
="$disks${disks:+ }$disk_nr"
177 while read tag data
; do
179 [ "$tag" ] ||
continue
180 if [ $tag = BOOT
]; then
181 if [ "$bootoptions" ]; then
182 echo "Multiple boot options found!"
183 rm -f $dat $index ${pathspec}_
*; exit 1
186 [[ $data == *-hfs* ]] && file_overhead
=12
188 elif [ $tag = SCRIPT
]; then
189 scripts
="$scripts $data"
192 while read tag data
; do
193 if [ "$tag" = BOOTx
]; then
194 bootoptions
="$bootoptions $data"
195 [[ $data == *-hfs* ]] && file_overhead
=12
199 echo "$spacer parsing for EVERY disk."
201 disks
="0"; disk_nr
=0; disk_0_size
=0
202 echo "index.txt=${isoprefix}_index.txt" >> ${pathspec}_0
203 while read type from to
; do
204 if [ "$type" = EVERY
]; then
206 if [ $disk_nr -gt 0 ]; then
207 echo "Every-disk data is too big!"
208 rm -f $dat $index ${pathspec}_
*; exit 1
213 echo "$spacer parsing for DISK1 disk."
216 while read type from to
; do
217 if [ "$type" = DISK1
]; then
219 if [ $disk_nr -gt 1 ]; then
220 echo "Disk 1 is too big!"
221 rm -f $dat $index ${pathspec}_
*; exit 1
226 echo "$spacer parsing for SINGLE disk."
228 while read type from to
; do
229 if [ "$type" = SINGLE
]; then
234 echo "$spacer parsing for SPLIT disk."
236 while read type from to
; do
237 if [ "$type" = SPLIT
]; then
238 find $from -type f
-printf '%P\n' |
sort > $index
245 if [ $src = 1 ]; then
246 date "+ [%X] Embedding source ..."
248 scripts
/Create-SrcTar
250 for x
in doc
/* t2-src-
$sdever.
tar.bz2
; do
251 [ ! -d $x ] && add
$x ${x/doc\/}
255 from
="`bz2filename $from`"
256 if [ -e $from ]; then
259 echo "WARNING: File $from is missing!"
261 done < <( scripts
/Download
-list |
sort -u )
264 date "+ [%X] Creating ISO index ..."
266 for x
in 0 $disks; do
268 for y
in ${!dd} `cat ${pathspec}_${x} 2> /dev
/null
`; do
269 to=${y%=*}; from=${y#*=}
270 if [ -e $from ]; then
271 find $from -printf "disk$x $to%P\\n" >> $index
273 echo "disk$x $to" >> $index
277 disk_0_size=$(( $disk_0_size + $( du -sk $index | cut -f1 ) ))
279 if [ -z "$bootoptions" ]; then
280 echo "WARNING: Disk1 is not bootable - no boot options defined."
285 for x in 0 $disks; do
287 total=$(( $total + ${!ds} ))
289 if [ $x = 0 ]; then y="Shared"
290 else y="`printf 'Disk%2d' $x`"; fi
292 z="$( grep "^disk$x " $index | wc -l )"
294 if [ -z "$bootoptions" -o $x != 1 ]; then
295 printf "%15s $y: %7s kB in %5d files\n" "" ${!ds} $z
297 printf "%15s $y: %7s kB in %5d files (boot)\n" "" ${!ds} $z
300 printf "%15s Total: %8s kB in %5d files\n" "" $total $( wc -l < $index )
303 date "+ [%X] Creating ${isoprefix}_index.txt ..."
304 sort -tk -n -k2 < $index > ${isoprefix}_index.txt
307 for x in xorrisofs genisoimage mkisofs; do
308 if [ "`type -p $x`" ]; then
309 if [ $x = "xorrisofs" ] && [[ "$bootoptions" = *-hfs* ]]; then
310 echo "$x does not yet support -hfs, ... skipped."
316 [ ! "$mkisofs" ] && echo 'No "mkisofs" found in path!' && exit 1
321 [ "${disks// /}" != "$disks" ] && isoname=${isoname}_$x
322 date "+ [%X] Creating $isoname ..."
323 echo "This is disc #$x." > $dat
324 # FIXME: current mkisofs does only accept one -path-list
325 sort -u ${pathspec}_${x} ${pathspec}_0 > ${pathspec}_current 2> /dev/null
326 $mkisofs -r -J -l -V "T2SDE" -A "T2 SDE - Disc $x" \
327 -publisher 'T2 System Develop Environment - https://t2sde.org' \
328 -graft-points -path-list ${pathspec}_current \
329 $bootoptions disk$x.txt=$dat \
330 `cat ${pathspec}_iso
2>/dev
/null
` | tee $isoname.iso |
331 sha${shalen}sum | sed "s/ -/ `basename ${isoname}.iso`/" >> $isoname.sha${shalen}
332 rm -f ${pathspec}_iso
333 rm -f ${pathspec}_current
337 if [ "$scripts" ]; then
338 echo "$spacer Running post-processing scripts on image"
339 eval $scripts $x ${isoname}.iso
342 if [ "$mkdebug" = 1 ]; then
343 cat > ${isoprefix}_loop$x.sh << EOT
346 if [ "\$1" -a -z "\${1//[0-9]/}" ]; then
347 [ "\$2" ] && umount \$2 > /dev/null 2>&1
348 losetup -d /dev/loop\$1 > /dev/null 2>&1
349 losetup /dev/loop\$1 $isoname.iso
350 [ "\$2" ] && mount /dev/loop\$1 \$2
352 echo "Usage: \$0 loopback-dev-nr [ mount-point ]"
356 chmod +x ${isoprefix}_loop$x.sh
360 date "+ [%X] Done. Have fun!"
363 rm -f $index $dat ${pathspec}_*