You are not logged in.

#1 2020-05-13 19:12:58

ente
Member
Registered: 2016-04-10
Posts: 4

[solved] PKGBUILD: post_upgrade() of installation script

When is the post_upgrade() function of an installation script executed? In my test is run during installation, which surprised me. Is this a defect /side effect or can this be expected to be stable functionality? If this is desired, I have to move all the steps that are supposed to be executed during installation & upgrade to the upgrade function only. Otherwise they are executed twice during installation.

Last edited by ente (2020-05-15 19:14:30)

Offline

#2 2020-05-13 21:22:03

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: [solved] PKGBUILD: post_upgrade() of installation script

Have you read the PKGBUILD man page?


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2020-05-13 22:36:15

2ManyDogs
Forum Moderator
Registered: 2012-01-15
Posts: 4,645

Re: [solved] PKGBUILD: post_upgrade() of installation script


How to post. A sincere effort to use modest and proper language and grammar is a sign of respect toward the community.

Offline

#4 2020-05-14 18:16:43

ente
Member
Registered: 2016-04-10
Posts: 4

Re: [solved] PKGBUILD: post_upgrade() of installation script

Yes. I read the wiki. I read the man page. Did you read my question?
From the wiki (and the man page is exactly as vague):

post_upgrade — The script is run right after files are extracted. Two arguments are passed in the following order: new package version, old package version.

This would make me assume the function is not called during an installation. The description is not getting even close to make me assume it would be executed during installation. So what should I read? Where does it say that "post_upgrade" is executed during an installation process as well and not only during a package upgrade.

Offline

#5 2020-05-14 19:25:16

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: [solved] PKGBUILD: post_upgrade() of installation script

test PKGBUILD

pkgname=test
pkgver=1
pkgrel=1
pkgdesc=""
arch=('any')
url=""
license=('GPL')
install=test.install

test.install

## arg 1:  the new package version
pre_install() {
	echo pre_install $1
}

## arg 1:  the new package version
post_install() {
	echo post_install $1
}

## arg 1:  the new package version
## arg 2:  the old package version
pre_upgrade() {
	echo pre_upgrade $1 $2
}

## arg 1:  the new package version
## arg 2:  the old package version
post_upgrade() {
	echo post_upgrade $1 $2
}

## arg 1:  the old package version
pre_remove() {
	echo pre_remove $1
}

## arg 1:  the old package version
post_remove() {
	echo post_remove $1
}

Produces the following

$ pacman -U test-1-1-any.pkg.tar.zst
loading packages...
resolving dependencies...
looking for conflicting packages...

Packages (1) test-1-1


:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring                                                                                     [####################################################################] 100%
(1/1) checking package integrity                                                                                   [####################################################################] 100%
(1/1) loading package files                                                                                        [####################################################################] 100%
(1/1) checking for file conflicts                                                                                  [####################################################################] 100%
(1/1) checking available disk space                                                                                [####################################################################] 100%
:: Processing package changes...
pre_install 1-1
(1/1) installing test                                                                                              [####################################################################] 100%
post_install 1-1
$ pacman -U test-2-1-any.pkg.tar.zst
loading packages...
resolving dependencies...
looking for conflicting packages...

Packages (1) test-2-1


:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring                                                                                     [####################################################################] 100%
(1/1) checking package integrity                                                                                   [####################################################################] 100%
(1/1) loading package files                                                                                        [####################################################################] 100%
(1/1) checking for file conflicts                                                                                  [####################################################################] 100%
(1/1) checking available disk space                                                                                [####################################################################] 100%
:: Processing package changes...
pre_upgrade 2-1 1-1
(1/1) upgrading test                                                                                               [####################################################################] 100%
post_upgrade 2-1 1-1

Offline

#6 2020-05-15 16:42:14

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [solved] PKGBUILD: post_upgrade() of installation script

ente wrote:

In my test is run during installation, which surprised me. Is this a defect /side effect or can this be expected to be stable functionality?

This is an anomalous occurrence, it directly contradicts the documentation, the name of the feature, and the intention of the pacman developers.

ente wrote:

Yes. I read the wiki. I read the man page. Did you read my question?
From the wiki (and the man page is exactly as vague):

post_upgrade — The script is run right after files are extracted. Two arguments are passed in the following order: new package version, old package version.

This would make me assume the function is not called during an installation. The description is not getting even close to make me assume it would be executed during installation. So what should I read? Where does it say that "post_upgrade" is executed during an installation process as well and not only during a package upgrade.

I don't know how this is supposed to be vague. If the possible transaction types are "install", "upgrade", and "remove", it seems to be obvious that installing is not the same as upgrading, and in fact, pacman will print out a status message for every package saying either "installing" or "upgrading" the package.

"The exact time the script is run varies with each operation, and should be self-explanatory. Note that during an upgrade operation, none of the install or remove functions will be called."

This second sentence is bulletproof. There is no vagueness here. graysky was entirely correct in calling you out on reading the manpage and questioning why you asked whether it's expected behavior. Apparently, you did read the manpage, but you didn't fully read it; fortunately, we can read it for you and parrot specific sentences at you, though honestly, it would be more efficient and less distracting if you were to read it for yourself first. smile

To be perfectly, unambiguously clear: you are claiming you have observed that something has happened. The PKGBUILD manpage says that your observation must not, under any circumstances, happen.

...

tl;dr

As a result, I don't believe you that it's actually occurring at all.

Please post a sample PKGBUILD and install script which you claim demonstrates this defect. Please also post the entire output of pacman --debug -U /path/to/built/package.pkg.tar.zst (or pacman --debug -S foopkg). I would like to see the --debug output of this transaction, as it will prove, once and for all, whether this is actually happening.

If it is indeed going wrong, this is an extremely serious bug, but I cannot reproduce it.

Last edited by eschwartz (2020-05-15 16:49:45)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#7 2020-05-15 19:10:26

ente
Member
Registered: 2016-04-10
Posts: 4

Re: [solved] PKGBUILD: post_upgrade() of installation script

Correct. There is been an issue in the PKGBUILD. I didn't remove some # which caused me to believe the function would be called during installation while it actually wasn't. Sorry for the noise.

Thanks loqs for actually making me check my script once more.

Offline

#8 2020-05-15 19:13:54

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [solved] PKGBUILD: post_upgrade() of installation script

OK, great, glad that's solved then. wink

Please change the [closed] in the thread title to [solved] or similar -- "[closed]" is easily confused with "Closed:" which is the forum software's tag for threads which have been locked by the moderators.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB