You are not logged in.

#1 2015-09-06 05:25:17

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Don't use $pkgname in paths in split packages: example of libsystemd

libsystemd's PKGBUILD uses $pkgname to specify a build directory.

prepare() {
  cd "$pkgname"

  ./autogen.sh
}

This is also a split-package that builds systemd, libsystemd, systemd-sysvcompat, and debug packages. When"makepkg --pkg targetpkg" tries to build one of the other packages, it assigns $pkgname to targetpkg--such as "libsystemd" or "systemd-sysvcompat", etc--but the build directory will always be "systemd" because it is named after the source tarball, so build fails.

I think the easiest way around this is not to use $pkgname to reference files or directories in split packages. These names have nothing to do with makepkg's variable; they are created when the source() is downloaded or extracted based on the source url or filename. Some parts of the split-packge PKGBUILD require that $pkgname change (package_libsystemd() or package_sysvcompat()).

Last edited by quequotion (2015-09-06 14:34:33)

Offline

#2 2015-09-06 05:30:38

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,390
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

It should be using $pkgbase.   But also I have no idea what yaourt is doing...

Offline

#3 2015-09-06 06:18:27

severach
Member
Registered: 2015-05-23
Posts: 192

Re: Don't use $pkgname in paths in split packages: example of libsystemd

It doesn't matter if it's $pkgbase or $pkgname. To see why, run these commands from the systemd PKGBUILD in bash.

# pkgbase=systemd
# pkgname=('systemd' 'libsystemd' 'systemd-sysvcompat')
# echo $pkgbase
systemd
# echo $pkgname
systemd

This is bash's business. I don't see how yaourt could mess this up. From what you say it sounds like yaourt is calling prepare() and build() multiple times with hacked up arrays. That isn't how its done. Prepare and build are only called one time for all packages. Each package function pulls different pieces out of the build.

Why are you using yaourt to build? Use yaourt to download and makepkg to build.

# cd ~/build
# yaourt -G systemd
# cd systemd
# makepkg -sCf

Downloading single ABS sources is one of the few things yaourt is good for.

Offline

#4 2015-09-06 09:04:30

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

severach wrote:

It doesn't matter if it's $pkgbase or $pkgname. To see why, run these commands from the systemd PKGBUILD in bash.

# pkgbase=systemd
# pkgname=('systemd' 'libsystemd' 'systemd-sysvcompat')
# echo $pkgbase
systemd
# echo $pkgname
systemd

This is bash's business. I don't see how yaourt could mess this up.

The problem isn't caused by yaourt. The problem is with "makepkg --pkg targetpkg", which assigns the name of the package being built to $pkgname. What I am pointing out is that using $pkgname to then refer to a directory causes a problem, because names of the directories and files have nothing to do with the value of $pkgname. The directory names are chosen based on the source() url or file names.

From what you say it sounds like yaourt is calling prepare() and build() multiple times with hacked up arrays.

makepkg does not understand that PKGBUILDs will never have multiple prepare() and build() functions; so it assigns the name of the package it was told to build to $pkgname.

We need to tell makepkg to always use a particular one of the split-package's package names when in prepare() and build(), even when it was told to build a different package. How could makepkg know which name is the real package name? EDIT: $pkgbase

Why are you using yaourt to build?

I want this to work:

yaourt -Syubb

It very nearly does work.

Last edited by quequotion (2015-09-06 14:24:11)

Offline

#5 2015-09-06 09:24:08

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,390
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

This is nothing to do with makepkg - it is yaourt being shit.   Talk to yaourt devs.

Offline

#6 2015-09-06 10:07:23

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

Allan wrote:

This is nothing to do with makepkg - it is yaourt being shit.   Talk to yaourt devs.

I am not so sure, mostly because:

quequotion wrote:

How will yaourt know which name is the real package name?

By design, yaourt avoids packaging unrequested extras from split-packages. Rather than getting $pkgname for "libtarget" by reading the value in the PKGBUILD as a bash variable (which would return "target"--assuming the author has the names in order), it assigns $pkgbuild the value of the package it was told to build ("libtarget") and attempts to run prepare() build() and package_$pkgname(). In package_$pkgname() the value of $pkgbuild needs to be "libtarget", but in prepare() and build() the value should be "target"--how is yaourt to know?

Edit: Not yaourt's problem after all. Yaourt calls "makepkg --pkg targetpkg" and makepkg assigns $pkgname to targetpkg.

Last edited by quequotion (2015-09-06 14:15:07)

Offline

#7 2015-09-06 10:14:49

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,858
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

Mod note: Not a SysAdmin topic, moving to AUR Issues/discussion.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#8 2015-09-06 10:22:44

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

Is it an AUR issue?

The same problem shoud be reproducible with makepkg --pkg libtarget

Finished testing that before even posting: yep, same problem in makepkg

This is neither a yaourt nor AUR issue.

With the systemd (libsystemd, systemd-sysvinitcompat, systemd-debug, etc) PKGBUILD as is, try:

makepkg --pkg libsystemd

This fails because $pkgname is assigned "libsystemd", but the directory the files are extracted to is not assigned a name based on the value of $pkgname. The directory name comes from the source() (git repository), and happens to be "systemd".

Last edited by quequotion (2015-09-06 14:17:48)

Offline

#9 2015-09-06 10:33:29

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,858
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

quequotion wrote:

Is it an AUR issue?

It appeared to be, however your last post clarifies that it is not. Moving to Creating & Modifying Packages.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#10 2015-09-06 10:41:44

progandy
Member
Registered: 2012-05-17
Posts: 5,192

Re: Don't use $pkgname in paths in split packages: example of libsystemd

So what is the real problem here? As Allan already said, update the PKGBUILD to use $pkgbase in prepare() and build() and everything is well. I think a split package should never use $pkgname in the splitpackage-agnostic functions.

Last edited by progandy (2015-09-06 10:45:25)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#11 2015-09-06 10:44:29

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

progandy wrote:

So what is the real problem here?

Systemd's PKGBUILD using $pkgname to reference directories in prepare() and build().

I think a split package should never use $pkgname in the splitpackage-agnostic functions.

I agree.

As Allan already said, Update the PKGBUILD to use $pkgbase in prepare() and build() and everything is well.

That would do it.

Just making sure everyone knows, because there must be many other packages with the same problem.

Last edited by quequotion (2015-09-06 12:01:57)

Offline

#12 2015-09-06 12:14:33

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,920

Re: Don't use $pkgname in paths in split packages: example of libsystemd

I think you should also create a bug report to get systemd package itself fixed.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#13 2015-09-06 14:11:33

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

Lone_Wolf wrote:

I think you should also create a bug report to get systemd package itself fixed.

Done, with patch.

Offline

#14 2015-09-07 03:26:48

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

Wait a minute, wouldn't "$srcdir" be ideal here? Since the PKGBUILD author is referring to the extraction directory?

Edit: Nope. "$srcdir" is src/; need a different variable to get the extraction directory for systemd's source, src/systemd

Edit again: Do we need new variables that refer to the extraction directories of individual sources?

I'm not sure the return on investing that much work is worth it. It would be simpler to explicitly name the source's directory (with $pkgbase):

source=("$pkgbase::git://github.com/systemd/systemd.git#tag=v$pkgver"

Of course, the author can only use $pkgbase for one source.

Last edited by quequotion (2015-09-07 03:43:52)

Offline

#15 2015-09-07 05:52:59

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,390
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

$pkgbase would usually be the upstream project name which would also be the directory created by the tarball.   No point making this complicated.

Offline

#16 2015-09-07 08:24:13

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

Allan wrote:

$pkgbase would usually be the upstream project name which would also be the directory created by the tarball.   No point making this complicated.

I agree.

Some tarballs exrtact to upstreamname-10.1.2, etc. This can be avoided by defining $pkgbase as "upstreamname" and having mkpkg extract the source to $pkgbase as shown above.

Seems more complicated to explain than to do.

...but does it work? i haven't tested yet..

Should we do something about the wiki?

Last edited by quequotion (2015-09-07 08:35:43)

Offline

#17 2015-09-07 08:30:58

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,390
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

the source=(foo::http://blahblahblah.tar.gz) syntax only renames the tarball, not the directory it is extracted to.

Offline

#18 2015-09-07 10:56:30

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

Allan wrote:

the source=(foo::http://blahblahblah.tar.gz) syntax only renames the tarball, not the directory it is extracted to.

Oh? Then we have a problem. (Lazy) PKGBUILD authors need a way to refer to source's extraction directories other than typing them out. $pkgname is obviously incorrect, $pkgbase only works with a single source, and makepkg does not feature controls or settings I know of to specify a source's extraction directory.

Wouldn't it be nice to write every PKGBUILD with a line like

cd "$targetsrcdir"

instead of having to know exactly what the directory is called? (ie target, target-10.2.1, target-bzr, target-10.2.1-debian1-1, etc)

Last edited by quequotion (2015-09-12 11:30:12)

Offline

#19 2015-09-07 12:11:57

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,390
Website

Re: Don't use $pkgname in paths in split packages: example of libsystemd

cd $pkgbase-$pkgver works for 99% of packages that have tarballs.

Offline

#20 2015-09-12 05:44:37

severach
Member
Registered: 2015-05-23
Posts: 192

Re: Don't use $pkgname in paths in split packages: example of libsystemd

cd "${pkgbase}"*/ works for almost all the rest.

Offline

Board footer

Powered by FluxBB