openSUSE / obs-build

OBS build script, can be used with OBS or stand alone
GNU General Public License v2.0
132 stars 183 forks source link

pacman dependencies with building Archlinux package #890

Open lamskoy opened 1 year ago

lamskoy commented 1 year ago

Have Archlinux PKGBUILD which was building before successfully.

OBS does something wrong: after running pacman it waits one minute for password input for sudo command.

Issue is that I can't see neither which dependencies are missed nor which exact command is running by sudo

How to debug this if no real details in logs?

Have about 30 dependencies and complex package - PHP with all extensions

[ 39s] :: Running post-transaction hooks... [ 39s] (1/1) Arming ConditionNeedsUpdate... [ 39s] now finalizing build dir... [ 39s] SIOCSIFADDR: File exists [ 39s] Running build time source services... [ 39s] Preparing sources... [ 110s] [ 110s] We trust you have received the usual lecture from the local System [ 110s] Administrator. It usually boils down to these three things: [ 110s] [ 110s] openSUSE/open-build-service#1) Respect the privacy of others. [ 110s] openSUSE/open-build-service#2) Think before you type. [ 110s] openSUSE/open-build-service#3) With great power comes great responsibility. [ 110s] [ 110s] sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper [ 112s] sudo: a password is required [ 112s] ==> ERROR: 'pacman' failed to install missing dependencies. [ 112s] ==> ERROR: Could not resolve all dependencies.

Full build log is in attachment:

log.txt

lamskoy commented 1 year ago

Found issue

PKGBUILD checkdepends=('package') is not handled properly by OBS

luc14n0 commented 1 year ago

Could you elaborate on your findings, please? Though I'm not versed in Perl, it seems that checkdepends are treated just like makedepends, as seen in here, and should be downloaded and installed.

lamskoy commented 1 year ago
pkgname=test
pkgver=1.0.0
pkgrel=1
pkgdesc="test"
arch=("x86_64" "i686")
backup=()

build() {
  echo Make
}

package() {
  echo Package
}

check() {
  echo Check
}

checkdepends=('procps-ng')

Here's sample PKGBUILD which it fails with Save it and run "osc build"

luc14n0 commented 1 year ago

Indeed, this dummy package fails.

However, if I use:

pkgname=test
pkgver=1.0.0
pkgrel=1
pkgdesc="test"
arch=("x86_64" "i686")
backup=()
checkdepends=('procps-ng')

build() {
  echo Make
}

package() {
  echo Package
}

check() {
  echo Check
}

It just works [TM]. I don't have an Arch devel environment set up where I can do some testing. However, from what I've read in the Arch Wiki, it does not state anything about ordering (it was a quick read though), but the example given by the wiki article (the same pointed by the PKGBUILD(5) manual page), as well as several PKGBUILD files I've came across from my own experience, they all declare dependencies at the top section, before the build()/prepare() function(s).

And from any Arch package build log (be it in an Arch system, be it in OBS/OSC - as build still uses makepkg in the end) we can see similar output like this (produced by the sample provided by you):

==> Making package: test 1.0.0-1 (Thu Jan 12 00:41:07 2023)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> WARNING: Using existing $srcdir/ tree
==> Starting build()...
Make
==> Starting check()...
Check
==> Entering fakeroot environment...
==> Starting package()...
Package
==> Tidying install...

As we can observe, before building the package makepkg checks build-time dependencies. So, unless that in a native Arch system makepkg parses the PKGBUILD more than once first scanning the whole file looking for dependency arrays or something of the sort, the same error would be observed. Do you know whether that's really the case?

luc14n0 commented 1 year ago

Taking a second look, after giving it some thought. Trying to understand the error you ran into and analyzing the full build log (as well as the one from the dummy PKGBUILD you provided) I see that the build, per se, doesn't even start:

...
[110/111] keeping gpgme-1.18.0-1                                                                                 
[111/111] keeping pacman-6.0.2-5                                                                                 
now finalizing build dir...                                                                                      
Preparing sources...                                                                                             

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.              
    #2) Think before you type.
    #3) With great power comes great responsibility. 

sudo: a terminal is required to read the password; either use the -S option to read from standard input or config
kpass helper
sudo: a password is required
==> ERROR: 'pacman' failed to install missing dependencies.
==> ERROR: Could not resolve all dependencies.
failed to prepare sources
...

Normal build excerpt:

...
[111/112] keeping gpgme-1.18.0-1                                                                                 
[112/112] keeping pacman-6.0.2-5                                                                                 
now finalizing build dir...                                                                                      
Preparing sources...                                
==> WARNING: Skipping verification of source file PGP signatures.
-----------------------------------------------------------------
----- building PKGBUILD (user abuild)
-----------------------------------------------------------------
-----------------------------------------------------------------
==> Making package: test 1.0.0-1 (Thu Jan 12 00:31:38 2023)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> WARNING: Using existing $srcdir/ tree
==> Starting build()...
...

Now, I suspect that makepkg really scan for dependencies even when they are declared on the bottom of the PKGBUILD file. Since OBS uses download on demand (DoD) for Linux distros other than openSUSE ones, all dependencies declared must be fetched and installed before build calls makepkg, otherwise makepkg will call pacman to account for the missing packages. And since OBS uses a hermetic build environment that doesn't allow Internet access... Pacman will fail (either by the semi-broken sudo call we observed, or by no access to Internet).

I hope the workaround - declaring all dependencies at the top of the PKGBUILD file - works for you too, as we might not see this issue get fixed so soon.

lamskoy commented 1 year ago

I'm building my package from AUR: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=php82#n384 and have checkdepends before prepare() and make() And getting same error as with dummy package

luc14n0 commented 1 year ago

Hmm, I see. Then I'm of no help here. Let's hope someone with better insights joins in the discussion.