From maechler at stat.math.ethz.ch  Sat Jun 15 20:42:23 2013
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Sat, 15 Jun 2013 20:42:23 +0200
Subject: [Rd] R CMD INSTALL and file permission settings
In-Reply-To: <20924.35840.998596.681242@max.nulle.part>
References: <20915.23136.75704.347469@max.nulle.part>
	<20917.40985.705751.95999@stat.math.ethz.ch>
	<20923.30546.509634.752403@stat.math.ethz.ch>
	<1A628E3D-CC34-4C38-B23B-03169D3C7AD0@r-project.org>
	<20923.32408.400045.470669@max.nulle.part>
	<046C1EB4-F22D-457F-BB2C-27D666E3418F@r-project.org>
	<20923.57124.150011.263475@max.nulle.part>
	<82EC6E1A-75F7-4172-968B-CA55AB102171@r-project.org>
	<20924.22356.973252.449984@max.nulle.part>
	<20924.35840.998596.681242@max.nulle.part>
Message-ID: <20924.46479.760166.350303@stat.math.ethz.ch>

>>>>> Dirk Eddelbuettel <edd at debian.org>
>>>>>     on Sat, 15 Jun 2013 10:45:04 -0500 writes:

    > On 15 June 2013 at 07:00, Dirk Eddelbuettel wrote:
    > | 
    > | On 15 June 2013 at 07:47, Simon Urbanek wrote: | |
    > Because update.packages() doesn't restore the
    > group-writable bit. Which leads us to my point that this
    > is not what you really want.
    > | 
    > | Ooops. I'll take another look.

    > Done.  "It works."  For fairly generous definitions of
    > working. I'll detail:

    > i) My initial patch only used options() to set things.
    > Martin was not to enthralled with this and guided the
    > patch towards using --group-writable as an option.

    > ii) With --group-writable, installation works but updates
    > fail as noticed by Simon.

    > iii) If we fall back to using options() [ or an
    > environment variable ], things works.  A log is below.

Hmm, but this only works if everyone who calls  update.packages() also has
this options() setting, no?
Why would the update keep the package files group writable otherwise ?
If the updater has no group-writable option she can still update
the package you installed, but you can no longer, right?

I still think the approach to abolish all settings and just
trigger group-writable package installation *when* the library
directory is group writable is so simple we should adopt it,
and can forget all options/ command line arguments / environment
variables about this topic.

Martin

    > iv) I guess those of you who want the --group-writeable
    > option need to ensure it also works for update.packages()
    > as new option?

    > I am happy with what we have right now as it works in the
    > context established by my patch.  Martin's addition of
    > --group-writable is a bit more ambitious and we may need
    > to enhance update.package(), or tell everybody to also
    > (??)  use the option() setting, or environment variable.

    > Two things follow, a quick test script and a log from the
    > script.

    > Dirk


> Script
> 
> #!/bin/bash
> 
> ## we use digest as an example as it is pretty small
> cd ~/svn/digest
> ls -l digest_0.6.?.tar.gz 
> 
> ## we make two assumptions:
> ##
> ## a) R-devel (called via a shell script wrapper)
> ~/bin/R-devel.sh --version | head -1
> ##
> ## b) An option has been set
> cat /usr/local/lib/R-devel/lib/R/etc/Rprofile.site
> 
> ## now install an older version so that we can upgrade later
> ## this is running as 'edd' ie me
> ~/bin/R-devel.sh CMD INSTALL digest_0.6.2.tar.gz
> 
> ls -ld /usr/local/lib/R/site-library/digest/
> ls -lR /usr/local/lib/R/site-library/digest/
> 
> ## now try the upgrade as another user in the group 
> sudo su lmp -c '~edd/bin/R-devel.sh -e "update.packages(repos=\"http://cran.r-project.org\", ask=FALSE, lib.loc=\"/usr/local/lib/R/site-library\")"'
> 
> ls -ld /usr/local/lib/R/site-library/digest/
> ls -lR /usr/local/lib/R/site-library/digest/
> 
> 
> 
> Session log
> 
> edd at max:~$ /tmp/testRupgrade.sh 
> -rw-r--r-- 1 edd edd 53344 Nov 25  2012 digest_0.6.0.tar.gz
> -rw-r--r-- 1 edd edd 76839 Jan 21 09:25 digest_0.6.1.tar.gz
> -rw-r--r-- 1 edd edd 76771 Jan 25 11:33 digest_0.6.2.tar.gz
> -rw-r--r-- 1 edd edd 78002 Feb 16 06:35 digest_0.6.3.tar.gz
> R Under development (unstable) (2013-06-14 r62964) -- "Unsuffered Consequences"
> options("group.writable.pkgs"=TRUE)
> * installing to library ?/usr/local/lib/R/site-library?
> * installing *source* package ?digest? ...
> ** libs
> ccache gcc-4.7 -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -O3 -g0 -Wall -pipe -pedantic -std=gnu99  -c aes.c -o aes.o
> ccache gcc-4.7 -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -O3 -g0 -Wall -pipe -pedantic -std=gnu99  -c crc32.c -o crc32.o
> ccache gcc-4.7 -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -O3 -g0 -Wall -pipe -pedantic -std=gnu99  -c digest.c -o digest.o
> ccache gcc-4.7 -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -O3 -g0 -Wall -pipe -pedantic -std=gnu99  -c md5.c -o md5.o
> ccache gcc-4.7 -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -O3 -g0 -Wall -pipe -pedantic -std=gnu99  -c raes.c -o raes.o
> ccache gcc-4.7 -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -O3 -g0 -Wall -pipe -pedantic -std=gnu99  -c sha1.c -o sha1.o
> ccache gcc-4.7 -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -O3 -g0 -Wall -pipe -pedantic -std=gnu99  -c sha2.c -o sha2.o
> ccache gcc-4.7 -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -O3 -g0 -Wall -pipe -pedantic -std=gnu99  -c sha256.c -o sha256.o
> sha2.c: In function ?SHA256_Final?:
> sha2.c:606:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
> sha2.c: In function ?SHA512_Last?:
> sha2.c:923:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
> sha2.c:924:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
> ccache gcc-4.7 -shared -L/usr/local/lib -o digest.so aes.o crc32.o digest.o md5.o raes.o sha1.o sha2.o sha256.o -L/usr/local/lib/R-devel/lib/R/lib -lR
> installing to /usr/local/lib/R/site-library/digest/libs
> ** R
> ** inst
> ** preparing package for lazy loading
> ** help
> *** installing help indices
> ** building package indices
> ** testing if installed package can be loaded
> * DONE (digest)
> drwxrwxr-x 7 edd staff 4096 Jun 15 10:42 /usr/local/lib/R/site-library/digest/
> /usr/local/lib/R/site-library/digest/:
> total 52
> -rw-rw-r-- 1 edd staff  1605 Jun 15 10:42 DESCRIPTION
> -rw-rw-r-- 1 edd staff 18092 Jun 15 10:42 GPL-2
> drwxrwxr-x 2 edd staff  4096 Jun 15 10:42 help
> drwxrwxr-x 2 edd staff  4096 Jun 15 10:42 html
> -rw-rw-r-- 1 edd staff   271 Jun 15 10:42 INDEX
> drwxrwxr-x 2 edd staff  4096 Jun 15 10:42 libs
> drwxrwxr-x 2 edd staff  4096 Jun 15 10:42 Meta
> -rw-rw-r-- 1 edd staff   140 Jun 15 10:42 NAMESPACE
> drwxrwxr-x 2 edd staff  4096 Jun 15 10:42 R
> 
> /usr/local/lib/R/site-library/digest/help:
> total 36
> -rw-rw-r-- 1 edd staff    80 Jun 15 10:42 aliases.rds
> -rw-rw-r-- 1 edd staff    32 Jun 15 10:42 AnIndex
> -rw-rw-r-- 1 edd staff 17857 Jun 15 10:42 digest.rdb
> -rw-rw-r-- 1 edd staff   193 Jun 15 10:42 digest.rdx
> -rw-rw-r-- 1 edd staff   140 Jun 15 10:42 paths.rds
> 
> /usr/local/lib/R/site-library/digest/html:
> total 8
> -rw-rw-r-- 1 edd staff 1236 Jun 15 10:42 00Index.html
> -rw-rw-r-- 1 edd staff 1179 Jun 15 10:42 R.css
> 
> /usr/local/lib/R/site-library/digest/libs:
> total 120
> -rwxrwxr-x 1 edd staff 118956 Jun 15 10:42 digest.so
> 
> /usr/local/lib/R/site-library/digest/Meta:
> total 20
> -rw-rw-r-- 1 edd staff  351 Jun 15 10:42 hsearch.rds
> -rw-rw-r-- 1 edd staff  117 Jun 15 10:42 links.rds
> -rw-rw-r-- 1 edd staff  224 Jun 15 10:42 nsInfo.rds
> -rw-rw-r-- 1 edd staff 1271 Jun 15 10:42 package.rds
> -rw-rw-r-- 1 edd staff  331 Jun 15 10:42 Rd.rds
> 
> /usr/local/lib/R/site-library/digest/R:
> total 16
> -rw-rw-r-- 1 edd staff 1056 Jun 15 10:42 digest
> -rw-rw-r-- 1 edd staff 4168 Jun 15 10:42 digest.rdb
> -rw-rw-r-- 1 edd staff  388 Jun 15 10:42 digest.rdx
> 
> R Under development (unstable) (2013-06-14 r62964) -- "Unsuffered Consequences"
> Copyright (C) 2013 The R Foundation for Statistical Computing
> Platform: x86_64-unknown-linux-gnu (64-bit)
> 
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
> 
>   Natural language support but running in an English locale
> 
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
> 
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
> 
> > update.packages(repos="http://cran.r-project.org", ask=FALSE, lib.loc="/usr/local/lib/R/site-library")
> trying URL 'http://cran.r-project.org/src/contrib/digest_0.6.3.tar.gz'
> Content type 'application/x-gzip' length 80083 bytes (78 Kb)
> opened URL
> ==================================================
> downloaded 78 Kb
> 
> * installing *source* package ?digest? ...
> ** package ?digest? successfully unpacked and MD5 sums checked
> ** libs
> ccache gcc -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -ggdb -pipe -std=gnu99 -Wall -pedantic  -c aes.c -o aes.o
> ccache gcc -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -ggdb -pipe -std=gnu99 -Wall -pedantic  -c crc32.c -o crc32.o
> ccache gcc -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -ggdb -pipe -std=gnu99 -Wall -pedantic  -c digest.c -o digest.o
> ccache gcc -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -ggdb -pipe -std=gnu99 -Wall -pedantic  -c md5.c -o md5.o
> ccache gcc -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -ggdb -pipe -std=gnu99 -Wall -pedantic  -c raes.c -o raes.o
> ccache gcc -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -ggdb -pipe -std=gnu99 -Wall -pedantic  -c sha1.c -o sha1.o
> ccache gcc -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -ggdb -pipe -std=gnu99 -Wall -pedantic  -c sha2.c -o sha2.o
> ccache gcc -I/usr/local/lib/R-devel/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -ggdb -pipe -std=gnu99 -Wall -pedantic  -c sha256.c -o sha256.o
> ccache gcc -shared -L/usr/local/lib -o digest.so aes.o crc32.o digest.o md5.o raes.o sha1.o sha2.o sha256.o -L/usr/local/lib/R-devel/lib/R/lib -lR
> installing to /usr/local/lib/R/site-library/digest/libs
> ** R
> ** inst
> ** preparing package for lazy loading
> ** help
> *** installing help indices
> ** building package indices
> ** testing if installed package can be loaded
> * DONE (digest)
> 
> The downloaded source packages are in
> 	?/tmp/RtmpxJgmSB/downloaded_packages?
> > 
> > 
> drwxrwxr-x 7 lmp staff 4096 Jun 15 10:42 /usr/local/lib/R/site-library/digest/
> /usr/local/lib/R/site-library/digest/:
> total 52
> -rw-rw-r-- 1 lmp staff  1767 Jun 15 10:42 DESCRIPTION
> -rw-rw-r-- 1 lmp staff 18092 Jun 15 10:42 GPL-2
> drwxrwxr-x 2 lmp staff  4096 Jun 15 10:42 help
> drwxrwxr-x 2 lmp staff  4096 Jun 15 10:42 html
> -rw-rw-r-- 1 lmp staff   253 Jun 15 10:42 INDEX
> drwxrwxr-x 2 lmp staff  4096 Jun 15 10:42 libs
> drwxrwxr-x 2 lmp staff  4096 Jun 15 10:42 Meta
> -rw-rw-r-- 1 lmp staff   140 Jun 15 10:42 NAMESPACE
> drwxrwxr-x 2 lmp staff  4096 Jun 15 10:42 R
> 
> /usr/local/lib/R/site-library/digest/help:
> total 36
> -rw-rw-r-- 1 lmp staff    80 Jun 15 10:42 aliases.rds
> -rw-rw-r-- 1 lmp staff    32 Jun 15 10:42 AnIndex
> -rw-rw-r-- 1 lmp staff 17871 Jun 15 10:42 digest.rdb
> -rw-rw-r-- 1 lmp staff   195 Jun 15 10:42 digest.rdx
> -rw-rw-r-- 1 lmp staff   140 Jun 15 10:42 paths.rds
> 
> /usr/local/lib/R/site-library/digest/html:
> total 8
> -rw-rw-r-- 1 lmp staff 1236 Jun 15 10:42 00Index.html
> -rw-rw-r-- 1 lmp staff 1179 Jun 15 10:42 R.css
> 
> /usr/local/lib/R/site-library/digest/libs:
> total 172
> -rwxrwxr-x 1 lmp staff 175154 Jun 15 10:42 digest.so
> 
> /usr/local/lib/R/site-library/digest/Meta:
> total 20
> -rw-rw-r-- 1 lmp staff  351 Jun 15 10:42 hsearch.rds
> -rw-rw-r-- 1 lmp staff  117 Jun 15 10:42 links.rds
> -rw-rw-r-- 1 lmp staff  224 Jun 15 10:42 nsInfo.rds
> -rw-rw-r-- 1 lmp staff 1325 Jun 15 10:42 package.rds
> -rw-rw-r-- 1 lmp staff  331 Jun 15 10:42 Rd.rds
> 
> /usr/local/lib/R/site-library/digest/R:
> total 16
> -rw-rw-r-- 1 lmp staff 1056 Jun 15 10:42 digest
> -rw-rw-r-- 1 lmp staff 4205 Jun 15 10:42 digest.rdb
> -rw-rw-r-- 1 lmp staff  385 Jun 15 10:42 digest.rdx
> edd at max:~$ 
> 
> -- 
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com



[Rd] R CMD INSTALL and file permission settings
Martin Maechler