Git Product home page Git Product logo

package-path's Introduction

package-path

InstallerPane category to query the package path.

This should have been a public API in InstallerPane interface. Since it is not, here is the category to query the package path.

To use, add InstallerPane+VHInstallerPaneMissingMethodAdditions.h and InstallerPane+VHInstallerPaneMissingMethodAdditions.m files to your Installer plug-in project.

This will add 2 new methods to the InstallerPane class:

@interface InstallerPane (VHInstallerPaneMissingMethodAdditions)
- (NSString *)packagePath;
- (NSURL *)packageURL;
@end

and in your InstallerPane subclass file import the header file:

#import "InstallerPane+VHInstallerPaneMissingMethodAdditions.h"

The sample InstallerPluginTest project and InstallerPluginTest package demonstrate the usage. Works on macOS 10.15 Catalina and previous versions as well.

Installer Plugin Test

There a catch though:

On macOS 10.14 or earlier, the package path is queried from the Installer window that is hosting our InstallerPane, so the content view of the InstallerPane should be already added to the window. On macOS 10.15 Catalina, Installer plug-ins are instantiated in the separate process, so the caller need to wait for the response from the main Installer process. This means that the first call to packagePath/packageURL will initiate the query, but will return an empty path until the Installer process responds with the answer.

For that reason, packagePath and packageURL properties are KVO compliant on macOS 10.15 Catalina!

- (void)willEnterPane:(InstallerSectionDirection)dir
{
    // the call will not succeed on Catalina because of request roundtrip to another process
    // and on previous versions, because plug-in view is not yet added to the Installer window
    NSLog(@"****** ---%@", self.packagePath);
}

- (void)didEnterPane:(InstallerSectionDirection)dir
{
    // this call will succeed, because the plug-in view already added to the Installer window
    NSLog(@"****** +++%@", self.packagePath);
}

PACKAGE_PATH for requirement scripts

Discovered that PACKAGE_PATH is not available for the scripts running in the installer requirements validation phase. This code snippet will get it for you...

if [[ "${PACKAGE_PATH}" == "" ]]; then
    PROCESS_PATH=`ps -p $PPID -o comm=`
    if [[ "${PROCESS_PATH}" == */Installer.app/Contents/MacOS/Installer ]];
    then
        PACKAGE_PATH=`sed -n -e "s/^.*Installer\[${PPID}\]: Opened from: //p" /var/log/install.log | tail -n1`
    else
        PACKAGE_PATH=`lsof -Fn -p $PPID | grep "n.*[.]pkg" | tail -n1 | cut -b 2-`
    fi
fi

package-path's People

Contributors

vachooho avatar

Stargazers

triste24 avatar Hristo Hristov avatar Hristo Hristov avatar  avatar Robert Welz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.