You are not logged in.

#1 2016-05-02 00:59:54

DCengineer
Member
Registered: 2015-12-11
Posts: 15

[SOLVED] Is rm -rf "${pkgdir}"/usr/{bin,include,share} safe?

I was looking at a PKGBUILD file (the one for lib32-libjpeg6-turbo), and I saw this line:

rm -rf "${pkgdir}"/usr/{bin,include,share}

  It looks like it will attempt to erase /usr/bin, /usr/include, and /usr/share. I am wondering if this is actually the case, or if the contents of "${pkgdir}" prevents that from happening. I know that Arch Build System also creates a fake root, is that what is getting cleared?

Last edited by DCengineer (2016-05-02 04:02:23)

Offline

#2 2016-05-02 01:27:47

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,560

Re: [SOLVED] Is rm -rf "${pkgdir}"/usr/{bin,include,share} safe?

It's doing this in $pkgdir, not your root filesystem

Last edited by Scimmia (2016-05-02 10:51:48)

Offline

#3 2016-05-02 02:23:39

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: [SOLVED] Is rm -rf "${pkgdir}"/usr/{bin,include,share} safe?

In theory it's not safe -- for example if you copied it to your own script where $pkgdir is not defined, and ran it as root, then yes it would wipe those important paths.

Within a PKGBUILD, it's practically safe since (baring any bugs) $pkgdir is always set correctly, and should be running inside a fakeroot environment as a non-root user to protect your actual filesystem.

Offline

#4 2016-05-02 03:55:15

DCengineer
Member
Registered: 2015-12-11
Posts: 15

Re: [SOLVED] Is rm -rf "${pkgdir}"/usr/{bin,include,share} safe?

Where is $pkgdir defined? My guess is that it is intentionally not defined directly in PKGBUILD

Offline

#5 2016-05-02 03:56:52

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: [SOLVED] Is rm -rf "${pkgdir}"/usr/{bin,include,share} safe?

$pkgdir is setup by `makepkg`

Check the "PACKAGING FUNCTIONS" section of the PKGBUILD man page.

Offline

Board footer

Powered by FluxBB