Page 1 of 1

How about.pet pre and post uninstall scripts?

Posted: Fri 04 Feb 2011, 21:48
by _Mark_
A question for you PET experts
Is it possible to create a pre and post uninstall script for a .pet?

I know you can create a puninstall.sh to run post un-installation script but I want to run one pre uninstall and post uninstall

Thanks
Mark

Posted: Sat 05 Feb 2011, 01:12
by noryb009
You can use pinstall.sh for an install script.

Posted: Sat 05 Feb 2011, 07:38
by amigo
puppy's package manager does not support pre-install or pre-remove scripts.

Posted: Sat 05 Feb 2011, 08:35
by Sit Heel Speak
But, of course, you can include in your .pet package a pre-uninstall script. You'll just have to instruct the user prominently somehow, upon installation, to run the pre-uninstall script first before uninstalling. And hope they remember to do so. Maybe if, when you create the .pet, you give it the description "RUN PRE-UNINSTALL-(name) BEFORE UNINSTALLING!!!" so they will see this warning when they go to click-it-to-uninstall in Puppy Package Manager. Or maybe put a pre-uninstall script icon on the desktop.

Posted: Sat 05 Feb 2011, 10:00
by sc0ttman
You could create an "installer" pet file, which contains other pet files and a pinstall script like this one:

Example: petinstaller.pet contains this pinstall script:

Code: Select all

petget ~/petfile1.pet
petget ~/petfile2.pet
rm ~/petfile1.pet
rm ~/petfile2.pet
(the "~" means "/root")

And in your "petinstaller" pet file, you would the following files:

Code: Select all

/petinstaller/root/petfile1.pet
/petinstaller/root/petfile2.pet
/petinstaller/pinstall.sh
And pet files an indeed contain an uninstall script, simply add:

Code: Select all

/petinstaller/puninstall.sh
NOTE:
Doing an "installer" pet this way, is definitely NOT the recommended or accepted standard way, but it should work fine.

Posted: Sat 05 Feb 2011, 21:47
by _Mark_
Thanks for the feeback all, food for thought, will have to have a think on the best way forward.

And who changed the title of my thread, bit rude if you ask me

Posted: Sun 06 Feb 2011, 03:52
by Lobster
Flash (moderator) has probably changed the title
to something more comprehensible to our forum members.
It is not done often and is meant kindly :)

Posted: Sun 06 Feb 2011, 05:50
by technosaurus

Posted: Sun 06 Feb 2011, 11:38
by _Mark_
Lobster wrote:Flash (moderator) has probably changed the title
to something more comprehensible to our forum members.
It is not done often and is meant kindly :)
You are assuming that my original title was not comprehensible!

All that was added was the "How about" which to me sounds a bit daft considering the nature of the question

Posted: Sun 06 Feb 2011, 20:07
by Karl Godt
/usr/local/petget/installpkg.sh

Code: Select all

if [ -f /pinstall.sh ];then #pet pkgs.
 chmod +x /pinstall.sh
 cd /
 sh /pinstall.sh
 rm -f /pinstall.sh
fi
if [ -f /install/doinst.sh ];then #slackware pkgs.
 chmod +x /install/doinst.sh
 cd /
 sh /install/doinst.sh
 rm -rf /install
fi
#v424 .pet pkgs may have a post-uninstall script...
if [ -f /puninstall.sh ];then
 mv -f /puninstall.sh /root/.packages/${DLPKG_NAME}.remove
fi
A dotpet is made at "/" :
mkdir /MYDOTPETNAME-VERSION
mkdir /MYDOTPETNAME-VERSION/etc
mkdir ALLDIRS
do not forget
mkdir /MYDOTPETNAME-VERSION/usr/local/lib/X11/mini-icons
mkdir /MYDOTPETNAME-VERSION/usr/share/applications

echo > /MYDOTPETNAME-VERSION/pinstall.sh
echo > /MYDOTPETNAME-VERSION/puninstall.sh
geany /MYDOTPETNAME-VERSION/pinstall,sh
geany /MYDOTPETNAME-VERSION/puninstall.sh

save the p[un]install.sh
and run dir2pet

Posted: Sun 06 Feb 2011, 20:35
by Sit Heel Speak
_Mark_ wrote:And who changed the title of my thread, bit rude if you ask me
My guess is, the title with the leading dot caused a problem when trying to load it, or maybe when trying to locally save it, in the moderator's browser. Opera had no trouble with this thread as originally titled.

Posted: Mon 07 Feb 2011, 17:00
by Karl Godt
I want to run one pre uninstall and post uninstall
puppy's package manager does not support pre-install or pre-remove scripts.
I really think that is a suggestion for the installpkg.sh :

Code: Select all

if [ -f /ppreinstall.sh ];then #pet pkgs.
 chmod +x /ppreinstall.sh
 cd /
 sh /ppreinstall.sh
 rm -f /ppreinstall.sh
fi
before

Code: Select all

cd $DLPKG_PATH
case $DLPKG_BASE in
 *.pet)
to get the possibility for backups :

Code: Select all

if test -d /root/.PKG ; then mv /root/.PKG /root/.PKG-instNEWPKG.bak; fi
if test -f /usr/bin/PKGBIN ; then mv /usr/bin/PKGBIN /usr/bin/PKGBIN-instNEWWPKG.bak;fi
and the /usr/local/petget/removepreview.sh
could have something like

Code: Select all

if [ -f /root/.packages/${DB_pkgname}.preremove ];then
 /bin/sh /root/.packages/${DB_pkgname}.preremove
 rm -f /root/.packages/${DB_pkgname}.preremove
before

Code: Select all

export REM_DIALOG="<window title=\"Puppy Package Manager\" icon-name=\"gtk-about\">
  <vbox>
   <pixmap><input file>/usr/local/lib/X11/pixmaps/question.xpm</input></pixmap>
   <text><label>Click 'OK' button to confirm that you wish to uninstall package '$DB_pkgname'</label></text>
which would need

Code: Select all

if [ -f /ppreuninstall.sh ];then
 mv -f /ppreuninstall.sh /root/.packages/${DLPKG_NAME}.preremove
fi
if [ -f /ppostuninstall.sh ];then
 mv -f /ppostuninstall.sh /root/.packages/${DLPKG_NAME}.postremove
fi
at /usr/local/petget
actually the pinstall.sh and puninstall.sh are getting executed after the main part of the [un]installation and are practically postp[un]install.sh

Posted: Mon 07 Feb 2011, 18:08
by Karl Godt
An workaround for a pre-install.sh would be

Code: Select all

mkdir /MYPKGNAME
mkdir /MYPKGNAME/MYPKGNAME
mkdir /MYPKGNAME/MYPKGNAME/usr[etc root ...]
which would install the PKG at "/"
and let the pinstall.sh `cp -r /MYPKGNAME/* /` and `rm -r /MYPKGNAME` at the very end of it .

Posted: Mon 07 Feb 2011, 22:52
by _Mark_
Thanks for all the feedback all, I have now reworked things and now don't need a pinstall or puninstall

Karl Godt

While I'm sure all the information you gave is excellent I didn't understand half of it :D but thanks for taking the time to post it all

Posted: Mon 07 Feb 2011, 23:31
by Karl Godt
I must say , that I did not really understood the initial question either . I thought it would have been a typing mistake :wink:

But after reading the whole page several times i think that i even got sc0ttman's post :

Just create a preinstallscript that downloads the real package via wget or curl and installs it and a postinstallscript to remove everything .

And about a dot at the begining of the headline : I don't know if this forces this thread to be a hidden folder on the server .