You are not logged in.

#1 2016-03-14 06:30:03

bsujja
Member
From: Thailand
Registered: 2013-01-27
Posts: 19

[SOLVED] Symlink permission denied

I've just adopted a package and trying to incorporate a symlink in the build process. My issue is I cannot simply use

ln -s destfile linkfile

in the script because it causes permission denied error. I change to

sudo ln -s destfile linkfile

and it works. I'm very new to this and I'm not sure if this is the right way to solve the issue. Any guide would be appreciated.

Last edited by bsujja (2016-03-15 01:59:41)

Offline

#2 2016-03-14 08:42:23

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: [SOLVED] Symlink permission denied

You shouldn't need root for symlinks anywhere in a PKGBUILD but it depends on what you're doing, can you show your work instead?

Offline

#3 2016-03-14 11:42:05

bsujja
Member
From: Thailand
Registered: 2013-01-27
Posts: 19

Re: [SOLVED] Symlink permission denied

Thank you. That's what I tought. Here is the full PKGBUILD:

pkgname=invoiceplane
_pkgname=InvoicePlane
pkgver=1.4.6
pkgrel=1
pkgdesc="Self hosted invoicing for freelancers and small businesses"
arch=(any)
url="https://invoiceplane.com/"
license=('MIT')
depends=('php')
#optdepends=('php-mysql: for MySQL database support')
source=("https://github.com/InvoicePlane/InvoicePlane/archive/v1.4.6.tar.gz")
sha512sums=('6bd57bb0ec2c5d04e0ac815bd1da75c175bf50597d5dae7b3b04f8eecd1035f65217e09c56114e930df2219f478df3bea11546ab2003e80d405739bf5f29c9d3')

package() {
  cd ${srcdir}
  install -vdm0755 $pkgdir/usr/share/webapps
  mkdir -p $pkgdir/etc/webapps/invoiceplane
  cp -a "${_pkgname}-${pkgver}" ${pkgdir}/usr/share/webapps/invoiceplane
  sudo ln -s "/etc/webapps/invoiceplane/database.php" "/usr/share/webapps/invoiceplane/application/config/database.php"
  install -D "${_pkgname}-${pkgver}/license.txt" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

I think it may be some thing to do with the fact I chown the linkfile http:http?

Offline

#4 2016-03-14 12:37:14

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,787
Website

Re: [SOLVED] Symlink permission denied

No, you're trying to make changes to the actual system running makepkg, rather than the package contents. You need to include pkgdir in the destination path, like the lines around your symlnk line.

You should probably standardise your pkgdir and srcdir usage too, you should always double-quote them, curly braces are optional.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#5 2016-03-14 12:41:41

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: [SOLVED] Symlink permission denied

Ah, I see.  In a PKGBUILD what you're actually going to do is create a broken symlink because you know it will be correct once the package has been extracted.

package() {
    # Each of these functions start in the $srcdir already.

    # Quote variables to prevent word splitting.
    # See <http://mywiki.wooledge.org/Quotes#When_Should_You_Quote.3F>

    install -d "$pkgdir"/usr/share/webapps

    # Consistency.
    install -d "$pkgdir"/etc/webapps/invoiceplane

    # Note that -a with --preserve=all only works here as package() is run
    # under fakeroot, otherwise you'd use -dr --no-preserve=ownership
    cp -a "$_pkgname-$pkgver" "$pkgdir"/usr/share/webapps/invoiceplane

    # This is temporarily a broken symlink but will be correct once installed.
    ln -s /etc/webapps/invoiceplane/database.php "$pkgdir"/usr/share/webapps/invoiceplane/application/config/database.php

    install -Dm644 "$_pkgname-$pkgver"/license.txt "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE
}

Edit: I would probably do this a bit differently personally but the result would be pretty much identical.

Last edited by Earnestly (2016-03-14 12:58:49)

Offline

#6 2016-03-15 00:51:19

bsujja
Member
From: Thailand
Registered: 2013-01-27
Posts: 19

Re: [SOLVED] Symlink permission denied

Thank you Earnestly. Your suggested script works but only when the link file doesn't already exist. So I had to add this before the symlink line:

file=""$pkgdir"/usr/share/webapps/invoiceplane/application/config/database.php"
    if [ -f $file ] ; then
       rm $file
    fi

Offline

#7 2016-03-15 01:04:37

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

Re: [SOLVED] Symlink permission denied

You can just use the -f option to ln instead and save 4 lines in the PKGBUILD. The file should never exist anyway unless you're re-running makepkg over an existing $pkgdir

Offline

#8 2016-03-15 02:00:46

bsujja
Member
From: Thailand
Registered: 2013-01-27
Posts: 19

Re: [SOLVED] Symlink permission denied

Thank you all. Considered SOLVED.

Offline

Board footer

Powered by FluxBB