Skip to content

Commit

Permalink
fsck, fixed the bug that prevented non-admin users from installing Cl…
Browse files Browse the repository at this point in the history
…ickToFlash to their OWN FRIGGIN' HOME DIRECTORY because we have to support 10.4 and because non-admin users can't write to the Receipts directory; fix involves creating TWO packages, one requiring admin privs, one not, and then creating a friggin' METAPKG which chooses which one to use based on whether the user is an admin and whether a receipt already exists, so that a password is required only when ABSOLUTELY needed; the updated script also replaces the bom and pax.gz files in one of the installers with a symbolic links to the respective files of the other installer, so we aren't having users unnecessarily download stuff; FRIGGIN' APPLE FIX YOUR INSTALLER TECHNOLOGY ALREADY, JESUS H. M. CHRIST
  • Loading branch information
Simone Manganelli authored and Simone Manganelli committed Aug 23, 2009
1 parent c73bba6 commit 96f78ed
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 5 deletions.
40 changes: 40 additions & 0 deletions Installer/Info-admin.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>com.github.rentzsch.clicktoflash.admin.pkg</string>
<key>CFBundleShortVersionString</key>
<string>1</string>
<key>IFMajorVersion</key>
<integer>1</integer>
<key>IFMinorVersion</key>
<integer>0</integer>
<key>IFPkgFlagAllowBackRev</key>
<true/>
<key>IFPkgFlagAuthorizationAction</key>
<string>RootAuthorization</string>
<key>IFPkgFlagDefaultLocation</key>
<string>/tmp</string>
<key>IFPkgFlagFollowLinks</key>
<true/>
<key>IFPkgFlagInstallFat</key>
<false/>
<key>IFPkgFlagInstalledSize</key>
<integer>1736</integer>
<key>IFPkgFlagIsRequired</key>
<false/>
<key>IFPkgFlagOverwritePermissions</key>
<false/>
<key>IFPkgFlagRelocatable</key>
<false/>
<key>IFPkgFlagRestartAction</key>
<string>None</string>
<key>IFPkgFlagRootVolumeOnly</key>
<false/>
<key>IFPkgFlagUpdateInstalledLanguages</key>
<false/>
<key>IFPkgFormatVersion</key>
<real>0.1000000014901161</real>
</dict>
</plist>
File renamed without changes.
51 changes: 46 additions & 5 deletions Installer/build_installer_pkg.command
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ fi

MY_INSTALLER_ROOT="$BUILT_PRODUCTS_DIR/ClickToFlash.dst"
BUILT_PLUGIN="$BUILT_PRODUCTS_DIR/ClickToFlash.webplugin"
BUILT_PKG="$BUILT_PRODUCTS_DIR/ClickToFlash.pkg" # Sparkle currently can't handle -$VERSION in .pkg names.
VERSIONED_NAME="ClickToFlash-$PRODUCT_VERSION"
BUILT_ZIP="$BUILT_PRODUCTS_DIR/$VERSIONED_NAME.zip"

Expand All @@ -41,17 +40,59 @@ cp -R "$BUILT_PLUGIN" "$MY_INSTALLER_ROOT"

"$SYSTEM_DEVELOPER_UTILITIES_DIR/PackageMaker.app/Contents/MacOS/PackageMaker" \
--root "$BUILT_PRODUCTS_DIR/ClickToFlash.dst" \
--info Info.plist \
--resources resources \
--info Info-nonadmin.plist \
--scripts scripts \
--target 10.4 \
--version "$PRODUCT_VERSION" \
--verbose \
--out "$BUILT_PKG"
--out "$BUILT_PRODUCTS_DIR/ClickToFlash-nonadmin.pkg"

"$SYSTEM_DEVELOPER_UTILITIES_DIR/PackageMaker.app/Contents/MacOS/PackageMaker" \
--root "$BUILT_PRODUCTS_DIR/ClickToFlash.dst" \
--info Info-admin.plist \
--scripts scripts \
--target 10.4 \
--version "$PRODUCT_VERSION" \
--verbose \
--out "$BUILT_PRODUCTS_DIR/ClickToFlash-admin.pkg"



# go into one of the packages and strip out the contents and symbolic link them to the other
# package so that we keep the file size down, since the only difference is requiring admin auth

cd "$BUILT_PRODUCTS_DIR/ClickToFlash-admin.pkg/Contents"
rm Archive.bom
rm Archive.pax.gz
ln -s ../../ClickToFlash-nonadmin.pkg/Contents/Archive.bom ./
ln -s ../../ClickToFlash-nonadmin.pkg/Contents/Archive.pax.gz ./
cd $SCRIPT_WD



# make the friggin' distribution ourselves since friggin' PackageMaker friggin' doesn't friggin' support this
mkdir "$BUILT_PRODUCTS_DIR/ClickToFlash.mpkg"
mkdir "$BUILT_PRODUCTS_DIR/ClickToFlash.mpkg/Contents"
mkdir "$BUILT_PRODUCTS_DIR/ClickToFlash.mpkg/Contents/Packages/"
mkdir "$BUILT_PRODUCTS_DIR/ClickToFlash.mpkg/Contents/Resources/"
cp -R distribution-mpkg/resources/en.lproj "$BUILT_PRODUCTS_DIR/ClickToFlash.mpkg/Contents/Resources/en.lproj"
cp -R distribution-mpkg/resources/admin_privs_needed.command "$BUILT_PRODUCTS_DIR/ClickToFlash.mpkg/Contents/Resources/admin_privs_needed.command"
cp -R distribution-mpkg/resources/no_admin_privs_needed.command "$BUILT_PRODUCTS_DIR/ClickToFlash.mpkg/Contents/Resources/no_admin_privs_needed.command"
cp distribution-mpkg/distribution.dist "$BUILT_PRODUCTS_DIR/ClickToFlash.mpkg/Contents/distribution.dist"

cp -R "$BUILT_PRODUCTS_DIR/ClickToFlash-nonadmin.pkg" "$BUILT_PRODUCTS_DIR/ClickToFlash.mpkg/Contents/Packages/ClickToFlash-nonadmin.pkg"
cp -R "$BUILT_PRODUCTS_DIR/ClickToFlash-admin.pkg" "$BUILT_PRODUCTS_DIR/ClickToFlash.mpkg/Contents/Packages/ClickToFlash-admin.pkg"


# clean up the non-mpkg pkgs

rm -rf "$BUILT_PRODUCTS_DIR/ClickToFlash-admin.pkg"
rm -rf "$BUILT_PRODUCTS_DIR/ClickToFlash-nonadmin.pkg"


# Stuff it into a .zip.
cd "$BUILT_PRODUCTS_DIR"
zip -r "$VERSIONED_NAME.zip" "ClickToFlash.pkg"
zip -r "$VERSIONED_NAME.zip" "ClickToFlash.mpkg"
cd $SCRIPT_WD

rm -rf "$MY_INSTALLER_ROOT"
84 changes: 84 additions & 0 deletions Installer/distribution-mpkg/distribution.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<installer-script minSpecVersion="1.000000" authoringTool="com.apple.PackageMaker" authoringToolVersion="3.0.3" authoringToolBuild="174">
<title>ClickToFlash</title>
<options customize="never" allow-external-scripts="yes" rootVolumeOnly="false"/>
<installation-check script="pm_install_check();"/>
<volume-check script="pm_volume_check();"/>
<script>function pm_volume_check() {
if(!(my.target.mountpoint == '/')) {
my.result.title = 'Failure';
my.result.message = 'This software can only be installed on the root volume.';
my.result.type = 'Fatal';
return false;
}
return true;
}


function pm_install_check() {
if(!(system.version.ProductVersion >= '10.5.0')) {
my.result.title = 'ClickToFlash requires MacOS X 10.5 Leopard';
my.result.message = 'ClickToFlash cannot be used with the version of Mac OS X installed on your computer.';
my.result.type = 'Fatal';
return false;
}
return true;
}



function pm_clicktoflashadmin_selected() {
result = true;
result = result &amp;&amp; (system.run('admin_privs_needed.command') == true);
return result;
}


function pm_clicktoflashadmin_hidden() {
result = true;
result = result &amp;&amp; (system.run('admin_privs_needed.command') == true);
return result;
}


function pm_clicktoflashadmin_enabled() {
result = true;
result = result &amp;&amp; (system.run('admin_privs_needed.command') == true);
return result;
}


function pm_clicktoflashnonadmin_selected() {
result = true;
result = result &amp;&amp; (system.run('no_admin_privs_needed.command') == true);
return result;
}


function pm_clicktoflashnonadmin_hidden() {
result = true;
result = result &amp;&amp; (system.run('no_admin_privs_needed.command') == true);
return result;
}


function pm_clicktoflashnonadmin_enabled() {
result = true;
result = result &amp;&amp; (system.run('no_admin_privs_needed.command') == true);
return result;
}</script>
<background file="background" alignment="bottomright" scaling="none"/>
<readme file="ReadMe"/>
<choices-outline>
<line choice="clicktoflashadmin"/>
<line choice="clicktoflashnonadmin"/>
</choices-outline>
<choice id="clicktoflashadmin" title="ClickToFlash-admin" selected="pm_clicktoflashadmin_selected()" enabled="pm_clicktoflashadmin_enabled()" visible="!pm_clicktoflashadmin_hidden()">
<pkg-ref id="com.github.rentzsch.clicktoflash.admin.pkg"/>
</choice>
<choice id="clicktoflashnonadmin" title="ClickToFlash-nonadmin" selected="pm_clicktoflashnonadmin_selected()" enabled="pm_clicktoflashnonadmin_enabled()" visible="!pm_clicktoflashnonadmin_hidden()">
<pkg-ref id="com.github.rentzsch.clicktoflash.nonadmin.pkg"/>
</choice>
<pkg-ref id="com.github.rentzsch.clicktoflash.admin.pkg" installKBytes="1736" version="1" auth="Root">file:./Contents/Packages/clicktoflash-admin.pkg</pkg-ref>
<pkg-ref id="com.github.rentzsch.clicktoflash.nonadmin.pkg" installKBytes="1736" version="1">file:./Contents/Packages/clicktoflash-nonadmin.pkg</pkg-ref>
</installer-script>
23 changes: 23 additions & 0 deletions Installer/distribution-mpkg/resources/admin_privs_needed.command
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
cd "`dirname \"$0\"`"
SCRIPT_WD=`pwd`
DIR=/Library/Receipts/clicktoflash-nonadmin.pkg/
GROUPS=`id -Gn $USER`

if [ -d $DIR ]; then
echo "There is a receipt, no admin privs required for installer pkg."
exit 0
fi

if [ "$GROUPS" == "20" ]; then
echo "User has admin privs, no admin privs required for installer pkg."
exit 0
else
if [[ "$GROUPS" =~ " 20 " ]]; then
echo "User has admin privs, no admin privs required for installer pkg."
exit 0
fi
fi

echo "No receipt, no admin privs, installer must ask for admin password."
exit 1
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
cd "`dirname \"$0\"`"
SCRIPT_WD=`pwd`
DIR=/Library/Receipts/clicktoflash-nonadmin.pkg/
GROUPS=`id -Gn $USER`

if [ -d $DIR ]; then
echo "There is a receipt, no admin privs required for installer pkg."
exit 1
fi

if [ "$GROUPS" == "20" ]; then
echo "User has admin privs, no admin privs required for installer pkg."
exit 1
else
if [[ "$GROUPS" =~ " 20 " ]]; then
echo "User has admin privs, no admin privs required for installer pkg."
exit 1
fi
fi

echo "No receipt, no admin privs, installer must ask for admin password."
exit 0
1 change: 1 addition & 0 deletions Installer/scripts/postflight
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
rm -rf "$HOME/Library/Internet Plug-Ins/ClickToFlash.plugin"
rm -rf "$HOME/Library/Internet Plug-Ins/ClickToFlash.webplugin"
mv /tmp/ClickToFlash.webplugin "$HOME/Library/Internet Plug-Ins/"
chown -R $USER "$HOME/Library/Internet Plug-Ins/ClickToFlash.webplugin"
pkgutil --forget com.github.rentzsch.clicktoflash.pkg

exit 0

0 comments on commit 96f78ed

Please sign in to comment.