Chameleon

Chameleon Commit Details

Date:2011-06-20 22:47:56 (8 years 29 days ago)
Author:Azimutz
Commit:1032
Parents: 1031
Message:Merge r1012.
Changes:
D/branches/azimutz/Chazi/package/Scripts/Options/EHCIacquire/postinstall
D/branches/azimutz/Chazi/package/Scripts/Options/GUI/postinstall
D/branches/azimutz/Chazi/package/Scripts/HFS/postinstall
D/branches/azimutz/Chazi/package/Scripts/Options/GraphicsEnabler/postinstall
D/branches/azimutz/Chazi/package/Scripts/Post/postinstall
D/branches/azimutz/Chazi/package/Scripts/Options/UHCIreset/postinstall
D/branches/azimutz/Chazi/package/buildpkg
D/branches/azimutz/Chazi/package/Scripts/Options/EthernetBuiltIn/postinstall
D/branches/azimutz/Chazi/package/Scripts/Standard/postinstall
D/branches/azimutz/Chazi/package/Scripts/Options/ForceWake/postinstall
D/branches/azimutz/Chazi/package/Scripts/Options/ForceHPET/postinstall
D/branches/azimutz/Chazi/package/Scripts/FAT/postinstall
C/trunk/package/Scripts/Options/ForceHPET/postinstall.sh → /branches/azimutz/Chazi/package/Scripts/Options/ForceHPET/postinstall.sh
C/trunk/package/Scripts/FAT/postinstall.sh → /branches/azimutz/Chazi/package/Scripts/FAT/postinstall.sh
C/trunk/package/Scripts/Options/EHCIacquire/postinstall.sh → /branches/azimutz/Chazi/package/Scripts/Options/EHCIacquire/postinstall.sh
C/trunk/package/Scripts/Options/GUI/postinstall.sh → /branches/azimutz/Chazi/package/Scripts/Options/GUI/postinstall.sh
C/trunk/package/Scripts/HFS/postinstall.sh → /branches/azimutz/Chazi/package/Scripts/HFS/postinstall.sh
C/trunk/package/Scripts/Options/GraphicsEnabler/postinstall.sh → /branches/azimutz/Chazi/package/Scripts/Options/GraphicsEnabler/postinstall.sh
C/trunk/package/Scripts/Post/postinstall.sh → /branches/azimutz/Chazi/package/Scripts/Post/postinstall.sh
C/trunk/package/Scripts/Options/UHCIreset/postinstall.sh → /branches/azimutz/Chazi/package/Scripts/Options/UHCIreset/postinstall.sh
C/trunk/package/buildpkg.sh → /branches/azimutz/Chazi/package/buildpkg.sh
C/trunk/package/Scripts/Options/EthernetBuiltIn/postinstall.sh → /branches/azimutz/Chazi/package/Scripts/Options/EthernetBuiltIn/postinstall.sh
C/trunk/package/Scripts/Standard/postinstall.sh → /branches/azimutz/Chazi/package/Scripts/Standard/postinstall.sh
C/trunk/package/Scripts/Options/ForceWake/postinstall.sh → /branches/azimutz/Chazi/package/Scripts/Options/ForceWake/postinstall.sh
M/branches/azimutz/Chazi

File differences

branches/azimutz/Chazi/package/buildpkg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#!/bin/bash
# $1 Path to store built package
packagesidentity="org.chameleon"
packagename="Chameleon"
pkgroot="${0%/*}"
#version=$( grep I386BOOT_CHAMELEONVERSION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )
version=$( cat version )
stage=${version##*-}
revision=$( grep I386BOOT_CHAMELEONREVISION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )
builddate=$( grep I386BOOT_BUILDDATE sym/i386/vers.h | awk '{ print $3,$4 }' | tr -d '\"' )
timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )
distributioncount=0
xmlindent=0
indent[0]="\t"
indent[1]="\t\t"
indent[2]="\t\t\t"
indent[3]="\t\t\t\t"
main ()
{
# clean up the destination path
rm -R -f "${1}"
echo "Building $packagename Install Package v${version%%-*} $stage r$revision $builddate"
outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
# build core package
mkdir -p ${1}/Core/Root/usr/sbin
mkdir -p ${1}/Core/Root/usr/local/bin
mkdir -p ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot0 ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1f32 ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1h ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1he ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1hp ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/cdboot ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/chain0 ${1}/Core/Root/usr/standalone/i386
fixperms "${1}/Core/Root/"
cp -f ${pkgroot}/fdisk ${1}/Core/Root/usr/sbin
local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} )
buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\""
# build standard package
mkdir -p ${1}/Standard/Root
mkdir -p ${1}/Standard/Scripts/Tools
cp -f ${pkgroot}/Scripts/Standard/* ${1}/Standard/Scripts
ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Tools/SetFile
buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EnhancedHFS']) &amp;&amp; exclusive(choices['EnhancedFAT'])\""
# build efi fat32 package
mkdir -p ${1}/EnhancedFAT/Root
mkdir -p ${1}/EnhancedFAT/Scripts/Tools
cp -f ${pkgroot}/Scripts/FAT/* ${1}/EnhancedFAT/Scripts
ditto --arch i386 `which SetFile` ${1}/EnhancedFAT/Scripts/Tools/SetFile
buildpackage "${1}/EnhancedFAT" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EnhancedHFS'])\""
# build efi hfs package
mkdir -p ${1}/EnhancedHFS/Root
mkdir -p ${1}/EnhancedHFS/Scripts/Tools
cp -f ${pkgroot}/Scripts/HFS/* ${1}/EnhancedHFS/Scripts
ditto --arch i386 `which SetFile` ${1}/EnhancedHFS/Scripts/Tools/SetFile
buildpackage "${1}/EnhancedHFS" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EnhancedFAT'])\""
# build options packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Options\">"
choices[$((choicescount++))]="<choice\n\tid=\"Options\"\n\ttitle=\"Options_title\"\n\tdescription=\"Options_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon"
options=($( find "${pkgroot}/Scripts/Options" -type d -depth 1 -not -name '.svn' ))
for (( i = 0 ; i < ${#options[@]} ; i++ ))
do
mkdir -p "${1}/${options[$i]##*/}/Root"
mkdir -p "${1}/${options[$i]##*/}/Scripts"
ditto --noextattr --noqtn "${options[$i]}/postinstall" "${1}/${options[$i]##*/}/Scripts/postinstall"
buildpackage "${1}/${options[$i]##*/}" "/" "" "start_selected=\"false\""
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build theme packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Themes\">"
choices[$((choicescount++))]="<choice\n\tid=\"Themes\"\n\ttitle=\"Themes_title\"\n\tdescription=\"Themes_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.theme"
artwork="${1%/*}"
themes=($( find "${artwork%/*}/artwork/themes" -type d -depth 1 -not -name '.svn' ))
for (( i = 0 ; i < ${#themes[@]} ; i++ ))
do
theme=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' )
mkdir -p "${1}/${theme}/Root/"
ditto --noextattr --noqtn "${themes[$i]}" "${1}/${themes[$i]##*/}/Root/${theme}"
find "${1}/${themes[$i]##*/}" -name '.DS_Store' -or -name '.svn' -exec rm -R {} \+
find "${1}/${themes[$i]##*/}" -type f -exec chmod 644 {} \+
buildpackage "${1}/${theme}" "/.Chameleon/Extra/Themes" ""
rm -R -f "${1}/${i##*/}"
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Extras\">"
choices[$((choicescount++))]="<choice\n\tid=\"Extras\"\n\ttitle=\"Extras_title\"\n\tdescription=\"Extras_description\"\n>\n</choice>\n"
((xmlindent++))
# build kext packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Kexts\">"
choices[$((choicescount++))]="<choice\n\tid=\"Kexts\"\n\ttitle=\"Kexts_title\"\n\tdescription=\"Kexts_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon"
kexts=($( find "${pkgroot}/Kexts" -type d -name '*.kext' -depth 1 ))
for (( i = 0 ; i < ${#kexts[@]} ; i++ ))
do
filename="${kexts[$i]##*/}"
mkdir -p "${1}/${filename%.kext}/Root/"
ditto --noextattr --noqtn --arch i386 "${kexts[$i]}" "${1}/${filename%.kext}/Root/${filename}"
find "${1}/${filename%.kext}" -name '.DS_Store' -or -name '.svn' -exec rm -R -f {} \; 2>/dev/null
fixperms "${1}/${filename%.kext}/Root/"
chown 501:20 "${1}/${filename%.kext}/Root/"
buildpackage "${1}/${filename%.kext}" "/.Chameleon/Extra/Extensions" ""
rm -R -f "${1}/${filename%.kext}"
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build post install package
mkdir -p ${1}/Post/Root
mkdir -p ${1}/Post/Scripts
cp -f ${pkgroot}/Scripts/Post/* ${1}/Post/Scripts
buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\""
outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
# build meta package
makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"
# clean up
rm -R -f "${1}"
}
fixperms ()
{
# $1 path
find "${1}" -type f -exec chmod 644 {} \;
find "${1}" -type d -exec chmod 755 {} \;
chown -R 0:0 "${1}"
}
buildpackage ()
{
# $1 Path to package to build containing Root and or Scripts
# $2 Install Location
# $3 Size
# $4 Options
if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then
local packagename="${1##*/}"
local identifier=$( echo ${packagesidentity}.${packagename//_/.} | tr [:upper:] [:lower:] )
find "${1}" -name '.DS_Store' -delete
local filecount=$( find "${1}/Root" | wc -l )
if [ "${3}" ]; then
local installedsize="${3}"
else
local installedsize=$( du -hkc "${1}/Root" | tail -n1 | awk {'print $1'} )
fi
local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "
#[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "
header+="identifier=\"${identifier}\" "
header+="version=\"${version}\" "
[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "
header+="auth=\"root\">\n"
header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
rm -R -f "${1}/Temp"
[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"
[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"
if [ -d "${1}/Scripts" ]; then
header+="\t<scripts>\n"
for script in $( find "${1}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) )
do
header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"
done
header+="\t</scripts>\n"
chown -R 0:0 "${1}/Scripts"
pushd "${1}/Scripts" >/dev/null
find . -print | cpio -o -z -H cpio > "../Temp/Scripts"
popd >/dev/null
fi
header+="</pkg-info>"
echo -e "${header}" > "${1}/Temp/PackageInfo"
pushd "${1}/Root" >/dev/null
find . -print | cpio -o -z -H cpio > "../Temp/Payload"
popd >/dev/null
pushd "${1}/Temp" >/dev/null
xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .
popd >/dev/null
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${packagename// /}\"/>"
if [ "${4}" ]; then
local choiceoptions="${indent[$xmlindent]}${4}\n"
fi
choices[$((choicescount++))]="<choice\n\tid=\"${packagename// /}\"\n\ttitle=\"${packagename}_title\"\n\tdescription=\"${packagename}_description\"\n${choiceoptions}>\n\t<pkg-ref id=\"${identifier}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}' auth='root'>#${packagename// /}.pkg</pkg-ref>\n</choice>\n"
rm -R -f "${1}"
fi
}
makedistribution ()
{
rm -f "${1%/*}/${packagename// /}"*.pkg
find "${1}" -type f -name '*.pkg' -depth 1 | while read component
do
mkdir -p "${1}/${packagename}/${component##*/}"
pushd "${1}/${packagename}/${component##*/}" >/dev/null
xar -x -f "${1%}/${component##*/}"
popd >/dev/null
done
ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"
ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"
find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null
for (( i=0; i < ${#outline[*]} ; i++));
do
echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"
done
for (( i=0; i < ${#choices[*]} ; i++));
do
echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"
done
echo "</installer-gui-script>" >> "${1}/${packagename}/Distribution"
perl -i -p -e "s/%CHAMELEONVERSION%/${version%%-*}/g" `find "${1}/${packagename}/Resources" -type f`
perl -i -p -e "s/%CHAMELEONREVISION%/${revision}/g" `find "${1}/${packagename}/Resources" -type f`
stage=${stage/RC/Release Candidate }
stage=${stage/FINAL/2.0 Final}
perl -i -p -e "s/%CHAMELEONSTAGE%/${stage}/g" `find "${1}/${packagename}/Resources" -type f`
find "${1}/${packagename}" -name '.DS_Store' -delete
pushd "${1}/${packagename}" >/dev/null
xar -c -f "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" --compression none .
popd >/dev/null
md5=$( md5 "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" | awk {'print $4'} )
echo "MD5 (${packagename// /}-${version}-r${revision}.pkg) = ${md5}" > "${1%/*}/${packagename// /}-${version}-r${revision}.pkg.md5"
}
main "${1}" "${2}" "${3}" "${4}" "${5}"
branches/azimutz/Chazi/package/Scripts/HFS/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#!/bin/bash
diskloader="/usr/standalone/i386/boot0"
partitionloader="/usr/standalone/i386/boot1h"
filesystemloader="/usr/standalone/i386/boot"
bootervolumename="EFI"
booterextensions="Extra/Extensions"
bootresources="${0%/*}"
diskmicrocodetype[1]="GRUB,47525542"
diskmicrocodetype[2]="LILO,4c494c4f"
start ()
{
# $1 volume
osxvolume="${@}"
if [ -z "${osxvolume}" ]; then
echo
echo "Cannot find the volume. Exiting."
exit
fi
bootdev=$( df "${osxvolume}" | sed -n '2p' | awk '{print $1}' )
if [ "${bootdev}" = "${bootdev#*disk*s}" ]; then
echo
echo "ERROR Volume does not use slices."
echo "Volume may be stored on a RAID array."
echo
exit
fi
partitiontable=$( dd 2>/dev/null if=${bootdev%s*} count=1 skip=1 | dd 2>/dev/null count=8 bs=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:0:16}" == "4546492050415254" ]; then
partitiontable=$( dd 2>/dev/null if=${bootdev%s*} count=1 | dd 2>/dev/null count=64 bs=1 skip=446 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:8:2}" == "ee" ]; then
if [ "${partitiontable:40:2}" == "00" ] && [ "${partitiontable:72:2}" == "00" ] && [ "${partitiontable:104:2}" == "00" ]; then
partitiontable="GPT"
else
partitiontable="GPT/MBR"
fi
fi
else
echo
echo "ERROR Volume is not on a GPT partitioned disc."
echo
exit
fi
echo "${partitiontable} found."
echo "OS X Volume is ${osxvolume}"
echo "OX X Volume device is ${bootdev}"
bootvolume="/Volumes/$bootervolumename"
bootdev=${bootdev%s*}s1
bootrdev=${bootdev/disk/rdisk}
bootdisk=${bootdev%s*}
bootrdisk=${bootdisk/disk/rdisk}
bootslice=${bootdev#*disk*s}
echo "EFI Volume device is ${bootdev}"
echo "EFI Volume raw device is ${bootrdev}"
echo "EFI Volume slice is ${bootslice}"
echo "Disk device is ${bootdisk}"
echo "Disk raw device is ${bootrdisk}"
echo "Disk loader is ${diskloader}"
echo "Partition loader is ${partitionloader}"
echo "Filesystem loader is ${filesystemloader}"
}
checkdiskmicrocodetype ()
{
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodetypecounter=0
while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do
diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 ))
diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,}
if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then
echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found."
fi
done
}
checkdiskmicrocode ()
{
# 1 action ( check or set )
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodemd5=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | md5 )
if [ $( echo "${diskmicrocode}" | awk -F0 '{print NF-1}' ) = 874 ]; then
if [ "${1}" = "set" ]; then
echo "No disk microcode found. Updating."
diskupdate=true
else
echo "No disk microcode found."
fi
else
if [ ${1} = set ]; then
echo "Disk microcode found. Preserving."
else
echo "Disk microcode found."
fi
echo "Disk microcode MD5 is ${diskmicrocodemd5}"
fi
}
checkdisksignature ()
{
disksignature=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${disksignature}" | awk -F0 '{print NF-1}' ) = 8 ]; then
echo "No disk signature found."
else
echo "Disk signature found."
echo "Disk signature is 0x${disksignature}"
fi
}
checkpartitionbootcode ()
{
# 1 action ( check or set )
partitionbootcode=$( dd if=${bootrdev} count=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
partitionbootcodeextended=$( dd if=${bootrdev} count=1 skip=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${partitionbootcode}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
if [ "${1}" = "set" ]; then
echo "No partition bootcode found. Updating."
else
echo "No partition bootcode found."
fi
else
if [ "${1}" = "set" ]; then
echo "Partition bootcode found. Overwriting."
else
echo "Partition bootcode found."
fi
if [ $( echo "${partitionbootcodeextended}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=1 | md5 )
else
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=2 | md5 )
echo "Partition bootcode is dual sector."
fi
echo "Partition bootcode MD5 is ${partitionbootcodemd5}"
fi
}
checkpartitionactive ()
{
partitionactive=$( fdisk -d ${bootrdisk} | grep -n "*" | awk -F: '{print $1}')
if [ -n "${partitionactive}" ]; then
echo "Partition flagged active is ${partitionactive}"
else
echo "No partition flagged active."
fi
}
start ${3}
if [ "$( df | grep ${bootdev} )" ]; then
umount -f ${bootdev}
fi
if ! [ "$( fstyp ${bootdev} | grep hfs )" ]; then
echo "${bootdev} isn't a HFS partition"
echo "Executing command: newfs_hfs -v ${bootervolumename} ${bootdev}"
newfs_hfs -v "${bootervolumename}" "${bootdev}"
else
echo "${bootdev} is already a HFS partition (skipping)"
fi
diskupdate=false
checkdiskmicrocodetype
checkdiskmicrocode set
checkdisksignature
checkpartitionbootcode set
checkpartitionactive
if ${diskupdate}; then
echo "Executing command: fdisk -u -f ${diskloader} -y ${bootdisk}"
fdisk -u -f "${osxvolume}/${diskloader}" -y ${bootdisk}
fi
echo "Executing command: dd if=${partitionloader} of=${bootrdev}"
dd if="${osxvolume}/${partitionloader}" of=${bootrdev}
# If table is GPT make the first partition active (BadAxe compatibility).
[ "${partitiontable}" = "GPT" ] && bootslice=1
if [[ "${partitiontable}" = "GPT" ]]; then
fdisk -e ${bootdisk} <<-MAKEACTIVE
print
flag ${bootslice}
write
y
quit
MAKEACTIVE
fi
checkdiskmicrocode check
checkdisksignature
checkpartitionbootcode check
checkpartitionactive
[ -d "${bootvolume}" ] || mkdir -p "${bootvolume}"
echo "Executing command: mount_hfs ${bootdev} ${bootvolume}"
mount_hfs "${bootdev}" "${bootvolume}"
echo "Executing command: cp ${osxvolume}${filesystemloader} ${bootvolume}/boot"
cp "${osxvolume}${filesystemloader}" "${bootvolume}/boot"
if ! [ -d "${bootvolume}/Extra/Extensions" ]; then
echo "Executing command: mkdir -p ${bootvolume}/Extra/Extensions"
mkdir -p "${bootvolume}/Extra/Extensions"
fi
# unpack any existing Extensions.mkext already on the booter volume
if [ -e "${bootvolume}/Extra/Extensions.mkext" ]; then
echo "Executing command: mkextunpack -d ${bootvolume}/Extra/Extensions ${bootvolume}/Extra/Extensions.mkext"
mkextunpack -d "${bootvolume}/Extra/Extensions" "${bootvolume}/Extra/Extensions.mkext"
echo "Executing command: rm -R -f ${bootvolume}/Extra/Extensions.mkext"
rm -R -f "${bootvolume}/Extra/Extensions.mkext"
fi
# copy existing /Extra
if [ -d "${2}/Extra" ]; then
[ -d "${bootvolume}/Extra/Extensions" ] || mkdir -p "${bootvolume}/Extra/Extensions"
echo "Executing command: find ${2}/Extra -name '*.plist' -depth 1 -exec cp -f {} ${bootvolume}/Extra \;"
find "${2}/Extra" -name '*.plist' -depth 1 -exec cp -f {} "${bootvolume}/Extra/" \;
if [ -f "${2}/Extra/Extensions.mkext" ]; then
echo "Executing command: mkextunpack -d ${2}/Extra/Extensions ${2}/Extra/Extensions.mkext"
mkextunpack -d "${bootvolume}/Extra/Extensions" "${2}/Extra/Extensions.mkext"
fi
if [ -d "${2}/Extra/Extensions" ]; then
echo "Executing command: find ${2}/Extra/Extensions -name '*.kext' -depth 1 -exec cp -R {} ${bootvolume}/Extra/Extensions \;"
find "${2}/Extra/Extensions" -name '*.kext' -depth 1 -exec cp -R {} "${bootvolume}/Extra/Extensions" \;
fi
fi
# setup link for extras
[ -h "${2}/.Chameleon" ] && unlink "${2}/.Chameleon"
echo "Executing command: ln -s /Volumes/${bootervolumename} ${2}/.Chameleon"
ln -s "/Volumes/${bootervolumename}" "${2}/.Chameleon"
exit
branches/azimutz/Chazi/package/Scripts/HFS/postinstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#!/bin/bash
diskloader="/usr/standalone/i386/boot0"
partitionloader="/usr/standalone/i386/boot1h"
filesystemloader="/usr/standalone/i386/boot"
bootervolumename="EFI"
booterextensions="Extra/Extensions"
bootresources="${0%/*}"
diskmicrocodetype[1]="GRUB,47525542"
diskmicrocodetype[2]="LILO,4c494c4f"
start ()
{
# $1 volume
osxvolume="${@}"
if [ -z "${osxvolume}" ]; then
echo
echo "Cannot find the volume. Exiting."
exit
fi
bootdev=$( df "${osxvolume}" | sed -n '2p' | awk '{print $1}' )
if [ "${bootdev}" = "${bootdev#*disk*s}" ]; then
echo
echo "ERROR Volume does not use slices."
echo "Volume may be stored on a RAID array."
echo
exit
fi
partitiontable=$( dd 2>/dev/null if=${bootdev%s*} count=1 skip=1 | dd 2>/dev/null count=8 bs=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:0:16}" == "4546492050415254" ]; then
partitiontable=$( dd 2>/dev/null if=${bootdev%s*} count=1 | dd 2>/dev/null count=64 bs=1 skip=446 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:8:2}" == "ee" ]; then
if [ "${partitiontable:40:2}" == "00" ] && [ "${partitiontable:72:2}" == "00" ] && [ "${partitiontable:104:2}" == "00" ]; then
partitiontable="GPT"
else
partitiontable="GPT/MBR"
fi
fi
else
echo
echo "ERROR Volume is not on a GPT partitioned disc."
echo
exit
fi
echo "${partitiontable} found."
echo "OS X Volume is ${osxvolume}"
echo "OX X Volume device is ${bootdev}"
bootvolume="/Volumes/$bootervolumename"
bootdev=${bootdev%s*}s1
bootrdev=${bootdev/disk/rdisk}
bootdisk=${bootdev%s*}
bootrdisk=${bootdisk/disk/rdisk}
bootslice=${bootdev#*disk*s}
echo "EFI Volume device is ${bootdev}"
echo "EFI Volume raw device is ${bootrdev}"
echo "EFI Volume slice is ${bootslice}"
echo "Disk device is ${bootdisk}"
echo "Disk raw device is ${bootrdisk}"
echo "Disk loader is ${diskloader}"
echo "Partition loader is ${partitionloader}"
echo "Filesystem loader is ${filesystemloader}"
}
checkdiskmicrocodetype ()
{
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodetypecounter=0
while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do
diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 ))
diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,}
if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then
echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found."
fi
done
}
checkdiskmicrocode ()
{
# 1 action ( check or set )
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodemd5=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | md5 )
if [ $( echo "${diskmicrocode}" | awk -F0 '{print NF-1}' ) = 874 ]; then
if [ "${1}" = "set" ]; then
echo "No disk microcode found. Updating."
diskupdate=true
else
echo "No disk microcode found."
fi
else
if [ ${1} = set ]; then
echo "Disk microcode found. Preserving."
else
echo "Disk microcode found."
fi
echo "Disk microcode MD5 is ${diskmicrocodemd5}"
fi
}
checkdisksignature ()
{
disksignature=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${disksignature}" | awk -F0 '{print NF-1}' ) = 8 ]; then
echo "No disk signature found."
else
echo "Disk signature found."
echo "Disk signature is 0x${disksignature}"
fi
}
checkpartitionbootcode ()
{
# 1 action ( check or set )
partitionbootcode=$( dd if=${bootrdev} count=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
partitionbootcodeextended=$( dd if=${bootrdev} count=1 skip=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${partitionbootcode}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
if [ "${1}" = "set" ]; then
echo "No partition bootcode found. Updating."
else
echo "No partition bootcode found."
fi
else
if [ "${1}" = "set" ]; then
echo "Partition bootcode found. Overwriting."
else
echo "Partition bootcode found."
fi
if [ $( echo "${partitionbootcodeextended}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=1 | md5 )
else
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=2 | md5 )
echo "Partition bootcode is dual sector."
fi
echo "Partition bootcode MD5 is ${partitionbootcodemd5}"
fi
}
checkpartitionactive ()
{
partitionactive=$( fdisk -d ${bootrdisk} | grep -n "*" | awk -F: '{print $1}')
if [ -n "${partitionactive}" ]; then
echo "Partition flagged active is ${partitionactive}"
else
echo "No partition flagged active."
fi
}
start ${3}
if [ "$( df | grep ${bootdev} )" ]; then
umount -f ${bootdev}
fi
if ! [ "$( fstyp ${bootdev} | grep hfs )" ]; then
echo "${bootdev} isn't a HFS partition"
echo "Executing command: newfs_hfs -v ${bootervolumename} ${bootdev}"
newfs_hfs -v "${bootervolumename}" "${bootdev}"
else
echo "${bootdev} is already a HFS partition (skipping)"
fi
diskupdate=false
checkdiskmicrocodetype
checkdiskmicrocode set
checkdisksignature
checkpartitionbootcode set
checkpartitionactive
if ${diskupdate}; then
echo "Executing command: fdisk -u -f ${diskloader} -y ${bootdisk}"
fdisk -u -f "${osxvolume}/${diskloader}" -y ${bootdisk}
fi
echo "Executing command: dd if=${partitionloader} of=${bootrdev}"
dd if="${osxvolume}/${partitionloader}" of=${bootrdev}
# If table is GPT make the first partition active (BadAxe compatibility).
[ "${partitiontable}" = "GPT" ] && bootslice=1
if [[ "${partitiontable}" = "GPT" ]]; then
fdisk -e ${bootdisk} <<-MAKEACTIVE
print
flag ${bootslice}
write
y
quit
MAKEACTIVE
fi
checkdiskmicrocode check
checkdisksignature
checkpartitionbootcode check
checkpartitionactive
[ -d "${bootvolume}" ] || mkdir -p "${bootvolume}"
echo "Executing command: mount_hfs ${bootdev} ${bootvolume}"
mount_hfs "${bootdev}" "${bootvolume}"
echo "Executing command: cp ${osxvolume}${filesystemloader} ${bootvolume}/boot"
cp "${osxvolume}${filesystemloader}" "${bootvolume}/boot"
if ! [ -d "${bootvolume}/Extra/Extensions" ]; then
echo "Executing command: mkdir -p ${bootvolume}/Extra/Extensions"
mkdir -p "${bootvolume}/Extra/Extensions"
fi
# unpack any existing Extensions.mkext already on the booter volume
if [ -e "${bootvolume}/Extra/Extensions.mkext" ]; then
echo "Executing command: mkextunpack -d ${bootvolume}/Extra/Extensions ${bootvolume}/Extra/Extensions.mkext"
mkextunpack -d "${bootvolume}/Extra/Extensions" "${bootvolume}/Extra/Extensions.mkext"
echo "Executing command: rm -R -f ${bootvolume}/Extra/Extensions.mkext"
rm -R -f "${bootvolume}/Extra/Extensions.mkext"
fi
# copy existing /Extra
if [ -d "${2}/Extra" ]; then
[ -d "${bootvolume}/Extra/Extensions" ] || mkdir -p "${bootvolume}/Extra/Extensions"
echo "Executing command: find ${2}/Extra -name '*.plist' -depth 1 -exec cp -f {} ${bootvolume}/Extra \;"
find "${2}/Extra" -name '*.plist' -depth 1 -exec cp -f {} "${bootvolume}/Extra/" \;
if [ -f "${2}/Extra/Extensions.mkext" ]; then
echo "Executing command: mkextunpack -d ${2}/Extra/Extensions ${2}/Extra/Extensions.mkext"
mkextunpack -d "${bootvolume}/Extra/Extensions" "${2}/Extra/Extensions.mkext"
fi
if [ -d "${2}/Extra/Extensions" ]; then
echo "Executing command: find ${2}/Extra/Extensions -name '*.kext' -depth 1 -exec cp -R {} ${bootvolume}/Extra/Extensions \;"
find "${2}/Extra/Extensions" -name '*.kext' -depth 1 -exec cp -R {} "${bootvolume}/Extra/Extensions" \;
fi
fi
# setup link for extras
[ -h "${2}/.Chameleon" ] && unlink "${2}/.Chameleon"
echo "Executing command: ln -s /Volumes/${bootervolumename} ${2}/.Chameleon"
ln -s "/Volumes/${bootervolumename}" "${2}/.Chameleon"
exit
branches/azimutz/Chazi/package/Scripts/Standard/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/bash
diskloader="boot0"
partitionloader="boot1h"
filesystemloader="boot"
diskmicrocodetype[1]="GRUB,47525542"
diskmicrocodetype[2]="LILO,4c494c4f"
start ()
{
# 1 volume
bootvolume="${@}"
bootresources="${0%/*}"
if [ -z "${bootvolume}" ]; then
echo
echo "Cannot find the volume. Exiting."
echo
exit
fi
bootdev=$( df "${bootvolume}" | sed -n '2p' | awk '{print $1}' )
bootrdev=${bootdev/disk/rdisk}
if [ "${bootdev}" = "${bootdev#*disk*s}" ]; then
echo
echo "ERROR Volume does not use slices."
echo
exit
fi
bootdisk=${bootdev%s*}
bootrdisk=${bootdisk/disk/rdisk}
bootslice=${bootdev#*disk*s}
echo "Volume is ${bootvolume}"
echo "Volume device is ${bootdev}"
echo "Volume raw device is ${bootrdev}"
echo "Volume slice is ${bootslice}"
echo "Disk device is ${bootdisk}"
echo "Disk raw device is ${bootrdisk}"
echo "Disk loader is ${diskloader}"
echo "Partition loader is ${partitionloader}"
echo "Filesystem loader is ${filesystemloader}"
echo "Boot Resources is ${bootresources}"
}
checkdiskmicrocodetype ()
{
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodetypecounter=0
while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do
diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 ))
diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,}
if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then
echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found."
fi
done
}
checkdiskmicrocode ()
{
# 1 action ( check or set )
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodemd5=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | md5 )
if [ $( echo "${diskmicrocode}" | awk -F0 '{print NF-1}' ) = 874 ]; then
if [ "${1}" = "set" ]; then
echo "No disk microcode found. Updating."
diskupdate=true
else
echo "No disk microcode found."
fi
else
if [ ${1} = set ]; then
echo "Disk microcode found. Preserving."
else
echo "Disk microcode found."
fi
echo "Disk microcode MD5 is ${diskmicrocodemd5}"
fi
}
checkdisksignature ()
{
disksignature=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${disksignature}" | awk -F0 '{print NF-1}' ) = 8 ]; then
echo "No disk signature found."
else
echo "Disk signature found."
echo "Disk signature is 0x${disksignature}"
fi
}
checkpartitionbootcode ()
{
# 1 action ( check or set )
partitionbootcode=$( dd if=${bootrdev} count=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
partitionbootcodeextended=$( dd if=${bootrdev} count=1 skip=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${partitionbootcode}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
if [ "${1}" = "set" ]; then
echo "No partition bootcode found. Updating."
else
echo "No partition bootcode found."
fi
else
if [ "${1}" = "set" ]; then
echo "Partition bootcode found. Overwriting."
else
echo "Partition bootcode found."
fi
if [ $( echo "${partitionbootcodeextended}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=1 | md5 )
else
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=2 | md5 )
echo "Partition bootcode is dual sector."
fi
echo "Partition bootcode MD5 is ${partitionbootcodemd5}"
fi
}
checkpartitionactive ()
{
partitionactive=$( fdisk -d ${bootrdisk} | grep -n "*" | awk -F: '{print $1}')
if [ -n "${partitionactive}" ]; then
echo "Partition flagged active is ${partitionactive}"
else
echo "No partition flagged active."
fi
}
start ${3}
#partitiontable=$( diskutil list ${bootdisk} | sed -n '3p' | awk '{print $2}' )
#[ "${partitiontable}" = "GUID_partition_scheme" ] && echo "GPT found."
#[ "${partitiontable}" = "FDisk_partition_scheme" ] && echo "MBR found."
#[ "${partitiontable}" = "Apple_partition_scheme" ] && echo "APT found." && exit
partitiontable=$( dd 2>/dev/null if=${bootdisk} count=1 skip=1 | dd 2>/dev/null count=8 bs=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:0:16}" == "4546492050415254" ]; then
partitiontable=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=64 bs=1 skip=446 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:8:2}" == "ee" ]; then
if [ "${partitiontable:40:2}" == "00" ] && [ "${partitiontable:72:2}" == "00" ] && [ "${partitiontable:104:2}" == "00" ]; then
partitiontable="GPT"
else
partitiontable="GPT/MBR"
fi
fi
else
partitiontable="MBR"
fi
echo "${partitiontable} found."
diskupdate=false
checkdiskmicrocodetype
checkdiskmicrocode set
checkdisksignature
checkpartitionbootcode set
checkpartitionactive
if ${diskupdate}; then
echo "Executing command: fdisk -u -f /usr/standalone/i386/${diskloader} -y ${bootdisk}"
fdisk -u -f "${bootvolume}/usr/standalone/i386/${diskloader}" -y ${bootdisk}
fi
echo "Executing command: dd if=/usr/standalone/i386/${partitionloader} of=${bootrdev}"
dd if="${bootvolume}/usr/standalone/i386/${partitionloader}" of=${bootrdev}
echo "Executing command: cp /usr/standalone/i386/${filesystemloader} ${bootvolume}"
cp "${bootvolume}/usr/standalone/i386/${filesystemloader}" "${bootvolume}"
echo "Executing command: ${bootresources}/Tools/SetFile -a V ${bootvolume}/${filesystemloader}"
"${bootresources}/Tools/SetFile" -a V "${bootvolume}/${filesystemloader}"
# If table is GPT make the first partition active (BadAxe compatibility).
[ "${partitiontable}" = "GPT" ] && bootslice=1
fdisk -e ${bootdisk} <<-MAKEACTIVE
print
flag ${bootslice}
write
y
quit
MAKEACTIVE
checkdiskmicrocode check
checkdisksignature
checkpartitionbootcode check
checkpartitionactive
if ! [ -d "${bootvolume}/Extra/Extensions" ]; then
echo "Executing command: mkdir -p ${bootvolume}/Extra/Extensions"
mkdir -p "${bootvolume}/Extra/Extensions"
fi
# unpack any existing Extensions.mkext already on the booter volume
if [ -f "${2}/Extra/Extensions.mkext" ]; then
echo "Executing command: mkextunpack -d ${2}/Extra/Extensions ${2}/Extra/Extensions.mkext"
mkextunpack -d "${2}/Extra/Extensions" "${2}/Extra/Extensions.mkext"
echo "Executing command: rm -R -f ${2}/Extra/Extensions.mkext"
rm -R -f "${2}/Extra/Extensions.mkext"
fi
# setup link for extras
[ -h "${2}/.Chameleon" ] && unlink "${2}/.Chameleon"
echo "Executing command: ln -s . ${2}/.Chameleon"
ln -s "." "${2}/.Chameleon"
exit
branches/azimutz/Chazi/package/Scripts/Standard/postinstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/bash
diskloader="boot0"
partitionloader="boot1h"
filesystemloader="boot"
diskmicrocodetype[1]="GRUB,47525542"
diskmicrocodetype[2]="LILO,4c494c4f"
start ()
{
# 1 volume
bootvolume="${@}"
bootresources="${0%/*}"
if [ -z "${bootvolume}" ]; then
echo
echo "Cannot find the volume. Exiting."
echo
exit
fi
bootdev=$( df "${bootvolume}" | sed -n '2p' | awk '{print $1}' )
bootrdev=${bootdev/disk/rdisk}
if [ "${bootdev}" = "${bootdev#*disk*s}" ]; then
echo
echo "ERROR Volume does not use slices."
echo
exit
fi
bootdisk=${bootdev%s*}
bootrdisk=${bootdisk/disk/rdisk}
bootslice=${bootdev#*disk*s}
echo "Volume is ${bootvolume}"
echo "Volume device is ${bootdev}"
echo "Volume raw device is ${bootrdev}"
echo "Volume slice is ${bootslice}"
echo "Disk device is ${bootdisk}"
echo "Disk raw device is ${bootrdisk}"
echo "Disk loader is ${diskloader}"
echo "Partition loader is ${partitionloader}"
echo "Filesystem loader is ${filesystemloader}"
echo "Boot Resources is ${bootresources}"
}
checkdiskmicrocodetype ()
{
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodetypecounter=0
while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do
diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 ))
diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,}
if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then
echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found."
fi
done
}
checkdiskmicrocode ()
{
# 1 action ( check or set )
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodemd5=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | md5 )
if [ $( echo "${diskmicrocode}" | awk -F0 '{print NF-1}' ) = 874 ]; then
if [ "${1}" = "set" ]; then
echo "No disk microcode found. Updating."
diskupdate=true
else
echo "No disk microcode found."
fi
else
if [ ${1} = set ]; then
echo "Disk microcode found. Preserving."
else
echo "Disk microcode found."
fi
echo "Disk microcode MD5 is ${diskmicrocodemd5}"
fi
}
checkdisksignature ()
{
disksignature=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${disksignature}" | awk -F0 '{print NF-1}' ) = 8 ]; then
echo "No disk signature found."
else
echo "Disk signature found."
echo "Disk signature is 0x${disksignature}"
fi
}
checkpartitionbootcode ()
{
# 1 action ( check or set )
partitionbootcode=$( dd if=${bootrdev} count=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
partitionbootcodeextended=$( dd if=${bootrdev} count=1 skip=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${partitionbootcode}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
if [ "${1}" = "set" ]; then
echo "No partition bootcode found. Updating."
else
echo "No partition bootcode found."
fi
else
if [ "${1}" = "set" ]; then
echo "Partition bootcode found. Overwriting."
else
echo "Partition bootcode found."
fi
if [ $( echo "${partitionbootcodeextended}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=1 | md5 )
else
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=2 | md5 )
echo "Partition bootcode is dual sector."
fi
echo "Partition bootcode MD5 is ${partitionbootcodemd5}"
fi
}
checkpartitionactive ()
{
partitionactive=$( fdisk -d ${bootrdisk} | grep -n "*" | awk -F: '{print $1}')
if [ -n "${partitionactive}" ]; then
echo "Partition flagged active is ${partitionactive}"
else
echo "No partition flagged active."
fi
}
start ${3}
#partitiontable=$( diskutil list ${bootdisk} | sed -n '3p' | awk '{print $2}' )
#[ "${partitiontable}" = "GUID_partition_scheme" ] && echo "GPT found."
#[ "${partitiontable}" = "FDisk_partition_scheme" ] && echo "MBR found."
#[ "${partitiontable}" = "Apple_partition_scheme" ] && echo "APT found." && exit
partitiontable=$( dd 2>/dev/null if=${bootdisk} count=1 skip=1 | dd 2>/dev/null count=8 bs=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:0:16}" == "4546492050415254" ]; then
partitiontable=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=64 bs=1 skip=446 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:8:2}" == "ee" ]; then
if [ "${partitiontable:40:2}" == "00" ] && [ "${partitiontable:72:2}" == "00" ] && [ "${partitiontable:104:2}" == "00" ]; then
partitiontable="GPT"
else
partitiontable="GPT/MBR"
fi
fi
else
partitiontable="MBR"
fi
echo "${partitiontable} found."
diskupdate=false
checkdiskmicrocodetype
checkdiskmicrocode set
checkdisksignature
checkpartitionbootcode set
checkpartitionactive
if ${diskupdate}; then
echo "Executing command: fdisk -u -f /usr/standalone/i386/${diskloader} -y ${bootdisk}"
fdisk -u -f "${bootvolume}/usr/standalone/i386/${diskloader}" -y ${bootdisk}
fi
echo "Executing command: dd if=/usr/standalone/i386/${partitionloader} of=${bootrdev}"
dd if="${bootvolume}/usr/standalone/i386/${partitionloader}" of=${bootrdev}
echo "Executing command: cp /usr/standalone/i386/${filesystemloader} ${bootvolume}"
cp "${bootvolume}/usr/standalone/i386/${filesystemloader}" "${bootvolume}"
echo "Executing command: ${bootresources}/Tools/SetFile -a V ${bootvolume}/${filesystemloader}"
"${bootresources}/Tools/SetFile" -a V "${bootvolume}/${filesystemloader}"
# If table is GPT make the first partition active (BadAxe compatibility).
[ "${partitiontable}" = "GPT" ] && bootslice=1
fdisk -e ${bootdisk} <<-MAKEACTIVE
print
flag ${bootslice}
write
y
quit
MAKEACTIVE
checkdiskmicrocode check
checkdisksignature
checkpartitionbootcode check
checkpartitionactive
if ! [ -d "${bootvolume}/Extra/Extensions" ]; then
echo "Executing command: mkdir -p ${bootvolume}/Extra/Extensions"
mkdir -p "${bootvolume}/Extra/Extensions"
fi
# unpack any existing Extensions.mkext already on the booter volume
if [ -f "${2}/Extra/Extensions.mkext" ]; then
echo "Executing command: mkextunpack -d ${2}/Extra/Extensions ${2}/Extra/Extensions.mkext"
mkextunpack -d "${2}/Extra/Extensions" "${2}/Extra/Extensions.mkext"
echo "Executing command: rm -R -f ${2}/Extra/Extensions.mkext"
rm -R -f "${2}/Extra/Extensions.mkext"
fi
# setup link for extras
[ -h "${2}/.Chameleon" ] && unlink "${2}/.Chameleon"
echo "Executing command: ln -s . ${2}/.Chameleon"
ln -s "." "${2}/.Chameleon"
exit
branches/azimutz/Chazi/package/Scripts/Post/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
temp="/tmp/Chameleon"
# source com.apple.boot.plist
if ! [ -f "${2}/.Chameleon/Extra/com.apple.Boot.plist" ]; then
if [ -f "${2}/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" ]; then
cp -f "${2}/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" "${2}/.Chameleon/Extra"
fi
fi
# fix kext permissions
find "${2}/.Chameleon/Extra/Extensions" -type f -exec chmod 644 {} \;
find "${2}/.Chameleon/Extra/Extensions" -type d -exec chmod 755 {} \;
chown -R 0:0 "${2}/.Chameleon/Extra/Extensions"
# build mkext for extras
[ -d "${temp}" ] && rm -R -f "${temp}"
mkdir -p "${temp}/Extensions"
ditto --noextattr --noqtn --arch i386 "${2}/.Chameleon/Extra/Extensions" "${temp}/Extensions"
find "${temp}" -type f -exec chmod 644 {} \;
find "${temp}" -type d -exec chmod 755 {} \;
chown -R 0:0 "${temp}"
kextcache -m "${temp}/Extensions.mkext" "${temp}/Extensions"
cp -f "${temp}/Extensions.mkext" "${2}/.Chameleon/Extra"
rm -R -f "${temp}"
# remove link for extras install
unlink "${2}/.Chameleon"
# umount efi partition
if [ -d /Volumes/EFI ]; then
umount -f /Volumes/EFI
rm -R -f /Volumes/EFI
fi
exit 0
branches/azimutz/Chazi/package/Scripts/Post/postinstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
temp="/tmp/Chameleon"
# source com.apple.boot.plist
if ! [ -f "${2}/.Chameleon/Extra/com.apple.Boot.plist" ]; then
if [ -f "${2}/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" ]; then
cp -f "${2}/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" "${2}/.Chameleon/Extra"
fi
fi
# fix kext permissions
find "${2}/.Chameleon/Extra/Extensions" -type f -exec chmod 644 {} \;
find "${2}/.Chameleon/Extra/Extensions" -type d -exec chmod 755 {} \;
chown -R 0:0 "${2}/.Chameleon/Extra/Extensions"
# build mkext for extras
[ -d "${temp}" ] && rm -R -f "${temp}"
mkdir -p "${temp}/Extensions"
ditto --noextattr --noqtn --arch i386 "${2}/.Chameleon/Extra/Extensions" "${temp}/Extensions"
find "${temp}" -type f -exec chmod 644 {} \;
find "${temp}" -type d -exec chmod 755 {} \;
chown -R 0:0 "${temp}"
kextcache -m "${temp}/Extensions.mkext" "${temp}/Extensions"
cp -f "${temp}/Extensions.mkext" "${2}/.Chameleon/Extra"
rm -R -f "${temp}"
# remove link for extras install
unlink "${2}/.Chameleon"
# umount efi partition
if [ -d /Volumes/EFI ]; then
umount -f /Volumes/EFI
rm -R -f /Volumes/EFI
fi
exit 0
branches/azimutz/Chazi/package/Scripts/FAT/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/bin/bash
diskloader="/usr/standalone/i386/boot0"
partitionloader="/usr/standalone/i386/boot1f32"
filesystemloader="/usr/standalone/i386/boot"
bootervolumename="EFI"
booterextensions="Extra/Extensions"
bootresources="${0%/*}"
diskmicrocodetype[1]="GRUB,47525542"
diskmicrocodetype[2]="LILO,4c494c4f"
start ()
{
# $1 volume
osxvolume="${@}"
if [ -z "${osxvolume}" ]; then
echo
echo "Cannot find the volume. Exiting."
exit
fi
bootdev=$( df "${osxvolume}" | sed -n '2p' | awk '{print $1}' )
if [ "${bootdev}" = "${bootdev#*disk*s}" ]; then
echo
echo "ERROR Volume does not use slices."
echo "Volume may be stored on a RAID array."
echo
exit
fi
bootuuid=$( diskutil info "$bootdev" | grep Volume\ UUID | awk {'print $3'} )
partitiontable=$( diskutil list ${bootdev%s*} | sed -n '3p' | awk '{print $2}' )
if [ ${partitiontable} != "GUID_partition_scheme" ]; then
echo
echo "ERROR Volume is not on a GPT partitioned disc."
echo
exit
fi
echo "GPT found."
echo "OS X Volume is ${osxvolume}"
echo "OX X Volume device is ${bootdev}"
echo "OS X Volume UUID is ${bootuuid}"
bootvolume="/Volumes/$bootervolumename"
bootdev=${bootdev%s*}s1
bootrdev=${bootdev/disk/rdisk}
bootdisk=${bootdev%s*}
bootrdisk=${bootdisk/disk/rdisk}
bootslice=${bootdev#*disk*s}
echo "EFI Volume device is ${bootdev}"
echo "EFI Volume raw device is ${bootrdev}"
echo "EFI Volume slice is ${bootslice}"
echo "Disk device is ${bootdisk}"
echo "Disk raw device is ${bootrdisk}"
echo "Disk loader is ${diskloader}"
echo "Partition loader is ${partitionloader}"
echo "Filesystem loader is ${filesystemloader}"
}
checkdiskmicrocodetype ()
{
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodetypecounter=0
while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do
diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 ))
diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,}
if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then
echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found."
fi
done
}
checkdiskmicrocode ()
{
# 1 action ( check or set )
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodemd5=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | md5 )
if [ $( echo "${diskmicrocode}" | awk -F0 '{print NF-1}' ) = 874 ]; then
if [ "${1}" = "set" ]; then
echo "No disk microcode found. Updating."
diskupdate=true
else
echo "No disk microcode found."
fi
else
if [ ${1} = set ]; then
echo "Disk microcode found. Preserving."
else
echo "Disk microcode found."
fi
echo "Disk microcode MD5 is ${diskmicrocodemd5}"
fi
}
checkdisksignature ()
{
disksignature=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${disksignature}" | awk -F0 '{print NF-1}' ) = 8 ]; then
echo "No disk signature found."
else
echo "Disk signature found."
echo "Disk signature is 0x${disksignature}"
fi
}
checkpartitionbootcode ()
{
# 1 action ( check or set )
partitionbootcode=$( dd if=${bootrdev} count=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
partitionbootcodeextended=$( dd if=${bootrdev} count=1 skip=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${partitionbootcode}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
if [ "${1}" = "set" ]; then
echo "No partition bootcode found. Updating."
else
echo "No partition bootcode found."
fi
else
if [ "${1}" = "set" ]; then
echo "Partition bootcode found. Overwriting."
else
echo "Partition bootcode found."
fi
if [ $( echo "${partitionbootcodeextended}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=1 | md5 )
else
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=2 | md5 )
echo "Partition bootcode is dual sector."
fi
echo "Partition bootcode MD5 is ${partitionbootcodemd5}"
fi
}
checkpartitionactive ()
{
partitionactive=$( fdisk -d ${bootrdisk} | grep -n "*" | awk -F: '{print $1}')
if [ -n "${partitionactive}" ]; then
echo "Partition flagged active is ${partitionactive}"
else
echo "No partition flagged active."
fi
}
start ${3}
if [ "$( df | grep ${bootdev} )" ]; then
umount -f ${bootdev}
fi
#if [[ `dd if=/dev/disk${1}s1 count=8 bs=1 skip=82 | uuencode -m -|head -n 2|tail -n 1` != "RkFUMzIgICA=" ]]; then
#echo "${bootdev} isn't a FAT32 partition"
#newfs_msdos -v "${bootervolumename}" "${bootdev}"
#fi
if ! [ "$( fstyp ${bootdev} | grep msdos )" ]; then
echo "${bootdev} isn't a FAT32 partition"
echo "Executing command: newfs_msdos -F 32 ${bootdev}"
newfs_msdos -F 32 "${bootdev}"
else
echo "${bootdev} is already a FAT32 partition (skipping)"
fi
diskupdate=false
checkdiskmicrocodetype
checkdiskmicrocode set
checkdisksignature
checkpartitionbootcode set
checkpartitionactive
if ${diskupdate}; then
echo "Executing command: fdisk -u -f ${diskloader} -y ${bootdisk}"
fdisk -u -f "${osxvolume}/${diskloader}" -y ${bootdisk}
fi
#echo "Executing command: dd if=${partitionloader} of=${bootrdev}"
#dd if="${osxvolume}/${partitionloader}" of=${bootrdev}
echo "Stage 1"
echo "Executing command: dd if=${bootrdev} count=1 bs=512 of=/tmp/origbs"
dd if=${bootrdev} count=1 bs=512 of=/tmp/origbs
echo "Executing command: cp ${osxvolume}/${partitionloader} /tmp/newbs"
cp "${osxvolume}/${partitionloader}" /tmp/newbs
echo "Executing command: dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc"
dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
echo "Executing command: dd of=${bootrdev} count=1 bs=512 if=/tmp/newbs"
dd if=/tmp/newbs of=${bootrdev} count=1 bs=512
# If table is MBR make the correct slice active. If table is GPT make the first partition active (BadAxe compatibility).
[ "${partitiontable}" = "GUID_partition_scheme" ] && bootslice=1
if [[ "${partitiontable}" = "FDisk_partition_scheme" || "${partitiontable}" = "GUID_partition_scheme" ]]; then
fdisk -e ${bootdisk} <<-MAKEACTIVE
print
flag ${bootslice}
write
y
quit
MAKEACTIVE
fi
checkdiskmicrocode check
checkdisksignature
checkpartitionbootcode check
checkpartitionactive
[ -d "${bootvolume}" ] || mkdir -p "${bootvolume}"
echo "Executing command: mount_hfs ${bootdev} ${bootvolume}"
mount_msdos -u 0 -g 0 "${bootdev}" "${bootvolume}"
echo "Executing command: cp ${osxvolume}${filesystemloader} ${bootvolume}/boot"
cp "${osxvolume}${filesystemloader}" "${bootvolume}/boot"
if ! [ -d "${bootvolume}/Extra/Extensions" ]; then
echo "Executing command: mkdir -p ${bootvolume}/Extra/Extensions"
mkdir -p "${bootvolume}/Extra/Extensions"
fi
# unpack any existing Extensions.mkext already on the booter volume
if [ -e "${bootvolume}/Extra/Extensions.mkext" ]; then
echo "Executing command: mkextunpack -d ${bootvolume}/Extra/Extensions ${bootvolume}/Extra/Extensions.mkext"
mkextunpack -d "${bootvolume}/Extra/Extensions" "${bootvolume}/Extra/Extensions.mkext"
echo "Executing command: rm -R -f ${bootvolume}/Extra/Extensions.mkext"
rm -R -f "${bootvolume}/Extra/Extensions.mkext"
fi
# copy existing /Extra
if [ -d "${2}/Extra" ]; then
[ -d "${bootvolume}/Extra/Extensions" ] || mkdir -p "${bootvolume}/Extra/Extensions"
echo "Executing command: find ${2}/Extra -name '*.plist' -depth 1 -exec cp -f {} ${bootvolume}/Extra \;"
find "${2}/Extra" -name '*.plist' -depth 1 -exec cp -f {} "${bootvolume}/Extra/" \;
if [ -f "${2}/Extra/Extensions.mkext" ]; then
echo "Executing command: mkextunpack -d ${2}/Extra/Extensions ${2}/Extra/Extensions.mkext"
mkextunpack -d "${bootvolume}/Extra/Extensions" "${2}/Extra/Extensions.mkext"
fi
if [ -d "${2}/Extra/Extensions" ]; then
echo "Executing command: find ${2}/Extra/Extensions -name '*.kext' -depth 1 -exec cp -R {} ${bootvolume}/Extra/Extensions \;"
find "${2}/Extra/Extensions" -name '*.kext' -depth 1 -exec cp -R {} "${bootvolume}/Extra/Extensions" \;
fi
fi
# setup link for extras
echo "Executing command: ln -s /Volumes/${bootervolumename} ${2}/.Chameleon"
ln -s "/Volumes/${bootervolumename}" "${2}/.Chameleon"
exit
branches/azimutz/Chazi/package/Scripts/FAT/postinstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/bin/bash
diskloader="/usr/standalone/i386/boot0"
partitionloader="/usr/standalone/i386/boot1f32"
filesystemloader="/usr/standalone/i386/boot"
bootervolumename="EFI"
booterextensions="Extra/Extensions"
bootresources="${0%/*}"
diskmicrocodetype[1]="GRUB,47525542"
diskmicrocodetype[2]="LILO,4c494c4f"
start ()
{
# $1 volume
osxvolume="${@}"
if [ -z "${osxvolume}" ]; then
echo
echo "Cannot find the volume. Exiting."
exit
fi
bootdev=$( df "${osxvolume}" | sed -n '2p' | awk '{print $1}' )
if [ "${bootdev}" = "${bootdev#*disk*s}" ]; then
echo
echo "ERROR Volume does not use slices."
echo "Volume may be stored on a RAID array."
echo
exit
fi
bootuuid=$( diskutil info "$bootdev" | grep Volume\ UUID | awk {'print $3'} )
partitiontable=$( diskutil list ${bootdev%s*} | sed -n '3p' | awk '{print $2}' )
if [ ${partitiontable} != "GUID_partition_scheme" ]; then
echo
echo "ERROR Volume is not on a GPT partitioned disc."
echo
exit
fi
echo "GPT found."
echo "OS X Volume is ${osxvolume}"
echo "OX X Volume device is ${bootdev}"
echo "OS X Volume UUID is ${bootuuid}"
bootvolume="/Volumes/$bootervolumename"
bootdev=${bootdev%s*}s1
bootrdev=${bootdev/disk/rdisk}
bootdisk=${bootdev%s*}
bootrdisk=${bootdisk/disk/rdisk}
bootslice=${bootdev#*disk*s}
echo "EFI Volume device is ${bootdev}"
echo "EFI Volume raw device is ${bootrdev}"
echo "EFI Volume slice is ${bootslice}"
echo "Disk device is ${bootdisk}"
echo "Disk raw device is ${bootrdisk}"
echo "Disk loader is ${diskloader}"
echo "Partition loader is ${partitionloader}"
echo "Filesystem loader is ${filesystemloader}"
}
checkdiskmicrocodetype ()
{
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodetypecounter=0
while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do
diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 ))
diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,}
if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then
echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found."
fi
done
}
checkdiskmicrocode ()
{
# 1 action ( check or set )
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodemd5=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | md5 )
if [ $( echo "${diskmicrocode}" | awk -F0 '{print NF-1}' ) = 874 ]; then
if [ "${1}" = "set" ]; then
echo "No disk microcode found. Updating."
diskupdate=true
else
echo "No disk microcode found."
fi
else
if [ ${1} = set ]; then
echo "Disk microcode found. Preserving."
else
echo "Disk microcode found."
fi
echo "Disk microcode MD5 is ${diskmicrocodemd5}"
fi
}
checkdisksignature ()
{
disksignature=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${disksignature}" | awk -F0 '{print NF-1}' ) = 8 ]; then
echo "No disk signature found."
else
echo "Disk signature found."
echo "Disk signature is 0x${disksignature}"
fi
}
checkpartitionbootcode ()
{
# 1 action ( check or set )
partitionbootcode=$( dd if=${bootrdev} count=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
partitionbootcodeextended=$( dd if=${bootrdev} count=1 skip=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${partitionbootcode}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
if [ "${1}" = "set" ]; then
echo "No partition bootcode found. Updating."
else
echo "No partition bootcode found."
fi
else
if [ "${1}" = "set" ]; then
echo "Partition bootcode found. Overwriting."
else
echo "Partition bootcode found."
fi
if [ $( echo "${partitionbootcodeextended}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=1 | md5 )
else
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=2 | md5 )
echo "Partition bootcode is dual sector."
fi
echo "Partition bootcode MD5 is ${partitionbootcodemd5}"
fi
}
checkpartitionactive ()
{
partitionactive=$( fdisk -d ${bootrdisk} | grep -n "*" | awk -F: '{print $1}')
if [ -n "${partitionactive}" ]; then
echo "Partition flagged active is ${partitionactive}"
else
echo "No partition flagged active."
fi
}
start ${3}
if [ "$( df | grep ${bootdev} )" ]; then
umount -f ${bootdev}
fi
#if [[ `dd if=/dev/disk${1}s1 count=8 bs=1 skip=82 | uuencode -m -|head -n 2|tail -n 1` != "RkFUMzIgICA=" ]]; then
#echo "${bootdev} isn't a FAT32 partition"
#newfs_msdos -v "${bootervolumename}" "${bootdev}"
#fi
if ! [ "$( fstyp ${bootdev} | grep msdos )" ]; then
echo "${bootdev} isn't a FAT32 partition"
echo "Executing command: newfs_msdos -F 32 ${bootdev}"
newfs_msdos -F 32 "${bootdev}"
else
echo "${bootdev} is already a FAT32 partition (skipping)"
fi
diskupdate=false
checkdiskmicrocodetype
checkdiskmicrocode set
checkdisksignature
checkpartitionbootcode set
checkpartitionactive
if ${diskupdate}; then
echo "Executing command: fdisk -u -f ${diskloader} -y ${bootdisk}"
fdisk -u -f "${osxvolume}/${diskloader}" -y ${bootdisk}
fi
#echo "Executing command: dd if=${partitionloader} of=${bootrdev}"
#dd if="${osxvolume}/${partitionloader}" of=${bootrdev}
echo "Stage 1"
echo "Executing command: dd if=${bootrdev} count=1 bs=512 of=/tmp/origbs"
dd if=${bootrdev} count=1 bs=512 of=/tmp/origbs
echo "Executing command: cp ${osxvolume}/${partitionloader} /tmp/newbs"
cp "${osxvolume}/${partitionloader}" /tmp/newbs
echo "Executing command: dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc"
dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
echo "Executing command: dd of=${bootrdev} count=1 bs=512 if=/tmp/newbs"
dd if=/tmp/newbs of=${bootrdev} count=1 bs=512
# If table is MBR make the correct slice active. If table is GPT make the first partition active (BadAxe compatibility).
[ "${partitiontable}" = "GUID_partition_scheme" ] && bootslice=1
if [[ "${partitiontable}" = "FDisk_partition_scheme" || "${partitiontable}" = "GUID_partition_scheme" ]]; then
fdisk -e ${bootdisk} <<-MAKEACTIVE
print
flag ${bootslice}
write
y
quit
MAKEACTIVE
fi
checkdiskmicrocode check
checkdisksignature
checkpartitionbootcode check
checkpartitionactive
[ -d "${bootvolume}" ] || mkdir -p "${bootvolume}"
echo "Executing command: mount_hfs ${bootdev} ${bootvolume}"
mount_msdos -u 0 -g 0 "${bootdev}" "${bootvolume}"
echo "Executing command: cp ${osxvolume}${filesystemloader} ${bootvolume}/boot"
cp "${osxvolume}${filesystemloader}" "${bootvolume}/boot"
if ! [ -d "${bootvolume}/Extra/Extensions" ]; then
echo "Executing command: mkdir -p ${bootvolume}/Extra/Extensions"
mkdir -p "${bootvolume}/Extra/Extensions"
fi
# unpack any existing Extensions.mkext already on the booter volume
if [ -e "${bootvolume}/Extra/Extensions.mkext" ]; then
echo "Executing command: mkextunpack -d ${bootvolume}/Extra/Extensions ${bootvolume}/Extra/Extensions.mkext"
mkextunpack -d "${bootvolume}/Extra/Extensions" "${bootvolume}/Extra/Extensions.mkext"
echo "Executing command: rm -R -f ${bootvolume}/Extra/Extensions.mkext"
rm -R -f "${bootvolume}/Extra/Extensions.mkext"
fi
# copy existing /Extra
if [ -d "${2}/Extra" ]; then
[ -d "${bootvolume}/Extra/Extensions" ] || mkdir -p "${bootvolume}/Extra/Extensions"
echo "Executing command: find ${2}/Extra -name '*.plist' -depth 1 -exec cp -f {} ${bootvolume}/Extra \;"
find "${2}/Extra" -name '*.plist' -depth 1 -exec cp -f {} "${bootvolume}/Extra/" \;
if [ -f "${2}/Extra/Extensions.mkext" ]; then
echo "Executing command: mkextunpack -d ${2}/Extra/Extensions ${2}/Extra/Extensions.mkext"
mkextunpack -d "${bootvolume}/Extra/Extensions" "${2}/Extra/Extensions.mkext"
fi
if [ -d "${2}/Extra/Extensions" ]; then
echo "Executing command: find ${2}/Extra/Extensions -name '*.kext' -depth 1 -exec cp -R {} ${bootvolume}/Extra/Extensions \;"
find "${2}/Extra/Extensions" -name '*.kext' -depth 1 -exec cp -R {} "${bootvolume}/Extra/Extensions" \;
fi
fi
# setup link for extras
echo "Executing command: ln -s /Volumes/${bootervolumename} ${2}/.Chameleon"
ln -s "/Volumes/${bootervolumename}" "${2}/.Chameleon"
exit
branches/azimutz/Chazi/package/Scripts/Options/ForceHPET/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="ForceHPET"
string="y"
main ()
{
bootplist="${3}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp -f "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=y to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/azimutz/Chazi/package/Scripts/Options/ForceHPET/postinstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="ForceHPET"
string="y"
main ()
{
bootplist="${3}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp -f "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=y to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/azimutz/Chazi/package/Scripts/Options/EHCIacquire/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="EHCIacquire"
string="y"
main ()
{
bootplist="${3}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/azimutz/Chazi/package/Scripts/Options/EHCIacquire/postinstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="EHCIacquire"
string="y"
main ()
{
bootplist="${3}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/azimutz/Chazi/package/Scripts/Options/GUI/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="GUI"
string="n"
main ()
{
bootplist="${3}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/azimutz/Chazi/package/Scripts/Options/GUI/postinstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="GUI"
string="n"
main ()
{
bootplist="${3}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=${string} to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/azimutz/Chazi/package/Scripts/Options/EthernetBuiltIn/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="EthernetBuiltIn"
string="y"
main ()
{
bootplist="${3}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp -f "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=y to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/azimutz/Chazi/package/Scripts/Options/EthernetBuiltIn/postinstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="EthernetBuiltIn"
string="y"
main ()
{
bootplist="${3}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp -f "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=y to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/azimutz/Chazi/package/Scripts/Options/ForceWake/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="ForceWake"
string="y"
main ()
{
bootplist="${3}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp -f "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=y to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/azimutz/Chazi/package/Scripts/Options/ForceWake/postinstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="ForceWake"
string="y"
main ()
{
bootplist="${3}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp -f "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=y to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/azimutz/Chazi/package/Scripts/Options/GraphicsEnabler/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="GraphicsEnabler"
string="y"
main ()
{
bootplist="${3}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp -f "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=y to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/azimutz/Chazi/package/Scripts/Options/GraphicsEnabler/postinstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="GraphicsEnabler"
string="y"
main ()
{
bootplist="${3}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp -f "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=y to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/azimutz/Chazi/package/Scripts/Options/UHCIreset/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="UHCIreset"
string="y"
main ()
{
bootplist="${3}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=y to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/azimutz/Chazi/package/Scripts/Options/UHCIreset/postinstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
# set com.apple.Boot.plist options
overide="UHCIreset"
string="y"
main ()
{
bootplist="${3}/.Chameleon/Extra/com.apple.Boot.plist"
systemplist="/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
bootoptionshdextra[1]="<key>${overide}</key>"
bootoptionshdextra[2]="<string>${string}</string>"
[ ! -d "${bootplist%/*}" ] && mkdir -p "${bootplist%/*}"
if [ ! -f "${bootplist}" ]; then
if [ -f "${systemplist}" ]; then
cp "${systemplist}" "${bootplist}"
fi
fi
xmlvalue=$( getxmlvalue ${overide} "${bootplist}" | tr "[:upper:]" "[:lower:]" )
case "${xmlvalue:0:1}" in
y)echo "${overide}=y already set in ${bootplist} skipping."
;;
n)echo "${overide}=n is set in ${bootplist} leaving."
;;
*)echo "Adding ${overide}=y to ${bootplist}"
array=("${bootoptionshdextra[@]}")
searchfilereplaceline "${bootplist}" "<key>Kernel Flags</key>" "" "" "2"
;;
esac
chown "${USER}:20" "${bootplist}"
}
getxmlvalue ()
{
# 1 xml key
# 2 xml file
if [ -f "${2}" ]; then
local value
while read value; do
if [ ! "${value}" = "${value/<key>${1}</key>/}" ]; then
read value
value="${value#*<}" ; value="<${value}" ; value="${value#*>}" ; value="${value# *}" ; value="${value%%<*}"
echo "$value"
break
fi
done < "${2}"
fi
}
searchfilereplaceline ()
{
mv "${1}" "${1}.orig"
prefunctionifs="${IFS}"
unset fileinput
unset fileoutput
unset find
unset replace
unset deletelines
unset deletelinesskip
unset insertlinesskip
fileinput="${1}.orig"
fileoutput="${1}"
find="${2}"
replace="${3}"
deletelines="${4%,*}"
insertlinesskip="${5}"
matchlinefound="0"
if [ "${#4}" = "${4#*,}" ]; then
deletelinesskip="0"
else
deletelinesskip="${4#*,}"
fi
IFS="\n"
while read line
do
{
if [ ! "${line}" = "${line/${find}/}" ]; then
{
# Trim the longest match from the end for <*
xmlelementindent="${line%%<*}"
# Trim the longest match from the start for *<
xmlelementtemp="${line#*<}"
# Add back in stripped <
xmlelement="<${xmlelementtemp}"
# Trim the shortest match from the start for <
xmltagtemp="${xmlelement#<}"
# Trim the longest match from the end for >*
xmltag="${xmltagtemp%%>*}"
# Trim the shortest match from the start for *>
xmltexttemp="${xmlelement#*>}"
# Trim the longest match from the end for <*
xmltext="${xmltexttemp%%<*}"
if [ "${replace}" ]; then
{
echo "${xmlelementindent}<${xmltag}>${replace}</${xmltag}>" >>"${fileoutput}"
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
matchlinefound="1"
}
else
{
if [ "${insertlinesskip}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -le "${insertlinesskip}" ]; then
{
if [ "${matchlinefound}" = "${insertlinesskip}" ]; then
{
arraysize=0
while [ ${arraysize} -lt ${#array[@]} ];
do
echo "${xmlelementindent}${array[${arraysize}]}" >>"${fileoutput}"
let arraysize="${arraysize}+1"
done
}
fi
}
fi
if [ "${deletelines}" ] && [ "${matchlinefound}" -gt 0 ] && [ "${matchlinefound}" -lt $((${deletelines}+${deletelinesskip})) ] && [ "${matchlinefound}" -ge ${deletelinesskip} ]; then
{
:
}
else
{
echo "${line}" >>"${fileoutput}"
}
fi
if [ "${matchlinefound}" -gt 0 ]; then
let matchlinefound="${matchlinefound}+1"
fi
}
fi
}
done < "${fileinput}"
IFS=${prefunctionifs}
rm -f "${fileinput}"
}
main "${1}" "${2}" "${3}" "${4}"
branches/azimutz/Chazi/package/buildpkg.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#!/bin/bash
# $1 Path to store built package
packagesidentity="org.chameleon"
packagename="Chameleon"
pkgroot="${0%/*}"
#version=$( grep I386BOOT_CHAMELEONVERSION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )
version=$( cat version )
stage=${version##*-}
revision=$( grep I386BOOT_CHAMELEONREVISION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )
builddate=$( grep I386BOOT_BUILDDATE sym/i386/vers.h | awk '{ print $3,$4 }' | tr -d '\"' )
timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )
distributioncount=0
xmlindent=0
indent[0]="\t"
indent[1]="\t\t"
indent[2]="\t\t\t"
indent[3]="\t\t\t\t"
main ()
{
# clean up the destination path
rm -R -f "${1}"
echo "Building $packagename Install Package v${version%%-*} $stage r$revision $builddate"
outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
# build core package
mkdir -p ${1}/Core/Root/usr/sbin
mkdir -p ${1}/Core/Root/usr/local/bin
mkdir -p ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot0 ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1f32 ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1h ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1he ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1hp ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/cdboot ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/chain0 ${1}/Core/Root/usr/standalone/i386
fixperms "${1}/Core/Root/"
cp -f ${pkgroot}/fdisk ${1}/Core/Root/usr/sbin
local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} )
buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\""
# build standard package
mkdir -p ${1}/Standard/Root
mkdir -p ${1}/Standard/Scripts/Tools
cp -f ${pkgroot}/Scripts/Standard/* ${1}/Standard/Scripts
ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Tools/SetFile
buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EnhancedHFS']) &amp;&amp; exclusive(choices['EnhancedFAT'])\""
# build efi fat32 package
mkdir -p ${1}/EnhancedFAT/Root
mkdir -p ${1}/EnhancedFAT/Scripts/Tools
cp -f ${pkgroot}/Scripts/FAT/* ${1}/EnhancedFAT/Scripts
ditto --arch i386 `which SetFile` ${1}/EnhancedFAT/Scripts/Tools/SetFile
buildpackage "${1}/EnhancedFAT" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EnhancedHFS'])\""
# build efi hfs package
mkdir -p ${1}/EnhancedHFS/Root
mkdir -p ${1}/EnhancedHFS/Scripts/Tools
cp -f ${pkgroot}/Scripts/HFS/* ${1}/EnhancedHFS/Scripts
ditto --arch i386 `which SetFile` ${1}/EnhancedHFS/Scripts/Tools/SetFile
buildpackage "${1}/EnhancedHFS" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EnhancedFAT'])\""
# build options packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Options\">"
choices[$((choicescount++))]="<choice\n\tid=\"Options\"\n\ttitle=\"Options_title\"\n\tdescription=\"Options_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon"
options=($( find "${pkgroot}/Scripts/Options" -type d -depth 1 -not -name '.svn' ))
for (( i = 0 ; i < ${#options[@]} ; i++ ))
do
mkdir -p "${1}/${options[$i]##*/}/Root"
mkdir -p "${1}/${options[$i]##*/}/Scripts"
ditto --noextattr --noqtn "${options[$i]}/postinstall" "${1}/${options[$i]##*/}/Scripts/postinstall"
buildpackage "${1}/${options[$i]##*/}" "/" "" "start_selected=\"false\""
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build theme packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Themes\">"
choices[$((choicescount++))]="<choice\n\tid=\"Themes\"\n\ttitle=\"Themes_title\"\n\tdescription=\"Themes_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.theme"
artwork="${1%/*}"
themes=($( find "${artwork%/*}/artwork/themes" -type d -depth 1 -not -name '.svn' ))
for (( i = 0 ; i < ${#themes[@]} ; i++ ))
do
theme=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' )
mkdir -p "${1}/${theme}/Root/"
ditto --noextattr --noqtn "${themes[$i]}" "${1}/${themes[$i]##*/}/Root/${theme}"
find "${1}/${themes[$i]##*/}" -name '.DS_Store' -or -name '.svn' -exec rm -R {} \+
find "${1}/${themes[$i]##*/}" -type f -exec chmod 644 {} \+
buildpackage "${1}/${theme}" "/.Chameleon/Extra/Themes" ""
rm -R -f "${1}/${i##*/}"
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Extras\">"
choices[$((choicescount++))]="<choice\n\tid=\"Extras\"\n\ttitle=\"Extras_title\"\n\tdescription=\"Extras_description\"\n>\n</choice>\n"
((xmlindent++))
# build kext packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Kexts\">"
choices[$((choicescount++))]="<choice\n\tid=\"Kexts\"\n\ttitle=\"Kexts_title\"\n\tdescription=\"Kexts_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon"
kexts=($( find "${pkgroot}/Kexts" -type d -name '*.kext' -depth 1 ))
for (( i = 0 ; i < ${#kexts[@]} ; i++ ))
do
filename="${kexts[$i]##*/}"
mkdir -p "${1}/${filename%.kext}/Root/"
ditto --noextattr --noqtn --arch i386 "${kexts[$i]}" "${1}/${filename%.kext}/Root/${filename}"
find "${1}/${filename%.kext}" -name '.DS_Store' -or -name '.svn' -exec rm -R -f {} \; 2>/dev/null
fixperms "${1}/${filename%.kext}/Root/"
chown 501:20 "${1}/${filename%.kext}/Root/"
buildpackage "${1}/${filename%.kext}" "/.Chameleon/Extra/Extensions" ""
rm -R -f "${1}/${filename%.kext}"
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build post install package
mkdir -p ${1}/Post/Root
mkdir -p ${1}/Post/Scripts
cp -f ${pkgroot}/Scripts/Post/* ${1}/Post/Scripts
buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\""
outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
# build meta package
makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"
# clean up
rm -R -f "${1}"
}
fixperms ()
{
# $1 path
find "${1}" -type f -exec chmod 644 {} \;
find "${1}" -type d -exec chmod 755 {} \;
chown -R 0:0 "${1}"
}
buildpackage ()
{
# $1 Path to package to build containing Root and or Scripts
# $2 Install Location
# $3 Size
# $4 Options
if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then
local packagename="${1##*/}"
local identifier=$( echo ${packagesidentity}.${packagename//_/.} | tr [:upper:] [:lower:] )
find "${1}" -name '.DS_Store' -delete
local filecount=$( find "${1}/Root" | wc -l )
if [ "${3}" ]; then
local installedsize="${3}"
else
local installedsize=$( du -hkc "${1}/Root" | tail -n1 | awk {'print $1'} )
fi
local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "
#[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "
header+="identifier=\"${identifier}\" "
header+="version=\"${version}\" "
[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "
header+="auth=\"root\">\n"
header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
rm -R -f "${1}/Temp"
[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"
[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"
if [ -d "${1}/Scripts" ]; then
header+="\t<scripts>\n"
for script in $( find "${1}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) )
do
header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"
done
header+="\t</scripts>\n"
chown -R 0:0 "${1}/Scripts"
pushd "${1}/Scripts" >/dev/null
find . -print | cpio -o -z -H cpio > "../Temp/Scripts"
popd >/dev/null
fi
header+="</pkg-info>"
echo -e "${header}" > "${1}/Temp/PackageInfo"
pushd "${1}/Root" >/dev/null
find . -print | cpio -o -z -H cpio > "../Temp/Payload"
popd >/dev/null
pushd "${1}/Temp" >/dev/null
xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .
popd >/dev/null
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${packagename// /}\"/>"
if [ "${4}" ]; then
local choiceoptions="${indent[$xmlindent]}${4}\n"
fi
choices[$((choicescount++))]="<choice\n\tid=\"${packagename// /}\"\n\ttitle=\"${packagename}_title\"\n\tdescription=\"${packagename}_description\"\n${choiceoptions}>\n\t<pkg-ref id=\"${identifier}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}' auth='root'>#${packagename// /}.pkg</pkg-ref>\n</choice>\n"
rm -R -f "${1}"
fi
}
makedistribution ()
{
rm -f "${1%/*}/${packagename// /}"*.pkg
find "${1}" -type f -name '*.pkg' -depth 1 | while read component
do
mkdir -p "${1}/${packagename}/${component##*/}"
pushd "${1}/${packagename}/${component##*/}" >/dev/null
xar -x -f "${1%}/${component##*/}"
popd >/dev/null
done
ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"
ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"
find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null
for (( i=0; i < ${#outline[*]} ; i++));
do
echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"
done
for (( i=0; i < ${#choices[*]} ; i++));
do
echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"
done
echo "</installer-gui-script>" >> "${1}/${packagename}/Distribution"