Re: [pacman-dev] How does pacman interact with a package's INSTALL script
lordbad wrote:
In the documentation I have read the following:
There are also install files. This PKGBUILD specifies 'foo.install' as the package's install file. Here is an example install file:
post_install() { /bin/true }
post_upgrade() { /bin/true }
pre_remove() { /bin/true }
op=$1 shift
$op "$@"
Here are the function explainations :
* post_install : this script is run right after files are installed, it takes one argument : o the package version * post_upgrade : this script is run after all files have been upgraded, it takes two arguments : o the new package version o the old package version * pre_remove : this script is run right before files are removed (stop a daemon for example) and takes one argument : o the package version
The three lines at the bottom are needed in every install file so that they run properly.
But I do not understand how does pacman handle these scripts. Does it source the scripts first and then call the shell functions defined in them with some C function like "system" for example? But if it does so why are the last 3 lines needed - I see little if any need for them. So if anyone can give me some hints on the subject and maybe even mention which of pacman's source files implements this functionality I'd be very grateful. Thanks in advance for your help.
Best Regards, Bozhidar
_____________________ http://www.e-card.bg/
_______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev
The function your looking for is _alpm_runscriptlet() (lib/libalpm/trans.c:567) http://projects.archlinux.org/git/?p=pacman.git;a=blob;f=lib/libalpm/trans.c... Pacman runs 'source <path to file>/.INSTALL <function name> <old ver> <new ver>', the last 3 lines of .INSTALL are needed to get the function name and call it. Andrew
For the record, he first asked on the forums : http://bbs.archlinux.org/viewtopic.php?id=34188 I answered but also said it was probably more appropriate to ask here. After reading this part, I was wondering what some TODO meant, which were added by Dan in this commit : http://projects.archlinux.org/git/gitweb.cgi?p=pacman.git;a=commit;h=cd34ced... + /*TODO clean this code up, remove weird SCRIPTLET_START/DONE, + * (void*)atol call, etc. */ I found this code a bit weird at the beginning, but finally, I don't really see how it could be improved so I'm curious.
Thanks for your responses. You have been most helpful. _____________________ http://www.e-card.bg/
Andrew Fyfe wrote:
lordbad wrote:
In the documentation I have read the following:
There are also install files. This PKGBUILD specifies 'foo.install' as the package's install file. Here is an example install file:
post_install() { /bin/true }
post_upgrade() { /bin/true }
pre_remove() { /bin/true }
op=$1 shift
$op "$@"
Here are the function explainations :
* post_install : this script is run right after files are installed, it takes one argument : o the package version * post_upgrade : this script is run after all files have been upgraded, it takes two arguments : o the new package version o the old package version * pre_remove : this script is run right before files are removed (stop a daemon for example) and takes one argument : o the package version
The three lines at the bottom are needed in every install file so that they run properly.
But I do not understand how does pacman handle these scripts. Does it source the scripts first and then call the shell functions defined in them with some C function like "system" for example? But if it does so why are the last 3 lines needed - I see little if any need for them. So if anyone can give me some hints on the subject and maybe even mention which of pacman's source files implements this functionality I'd be very grateful. Thanks in advance for your help.
Best Regards, Bozhidar
_____________________ http://www.e-card.bg/
_______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev
The function your looking for is _alpm_runscriptlet() (lib/libalpm/trans.c:567)
http://projects.archlinux.org/git/?p=pacman.git;a=blob;f=lib/libalpm/trans.c...
Pacman runs 'source <path to file>/.INSTALL <function name> <old ver> <new ver>', the last 3 lines of .INSTALL are needed to get the function name and call it.
Andrew
_______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev
One more question if I may. Old version and new version have meaning only in upgrade context. What should be the value of old version in install context and the value of new version in remove context?
I don't get it, read your original post again, it's said explicitly there there are two arguments only in upgrade case, and one argument in others.
Bozhidar Batsov wrote:
Andrew Fyfe wrote:
lordbad wrote:
In the documentation I have read the following:
There are also install files. This PKGBUILD specifies 'foo.install' as the package's install file. Here is an example install file:
post_install() { /bin/true }
post_upgrade() { /bin/true }
pre_remove() { /bin/true }
op=$1 shift
$op "$@"
Here are the function explainations :
* post_install : this script is run right after files are installed, it takes one argument : o the package version * post_upgrade : this script is run after all files have been upgraded, it takes two arguments : o the new package version o the old package version * pre_remove : this script is run right before files are removed (stop a daemon for example) and takes one argument : o the package version
The three lines at the bottom are needed in every install file so that they run properly.
But I do not understand how does pacman handle these scripts. Does it source the scripts first and then call the shell functions defined in them with some C function like "system" for example? But if it does so why are the last 3 lines needed - I see little if any need for them. So if anyone can give me some hints on the subject and maybe even mention which of pacman's source files implements this functionality I'd be very grateful. Thanks in advance for your help.
Best Regards, Bozhidar
_____________________ http://www.e-card.bg/
_______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev
The function your looking for is _alpm_runscriptlet() (lib/libalpm/trans.c:567)
http://projects.archlinux.org/git/?p=pacman.git;a=blob;f=lib/libalpm/trans.c...
Pacman runs 'source <path to file>/.INSTALL <function name> <old ver> <new ver>', the last 3 lines of .INSTALL are needed to get the function name and call it.
Andrew
_______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev
One more question if I may. Old version and new version have meaning only in upgrade context. What should be the value of old version in install context and the value of new version in remove context?
_______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev For install/remove it's 'source <path to file>/.INSTALL <function name> <version>'
Andrew
Andrew Fyfe wrote:
Bozhidar Batsov wrote:
Andrew Fyfe wrote:
lordbad wrote:
In the documentation I have read the following:
There are also install files. This PKGBUILD specifies 'foo.install' as the package's install file. Here is an example install file:
post_install() { /bin/true }
post_upgrade() { /bin/true }
pre_remove() { /bin/true }
op=$1 shift
$op "$@"
Here are the function explainations :
* post_install : this script is run right after files are installed, it takes one argument : o the package version * post_upgrade : this script is run after all files have been upgraded, it takes two arguments : o the new package version o the old package version * pre_remove : this script is run right before files are removed (stop a daemon for example) and takes one argument : o the package version
The three lines at the bottom are needed in every install file so that they run properly.
But I do not understand how does pacman handle these scripts. Does it source the scripts first and then call the shell functions defined in them with some C function like "system" for example? But if it does so why are the last 3 lines needed - I see little if any need for them. So if anyone can give me some hints on the subject and maybe even mention which of pacman's source files implements this functionality I'd be very grateful. Thanks in advance for your help.
Best Regards, Bozhidar
_____________________ http://www.e-card.bg/
_______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev
The function your looking for is _alpm_runscriptlet() (lib/libalpm/trans.c:567)
http://projects.archlinux.org/git/?p=pacman.git;a=blob;f=lib/libalpm/trans.c...
Pacman runs 'source <path to file>/.INSTALL <function name> <old ver> <new ver>', the last 3 lines of .INSTALL are needed to get the function name and call it.
Andrew
_______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev
One more question if I may. Old version and new version have meaning only in upgrade context. What should be the value of old version in install context and the value of new version in remove context?
_______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev
For install/remove it's 'source <path to file>/.INSTALL <function name> <version>'
Andrew
_______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev
Yes. I finally understood it completely. Thanks again.
participants (4)
-
Andrew Fyfe
-
Bozhidar Batsov
-
lordbad
-
Xavier