| 1 |
# Macintosh OS X backend
|
| 2 |
#
|
| 3 |
# References:
|
| 4 |
# http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/index.html
|
| 5 |
# http://mirrors-3v.club-internet.fr/mirrors/ftp.osxgnu.org/pub/osxgnu/OSXPM/package
|
| 6 |
# http://developer.apple.com/releasenotes/DeveloperTools/Installer.html
|
| 7 |
# Packagmeaker Help files
|
| 8 |
#
|
| 9 |
# For online update support, Apple keeps its 'softwareupdate' tool
|
| 10 |
# for apple use only. However, see http://code.google.com/p/update-engine/
|
| 11 |
|
| 12 |
: NOTES <<.
|
| 13 |
|
| 14 |
# creating a dmg file for publishing on the web
|
| 15 |
hdiutil create -srcfolder /path/foo foo.dmg
|
| 16 |
hdiutil internet-enable -yes /path/foo.dmg
|
| 17 |
# Layout for packages
|
| 18 |
<name>-<cpy>/component/<file>
|
| 19 |
<name>-<cpt>/extras/postinstall
|
| 20 |
<name>-<cpt>/extras/postupgrade
|
| 21 |
# /Developer/usr/bin/packagemaker (man packagemaker)
|
| 22 |
|
| 23 |
Make a bunch of packages, and then build a 'distribution'
|
| 24 |
which is only understood by macos>10.4
|
| 25 |
|
| 26 |
# Message files in the resource path used are
|
| 27 |
Welcome.{rtf,html,rtfd,txt} - limited text shown in Intro
|
| 28 |
ReadMe.{rtf,html,rtfd,txt} - scrollable/printable, after Intro
|
| 29 |
License.{rtf,html,rtfd,txt} - ditto, user must click 'Accept'
|
| 30 |
background.{jpg,tif,gif,pict,eps,pdf} 620x418 background image
|
| 31 |
|
| 32 |
# These scripts looked for in the resource path
|
| 33 |
InstallationCheck $pkgpath $defaultloc $targetvol
|
| 34 |
0:ok 32:warn 32+x:warn[1] 64:stop 96+x:stop[2]
|
| 35 |
VolumeCheck $volpath
|
| 36 |
0:ok 32:failure 32+x:failure[3]
|
| 37 |
preflight $pkgpath $targetloc $targetvol [priv]
|
| 38 |
preinstall $pkgpath $targetloc $targetvol [priv]
|
| 39 |
preupgrade $pkgpath $targetloc $targetvol [priv]
|
| 40 |
postinstall $pkgpath $targetloc $targetvol [priv]
|
| 41 |
postupgrade $pkgpath $targetloc $targetvol [priv]
|
| 42 |
postflight $pkgpath $targetloc $targetvol [priv]
|
| 43 |
0:ok else fail (for all scripts)
|
| 44 |
|
| 45 |
A detailed reason is deduced by finding an index x (16..31)
|
| 46 |
in the file InstallationCheck.strings or VolumeCheck.strings.
|
| 47 |
|
| 48 |
Scripts marked [priv] are executed with root privileges.
|
| 49 |
None of the [priv] scripts are used by metapackages.
|
| 50 |
|
| 51 |
# Default permissions
|
| 52 |
Permissions of existing directories should match those
|
| 53 |
of a clean install of the OS; typically root:admin 0775
|
| 54 |
New directories or files should be 0775 or 0664 with the
|
| 55 |
appropriate user:group.
|
| 56 |
Exceptions:
|
| 57 |
/etc root:admin 0755
|
| 58 |
/var root:admin 0755
|
| 59 |
|
| 60 |
<http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution4/Concepts/sd_pkg_flags.html>
|
| 61 |
Info.plist = {
|
| 62 |
CFBundleGetInfoString: "1.2.3, Quest Software, Inc.",
|
| 63 |
CFBundleIdentifier: "com.quest.rc.openssh",
|
| 64 |
CFBundleShortVersionString: "1.2.3",
|
| 65 |
IFMajorVersion: 1,
|
| 66 |
IFMinorVersion: 2,
|
| 67 |
IFPkgFlagAllowBackRev: false,
|
| 68 |
IFPkgFlagAuthorizationAction: "AdminAuthorization",
|
| 69 |
IFPkgFlagDefaultLocation: "/",
|
| 70 |
IFPkgFlagFollowLinks: true,
|
| 71 |
IFPkgFlagInstallFat: false,
|
| 72 |
IFPkgFlagInstalledSize: <integer>, # this is added by packagemaker
|
| 73 |
IFPkgFlagIsRequired: false,
|
| 74 |
IFPkgFlagOverwritePermissions: false,
|
| 75 |
IFPkgFlagRelocatable: false,
|
| 76 |
IFPkgFlagRestartAction: "NoRestart",
|
| 77 |
IFPkgFlagRootVolumeOnly: false,
|
| 78 |
IFPkgFlagUpdateInstalledLanguages: false,
|
| 79 |
IFPkgFormatVersion= 0.10000000149011612,
|
| 80 |
IFRequirementDicts: [ {
|
| 81 |
Level = "requires",
|
| 82 |
SpecArgument = "/opt/quest/lib/libvas.4.2.0.dylib",
|
| 83 |
SpecType = "file",
|
| 84 |
TestObject = true,
|
| 85 |
TestOperator = "eq", } ]
|
| 86 |
}
|
| 87 |
|
| 88 |
Description.plist = {
|
| 89 |
IFPkgDescriptionDescription = "this is the description text",
|
| 90 |
IFPkgDescriptionTitle = "quest-openssh"
|
| 91 |
}
|
| 92 |
|
| 93 |
# Startup scripts
|
| 94 |
'launchd' is a kind of combined inetd and rc/init.d system.
|
| 95 |
<http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/DesigningDaemons.html>
|
| 96 |
Create a /Library/LaunchDaemons/$daemonname.plist file
|
| 97 |
Examples found in /System/Library/LaunchDaemons/
|
| 98 |
See manual page launchd.plist(5) for details:
|
| 99 |
|
| 100 |
{ Label: "com.quest.vintela.foo", # required
|
| 101 |
Program: "/sbin/program",
|
| 102 |
ProgramArguments: [ "/sbin/program", "arg1", "arg2" ], # required
|
| 103 |
RunAtLoad: true,
|
| 104 |
WatchPaths: [ "/etc/crontab" ],
|
| 105 |
QueueDirectories: [ "/var/cron/tabs" ],
|
| 106 |
inetdCompatibility: { Wait: false }, # inetd-only
|
| 107 |
OnDemand: false, # recommended
|
| 108 |
SessionCreate: true,
|
| 109 |
UserName: "nobody",
|
| 110 |
InitGroups: true,
|
| 111 |
Sockets: { # inetd only
|
| 112 |
Listeners: {
|
| 113 |
SockServiceName: "ssh",
|
| 114 |
Bonjour: ["ssh", "sftp-ssh"], } },
|
| 115 |
Disabled: false,
|
| 116 |
StandardErrorPath: "/dev/null",
|
| 117 |
}
|
| 118 |
|
| 119 |
|
| 120 |
How to add a new user
|
| 121 |
dscl . -create /Users/$user
|
| 122 |
dscl . -create /Users/$user UserShell /bin/bash
|
| 123 |
dscl . -create /Users/$user RealName "$user"
|
| 124 |
dscl . -create /Users/$user UniqueID $uid
|
| 125 |
dscl . -create /Users/$user PrimaryGroupID $gid
|
| 126 |
dscl . -create /Users/$user NFSHomeDirectory /Users/$user
|
| 127 |
dscl . -passwd /Users/$user "$passwd"
|
| 128 |
mkdir /Users/$user
|
| 129 |
chown $uid.$gid /Users/$user
|
| 130 |
|
| 131 |
.
|
| 132 |
|
| 133 |
|
| 134 |
pp_platforms="$pp_platforms macos"
|
| 135 |
|
| 136 |
#@ pp_backend_macos_detect(uname_s): return true if matches uname on macos
|
| 137 |
pp_backend_macos_detect () {
|
| 138 |
[ x"$1" = x"Darwin" ]
|
| 139 |
}
|
| 140 |
|
| 141 |
#@ pp_backend_macos_init(): initialises platform variables for macos
|
| 142 |
pp_backend_macos_init () {
|
| 143 |
pp_macos_default_bundle_id_prefix="com.quest.rc."
|
| 144 |
pp_macos_bundle_id=
|
| 145 |
pp_macos_bundle_vendor=
|
| 146 |
pp_macos_bundle_version=
|
| 147 |
pp_macos_bundle_info_string=
|
| 148 |
pp_macos_prog_packagemaker=/Developer/usr/bin/packagemaker
|
| 149 |
pp_macos_pkg_domain=anywhere
|
| 150 |
pp_macos_pkg_extra_flags=
|
| 151 |
}
|
| 152 |
|
| 153 |
#@ pp_macos_plist(cmds...): emits plist xml fragments
|
| 154 |
pp_macos_plist () {
|
| 155 |
typeset in
|
| 156 |
in=""
|
| 157 |
while test $# -gt 0; do
|
| 158 |
case "$1" in
|
| 159 |
|
| 160 |
start-plist) cat <<-.; in=" "; shift ;;
|
| 161 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 162 |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
|
| 163 |
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
| 164 |
<plist version="1.0">
|
| 165 |
.
|
| 166 |
end-plist) echo "</plist>"; in=; shift;;
|
| 167 |
|
| 168 |
'[') echo "$in<array>"; in="$in "; shift;;
|
| 169 |
']') echo "$in</array>"; in="${in# }"; shift;;
|
| 170 |
'{') echo "$in<dict>"; in="$in "; shift;;
|
| 171 |
'}') echo "$in</dict>"; in="${in# }"; shift;;
|
| 172 |
key) shift; echo "$in<key>$1</key>"; shift;;
|
| 173 |
string) shift;
|
| 174 |
echo "$1" | sed -e 's/&/&/g;s/</\</g;s/>/\>/g;' \
|
| 175 |
-e 's/^/'"$in"'<string>/;s/$/<\/string>/';
|
| 176 |
shift;;
|
| 177 |
true) echo "$in<true />"; shift;;
|
| 178 |
false) echo "$in<false />"; shift;;
|
| 179 |
real) shift; echo "$in<real>$1</real>"; shift;;
|
| 180 |
integer) shift; echo "$in<integer>$1</integer>"; shift;;
|
| 181 |
date) shift; echo "$in<date>$1</date>"; shift;; # ISO 8601 format
|
| 182 |
data) shift; echo "$in<data>$1</data>"; shift;; # base64 encoded
|
| 183 |
*) pp_error "pp_macos_plist: bad argument '$1'"; shift;;
|
| 184 |
esac
|
| 185 |
done
|
| 186 |
}
|
| 187 |
|
| 188 |
#@ pp_macos_rewrite_cpio (filelists): filters a cpio stream changing uid/gid
|
| 189 |
pp_macos_rewrite_cpio () {
|
| 190 |
typeset script
|
| 191 |
script=$pp_wrkdir/cpio-rewrite.pl
|
| 192 |
# rely on the fact that OS X comes with perl. It is a little easier to
|
| 193 |
# re-write a binary stream with perl than it is with posix :)
|
| 194 |
#
|
| 195 |
# A CPIO header block has octal fields at the following offset/lengths:
|
| 196 |
# 0 6 magic
|
| 197 |
# 6 6 dev
|
| 198 |
# 12 6 ino
|
| 199 |
# 18 6 mode
|
| 200 |
# 24 6 uid
|
| 201 |
# 30 6 gid
|
| 202 |
# 36 6 nlink
|
| 203 |
# 42 6 rdev
|
| 204 |
# 48 11 mtime
|
| 205 |
# 59 6 namesize
|
| 206 |
# 65 11 filesize
|
| 207 |
# 76 --
|
| 208 |
cat <<-'.' >$script
|
| 209 |
while (<DATA>) {
|
| 210 |
my ($type,$mode,$uid,$gid,$flags,$name) =
|
| 211 |
m/^(.) (\d+) (\S+) (\S+) (\S+) (.*)/;
|
| 212 |
$uid = 0 if $uid eq "-";
|
| 213 |
$gid = 0 if $gid eq "-";
|
| 214 |
if ($uid ne "=" and $uid =~ m/\D/) {
|
| 215 |
my @pw = getpwnam($uid) or die "bad username '$uid'";
|
| 216 |
$uid = $pw[2];
|
| 217 |
}
|
| 218 |
if ($gid ne "=" and $gid =~ m/\D/) {
|
| 219 |
my @gr = getgrnam($gid) or die "bad group '$gid'";
|
| 220 |
$gid = $gr[2];
|
| 221 |
}
|
| 222 |
$name = ".".$name."\0";
|
| 223 |
$ok{$name} = 1;
|
| 224 |
$uid{$name} = sprintf("%06o",int($uid)) unless $uid eq "=";
|
| 225 |
$gid{$name} = sprintf("%06o",int($gid)) unless $gid eq "=";
|
| 226 |
$mode{$name} = sprintf("%06o",oct($mode)) unless $mode eq "=";
|
| 227 |
}
|
| 228 |
$ok{"TRAILER!!!\0"} = 1;
|
| 229 |
while (!eof STDIN) {
|
| 230 |
read STDIN, $header, 76;
|
| 231 |
die "bad magic" unless $header =~ m/^070707/;
|
| 232 |
$namesize = oct(substr($header,59,6));
|
| 233 |
$filesize = oct(substr($header,65,11));
|
| 234 |
read STDIN, $name, $namesize;
|
| 235 |
# convert uid and gid to 0
|
| 236 |
substr($header, 24, 6) = $uid{$name} if defined($uid{$name});
|
| 237 |
substr($header, 30, 6) = $gid{$name} if defined($gid{$name});
|
| 238 |
substr($header, 18, 6) = $mode{$name} if defined($mode{$name});
|
| 239 |
print ($header, $name) if $ok{$name};
|
| 240 |
# copy-through the file data
|
| 241 |
while ($filesize > 0) {
|
| 242 |
my $seg = 8192;
|
| 243 |
$seg = $filesize if $filesize < $seg;
|
| 244 |
undef $data;
|
| 245 |
read STDIN, $data, $seg;
|
| 246 |
print $data if $ok{$name};
|
| 247 |
$filesize -= $seg;
|
| 248 |
}
|
| 249 |
}
|
| 250 |
exit(0);
|
| 251 |
__DATA__
|
| 252 |
.
|
| 253 |
# Append to the script the %files data
|
| 254 |
cat "$@" </dev/null >> $script
|
| 255 |
/usr/bin/perl $script || pp_error "pp_macos_rewrite_cpio error";
|
| 256 |
}
|
| 257 |
|
| 258 |
#@ pp_rpm_files_bom() < %files: convert file list into input for mkbom
|
| 259 |
pp_macos_files_bom () {
|
| 260 |
typeset _l t m o g f p st owner
|
| 261 |
while read t m o g f p st; do
|
| 262 |
# make sure that $m is padded up to 4 digits long
|
| 263 |
case "$m" in
|
| 264 |
?) m="000$m";;
|
| 265 |
??) m="00$m";;
|
| 266 |
???) m="0$m";;
|
| 267 |
?????*) pp_fatal "pp_macos_writebom: mode '$m' too long";;
|
| 268 |
esac
|
| 269 |
|
| 270 |
# convert owner,group into owner/group in octal
|
| 271 |
case $o in -) o=0;; esac
|
| 272 |
case $g in -) g=0;; esac
|
| 273 |
owner=`pp_d2o $o`/`pp_d2o $g`
|
| 274 |
|
| 275 |
case $t in
|
| 276 |
f)
|
| 277 |
echo ".$p 10$m $owner `
|
| 278 |
/usr/bin/cksum < "${pp_destdir}$p" |
|
| 279 |
awk '{print $2 " " $1}'`";;
|
| 280 |
d)
|
| 281 |
echo ".${p%/} 4$m $owner";;
|
| 282 |
s)
|
| 283 |
rl=`/usr/bin/readlink "${pp_destdir}$p"`
|
| 284 |
test x"$rl" = x"$st" ||
|
| 285 |
pp_error "symlink mismatch $rl != $st"
|
| 286 |
echo ".$p 12$m $owner `
|
| 287 |
/usr/bin/readlink -n "${pp_destdir}$p" |
|
| 288 |
/usr/bin/cksum |
|
| 289 |
awk '{print $2 " " $1}'` $st";;
|
| 290 |
esac
|
| 291 |
done
|
| 292 |
}
|
| 293 |
|
| 294 |
#@ pp_macos_bom_fix_parents ($bomsrc) : inserts missing parents into bom src
|
| 295 |
pp_macos_bom_fix_parents () {
|
| 296 |
perl -pe '
|
| 297 |
sub dirname { my $d=shift; $d=~s,/[^/]*$,,; $d; }
|
| 298 |
sub chk { my $d=shift;
|
| 299 |
&chk(&dirname($d)) if $d =~ m,/,;
|
| 300 |
unless ($seen{$d}++) {
|
| 301 |
print "$d\t40755\t0/0\n";
|
| 302 |
}
|
| 303 |
}
|
| 304 |
m/^\S+/;
|
| 305 |
&chk(&dirname($&));'
|
| 306 |
}
|
| 307 |
|
| 308 |
#pp_macos_files_size() < %files: compute the occupation size in kB
|
| 309 |
# Note that each installed file (and directory) has its size rounded up to 4k
|
| 310 |
pp_macos_files_size () {
|
| 311 |
typeset _l t m o g f p st owner
|
| 312 |
while read t m o g f p st; do
|
| 313 |
case $t in
|
| 314 |
f) wc -c < "${pp_destdir}$p";;
|
| 315 |
s) echo 4095;;
|
| 316 |
d) ;; # always seems to be zero
|
| 317 |
esac
|
| 318 |
done | awk '{n+=1+int($1/4096)} END {print n*4}'
|
| 319 |
}
|
| 320 |
|
| 321 |
#@ pp_o2d($oct): prints the decimal form of octal number $oct to stdout
|
| 322 |
pp_o2d () {
|
| 323 |
awk 'BEGIN { x=0; '`echo "$1" |
|
| 324 |
sed -e 's/./x=x*8+&;/g'`'print x;}' </dev/null
|
| 325 |
}
|
| 326 |
#@ pp_d2o($dec): prints the octal form of decimal expression $dec to stdout
|
| 327 |
pp_d2o () {
|
| 328 |
case "$1" in
|
| 329 |
[0-7]) echo $1;;
|
| 330 |
*) awk 'BEGIN { printf("%o\n", 0+('"$1"'));}' < /dev/null;;
|
| 331 |
esac
|
| 332 |
}
|
| 333 |
|
| 334 |
#@ pp_macos_mkbom(bomls output.bom): build a bom file from a bomls
|
| 335 |
pp_macos_mkbom () {
|
| 336 |
#/usr/bin/mkbom -i $1 $2
|
| 337 |
typeset path mode ugid size cksum linkpath
|
| 338 |
typeset bomstage
|
| 339 |
|
| 340 |
# Use mkbom if it understands -i (avoids a copy)
|
| 341 |
if /usr/bin/mkbom -i /dev/null "$2" 2>/dev/null; then
|
| 342 |
rm -f "$2"
|
| 343 |
/usr/bin/mkbom -i "$1" "$2"
|
| 344 |
return
|
| 345 |
fi
|
| 346 |
|
| 347 |
# On 10.4 we have this nonsense.
|
| 348 |
pp_warn "mkbom workaround: copying source files to staging area"
|
| 349 |
|
| 350 |
bomstage=$pp_wrkdir/bom_stage
|
| 351 |
while IFS=' ' read path mode ugid size cksumi linkpath; do
|
| 352 |
if test -h "$pp_destdir/$path"; then
|
| 353 |
/bin/ln -s "$linkpath" "$bomstage/$path"
|
| 354 |
else
|
| 355 |
if test -d "$pp_destdir/$path"; then
|
| 356 |
/bin/mkdir -p "$bomstage/$path"
|
| 357 |
else
|
| 358 |
/bin/cp "$pp_destdir/$path" "$bomstage/$path"
|
| 359 |
fi
|
| 360 |
/bin/chmod $mode "$bomstage/$path"
|
| 361 |
/usr/sbin/chown `echo $ugid| tr / :` "$bomstage/$path"
|
| 362 |
fi
|
| 363 |
done <"$1"
|
| 364 |
(cd $bomstage && mkbom . $pp_wrkdir/bom_stage.bom) ||
|
| 365 |
pp_error "mkbom failed"
|
| 366 |
mv $pp_wrkdir/bom_stage.bom "$2"
|
| 367 |
}
|
| 368 |
|
| 369 |
#@ pp_backend_macos(): processes output files to generate a package files
|
| 370 |
pp_backend_macos () {
|
| 371 |
typeset dmgdir pkgdir Contents Resources lprojdir
|
| 372 |
typeset Info_plist Description_plist
|
| 373 |
typeset bundle_vendor bundle_version size
|
| 374 |
|
| 375 |
bundle_vendor=${pp_macos_bundle_vendor:-"Quest Software, Inc."}
|
| 376 |
|
| 377 |
if test -z "$pp_macos_bundle_version"; then
|
| 378 |
bundle_version=`echo "$version.0.0.0" | sed -n -e 's/[^0-9.]//g' \
|
| 379 |
-e 's/^\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/p'`
|
| 380 |
if test x"$bundle_version" != x"$version"; then
|
| 381 |
pp_warn "converted version from '$version' to '$bundle_version'"
|
| 382 |
fi
|
| 383 |
else
|
| 384 |
bundle_version="$pp_macos_bundle_version"
|
| 385 |
fi
|
| 386 |
|
| 387 |
# build the package layout
|
| 388 |
dmgdir=$pp_wrkdir/$name-Installer
|
| 389 |
pkgdir=$dmgdir/$name-$version.pkg
|
| 390 |
Contents=$pkgdir/Contents
|
| 391 |
Resources=$Contents/Resources
|
| 392 |
lprojdir=$Resources/en.lproj
|
| 393 |
mkdir $dmgdir $pkgdir $Contents $Resources $lprojdir ||
|
| 394 |
pp_fatal "Can't make package temporary directories"
|
| 395 |
|
| 396 |
echo major: 1 > $Resources/package_version
|
| 397 |
echo minor: 0 >> $Resources/package_version
|
| 398 |
|
| 399 |
# compute the installed size
|
| 400 |
size=`cat $pp_wrkdir/%files.* | pp_macos_files_size`
|
| 401 |
|
| 402 |
#-- Create Info.plist
|
| 403 |
Info_plist=$Contents/Info.plist
|
| 404 |
pp_macos_plist \
|
| 405 |
start-plist \{ \
|
| 406 |
key CFBundleGetInfoString string \
|
| 407 |
"${pp_macos_bundle_info_string:-$version $bundle_vendor}" \
|
| 408 |
key CFBundleIdentifier string \
|
| 409 |
"${pp_macos_bundle_id:-$pp_macos_default_bundle_id_prefix$name}" \
|
| 410 |
key CFBundleShortVersionString string "$bundle_version" \
|
| 411 |
key IFMajorVersion integer 1 \
|
| 412 |
key IFMinorVersion integer 2 \
|
| 413 |
key IFPkgFlagAllowBackRev false \
|
| 414 |
key IFPkgFlagAuthorizationAction string "AdminAuthorization" \
|
| 415 |
key IFPkgFlagDefaultLocation string "/" \
|
| 416 |
key IFPkgFlagFollowLinks true \
|
| 417 |
key IFPkgFlagInstallFat false \
|
| 418 |
key IFPkgFlagInstalledSize integer $size \
|
| 419 |
key IFPkgFlagIsRequired false \
|
| 420 |
key IFPkgFlagOverwritePermissions false \
|
| 421 |
key IFPkgFlagRelocatable false \
|
| 422 |
key IFPkgFlagRestartAction string "NoRestart" \
|
| 423 |
key IFPkgFlagRootVolumeOnly false \
|
| 424 |
key IFPkgFlagUpdateInstalledLanguages false \
|
| 425 |
key IFPkgFormatVersion real 0.10000000149011612 > $Info_plist
|
| 426 |
|
| 427 |
# insert requirements(VAS)
|
| 428 |
pp_macos_plist \
|
| 429 |
key IFRequirementDicts \[ \
|
| 430 |
\{ \
|
| 431 |
key Level string "requires" \
|
| 432 |
key SpecArgument string "/opt/quest/lib/libvas.4.dylib" \
|
| 433 |
key SpecType string "file" \
|
| 434 |
key TestObject true \
|
| 435 |
key TestOperator string "eq" \
|
| 436 |
\} \
|
| 437 |
\] >> $Info_plist
|
| 438 |
|
| 439 |
# finish Info.plist
|
| 440 |
pp_macos_plist \} end-plist >> $Info_plist
|
| 441 |
|
| 442 |
# write en.lproj/Description.plist
|
| 443 |
Description_plist=$lprojdir/Description.plist
|
| 444 |
pp_macos_plist \
|
| 445 |
start-plist \{ \
|
| 446 |
key IFPkgDescriptionDescription string "$description" \
|
| 447 |
key IFPkgDescriptionTitle string "$name $version" \
|
| 448 |
\} end-plist > $Description_plist
|
| 449 |
|
| 450 |
# write Resources/postinstall
|
| 451 |
for cmp in $pp_components; do
|
| 452 |
if test -s $pp_wrkdir/%post.$cmp; then
|
| 453 |
if test ! -s $Resources/postinstall; then
|
| 454 |
echo "#!/bin/sh" > $Resources/postinstall
|
| 455 |
chmod +x $Resources/postinstall
|
| 456 |
fi
|
| 457 |
cat $pp_wrkdir/%post.$cmp >> $Resources/postinstall
|
| 458 |
echo : >> $Resources/postinstall
|
| 459 |
fi
|
| 460 |
done
|
| 461 |
|
| 462 |
# Warn that %preun scripts are simply ignored.
|
| 463 |
# However, write out a 'preuninstall' script, in case one day
|
| 464 |
# it is supported.
|
| 465 |
for cmp in $pp_components; do
|
| 466 |
if test -s $pp_wrkdir/%preun.$cmp; then
|
| 467 |
pp_warn "%preun scripts are ignored on OSX"
|
| 468 |
if test ! -s $Resources/preuninstall; then
|
| 469 |
echo "#!/bin/sh" > $Resources/preuninstall
|
| 470 |
chmod +x $Resources/preuninstall
|
| 471 |
fi
|
| 472 |
cat $pp_wrkdir/%preun.$cmp >> $Resources/preuninstall
|
| 473 |
echo : >> $Resources/preuninstall
|
| 474 |
fi
|
| 475 |
done
|
| 476 |
|
| 477 |
# Create the bill-of-materials (Archive.bom)
|
| 478 |
cat $pp_wrkdir/%files.* | pp_macos_files_bom | sort |
|
| 479 |
pp_macos_bom_fix_parents > $pp_wrkdir/tmp.bomls
|
| 480 |
|
| 481 |
pp_macos_mkbom $pp_wrkdir/tmp.bomls $Contents/Archive.bom
|
| 482 |
|
| 483 |
# Create the cpio archive (Archive.pax.gz)
|
| 484 |
# On 10.5, we used "-f -" to write explicitly to stdout
|
| 485 |
(cd $pp_destdir && /bin/pax -w .) |
|
| 486 |
gzip -9 -c > $Contents/Archive.pax.gz
|
| 487 |
|
| 488 |
# create a package using packagemaker
|
| 489 |
# pp_verbose $pp_macos_prog_packagemaker \
|
| 490 |
# --root $pp_destdir \
|
| 491 |
# --verbose \
|
| 492 |
# --info $Info_plist \
|
| 493 |
# --title "$name-$version" \
|
| 494 |
# --out $dmgdir/$name-$version.pkg \
|
| 495 |
# --scripts $scriptdir \
|
| 496 |
# --domain $pp_macos_pkg_domain \
|
| 497 |
# --target 10.3 \
|
| 498 |
# $pp_macos_pkg_extra_flags \
|
| 499 |
# || pp_error "packagemaker failed"
|
| 500 |
|
| 501 |
#-- convert the pkg file into a disk image (dmg file)
|
| 502 |
if [ -d $dmgdir/$name-$version.pkg ]; then
|
| 503 |
dmg=`pp_backend_macos_names`
|
| 504 |
{ pp_verbose hdiutil create \
|
| 505 |
-srcfolder $dmgdir \
|
| 506 |
-mode 555 \
|
| 507 |
$pp_wrkdir/$dmg &&
|
| 508 |
pp_verbose hdiutil internet-enable -yes $pp_wrkdir/$dmg; } ||
|
| 509 |
pp_error "unable to build disk image"
|
| 510 |
else
|
| 511 |
pp_error "$dmgdir/$name-$version.pkg: not created"
|
| 512 |
fi
|
| 513 |
}
|
| 514 |
# -uid 99 -gid 99 -copyuid 99
|
| 515 |
|
| 516 |
#@ pp_backend_macos_cleanup(): removes any files created outside $pp_wrkdir
|
| 517 |
pp_backend_macos_cleanup () {
|
| 518 |
:
|
| 519 |
}
|
| 520 |
|
| 521 |
#@ pp_backend_macos_names(): prints the paths to package files
|
| 522 |
# each path should start with $name-$version
|
| 523 |
# the package must be relative to the $pp_wrkdir directory
|
| 524 |
pp_backend_macos_names () {
|
| 525 |
echo ${name}-${version}.dmg
|
| 526 |
}
|
| 527 |
|
| 528 |
#@ pp_backend_macos_install_script(component): generate helper install script
|
| 529 |
pp_backend_macos_install_script () {
|
| 530 |
echo '#!/bin/sh'
|
| 531 |
typeset pkgname platform
|
| 532 |
|
| 533 |
pkgname="`pp_backend_macos_names`"
|
| 534 |
platform="`pp_backend_macos_probe`"
|
| 535 |
pp_install_script_common
|
| 536 |
|
| 537 |
cat <<.
|
| 538 |
test \$# -eq 0 && usage
|
| 539 |
op="\$1"; shift
|
| 540 |
|
| 541 |
case "\$op" in
|
| 542 |
list-components)
|
| 543 |
test \$# -eq 0 || usage \$op
|
| 544 |
echo "$pp_components"
|
| 545 |
;;
|
| 546 |
list-services)
|
| 547 |
test \$# -eq 0 || usage \$op
|
| 548 |
echo "$pp_services"
|
| 549 |
;;
|
| 550 |
list-files)
|
| 551 |
test \$# -ge 1 || usage \$op
|
| 552 |
echo \${PP_PKGDESTDIR:-.}/"$pkgname"
|
| 553 |
;;
|
| 554 |
install)
|
| 555 |
test \$# -ge 1 || usage \$op
|
| 556 |
vol=/Volumes/pp\$\$
|
| 557 |
pkg=\$vol/${name}-${version}.pkg
|
| 558 |
hdiutil attach -readonly -mountpoint \$vol \
|
| 559 |
\${PP_PKGDESTDIR:-.}/"$pkgname"
|
| 560 |
trap "hdiutil detach \$vol" 0
|
| 561 |
installer -pkginfo -pkg \$pkg
|
| 562 |
installer -verbose -pkg \$pkg -target /
|
| 563 |
;;
|
| 564 |
uninstall)
|
| 565 |
test \$# -ge 1 || usage \$op
|
| 566 |
# XXX
|
| 567 |
echo "Uninstall not implemented" >&2
|
| 568 |
exit 1;;
|
| 569 |
start|stop)
|
| 570 |
test \$# -ge 1 || usage \$op
|
| 571 |
ec=0
|
| 572 |
for svc
|
| 573 |
do
|
| 574 |
# XXX
|
| 575 |
echo "\${op} not implemented" >&2
|
| 576 |
ec=1
|
| 577 |
done
|
| 578 |
exit \$ec
|
| 579 |
;;
|
| 580 |
print-platform)
|
| 581 |
echo "$platform"
|
| 582 |
;;
|
| 583 |
*)
|
| 584 |
usage;;
|
| 585 |
esac
|
| 586 |
.
|
| 587 |
}
|
| 588 |
|
| 589 |
#@ pp_backend_macos_init_svc_vars(): initialise service vars
|
| 590 |
pp_backend_macos_init_svc_vars () {
|
| 591 |
:
|
| 592 |
}
|
| 593 |
|
| 594 |
#@ pp_backend_macos_probe(): output local platform's short name
|
| 595 |
pp_backend_macos_probe () {
|
| 596 |
typeset name vers arch
|
| 597 |
case `sw_vers -productName` in
|
| 598 |
"Mac OS X") name="macos";;
|
| 599 |
*) name="unknown";;
|
| 600 |
esac
|
| 601 |
vers=`sw_vers -productVersion | sed -e 's/^\([^.]*\)\.\([^.]*\).*/\1\2/'`
|
| 602 |
arch=`arch`
|
| 603 |
echo "$name$vers-$arch"
|
| 604 |
}
|
| 605 |
|
| 606 |
#@ pp_backend_macos_vas_platforms(): print the VAS platform identifiers
|
| 607 |
pp_backend_macos_vas_platforms () {
|
| 608 |
echo "osx" # XXX non-really sure what they do.. it should be "macos"
|
| 609 |
}
|