From 96f78edb130f0b8d10149b9d0c053c9c6c9e5b43 Mon Sep 17 00:00:00 2001 From: Simone Manganelli Date: Sat, 22 Aug 2009 17:39:20 -0700 Subject: [PATCH] fsck, fixed the bug that prevented non-admin users from installing ClickToFlash 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 --- Installer/Info-admin.plist | 40 +++++++++ Installer/{Info.plist => Info-nonadmin.plist} | 0 Installer/build_installer_pkg.command | 51 +++++++++-- Installer/distribution-mpkg/distribution.dist | 84 ++++++++++++++++++ .../resources/admin_privs_needed.command | 23 +++++ .../resources/en.lproj/ReadMe.rtf | 0 .../resources/en.lproj/background.tiff | Bin .../resources/no_admin_privs_needed.command | 23 +++++ Installer/scripts/postflight | 1 + 9 files changed, 217 insertions(+), 5 deletions(-) create mode 100644 Installer/Info-admin.plist rename Installer/{Info.plist => Info-nonadmin.plist} (100%) create mode 100644 Installer/distribution-mpkg/distribution.dist create mode 100755 Installer/distribution-mpkg/resources/admin_privs_needed.command rename Installer/{ => distribution-mpkg}/resources/en.lproj/ReadMe.rtf (100%) rename Installer/{ => distribution-mpkg}/resources/en.lproj/background.tiff (100%) create mode 100755 Installer/distribution-mpkg/resources/no_admin_privs_needed.command diff --git a/Installer/Info-admin.plist b/Installer/Info-admin.plist new file mode 100644 index 00000000..8b34a21b --- /dev/null +++ b/Installer/Info-admin.plist @@ -0,0 +1,40 @@ + + + + + CFBundleIdentifier + com.github.rentzsch.clicktoflash.admin.pkg + CFBundleShortVersionString + 1 + IFMajorVersion + 1 + IFMinorVersion + 0 + IFPkgFlagAllowBackRev + + IFPkgFlagAuthorizationAction + RootAuthorization + IFPkgFlagDefaultLocation + /tmp + IFPkgFlagFollowLinks + + IFPkgFlagInstallFat + + IFPkgFlagInstalledSize + 1736 + IFPkgFlagIsRequired + + IFPkgFlagOverwritePermissions + + IFPkgFlagRelocatable + + IFPkgFlagRestartAction + None + IFPkgFlagRootVolumeOnly + + IFPkgFlagUpdateInstalledLanguages + + IFPkgFormatVersion + 0.1000000014901161 + + diff --git a/Installer/Info.plist b/Installer/Info-nonadmin.plist similarity index 100% rename from Installer/Info.plist rename to Installer/Info-nonadmin.plist diff --git a/Installer/build_installer_pkg.command b/Installer/build_installer_pkg.command index 18eb160c..b5e7c4b5 100755 --- a/Installer/build_installer_pkg.command +++ b/Installer/build_installer_pkg.command @@ -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" @@ -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" diff --git a/Installer/distribution-mpkg/distribution.dist b/Installer/distribution-mpkg/distribution.dist new file mode 100644 index 00000000..42d19c4c --- /dev/null +++ b/Installer/distribution-mpkg/distribution.dist @@ -0,0 +1,84 @@ + + + ClickToFlash + + + + + + + + + + + + + + + + + file:./Contents/Packages/clicktoflash-admin.pkg + file:./Contents/Packages/clicktoflash-nonadmin.pkg + \ No newline at end of file diff --git a/Installer/distribution-mpkg/resources/admin_privs_needed.command b/Installer/distribution-mpkg/resources/admin_privs_needed.command new file mode 100755 index 00000000..e4f9210a --- /dev/null +++ b/Installer/distribution-mpkg/resources/admin_privs_needed.command @@ -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 \ No newline at end of file diff --git a/Installer/resources/en.lproj/ReadMe.rtf b/Installer/distribution-mpkg/resources/en.lproj/ReadMe.rtf similarity index 100% rename from Installer/resources/en.lproj/ReadMe.rtf rename to Installer/distribution-mpkg/resources/en.lproj/ReadMe.rtf diff --git a/Installer/resources/en.lproj/background.tiff b/Installer/distribution-mpkg/resources/en.lproj/background.tiff similarity index 100% rename from Installer/resources/en.lproj/background.tiff rename to Installer/distribution-mpkg/resources/en.lproj/background.tiff diff --git a/Installer/distribution-mpkg/resources/no_admin_privs_needed.command b/Installer/distribution-mpkg/resources/no_admin_privs_needed.command new file mode 100755 index 00000000..164ad647 --- /dev/null +++ b/Installer/distribution-mpkg/resources/no_admin_privs_needed.command @@ -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 \ No newline at end of file diff --git a/Installer/scripts/postflight b/Installer/scripts/postflight index 4c106538..03aa38e5 100755 --- a/Installer/scripts/postflight +++ b/Installer/scripts/postflight @@ -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 \ No newline at end of file