Does the package manager handle upgrades?

Is it possible to install version 1.0 of a package and then install version 2.0 and have scripts (included with the package) handle any upgrade tasks?

I haven't seen this documented anywhere, so I'm guessing 'no' but I'm hoping 'yes'.

[The company I work for has several versions of our product and I'm working on our cross-Unix installer that needs to detect any previous versions, back up/convert configurations, uninstall old packages and then drop in new ones.]
 
The FreeBSD binary package spec includes pre-install and a post-install script hooks.

You can write a shell script to check for previous versions, backup the config files, call the pkg_delete on the existing version, etc and set it as the pre-install script.

Then write another shell script to take the old configuration data, convert it to the new form, and install the new config files, and use it as the post-install script. And do any cleanup from previous versions here as well.

IOW, the tools and hooks are there, but it's up to you to write the code to make it work for your package. :)

Reading through the man pages for pkg_create(), pkg_add() and pkg_delete() should be enough to get you going. The Porter's Handbook may be useful as well.
 
In all honesty, I don't think a package by itself should take care of upgrading. It's usually just a matter of pkg_delete and pkg_add. Just make sure the pkg_delete doesn't remove any customized configs and pkg_add shouldn't overwrite existing ones.
 
My netbsd box has a [cmd=]pkg_add -u packagename[/cmd] facility. Is there an equivalent for FreeBSD? I had a look at portupgrade but it seems to require ports to be installed which isn't quite what you want if you are using packages.
 
Code:
pkg_add -r pkgname
or
Code:
 ncftp ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8-stable/www
... 8 if running v8, for instance, and you can "get" the package if it exists then pkg_add it directly, once downloaded. (requires ncftp3 port installed, and www for browsers, lang for languages, audio for audio ports etc). You need its dependencies installed first. But in freebsd there is an advantage to using more than just packages unless one is REALLY short of disk space. (say, a 4g drive).
 
What does this mean?
Code:
pkg_add -r apache
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.0-release/Latest/apache.tbz... Done.
pkg_add: package 'apache-1.3.41_1' [b]or its older version already installed[/b]
 
I had a look at pkg_upgrade in sysutils/bsdadminscripts and on the face of it, it seems like it might be the most suitable tool for someone that has built a system purely from binary packages.

However I have run into some problems.

On running it I get this:-
Code:
# ./usr/local/sbin/pkg_upgrade -an
cd: can't cd to /usr/ports
cd: can't cd to /usr/ports
fetch: ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8-release/INDEX: File unavailable (e.g., file not found, no access)

I guess I can just create /usr/ports but it seems like it might be a bug that the script writer has assumed that directories will be there that might not be. I guess I'll file a bug report about that.

I can't figure out where the script has picked up the "packages-8-release" from. This directory doesn't exist on ftp.freebsd.org but "packages-8.0-release" does and would be correct for my system. Can anyone tell me how I configure this?

In the pkg_upgrade script I found this
Code:
# Get some environment variables from uma. This includes PACKAGESITE,
# TMPDIR and PKG_INDEX.
eval "$(uma env $pid)"
and I am guessing that it's the PACKAGESITE that is wrong but I haven't yet figured out what "environment variables from uma" means and how to fix it.

Thanks, DNJ
 
This solved the PACKAGESITE issue
# echo "PACKAGESITE=ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.0-release/All" >> .profile
# echo "export PACKAGESITE" >> .profile
Then logout of root and back in again

I still get errors if I run the pkg_upgrade in a jail though
Code:
# mkdir /usr/ports
# pkg_upgrade -an
fstat: /dev/mem: No such file or directory
fstat: /dev/mem: No such file or directory
/var/db/uma/FTPINDEX                          100% of   16 MB  247 kBps 00m00s
/usr/local/sbin/pkg_upgrade: cannot create /dev/tty: No such file or directory
/usr/local/sbin/pkg_upgrade: cannot create /dev/tty: No such file or directory
/usr/local/sbin/pkg_upgrade: cannot create /dev/tty: No such file or directory
So has it worked or not?
 
Back
Top