You are not logged in.

#1 2016-08-17 17:31:05

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 290
Website

makepkg and "./pkg: Permission denied"

Every now and then, when my makepkg fails, it leaves behind a ./pkg/ with these permissions:

d--x--x--x

When makepkg succeeds, they are more reasonable:

dwrxr-xr-x

Is there some reason for those x-only permissions after the build fails? (or during, for that matter?) All sorts of things tend to fail afterwards, like find, or grep, etc. Not a big thing but a little annoying ...

Add-on: even a subsequent makepkg invocation sometimes fails.

Last edited by jernst (2016-08-17 21:32:21)

Offline

#2 2016-08-17 21:16:40

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

Re: makepkg and "./pkg: Permission denied"

In line 1698 of makepkg.sh.in : https://git.archlinux.org/pacman.git/tr … 0de1#n1698

	mkdir -p "$pkgdirbase"
	chmod a-srw "$pkgdirbase"

I don't know why, but that sure seems to be deliberate.


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

Offline

#3 2016-08-17 22:27:08

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: makepkg and "./pkg: Permission denied"

Eschwartz wrote:

In line 1698 of makepkg.sh.in : https://git.archlinux.org/pacman.git/tr … 0de1#n1698

	mkdir -p "$pkgdirbase"
	chmod a-srw "$pkgdirbase"

I don't know why, but that sure seems to be deliberate.

This looks like Allan's handiwork. It must be how he gets his fix while building up to major breakage.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#4 2016-08-18 21:21:13

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 290
Website

Re: makepkg and "./pkg: Permission denied"

Created bug: https://bugs.archlinux.org/task/50439

Is there a milestone "major breakage" coming up? Based on insights received, I'd like to add this bug to that milestone.

Offline

#5 2016-08-19 00:42:26

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

Re: makepkg and "./pkg: Permission denied"

This prevents the build() function writing to $pkgdir.  After build, the permissions are updated to allow files to be placed there during package().

Where is makepkg failing to leave this behind?   During build()?

Offline

#6 2016-08-19 01:14:19

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

Re: makepkg and "./pkg: Permission denied"

Allan,

Thanks for the explanation. I figured it would be something sensible like that.

jernst,

The only "failing" by grep/find will be a warning that it couldn't search in there. But since that folder will be empty anyway, why do you care -- other than trivial noise?
Since makepkg will remove that directory anyway, how can it be stopping makepkg from working?


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

Offline

#7 2016-08-19 03:32:10

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 290
Website

Re: makepkg and "./pkg: Permission denied"

Here's an example:

pkgname=foobar
pkgver=0.1
pkgrel=1
pkgdesc='testing makepkg'
arch=('i686' 'x86_64')
license=('Apache')

build() {
    touch ${srcdir}/was-in-build
    false
}  

package() {
    install -Dm644 "${srcdir}/was-in-build" "${pkgdir}/"
#    false
}

The "false" in build() leaves the pkg/ around with the strange permissions.

Eschwartz: I cannot currently reproduce, but I believe I have seen pkg/ contain other files. As a result, a subsequent invocation of makepkg failed itself.

Offline

#8 2016-08-19 03:54:12

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

Re: makepkg and "./pkg: Permission denied"

Well, yeah -- any time build() aborts, even with CTRL+C, the "${pkgdir}" is left behind with no rw permissions. That is deliberate and intended.

But it is also always deleted whenever the build function is run, then created without rw permissions, and the only time it can contain other files is after it has been granted rw permissions -- during the package() step.
At which point it will not be chmodded a-rw until after a subsequent makepkg invocation first does rm -rf and then mkdir to create a newly-empty "${pkgdir}". And we are back where we started, without a problem.

...

So in the impossible case where it contains other files and is then chmodded a-rw, the "Removing existing $pkgdir/ directory..." step will fail with a permission denied error trying to recursively delete files it has no permission to view.
But in order to have that happen, you would need to create the situation by hand, since makepkg will never let that happen. And if you create the situation by hand, then that is not a makepkg bug.

Last edited by eschwartz (2016-08-19 03:56:44)


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

Offline

#9 2016-08-19 03:58:33

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 290
Website

Re: makepkg and "./pkg: Permission denied"

If I run into the case again, I will add it to this thread. I certainly do not manually put files into directories like that. Certainly makepkg sometimes fails if that directory exists, and works fine after I have manually removed it. (add-on: actually this might be caused by some code I have in prepare(); I can write that differently)

Regardless, it is an annoyance: what purpose does a (perhaps empty) left-over directory serve other than get in the way? Which was the point of my post ...

Last edited by jernst (2016-08-19 04:05:32)

Offline

Board footer

Powered by FluxBB