Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 48920 - [PATCH] GLEP #11 needs portage to provide upgrade notification
Summary: [PATCH] GLEP #11 needs portage to provide upgrade notification
Status: RESOLVED DUPLICATE of bug 273646
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All All
: High blocker (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: Inclusion
Depends on:
Blocks:
 
Reported: 2004-04-25 01:52 UTC by Stuart Herbert (RETIRED)
Modified: 2011-09-20 17:52 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Test Case (movetest-1.0.ebuild,293 bytes, text/plain)
2004-04-25 18:32 UTC, Jason Stubbs (RETIRED)
Details
Add a PORTAGE_PRIOR_VERSIONS var (upgrade-notification.patch,739 bytes, patch)
2005-11-08 04:42 UTC, Jason Stubbs (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stuart Herbert (RETIRED) gentoo-dev 2004-04-25 01:52:59 UTC
As part of GLEP #11, we're introducing a two-stage install process for all web-based applications.  This process is managed by the webapp.eclass, and the webapp-config tool.  The ebuild creates an intermediate install, which Portage puts under /usr/share/webapps.  Then, the user runs webapp-config to create the final working install under /var/www.  This two-stage process is essential for supporting virtual hosting - controlled by the 'vhosts' USE flag.

Users who do not have 'vhosts' in their USE flags still go through the two-stage install process.  The difference is that webapp.eclass automatically calls webapp-config in pkg_postinst().

webapp-config can run in install (-I) or upgrade (-U) mode.  webapp.eclass needs a reliable way to tell which of these switches it should be using.

The suggested way - calling has_version ${CATEGORY}/${PN} - does not work when a package changes category.  Consider the following scenario:

user installs net-www/foobar
we move net-www/foobar to www-blog/foobar
user runs 'emerge -u'
has_version fails, because ${CATEGORY} is set to www-blog

We need a way, in pkg_postinst(), to 100% reliably tell whether the ebuild is an upgrade or a fresh install.  We don't need to know which category it used to be in - we're not supporting two or more webapps with the same ${PN}.  

A simple IS_UPGRADE=0|1 type solution is all we need.

I've marked this as a blocker because this is holding up the roll-out of GLEP #11.  We can't roll out improved ebuilds if our users can't reliably upgrade their packages.

Best regards,
Stu
Comment 1 Jason Stubbs (RETIRED) gentoo-dev 2004-04-25 01:58:45 UTC
"has_version foo/bar" should work because portage updates the names of any installed packages when packages are moved. Can you give it a try and confirm that it doesn't work?
Comment 2 Stuart Herbert (RETIRED) gentoo-dev 2004-04-25 09:10:57 UTC
Nick seemed to think that only binary packages got re-categorised.

Any suggestions for how to test this without actually moving a package in the CVS tree?  If not, where can I find epkgmove?  It doesn't seem to be in gentoolkit, nor in the portage category :(

Thanks,
Stu
Comment 3 Jason Stubbs (RETIRED) gentoo-dev 2004-04-25 18:32:59 UTC
Created attachment 30048 [details]
Test Case

I used the attach ebuild and following commands to ensure that portage does
update the installed package database (although the ebuild wasn't renamed,
which is a different bug). However, this showed a different problem. Using
"has_version ${CATEGORY}/${PN}" from pkg_postinst will always return 1 as the
version being installed has already been added to the database.

bash-2.05b# emerge movetest
Calculating dependencies ...done!
>>> emerge (1 of 1) app-portage/movetest-1.0 to /
>>> Unpacking source...
>>> Source unpacked.
Compile

>>> Install movetest-1.0 into /var/tmp/portage/movetest-1.0/image/ category
app-portage
Install
man:
prepallstrip:
strip:
>>> Completed installing into /var/tmp/portage/movetest-1.0/image/

>>> Merging app-portage/movetest-1.0 to /
Post Install
*** Found! ***

!!! ERROR: app-portage/movetest-1.0 failed.
!!! Function pkg_postinst, Line 21, Exitcode 0
!!! (no error message)

!!! FAILED postinst: 1
bash-2.05b# ls /var/db/pkg/app-portage/movetest-1.0/
CATEGORY  CFLAGS    CXX       LICENSE  PROVIDE	environment.bz2
CBUILD	  CHOST     CXXFLAGS  PDEPEND  RDEPEND	movetest-1.0.ebuild
CC	  CONTENTS  DEPEND    PF       SLOT
CDEPEND   COUNTER   IUSE      PKGUSE   USE
bash-2.05b# echo "move app-portage/movetest app-portage/testmove" >>
/usr/portage/profiles/updates/1Q-2004
bash-2.05b# emerge


Performing Global Updates: /usr/portage/profiles/updates/1Q-2004
(Could take a couple minutes if you have a lot of binary packages.)
  .='update pass'  *='binary update'  @='/var/db move'
  s='/var/db SLOT move' S='binary SLOT move'
..........................................@
emerge: please tell me what to do.


Usage:
   emerge [ options ] [ action ] [ ebuildfile | tbz2file | dependency ] [ ... ]
   emerge [ options ] [ action ] < system | world >
   emerge < sync | info >
   emerge --resume [ --pretend | --ask | --skipfirst ]
   emerge help [ system | config | sync ]
Options: -[abcCdDefhikKlnoOpPsSuUvV] [--oneshot] [--noconfmem]
				    [--columns] [--nospinner]
Actions: [ clean | depclean | inject | prune | regen | search | unmerge ]


   For more help try 'emerge --help' or consult the man page.

bash-2.05b# ls /var/db/pkg/app-portage/
testmove-1.0
bash-2.05b# ls /var/db/pkg/app-portage/testmove-1.0/
CATEGORY  CFLAGS    CXX       LICENSE  PROVIDE	environment.bz2
CBUILD	  CHOST     CXXFLAGS  PDEPEND  RDEPEND	movetest-1.0.ebuild
CC	  CONTENTS  DEPEND    PF       SLOT
CDEPEND   COUNTER   IUSE      PKGUSE   USE
Comment 4 Stuart Herbert (RETIRED) gentoo-dev 2004-05-12 15:16:11 UTC
Where do we stand with this bug?  We still need this functionality.

Many thanks,
Stu
Comment 5 Marius Mauch (RETIRED) gentoo-dev 2004-05-12 16:34:00 UTC
a) both PKGDIR and /var/db/pkg will be updated during global updates.
b) you could workaround the has_version problem by calling it in pkg_setup() and store the result in a file in $T, then test for that in pkg_postinst(). It's a kludge, but should work.
c) there isn't a standard way to test for that yet, easiest would probably to move  the relevant code from emerge to portage and set a variable MERGE_MODE or so, comments?
Comment 6 Heinrich Wendel (RETIRED) gentoo-dev 2005-03-15 08:01:44 UTC
b) you could workaround the has_version problem by calling it in pkg_setup() and store the result in a file in $T, then test for that in pkg_postinst(). It's a kludge, but should work.

Could you post an example code snippet that does this? It would be very useful if it would respect SLOT as well. I tried to implement that for the motif ebuilds, but failed.
Comment 7 Jason Stubbs (RETIRED) gentoo-dev 2005-11-08 04:42:02 UTC
Created attachment 72444 [details, diff]
Add a PORTAGE_PRIOR_VERSIONS var

Would something like this work? The var is only available in
pkg_{pre,post}inst.
Comment 8 Marius Mauch (RETIRED) gentoo-dev 2005-12-04 09:51:30 UTC
Is there still a need for anything here or can this be closed?

As for a code example (untested):
pkg_setup() {
    if has_version {CATEGORY}/${PN}; then
        touch ${T}/is_upgrade
    fi
}

pkg_postinst() {
    if [ -e ${T}/is_upgrade ]; then
        # do upgrade stuff
    else
        # do first install stuff
    fi
}
Comment 9 Stuart Herbert (RETIRED) gentoo-dev 2005-12-04 15:52:27 UTC
Can we rely on ${T} not being emptied in between?

We worked around this problem by having webapp.eclass use webapp-config to
detect whether the package was already installed or not.  It works, but it's a
shame that Portage can't export this information natively to the ebuild/eclass.

Best regards,
Stu
Comment 10 Zac Medico gentoo-dev 2011-09-20 17:52:44 UTC

*** This bug has been marked as a duplicate of bug 273646 ***