You are not logged in.

#1 2021-08-11 18:45:28

T4rtP1ck73
Member
Registered: 2021-08-11
Posts: 10

Give root permissions to commands in a pkgbuild?

Hello, and thanks for reading this.
Is it possible to give a command root permissions in a pkgbuild without sudo? I'm trying to `cp` a file into `/usr/bin` and `touch` a file in /usr/share/applications, but I get a permission error. How can I avoid this problem?

Last edited by T4rtP1ck73 (2021-08-11 18:45:57)

Offline

#2 2021-08-11 18:50:02

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Give root permissions to commands in a pkgbuild?

Your doing it wrong. PKGBUILDS should never touch anything that isn't under $pkgdir.
Please post what you've come up with so far.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2021-08-11 18:56:18

T4rtP1ck73
Member
Registered: 2021-08-11
Posts: 10

Re: Give root permissions to commands in a pkgbuild?

How do I use code tags?

Offline

#4 2021-08-11 18:57:54

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: Give root permissions to commands in a pkgbuild?

Offline

#5 2021-08-11 18:59:28

T4rtP1ck73
Member
Registered: 2021-08-11
Posts: 10

Re: Give root permissions to commands in a pkgbuild?

 
pkgname=aio-backup
pkgver=0.1.2
pkgrel=3
makedepends=('rust' 'cargo')
arch=('any')

prepare() {
if [ -d /usr/bin/aio-backup ]; then
rm -rf /usr/bin/aio-backup
fi
if [ -d /usr/share/applications/AIO\ Backup ]; then
rm -rf /usr/share/applications/AIO\ Backup/
fi
}

package() {
cargo build --target-dir $pkgdir
chmod +x $pkgdir/debug/aio_backup
cp $pkgdir/debug/aio_backup $pkgdir/usr/bin/aio-backup
mv AIO\ Backup.desktop $pkgdir/usr/share/applications/AIO\ Backup.desktop
rm -rf $pkgdir/debug
}

Btw, I just realized I forgot the source, no need to tell me tongue

Last edited by T4rtP1ck73 (2021-08-11 19:02:07)

Offline

#6 2021-08-11 19:07:32

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Give root permissions to commands in a pkgbuild?

For your actual question you are misunderstanding how pacman works - you do not have to (and absolutely can not) remove existing files.  Pacman will remove the existing files when the new package is installed.  Even if this wasn't the case, you would not want to remove the existing files when the package is built, but only when it was installed.

So get rid of that prepare function all together.

Then read the wiki:
https://wiki.archlinux.org/title/Rust_p … guidelines


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2021-08-11 19:26:40

T4rtP1ck73
Member
Registered: 2021-08-11
Posts: 10

Re: Give root permissions to commands in a pkgbuild?

Ok, done

Offline

Board footer

Powered by FluxBB