Opened 21 years ago
Closed 15 years ago
#1068 closed enhancement (fixed)
Pre/Post-install and Post-removal scripts
Reported by: | jdputsch@… | Owned by: | macports-tickets@… |
---|---|---|---|
Priority: | Normal | Milestone: | MacPorts 1.9.0 |
Component: | base | Version: | |
Keywords: | Cc: | ||
Port: |
Description (last modified by jmpalacios (Juan Manuel Palacios))
It seems to me that Darwin Ports needs to have a script that runs after the install action. Let me explain why:
Take, for example, a port that installs info files into /opt/local/share/info using the "install-info" script. This script copies the info files to destination AND modifies the info directory file (/opt/ local/share/info/dir). Now the normal flow goes something like this:
port build port destroot # info files goto ..../work/destroot/opt/local/share/info
# and the .../work/destroot/opt/local/share/info/dir file # is modified to add the entries.
port install
After the "port install" step the "dir" file containing ONLY entries for the newly built/installed port is copied to /opt/local/share/info/dir. This wipes out any entries that may have previously been there. I don't think this is the behavior we want.
In addition if "port package" is run during this process a package is built that will install a "dir" file that only knows about the info files for that package. I don't believe this is proper behavior either.
I believe in both cases the proper thing to have happen is to have a post install action take place that makes sure the proper "dir" file is in place. If packages were never built this could be taken care of entirely in the Portfile. Unfortunately, I feel packages should do the right thing too and only add their info files to /opt/local/share/info/dir and not replace that file with their idea of what that file should be. I don't see any way to accomplish that without taking advantage of the "postinstall" or "postflight" scripts that Apple allows packages to have. See
http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/
Concepts/sd_pre_post_processing.html for more information.
In fact, I'd like to propose two files be added to ports directories: "files/preinstall" and "files/ postinstall". These files, if present, are run just before the "port install" action and just after it respectively. When building packages, these scripts would be put into the proper place in the package so they can achieve the same results as they would if run via the "port ..." command.
Basically, the port directory with these files would look like this:
Portfile files/postinstall files/preinstall
I believe that, when combined with actions such as post-destroot, these scripts would be allow ports to be constructed that do the right thing regardless of their installation order AND build packages that do the right thing regardless of their installation order.
I realize I've stressed the "info" files here, they are a concrete example of why I feel this feature needs to be added and supported. I'm sure others will be found.
I also realized that a "postremove" (and maybe) a "preremove" script are needed to so packages clean up after themselves when removed. Sticking with the earlier "info" example ${prefix}/share/ info/dir is edited by the "postinstall" script. When a package is removed, those edits need to be undone.
It was very easy to add a "postremove" script to the package DarwinPorts builds and modify the uninstall.tcl script used by the Uninstaller.app. I don't know how to do the same thing with the current receipts system for "port install"/"port remove". I know I can put tcl code to be executed post-remove in there, but I think it's better to have one source for these actions and any package built by DarwinPorts needs to have scripts since they become decoupled from the ports system itself.
Attachments (4)
Change History (10)
Changed 21 years ago by jdputsch@…
Attachment: | dports.patch added |
---|
Changed 21 years ago by jdputsch@…
Attachment: | uninst.patch added |
---|
Sample patch to Uninstall.app uninstall.tcl script
comment:1 Changed 21 years ago by jdputsch@…
attachments.isobsolete: | 0 → 1 |
---|
Changed 21 years ago by jdputsch@…
Attachment: | dports.2.patch added |
---|
Sample implementation patch to base/...
comment:2 Changed 21 years ago by jdputsch@…
attachments.isobsolete: | 0 → 1 |
---|
Changed 21 years ago by jdputsch@…
Attachment: | dports.3.patch added |
---|
Sample implementation patch to base/...
comment:3 Changed 17 years ago by nox@…
Milestone: | → MacPorts base enhancements |
---|---|
Priority: | Expected → Normal |
Version: | 1.0 |
comment:4 Changed 17 years ago by jmpalacios (Juan Manuel Palacios)
Description: | modified (diff) |
---|
This ticket is sorely out of date and many thing have changed since, specially with respect to the info files which we've been pruning from our destroots for a long while already. I'm nevertheless going to leave the ticket open, as it does contain some interesting suggestions for pre/post-installation/uninstallation scripts.
-jmpp
comment:5 Changed 17 years ago by Damien.Pollet@…
Why prune them? are you converting the documents to some other format?
comment:6 Changed 15 years ago by jmroot (Joshua Root)
Milestone: | MacPorts Future → MacPorts 1.9.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Sample implementation patch to base/...