Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/blackosx/trunk/PackageBuilder/Main_Package_Elements/Scripts/BuildBootOptions.sh

  • Property svn:executable set to *
1#!/bin/bash
2
3main ()
4{
5tempDir="${destinationDrive}/.Chameleon/"
6echo "DEBUG: tempDir is ${tempDir}"
7
8
9if [ ! -d "${tempDir}" ]; then
10echo "the temporary directory does not exist so no boot options have been selected"
11else
12# check to see if there are any boot options in the temporary directory
13
14cd "${tempDir}"
15Dirlist=$(ls | grep "@")
16
17if [ "${Dirlist}" ]; then
18
19echo "==============================================="
20echo "set com.apple.Boot.plist variables"
21echo "**********************************"
22
23bootplist="${tempDir}Extra/com.apple.Boot.plist"
24echo "DEBUG: bootplist = ${bootplist}"
25
26systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
27echo "DEBUG: systemplist= ${systemplist}"
28
29echo "if no directory exists named ${bootplist%/*} then mkdir ${bootplist%/*}"
30[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
31
32if [ ! -f "${bootplist}" ]; then
33echo "${bootplist} doesn't exist"
34if [ -f "${systemplist}" ]; then
35echo "${systemplist} doesn't exist"
36echo "copy ${systemplist} to ${bootplist}"
37cp "${systemplist}" "${bootplist}"
38fi
39fi
40echo "-----------------------------------------------"
41echo ""
42
43
44echo "==============================================="
45echo "Build Extra/com.apple.Boot.plist"
46echo "********************************"
47
48mv "${bootplist}" "${bootplist}.orig"
49
50#prefunctionifs="${IFS}"
51
52fileinput="${bootplist}.orig"
53fileoutput="${bootplist}"
54find="<key>Kernel Flags</key>"
55replace=""
56deletelines=""
57insertlinesskip="2"
58
59matchlinefound="0"
60
61while read line
62do
63{
64if [ ! "${line}" = "${line/${find}/}" ]; then
65{
66# Trim the longest match from the end for <*
67xmlelementindent="${line%%<*}"
68
69# Trim the longest match from the start for *<
70xmlelementtemp="${line#*<}"
71# Add back in stripped <
72xmlelement="<${xmlelementtemp}"
73
74# Trim the shortest match from the start for <
75xmltagtemp="${xmlelement#<}"
76# Trim the longest match from the end for >*
77xmltag="${xmltagtemp%%>*}"
78
79# Trim the shortest match from the start for *>
80xmltexttemp="${xmlelement#*>}"
81# Trim the longest match from the end for <*
82xmltext="${xmltexttemp%%<*}"
83
84if [ "${replace}" ]; then
85echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
86else
87echo "${line}" >>"${fileoutput}"
88fi
89
90matchlinefound="1"
91
92}
93else
94{
95
96if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
97if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
98
99for bootOptionFile in $Dirlist ; do
100overide=$(echo $bootOptionFile | sed 's/_/ /g' | tr -d "./@" |cut -d '+' -f1)
101string=$(echo $bootOptionFile | tr -d "./@" |cut -d'+' -f2)
102
103bootoptionshdextra[1]="<key>${overide}</key>"
104bootoptionshdextra[2]="<string>${string}</string>"
105
106echo "Adding ${overide}=${string} to ${bootplist}"
107 array=("${bootoptionshdextra[@]}")
108arraysize=0
109
110#prefunctionifs="${IFS}"
111#IFS="\n"
112
113while [ ${arraysize} -lt ${#array[@]} ];
114do
115echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
116 let arraysize="${arraysize}+1"
117done
118
119#IFS=${prefunctionifs}
120done
121
122#echo "set owner privileges for ${bootplist}"
123chown "${USER}:20" "${bootplist}"
124fi
125fi
126
127if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
128:
129else
130echo "${line}" >>"${fileoutput}"
131fi
132
133if [ "${matchlinefound}" -gt 0 ]; then
134let matchlinefound="${matchlinefound}+1"
135fi
136
137}
138fi
139}
140done < "${fileinput}"
141
142#IFS=${prefunctionifs}
143rm -f "${fileinput}"
144
145echo ""
146
147echo "-----------------------------------------------"
148echo ""
149
150
151echo "==============================================="
152echo "Clean up and Remove Boot Option Null Files"
153echo "******************************************"
154
155# make sure we're in the right directory
156cd "${tempDir}"
157
158Dirlist=$(find . -type f | grep "@")
159for bootOptionFile in ${Dirlist} ; do
160echo "Removing temporary boot option file: ${bootOptionFile}"
161rm $bootOptionFile
162done
163
164echo "-----------------------------------------------"
165echo ""
166
167else
168echo "No boot options in the temporary directory."
169fi
170fi
171}
172
173
174
175echo "==============================================="
176echo "Enter Build Boot Options script"
177echo "*******************************"
178
179# get the passed destination drive?
180
181if [ "$#" -eq 1 ]; then
182destinationDrive="$1"
183echo "DEBUG: passed argument for destinationDrive = $destinationDrive"
184fi
185
186# Build Boot Options
187main "${1}" "${2}" "${3}" "${4}"
188
189exit 0
190

Archive Download this file

Revision: 255