Discussion:
symlink permission denied in builder.sh
(too old to reply)
Nawal Husnoo
2017-06-20 08:27:10 UTC
Permalink
Hi

I have the following default.nix and builder.sh, copied from the acroread
example and adapted. They are called from config.nix. I'm getting
permission denied when I try to create a symbolic link. Any ideas?

thanks

Nawal


Error:

[***@heisenbug:~/data/nixos/user/pkgs/canon]$ nix-env -i all
warning: there are multiple derivations named ‘all’; using the first one
replacing old ‘all’
installing ‘all’
these derivations will be built:
/nix/store/w1w639kybx0lgvdmnb9ipg0j1xvb9wlq-canon-mp250.drv
/nix/store/bmp2ibgc82rmx14bgavd3pknwxwdp4ld-all.drv
building path(s) ‘/nix/store/q5qyxyqrfscdv7yj6aywx9v518215wdr-canon-mp250’
total 764K
dr-xr-xr-x 2 nixbld1 nixbld 4.0K Jun 20 08:23 bjlib
dr-xr-xr-x 4 nixbld1 nixbld 4.0K Jun 20 08:23 cups
-r-xr-xr-x 1 nixbld1 nixbld 47K Jun 20 08:23 libcnbpcmcm356.so.8.0.1
-r-xr-xr-x 1 nixbld1 nixbld 41K Jun 20 08:23 libcnbpcnclapi356.so.3.5.0
-r-xr-xr-x 1 nixbld1 nixbld 21K Jun 20 08:23 libcnbpcnclbjcmd356.so.3.3.0
-r-xr-xr-x 1 nixbld1 nixbld 29K Jun 20 08:23 libcnbpcnclui356.so.3.6.0
-r-xr-xr-x 1 nixbld1 nixbld 522K Jun 20 08:23 libcnbpess356.so.3.3.3
-r-xr-xr-x 1 nixbld1 nixbld 42K Jun 20 08:23 libcnbpo356.so.1.0.2
-r-xr-xr-x 1 nixbld1 nixbld 38K Jun 20 08:23 libcnnet.so.1.2.0
total 12K
dr-xr-xr-x 2 nixbld1 nixbld 4.0K Jun 20 08:23 bin
dr-xr-xr-x 4 nixbld1 nixbld 4.0K Jun 20 08:23 lib
dr-xr-xr-x 7 nixbld1 nixbld 4.0K Jun 20 08:23 share
ln: failed to create symbolic link
'/nix/store/q5qyxyqrfscdv7yj6aywx9v518215wdr-canon-mp250/lib/libcnbpcmcm356.so':
Permission denied
builder for ‘/nix/store/w1w639kybx0lgvdmnb9ipg0j1xvb9wlq-canon-mp250.drv’
failed with exit code 1
cannot build derivation
‘/nix/store/bmp2ibgc82rmx14bgavd3pknwxwdp4ld-all.drv’: 1 dependencies
couldn't be built
error: build of ‘/nix/store/bmp2ibgc82rmx14bgavd3pknwxwdp4ld-all.drv’ failed



config.nix
with import <nixpkgs> {};

{
allowUnfree = true;

packageOverrides = pkgs_: with pkgs_; {
canon = callPackage ./pkgs/canon {
inherit (pkgs) pkgs;
};


all = with pkgs; buildEnv {
name = "all";
paths = [
canon
];
};
};
}


default.nix:
{ stdenv
, pkgs
, udev
, alsaLib
, gtk2-x11
, patchelf
, binutils
, popt
, cups
, cairo
, pango
, fontconfig
, glib
, dpkg
, atk
, procps
, gdk_pixbuf
, zlib
, libxml2
, libtiff
, firefox
, libX11
, libXcursor
, libXrandr
, libXext
, libXinerama
, libXrender
, libXi
, libXfixes
}:

stdenv.mkDerivation {
name = "canon-mp250";
src = ./usr;
builder = ./builder.sh;
libPath = stdenv.lib.makeLibraryPath [
stdenv.cc.cc
udev
alsaLib
gtk2-x11
binutils
popt
cups
cairo
pango
fontconfig
glib
dpkg
atk
procps
patchelf
gdk_pixbuf
libxml2
libtiff
libX11
libXcursor
libXrandr
libXext
libXinerama
libXrender
libXi
libXfixes
];

}


builder.sh:
source $stdenv/setup

mkdir -p $out/
cp -r $src/* $out/


chmod 777 -R $out/bin/*
chmod 777 -R $out/lib/cups/filter/*
chmod 777 -R $out/lib/cups/backend/*

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cngpijmonmp250

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cngpij

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cnijnetprn

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/lgmonmp250

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cifmp250

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/printuimp250

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cnijnpr

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/lib/cups/filter/pstocanonij

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/lib/cups/backend/cnijusb

patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/lib/cups/backend/cnijnet

ls -lh $out/lib/
ls -lh $out/

ln -sv $out/lib/libcnbpcmcm356.so.8.0.1 $out/lib/libcnbpcmcm356.so
ln -sv $out/lib/libcnbpcnclbjcmd356.so.3.3.0 $out/lib/libcnbpcnclbjcmd356.so
ln -sv $out/lib/libcnbpess356.so.3.3.3 $out/lib/libcnbpess356.so
ln -sv $out/lib/libcnnet.so.1.2.0 $out/lib/libcnnet.so
ln -sv $out/lib/libcnbpcnclapi356.so.3.5.0 $out/lib/libcnbpcnclapi356.so
ln -sv $out/lib/libcnbpcnclui356.so.3.6.0 $out/lib/libcnbpcnclui356.so
ln -sv $out/lib/libcnbpo356.so.1.0.2 $out/lib/libcnbpo356.so
Kirill Elagin
2017-06-20 09:11:32 UTC
Permalink
You do `chmod 777` on a bunch of files, but not on `$out/lib`, but it’s the
creation of a link in `$out/lib` that fails, and according to your output
of `ls` the `lib` directory does not have the `w` permission indeed, which
is required to create a link in it.

I am not sure how this works exactly, but it seems that `cp` removes the
`w` permission when copying, so you either have to reset this permissions
yourself or, probably simpler, `mkdir -p "$out/lib"` beforehand, in which
case `cp` will not overwrite its permissions.
Post by Nawal Husnoo
Hi
I have the following default.nix and builder.sh, copied from the acroread
example and adapted. They are called from config.nix. I'm getting
permission denied when I try to create a symbolic link. Any ideas?
thanks
Nawal
warning: there are multiple derivations named ‘all’; using the first one
replacing old ‘all’
installing ‘all’
/nix/store/w1w639kybx0lgvdmnb9ipg0j1xvb9wlq-canon-mp250.drv
/nix/store/bmp2ibgc82rmx14bgavd3pknwxwdp4ld-all.drv
building path(s) ‘/nix/store/q5qyxyqrfscdv7yj6aywx9v518215wdr-canon-mp250’
total 764K
dr-xr-xr-x 2 nixbld1 nixbld 4.0K Jun 20 08:23 bjlib
dr-xr-xr-x 4 nixbld1 nixbld 4.0K Jun 20 08:23 cups
-r-xr-xr-x 1 nixbld1 nixbld 47K Jun 20 08:23 libcnbpcmcm356.so.8.0.1
-r-xr-xr-x 1 nixbld1 nixbld 41K Jun 20 08:23 libcnbpcnclapi356.so.3.5.0
-r-xr-xr-x 1 nixbld1 nixbld 21K Jun 20 08:23 libcnbpcnclbjcmd356.so.3.3.0
-r-xr-xr-x 1 nixbld1 nixbld 29K Jun 20 08:23 libcnbpcnclui356.so.3.6.0
-r-xr-xr-x 1 nixbld1 nixbld 522K Jun 20 08:23 libcnbpess356.so.3.3.3
-r-xr-xr-x 1 nixbld1 nixbld 42K Jun 20 08:23 libcnbpo356.so.1.0.2
-r-xr-xr-x 1 nixbld1 nixbld 38K Jun 20 08:23 libcnnet.so.1.2.0
total 12K
dr-xr-xr-x 2 nixbld1 nixbld 4.0K Jun 20 08:23 bin
dr-xr-xr-x 4 nixbld1 nixbld 4.0K Jun 20 08:23 lib
dr-xr-xr-x 7 nixbld1 nixbld 4.0K Jun 20 08:23 share
ln: failed to create symbolic link
Permission denied
builder for ‘/nix/store/w1w639kybx0lgvdmnb9ipg0j1xvb9wlq-canon-mp250.drv’
failed with exit code 1
cannot build derivation
‘/nix/store/bmp2ibgc82rmx14bgavd3pknwxwdp4ld-all.drv’: 1 dependencies
couldn't be built
error: build of ‘/nix/store/bmp2ibgc82rmx14bgavd3pknwxwdp4ld-all.drv’ failed
config.nix
with import <nixpkgs> {};
{
allowUnfree = true;
packageOverrides = pkgs_: with pkgs_; {
canon = callPackage ./pkgs/canon {
inherit (pkgs) pkgs;
};
all = with pkgs; buildEnv {
name = "all";
paths = [
canon
];
};
};
}
{ stdenv
, pkgs
, udev
, alsaLib
, gtk2-x11
, patchelf
, binutils
, popt
, cups
, cairo
, pango
, fontconfig
, glib
, dpkg
, atk
, procps
, gdk_pixbuf
, zlib
, libxml2
, libtiff
, firefox
, libX11
, libXcursor
, libXrandr
, libXext
, libXinerama
, libXrender
, libXi
, libXfixes
stdenv.mkDerivation {
name = "canon-mp250";
src = ./usr;
builder = ./builder.sh;
libPath = stdenv.lib.makeLibraryPath [
stdenv.cc.cc
udev
alsaLib
gtk2-x11
binutils
popt
cups
cairo
pango
fontconfig
glib
dpkg
atk
procps
patchelf
gdk_pixbuf
libxml2
libtiff
libX11
libXcursor
libXrandr
libXext
libXinerama
libXrender
libXi
libXfixes
];
}
source $stdenv/setup
mkdir -p $out/
cp -r $src/* $out/
chmod 777 -R $out/bin/*
chmod 777 -R $out/lib/cups/filter/*
chmod 777 -R $out/lib/cups/backend/*
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cngpijmonmp250
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cngpij
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cnijnetprn
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/lgmonmp250
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cifmp250
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/printuimp250
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/bin/cnijnpr
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/lib/cups/filter/pstocanonij
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/lib/cups/backend/cnijusb
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $libPath:$out/lib \
$out/lib/cups/backend/cnijnet
ls -lh $out/lib/
ls -lh $out/
ln -sv $out/lib/libcnbpcmcm356.so.8.0.1 $out/lib/libcnbpcmcm356.so
ln -sv $out/lib/libcnbpcnclbjcmd356.so.3.3.0
$out/lib/libcnbpcnclbjcmd356.so
ln -sv $out/lib/libcnbpess356.so.3.3.3 $out/lib/libcnbpess356.so
ln -sv $out/lib/libcnnet.so.1.2.0 $out/lib/libcnnet.so
ln -sv $out/lib/libcnbpcnclapi356.so.3.5.0 $out/lib/libcnbpcnclapi356.so
ln -sv $out/lib/libcnbpcnclui356.so.3.6.0 $out/lib/libcnbpcnclui356.so
ln -sv $out/lib/libcnbpo356.so.1.0.2 $out/lib/libcnbpo356.so
_______________________________________________
nix-dev mailing list
https://mailman.science.uu.nl/mailman/listinfo/nix-dev
Loading...