You are not logged in.

#1 2011-09-26 05:42:49

cdwijs
Member
Registered: 2010-04-24
Posts: 289

can't create directory while in fakeroot

Hi all,

I'm trying to create a PKGBUILD for mplabx. When the installer tries to create the directory /opt/microchip, it gets the error permission denied.

My pkgbuild:

# This is an example PKGBUILD file. Use this as a start to creating your own,
# and remove these comments. For more information, see 'man PKGBUILD'.
# NOTE: Please fill out the license field for your package! If it is unknown,
# then please put 'unknown'.

# Maintainer: Cedric de Wijs <cdwijs@telfort.nl>
pkgname=microchip_mplab-x
pkgver=7.02
pkgrel=1
epoch=
pkgdesc=""
arch=('x86_64')
url="http://www.microchip.com/en_US/family/mplabx/index.html"
license=('unknown')
groups=()
depends=()
makedepends=()
checkdepends=()
optdepends=()
provides=()
conflicts=()
replaces=()
backup=()
options=()
install=
changelog=
source=(http://ww1.microchip.com/downloads/mplab/X_Beta/mplabx-ide-beta7.02-linux-64-bit-installer.bin)
noextract=()
md5sums=('fbe573dabb54120947bbefaa2d8003d4')

build() {
  whoami
}

check() {
  whoami
}

package() {
  whoami
  chmod +x mplabx-ide-beta7.02-linux-64-bit-installer.bin
  mkdir -p /opt
  mkdir /opt/microchip
  mkdir /opt/microchip/mplabx
  ./mplabx-ide-beta7.02-linux-64-bit-installer.bin
}

The console output:

$ makepkg
==> Making package: microchip_mplab-x 7.02-1 (Mon Sep 26 07:42:15 CEST 2011)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving Sources...
  -> Found mplabx-ide-beta7.02-linux-64-bit-installer.bin
==> Validating source files with md5sums...
    mplabx-ide-beta7.02-linux-64-bit-installer.bin ... Passed
==> Extracting Sources...
==> Removing existing pkg/ directory...
==> Starting build()...
cedric
==> Starting check()...
cedric
==> Entering fakeroot environment...
==> Starting package()...
root
mkdir: cannot create directory `/opt/microchip': Permission denied
==> ERROR: A failure occurred in package().
    Aborting...

When I create the directory /opt/microchip (in the real root), the above error changes:

$ su
Password: 
[root@cedric mplab-test]# mkdir /opt/microchip
[root@cedric mplab-test]# exit
exit
[cedric@cedric mplab-test]$ makepkg
==> Making package: microchip_mplab-x 7.02-1 (Mon Sep 26 07:45:15 CEST 2011)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving Sources...
  -> Found mplabx-ide-beta7.02-linux-64-bit-installer.bin
==> Validating source files with md5sums...
    mplabx-ide-beta7.02-linux-64-bit-installer.bin ... Passed
==> Extracting Sources...
==> Removing existing pkg/ directory...
==> Starting build()...
cedric
==> Starting check()...
cedric
==> Entering fakeroot environment...
==> Starting package()...
root
mkdir: cannot create directory `/opt/microchip': File exists
==> ERROR: A failure occurred in package().
    Aborting...

What can I do to get around this?

Best regards,
Cedric

Offline

#2 2011-09-26 05:49:12

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: can't create directory while in fakeroot

replace:

  mkdir -p /opt
  mkdir /opt/microchip
  mkdir /opt/microchip/mplabx

by:

install -d "$pkgdir"/opt/microchip/mplabx

Your current PKGBUILD tries to create the directory directly in the system.

Offline

#3 2011-09-26 05:50:33

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: can't create directory while in fakeroot

You're trying to create the dir in your root file system. Arch packages are built under their own (fake) root. Read some more docs and look at some more examples, you'll get the idea.

Offline

#4 2011-09-26 06:05:59

cdwijs
Member
Registered: 2010-04-24
Posts: 289

Re: can't create directory while in fakeroot

Thanks. I have now adjusted the PKGBUILD as such

# This is an example PKGBUILD file. Use this as a start to creating your own,
# and remove these comments. For more information, see 'man PKGBUILD'.
# NOTE: Please fill out the license field for your package! If it is unknown,
# then please put 'unknown'.

# Maintainer: Cedric de Wijs <cdwijs@telfort.nl>
pkgname=microchip_mplab-x
pkgver=7.02
pkgrel=1
epoch=
pkgdesc=""
arch=('x86_64')
url="http://www.microchip.com/en_US/family/mplabx/index.html"
license=('unknown')
groups=()
depends=()
makedepends=()
checkdepends=()
optdepends=()
provides=()
conflicts=()
replaces=()
backup=()
options=()
install=
changelog=
source=(http://ww1.microchip.com/downloads/mplab/X_Beta/mplabx-ide-beta7.02-linux-64-bit-installer.bin)
noextract=()
md5sums=('fbe573dabb54120947bbefaa2d8003d4')

build() {
  whoami
}

check() {
  whoami
}

package() {
  whoami
  chmod +x mplabx-ide-beta7.02-linux-64-bit-installer.bin
  install -d "$pkgdir"/opt/microchip/mplabx
  ./mplabx-ide-beta7.02-linux-64-bit-installer.bin
}

The directories are no made without problems, but the mplab installer still complains it can't create the directories.

$ makepkg
==> Making package: microchip_mplab-x 7.02-1 (Mon Sep 26 08:04:04 CEST 2011)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving Sources...
  -> Found mplabx-ide-beta7.02-linux-64-bit-installer.bin
==> Validating source files with md5sums...
    mplabx-ide-beta7.02-linux-64-bit-installer.bin ... Passed
==> Extracting Sources...
==> Removing existing pkg/ directory...
==> Starting build()...
cedric
==> Starting check()...
cedric
==> Entering fakeroot environment...
==> Starting package()...
root
ERROR: ld.so: object 'libfakeroot.so' from LD_PRELOAD cannot be preloaded: ignored.
==> ERROR: A failure occurred in package().
    Aborting...

It looks like makepkg only runs install in the fakeroot. Is there any way a binary installer can be run inside the fakeroot?

Am I going in the right direction, or is there no way to run a binary installer like this?
Are there other binary installers that are run like this?

Best regards,
Cedric

Last edited by cdwijs (2011-09-26 06:32:06)

Offline

#5 2011-09-26 18:28:22

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: can't create directory while in fakeroot

You'll need to dig into that .bin, see what it actually does. It seems to be hardcoded for that /opt/.... path, which means it's going to be difficult to run it inside the makepkg process.

If you're lucky, it could be just a shell script, which would mean you could replicate its actions in your package function, instead of actually running it. Or maybe it could be patched to point at $pkgdir/opt instead of /opt.

All guesswork though, until you find out how it actually works.

Offline

#6 2011-09-26 19:34:05

BxS
Member
From: Portugal
Registered: 2009-04-05
Posts: 24

Re: can't create directory while in fakeroot

Ok, I decide to make a pkbuild for it:

https://aur.archlinux.org/packages.php?ID=52704

enjoy ;-)

Offline

#7 2011-09-27 00:17:07

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: can't create directory while in fakeroot

You're using a mix of /usr and /usr/local... no bueno. Why does it need to be symlinked at all? Add a single file in /etc/ld.so.conf.d to add the appropriate /opt/.../lib directory.

Offline

#8 2011-09-27 01:39:23

BxS
Member
From: Portugal
Registered: 2009-04-05
Posts: 24

Re: can't create directory while in fakeroot

falconindy wrote:

You're using a mix of /usr and /usr/local... no bueno. Why does it need to be symlinked at all? Add a single file in /etc/ld.so.conf.d to add the appropriate /opt/.../lib directory.

I made this package because of this: http://www.microchip.com/forums/m603390.aspx

I just made what the binary installer do when it have real root privileges, I just blindly replicate it, because I already used it and worked, so the fast way of doing the job.

But of course you are right, in older versions I did it, but now I was just lazy.

If you read the http://www.microchip.com/forums/m603390.aspx you will see that I don't lost my time trying to make PKGBUILDs for binary installers, like I did this one.

I just use an isolated system and run the installer there, them extract the changes to the file system, then sometimes make some changes and them create a package with it, it's lazy, but works for me ;-)

That way I can always use the pacman in my main system.

A new version of mplab should be out in a week or tow, I will try to be less lazy ;-)

Last edited by BxS (2011-10-04 14:59:26)

Offline

#9 2011-10-04 14:59:43

BxS
Member
From: Portugal
Registered: 2009-04-05
Posts: 24

Re: can't create directory while in fakeroot

falconindy wrote:

You're using a mix of /usr and /usr/local... no bueno. Why does it need to be symlinked at all? Add a single file in /etc/ld.so.conf.d to add the appropriate /opt/.../lib directory.

UPDATE:
Today I updated the package and looked at the libs, and for my surprise if they don't exist at that specif places the mplab doesn't work, even if I put the libs in other place that ld can see doesn't matter, the usb programmers don't work in mplab, the libs need to be in that exact place for usb programmers work.

So, hardcoded lib place...

Offline

#10 2011-10-04 16:00:10

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: can't create directory while in fakeroot

Yeah that's not correct. You probably neglected to run ldconfig after adding the /etc/ld.conf.so.d file. If, in the unlikely event it didn't work, there's some serious asshattery involved on the part of upstream and hardcoding RPATHs. That can be fixed, but things get a little more interesting at that point...

Offline

#11 2011-10-04 16:59:23

BxS
Member
From: Portugal
Registered: 2009-04-05
Posts: 24

Re: can't create directory while in fakeroot

Yeah I used LD_LIBRARY_PATH and nothing, added to /etc/ld.conf.so.d ran ldconfig and nothing, but even for the case I missed something I moved one lib to a place where ld already is configured, and nothing, the same.

I will not say that I didn't made any mistake, but I believe that paths are hardcoded.

Offline

Board footer

Powered by FluxBB