[R] RPM post-install scripts to update R

chris albert christopher.albert at mcgill.ca
Sat May 22 16:41:25 CEST 2004


Hi,

Paul Johnson asked:

    While I'm on the RPM subject, can I ask an R RPM packaging question? I
    want the R RPM to install so that post install then R starts and runs
    > update.packages()

    as well as

    install.packages(c("Design","Hmisc","lmtest","car","rgl","effects"))

    well, you get the idea. I want to add in more packages, of course. Can
    I ask what might be the best way to package this?

You can add scripts to the %post macro section.
If you look at the recent R.spec you'll see that there are already some :

    %post
    # Create directory entries for info files
    # (optional doc files, so we must check that they are installed)
    for doc in admin exts FAQ intro lang; do
       file=%{_infodir}/R-${doc}.info.gz
       if [ -e $file ]; then
          /sbin/install-info ${file} %{_infodir}/dir
       fi
    done
    # Update package indices
    %{_bindir}/R CMD perl %{_libdir}/R/share/perl/build-help.pl --htmllists
    %__cat %{_libdir}/R/library/*/CONTENTS >
    %{_libdir}/R/doc/html/search/index.txt

One way to do what you want would be to add something like the following
at the beginning:

    %post
    cat > /tmp/RPM_postinstall.R << EOF
    update.packages(ask=F)
    install.packages(c("Design","Hmisc","lmtest","car","rgl","effects"))
    EOF
    %{_bindir}/R BATCH /tmp/RPM_postinstall.R
    echo "Please check /tmp/RPM_postinstall.Rout for the update results"

This may not be the best way to do it. You'll need to decide what kind
of error checking to do, whether you want to run that batch command in
the background, and so on. However, this is how such tasks are often
dome in rpm spec files.

Chris




More information about the R-help mailing list