#!/bin/sh
|
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: bin/sde-create-iso
|
|
# Copyright (C) 2009 The OpenSDE Project
|
|
#
|
|
# More information can be found in the files COPYING and README.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; version 2 of the License. A copy of the
|
|
# GNU General Public License can be found in the file COPYING.
|
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
|
|
#set -xv
|
|
|
|
#Description: Creates an iso from selected config(s)
|
|
|
|
[ -n "$SDEROOT" ] ||
|
|
export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
|
|
|
|
. "$SDEROOT/lib/libsde.in"
|
|
. "$SDEROOT/lib/sde-config.in"
|
|
|
|
create_usage() {
|
|
local progname=$(echo ${0##*/} | tr '-' ' ')
|
|
cat <<-EOT
|
|
Usage: $progname [-s {dvd|dvd-dl|cd|cd74|cd90|cd99| n}] [-f <format>] -n <name> -c <config> [<config>....]"
|
|
Size:
|
|
dvd - 4.38GB
|
|
dvd-dl - 7.95GB
|
|
cd - 700MB
|
|
cd74 - 650MB
|
|
cd90 - 790MB
|
|
cd99 - 870MB
|
|
or
|
|
size n[k,m,g,t] - custom volumes of n KiB/MiB/GiB/TiB each
|
|
Size is optional, if none is given will default to 700MB CD.
|
|
Format: iso format iso9660 or udf, if none given iso9660 is used
|
|
Name: prefix for the media set mycdset => ${name}_cd$x.iso or ${name}_dvd$x.iso
|
|
Config is the name of the OpenSDE config(s) to be used.
|
|
EOT
|
|
exit 1
|
|
}
|
|
# Transform the given size in bytes
|
|
#
|
|
size_in_bytes() {
|
|
lsize="$1"
|
|
case "$lsize" in
|
|
dvd) bytes=$( gawk 'BEGIN {printf("%d",4480*1048576)}' ) ;;
|
|
dvd-dl) bytes=$( gawk 'BEGIN {printf("%d",8140*1048576)}') ;;
|
|
cd) bytes=$( gawk 'BEGIN {printf("%d",702*1048576)}') ;;
|
|
cd74) bytes=$( gawk 'BEGIN {printf("%d",650*1048576)}') ;;
|
|
cd90) bytes=$( gawk 'BEGIN {printf("%d",790*1048576)}') ;;
|
|
cd99) bytes=$( gawk 'BEGIN {printf("%d",870*1048576)}') ;;
|
|
*)
|
|
size2=$(echo "$lsize" | sed -n -e '/^[0-9]\+\(\.[0-9]*\)\?[kKmMgGtT]\?$/p')
|
|
[ -n "$size2" ] || echo_abort 1 "$lsize: invalid format, use <number>[U] where U can be kKmMgGtT"
|
|
bytes=$( echo "$size2" | sed -e 's,[t|T]$, 1099511627776,' -e 's,[gG]$, 1073741824,' \
|
|
-e 's,[mM]$, 1048576,' -e 's,[kK]$, 1024,' -e 's,^[0-9]\+$,\0 1,' | gawk '{printf("%d",$1 * $2)}' )
|
|
[ "$bytes" -gt 0 ] || echo_abort 1 "$lsize: invalid size ($bytes <= 0)"
|
|
esac
|
|
echo $bytes
|
|
}
|
|
|
|
shortopts='h,s:f:,n:,c:'
|
|
options=$( getopt -o "$shortopts" -- "$@" )
|
|
if [ $? -ne 0 ]; then
|
|
create_usage
|
|
exit -1
|
|
fi
|
|
|
|
# load new arguments list
|
|
eval set -- "$options"
|
|
size=
|
|
format=
|
|
name=
|
|
cfgs=
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
-h)
|
|
create_usage
|
|
exit 0 ;;
|
|
-s) size=`size_in_bytes "$2"`; shift ;;
|
|
-f) format="$1"; shift ;;
|
|
-n) name="$1"; shift ;;
|
|
-c) cfgs="$cfgs $2"; shift ;;
|
|
--) shift; break ;;
|
|
*) echo_abort 1 "$1: Unknown argument, aborting."
|
|
esac
|
|
shift
|
|
done
|
|
|
|
# Check Configs
|
|
#
|
|
dirs=
|
|
for cfg in $cfgs ; do
|
|
if [ ! -f config/"$cfg"/config ]; then
|
|
echo "Not a valid config: "$cfg""
|
|
fi
|
|
done
|
|
|
|
for cfg in $cfgs ; do
|
|
id="$( grep '^export SDECFG_ID=' config/"$cfg"/config | cut -f2 -d"'" 2> /dev/null)"
|
|
if [ ! -f build/"$id"/TOOLCHAIN/isofs.txt ]; then
|
|
echo "Not a valid build: "$cfg""
|
|
echo "build/"$id"/TOOLCHAIN/isofs.txt might be created."
|
|
else
|
|
dirs="${dirs}"$'\n'
|
|
dirs="${dirs}"`cat build/"$id"/TOOLCHAIN/isofs.txt`
|
|
fi
|
|
done
|
|
|
|
# Main processing
|
|
#
|
|
wantfiles=
|
|
grafts=`mktemp`
|
|
wantfiles=$( echo "${dirs}" | grep '^DISK1\|^SPLIT' | gawk '{print($2)}' )
|
|
|
|
for file in ${wantfiles}; do
|
|
mfileline=$( echo "${file}" | gawk -F/ '{print $NF}' )
|
|
dirline=$( echo "${file}" | gawk -F/ '{$NF=""; NF--; print}' | sed -e 's|\ |\/|g')
|
|
cdline=$( echo "${dirs}" | grep "${dirline}" | grep -v 'EVERY' | gawk '{print $3}' )
|
|
graftline="${cdline}${mfileline}=${file}"
|
|
echo ${graftline} >> $grafts
|
|
done
|
|
|
|
out_size=$(echo "${wantfiles}" | xargs mkisofs -quiet -print-size -V 0000 -graft-points)
|
|
out_size=$( gawk 'BEGIN {printf("%d",'$out_size'*2048)}' )
|
|
x=$(gawk 'BEGIN {print ('$out_size' > '$size') ? "true" : "false" }')
|
|
|
|
#mangle bootoptions
|
|
bootoptions=
|
|
bootoptions=$( echo "${dirs}" | grep '^BOOT ' | cut -f2- -d ' ')
|
|
bootoptions="${bootoptions}"`echo "${dirs}" | grep '^BOOTx ' | cut -f2- -d ' '`
|
|
|
|
udf=
|
|
[[ "$format" = "udf" ]] && udf="-udf"
|
|
|
|
if [ "$x" = "true" ]; then
|
|
echo_abort 1 "$out_size is bigger than $size and I am too dumb to split across multiple media :("
|
|
else
|
|
mkisofs "$udf" -r -T -J -l -A "OpenSDE - Disk 1" -publisher 'OpenSDE System Develop Environment - http://www.opensde.org' \
|
|
-path-list "$grafts" "${bootoptions}" -graft-points -o iso/"$name"_"$lsize".iso
|
|
fi
|