2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # Filename: scripts/Create-ISO
6 # Copyright (C) 2006 - 2008 The OpenSDE Project
7 # Copyright (C) 2004 - 2006 The T2 SDE Project
9 # More information can be found in the files COPYING and README.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; version 2 of the License. A copy of the
14 # GNU General Public License can be found in the file COPYING.
15 # --- SDE-COPYRIGHT-NOTE-END ---
18 # Commands in isofs.txt files:
20 # EVERY from to Put this on every disk
21 # DISK1 from to Put this on the 1st disk
22 # SINGLE from to Put it on any disk
23 # SPLIT from to You may split it up over many disks
25 # BOOT boot-options Add this mkisofs options for 1st disk
27 # If you want to add multiple 'BOOT' lines, use the tag-name 'BOOTx' for
28 # the 2nd and all further lines.
30 # SCRIPT script-name args Run given script for each image
32 # Intended for image post-processing. The first attached argument is the CD
33 # number and the second the image file.
36 eval `grep sdever lib/parse-config`
42 echo "Usage: $0 [ -size MB ] [ -source ] [ -mkdebug ] [ -nomd5 ] ISO-Prefix \\"
43 echo " ${0//?/ } Config [ Config [ .. ] ]"
45 echo "E.g.: $0 mycdset install generic"
51 dsize
=$
(( 700 * 1024 ))
53 src
=0; mkdebug
=0; implantisomd5
=1
58 dsize
=$
(( $2 * 1024 )) ; shift ; shift ;;
64 implantisomd5
=0 ; shift ;;
68 isoprefix
=$1 ; shift ; break ;;
77 if [ ! -f config
/$cfg/config
]; then
78 echo "Not a valid config: $cfg"
82 [ $errno -ne 0 ] && exit 1
84 if [ "$implantisomd5" = 1 -a ! -x tmp
/isomd5sum
/implantisomd5
] ; then
85 echo ; date "+ [%X] Creating ISO-MD5 tools ..."
86 rm -rf tmp
/isomd5sum
; mkdir
-p tmp
/isomd5sum
87 cp src
/isomd5sum
/* tmp
/isomd5sum
/
88 make -C tmp
/isomd5sum all
91 echo ; date "+ [%X] Removing old files with same prefix ..."
92 [ "${isoprefix//\//}" = "${isoprefix}" ] && isoprefix
="iso/$isoprefix"
93 mkdir
-vp ${isoprefix%/*}
94 rm -rvf ${isoprefix}_
* ${isoprefix}.md5
96 date "+ [%X] Reading configs ..."
97 index
=`mktemp` ; dat
=`mktemp` ; pathspec
=`mktemp`
101 id
="$( grep '^export SDECFG_ID=' config/$cfg/config | cut -f2 -d"'" 2> /dev/null)"
102 if ! cat build/$id/TOOLCHAIN/isofs.txt >> $dat 2> /dev/null
104 echo "Not a valid build: $cfg"
105 echo "build/$id/TOOLCHAIN/isofs.txt might be created."
106 rm -f $dat $index ${pathspec}_* ; exit 1
109 if test -f config/$cfg/license-issue.ask; then
110 if ! grep LICENSE-WARNING $dat &> /dev/null; then
111 echo "EVERY doc/files/LICENSE-WARNING LICENSE-WARNING" >> $dat
114 cp -vf doc/files/LICENSE-WARNING build/$id/TOOLCHAIN/
115 echo "" >> build/$id/TOOLCHAIN/LICENSE-WARNING
116 echo "The following packages may have license restrictions:" >> build/$id/TOOLCHAIN/LICENSE-WARNING
117 cat config/$cfg/license-issue.ask >> build/$id/TOOLCHAIN/LICENSE-WARNING
119 if [ "$( grep '^
export SDECFG_LICENSE_ISSUE
=' config/$cfg/config | cut -f2 -d"'")" = "0" ]; then
121 You have chosen to compile packages that are restricted
122 in their redistribution. Unless you accept this limitation
123 you cannot burn these packages.
125 Please rerun ./scripts/Config -cfg $cfg and check
126 'I have read and understood the licensing issues.'
129 #FIXME remove packages that have an issue instead of exiting
135 # function to add a given file $1 to the place $2 on the resulting ISO
138 local from
="$1" to
="$2" done=0
139 if [ ! -f "$from" -a ! -d "$from" ] ; then
140 echo "No such file or directory: $from"
141 rm -f $dat $index ${pathspec}_
* ; exit 1
144 files
="`find $from ! -type d | wc -l`"
145 size
="`du -s -b $from | cut -f1`"
146 size
=$
(( size
/ 1024 + files
* file_overhead
))
148 if [ $size -gt $
(( $dsize - $disk_0_size )) ] ; then
149 echo "Chunk $from is too big!"
150 rm -f $dat $index ${pathspec}_
* ; exit 1
154 ds
=disk_
${x}_size
; dd=disk_
${x}_data
155 if [ $
(( ${!ds} + $size )) -le \
156 $
(( $dsize - $disk_0_size )) ] ; then
157 eval "$ds=$(( ${!ds} + $size ))"
158 echo "$to=$from" >> ${pathspec}_
${disk_nr}
163 if [ $done = 0 ] ; then
164 disk_nr
=$
(( $disk_nr + 1 ))
165 ds
=disk_
${disk_nr}_size
; eval "$ds=$size"
167 # FIXME: if in a path-list files, mkisofs complains about
168 # missing isolinux. Should be a mkisofs bug!
169 if [ "$to" = "isolinux/" -o "$from" = "isolinux/" ] ; then
170 echo "$to=$from" >> ${pathspec}_iso
172 echo "$to=$from" >> ${pathspec}_
${disk_nr}
174 disks
="$disks $disk_nr"
180 while read tag data
; do
182 [ "$tag" ] ||
continue
183 if [ $tag = BOOT
]; then
184 if [ "$bootoptions" ]; then
185 echo "Multiple boot options found!"
186 rm -f $dat $index ${pathspec}_
* ; exit 1
189 [[ $data == *-hfs* ]] && file_overhead
=12
191 elif [ $tag = SCRIPT
]; then
192 scripts
="$scripts $data"
195 while read tag data
; do
196 if [ "$tag" = BOOTx
]; then
197 bootoptions
="$bootoptions $data"
198 [[ $data == *-hfs* ]] && file_overhead
=12
202 echo "$spacer parsing for EVERY disk."
204 disks
="0" ; disk_nr
=0 ; disk_0_size
=0
205 echo "index.txt=${isoprefix}_index.txt" >> ${pathspec}_0
206 while read type from to
; do
207 if [ "$type" = EVERY
]; then
209 if [ $disk_nr -gt 0 ] ; then
210 echo "Every-disk data is too big!"
211 rm -f $dat $index ${pathspec}_
* ; exit 1
216 echo "$spacer parsing for DISK1 disk."
219 while read type from to
; do
220 if [ "$type" = DISK1
] ; then
222 if [ $disk_nr -gt 1 ] ; then
223 echo "Disk 1 is too big!"
224 rm -f $dat $index ${pathspec}_
* ; exit 1
229 echo "$spacer parsing for SINGLE disk."
231 while read type from to
; do
232 if [ "$type" = SINGLE
] ; then
237 echo "$spacer parsing for SPLIT disk."
239 while read type from to
; do
240 if [ "$type" = SPLIT
] ; then
241 find $from -type f
-printf '%P\n' |
sort > $index
248 if [ $src = 1 ] ; then
249 date "+ [%X] Embedding source ..."
251 .
/scripts
/Create-SrcTar
253 for x
in doc
/* opensde-src-
$sdever.
tar.bz2
; do
254 [ ! -d $x ] && add
$x ${x/doc\/}
258 from
="`bz2filename $from`"
259 if [ -e $from ] ; then
262 echo "WARNING: File $from is missing!"
264 done < <( .
/bin
/sde-download
-list |
sort -u )
267 date "+ [%X] Creating ISO index ..."
269 for x
in 0 $disks ; do
271 for y
in ${!dd} `cat ${pathspec}_${x} 2> /dev
/null
` ; do
272 to=${y%=*} ; from=${y#*=}
273 if [ -e $from ] ; then
274 find $from -printf "disk$x $to%P\\n" >> $index
276 echo "disk$x $to" >> $index
280 disk_0_size=$(( $disk_0_size + $( du -sk $index | cut -f1 ) ))
282 if [ -z "$bootoptions" ] ; then
283 echo "WARNING: Disk1 is not bootable - no boot options defined."
288 for x in 0 $disks ; do
290 total=$(( $total + ${!ds} ))
292 if [ $x = 0 ] ; then y="Shared"
293 else y="`printf 'Disk%2d' $x`" ; fi
295 z="$( grep "^disk$x " $index | wc -l )"
297 if [ -z "$bootoptions" -o $x != 1 ] ; then
298 printf "%15s $y: %7s kB in %5d files\n" "" ${!ds} $z
300 printf "%15s $y: %7s kB in %5d files (boot)\n" "" ${!ds} $z
303 printf "%15s Total: %8s kB in %5d files\n" "" $total $( wc -l < $index )
306 date "+ [%X] Creating ${isoprefix}_index.txt ..."
307 sort -tk -n -k2 < $index | tee ${isoprefix}_index.txt | md5sum |
308 sed "s/ -/ ${isoprefix##*/}_index.txt/" >> ${isoprefix}.md5
312 date "+ [%X] Creating ${isoprefix}_cd$x.iso ..."
313 echo "This is disk #$x." > $dat
314 # FIXME: current mkisofs does only accept one -path-list
315 sort -u ${pathspec}_${x} ${pathspec}_0 > ${pathspec}_current 2> /dev/null
316 mkisofs -quiet -r -T -J -l -A "OpenSDE - Disk $x" \
317 -publisher 'OpenSDE System Develop Environment - http://www.opensde.org' \
318 -path-list ${pathspec}_current \
319 $bootoptions -graft-points disk$x.txt=$dat \
320 `cat ${pathspec}_iso
2>/dev
/null
` | tee ${isoprefix}_cd$x.iso |
321 md5sum | sed "s/ -/ ${isoprefix##*/}_cd$x.iso/" \
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 ${isoprefix}_cd$x.iso
333 if [ "$implantisomd5" = 1 -a -x ./src/isomd5sum/implantisomd5 ] ; then
334 echo "$spacer Calculating and implanting MD5 checksum ..."
335 ./tmp/isomd5sum/implantisomd5 ${isoprefix}_cd$x.iso >/dev/null
338 if [ "$mkdebug" = 1 ] ; then
339 cat > ${isoprefix}_loop$x.sh << EOT
342 if [ "\$1" -a -z "\${1//[0-9]/}" ] ; then
343 [ "\$2" ] && umount \$2 > /dev/null 2>&1
344 losetup -d /dev/loop/\$1 > /dev/null 2>&1
345 losetup /dev/loop/\$1 ${isoprefix##*/}_cd$x.iso
346 [ "\$2" ] && mount /dev/loop/\$1 \$2
348 echo "Usage: \$0 loopback-dev-nr [ mount-point ]"
352 chmod +x ${isoprefix}_loop$x.sh
356 date "+ [%X] Done. Have fun!"
359 rm -f $index $dat ${pathspec}_*