How to build a pkg for partial patches with pkgbuild?

106 Views Asked by At

I tried making an installer (*.pkg) that installs documents and files in the desired path through pkgbuild, and it works.

But in the same way, I made an installer for patching (adding or overwriting some files) via pkgbuild, but it works differently than expected.

Installing a patch file removes all existing source paths and files and installs only with the patch file configuration.

What I want to do is create an installer that will add or overwrite some files while preserving the existing source paths and files.

Take a look at the example below. Assume that My Project Folder is installed in the Library folder.

[Configure already installed directories and files]

my project folder
|__ my_img.png
|__ my_script_folder
    |__ my_script1.js
[Patch *.pkg installation file]
my project folder
|__ my_script_folder
    |__ my_script2.js
[Set directory and file after running patch *pkg]
|__ my_img.png (removed)
|__ my_script_folder
    |__ my_script1.js (removed)
    |__ my_script2.js

I want to make an installer that adds or overwrites some files while preserving the existing source paths and files, can I implement this with pkgbuild? Smart people please help.

1

There are 1 best solutions below

0
SammyIO On

Wow, I found the answer.

This has to do with the "--identifier" it generates when building pkg via pkgbuild.

pkg on macOS seems to remove the old install path and do a fresh install by inferring the install path from the identifier, regardless of the program path or name set. So you can build pkg with different --identifiers.

# first identifier pkg
pkgbuild --identifier "com.program.myproject"
# another identifier for patch pkg
pkgbuild --identifier "com.program.myproject.patch"