'Aur package Showing Permission denied
Hello folks actualy i'm making an AUR package for arch linux and i have made the PKGBUILD file with reference through various YouTube videos and Blog post and Official AUR packaging documentation all i want is to move the python scripts to the /usr/bin/ directory but its throwing error of permission denied, please help
This is my PKGBUILD file for AUR package
# Maintainer: Ashwini Sahu <[email protected]>
_pkgname=hbhc
pkgname=${_pkgname}-git
pkgver=r15.e5f7975
pkgrel=1
pkgdesc="A fast and Open Source Home Baked Hash Cracker for linux Written in Python3"
arch=('any')
url="https://github.com/ASHWIN990/${_pkgname}/sssssssss"
license=('GPL3')
depends=(python3)
makedepends=(git)
source=("git://github.com/ASHWIN990/hbhc.git")
md5sums=('SKIP')
pkgver() {
cd "$_pkgname"
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
package() {
cd "$_pkgname"
install -m 644 ".man/hbhc.1.gz" "/usr/local/share/man/man1/"
cp sha* /usr/bin/ | echo -e "MOVING THE PYTHON SCRIPTS IN /usr/bin"
cp md5* /usr/bin/
cp hbhc /usr/bin/
cp .man/hbhc.1.gz /usr/local/share/man/man1/hbhc.1.gz
}
This is the error that i'm getting which making the package
┌─[ashwinisahu@ashwini-main]─[~/Other/build]
└──╼ $makepkg
==> Making package: hbhc-git r15.e5f7975-1 (Friday 22 May 2020 01:45:52 AM)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
-> Cloning hbhc git repo...
Cloning into bare repository '/home/ashwinisahu/Other/build/hbhc'...
remote: Enumerating objects: 68, done.
remote: Counting objects: 100% (68/68), done.
remote: Compressing objects: 100% (36/36), done.
remote: Total 68 (delta 37), reused 49 (delta 28), pack-reused 0
Receiving objects: 100% (68/68), 15.20 MiB | 1.11 MiB/s, done.
Resolving deltas: 100% (37/37), done.
==> Validating source files with md5sums...
hbhc ... Skipped
==> Extracting sources...
-> Creating working copy of hbhc git repo...
Cloning into 'hbhc'...
done.
==> Starting pkgver()...
==> Entering fakeroot environment...
==> Starting package()...
install: cannot create regular file '/usr/local/share/man/man1/hbhc.1.gz': Permission denied
==> ERROR: A failure occurred in package().
Aborting...
Thanks to folks who give the answer and My new PKGBUILD file looks like this and also it runs without any error
# Maintainer: Ashwini Sahu <[email protected]>
_pkgname=hbhc
pkgname=${_pkgname}-git
pkgver=r17.82d9453
pkgrel=1
pkgdesc="A fast and Open Source Home Baked Hash Cracker for linux Written in Python3"
arch=('any')
url="https://github.com/ASHWIN990/${_pkgname}"
license=('GPL3')
depends=('python3')
makedepends=('git')
provides=('hbhc')
source=("git+https://github.com/ASHWIN990/hbhc.git")
md5sums=('SKIP')
pkgver() {
cd "$_pkgname"
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
package() {
cd "$srcdir/${_pkgname}"
install -Dm775 sha* -t ${pkgdir}/usr/bin/ | echo -e "MOVING THE PYTHON SCRIPTS IN /usr/bin"
install -Dm775 md5* -t ${pkgdir}/usr/bin/
install -Dm775 hbhc -t ${pkgdir}/usr/bin/
install -Dm644 ${PWD}/.man/hbhc.1.gz -t ${pkgdir}/usr/share/man/man1/
}
Solution 1:[1]
(Just a heads up, I dont use Arch and I have never written a PKGBUILD for it. I am Fedora guy, but a similar error has bitten me there often enough.)
package() {
cd "$_pkgname"
install -m 644 ".man/hbhc.1.gz" "/usr/local/share/man/man1/"
cp sha* /usr/bin/ | echo -e "MOVING THE PYTHON SCRIPTS IN /usr/bin"
cp md5* /usr/bin/
cp hbhc /usr/bin/
cp .man/hbhc.1.gz /usr/local/share/man/man1/hbhc.1.gz
}
This code is executed when you are building the package, not when you are installing it. This is not running as a root user, but as the package-build user (I am not sure what that is, on Arch). As a non-root user, you are trying to copy your package to paths (like /usr/...
) which only root can write to. That's not allowed and leads to the permission issue:
==> Starting package()...
install: cannot create regular file '/usr/local/share/man/man1/hbhc.1.gz': Permission denied
==> ERROR: A failure occurred in package().
But you dont want to run as root either. What you need to do is to install to the special location $pkgdir
: https://wiki.archlinux.org/index.php/Creating_packages#Defining_PKGBUILD_variables. This special location looks like /
, but you can write to it. Everything in $pkgdir
becomes a part of the package you are building. Then, when you install the package you have just built, everything from $pkgdir
is copied over to /
.
In other words, when building a package, you install things to $pkgdir/usr/bin/foo
. When that package is installed, that file gets placed at /usr/bin/foo
.
package() {
cd "$_pkgname"
install -m 644 ".man/hbhc.1.gz" "$pkgdir/usr/local/share/man/man1/"
cp sha* "$pkgdir/usr/bin/"
cp md5* "$pkgdir/usr/bin/"
cp hbhc "$pkgdir/usr/bin/"
cp .man/hbhc.1.gz "$pkgdir/usr/local/share/man/man1/hbhc.1.gz"
}
This idea is also known as DESTDIR
which is commonly documented in various make
and similar tools:
- https://www.gnu.org/software/automake/manual/html_node/DESTDIR.html
- https://www.gnu.org/prep/standards/html_node/DESTDIR.html
Hopefully that fixes the problem for you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | omajid |