From b97ed5efee3993e484b6e8c364c61ee882566e9c Mon Sep 17 00:00:00 2001 From: Matteo Delucchi <37136726+matteodelucchi@users.noreply.github.com> Date: Tue, 11 Jun 2024 16:04:24 +0200 Subject: [PATCH 1/4] exclude PACKAGE from being installed along with the dependencies --- containers/debian/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/containers/debian/Dockerfile b/containers/debian/Dockerfile index 9db8964..946ff14 100644 --- a/containers/debian/Dockerfile +++ b/containers/debian/Dockerfile @@ -82,4 +82,7 @@ RUN git clone --depth=1 https://$REPO_PATH target WORKDIR target/ # get a list of all dependencies; install remaining packages # escape=\ -RUN R -e "renv::deactivate();pckgs<-unique(renv::dependencies('$PACKAGE_PATH')[,'Package']);pres_pckgs<-installed.packages()[,'Package'];install.packages(pckgs[!(pckgs %in% pres_pckgs)])" +# Get the package name based on the repository +RUN PACKAGE_NAME=$(echo $REPO_PATH | grep -oP '(?<=\/)[^\/]+(?=\.git)') # Assumes that the package name equals the repository name. +# Install all dependencies of PACKAGE_NAME but not the package it self +RUN R -e "renv::deactivate();pckgs<-unique(renv::dependencies('$PACKAGE_PATH')[,'Package']);pres_pckgs<-installed.packages()[,'Package'];install.packages(pckgs[!(pckgs %in% pres_pckgs) & !(pckgs == 'PACKAGE_NAME')])" From 2dc7c64567f2b71cd4062f40e92151fbcdabe680 Mon Sep 17 00:00:00 2001 From: Matteo Delucchi <37136726+matteodelucchi@users.noreply.github.com> Date: Tue, 11 Jun 2024 16:06:03 +0200 Subject: [PATCH 2/4] also in fedora, exclude PACKAGE from being installed along with the dependencies --- containers/fedora/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/containers/fedora/Dockerfile b/containers/fedora/Dockerfile index ac99293..3987839 100644 --- a/containers/fedora/Dockerfile +++ b/containers/fedora/Dockerfile @@ -100,4 +100,7 @@ RUN git clone --depth=1 https://$REPO_PATH target WORKDIR target/ # get a list of all dependencies; install remaining packages # escape=\ -RUN R -e "renv::deactivate();pckgs<-unique(renv::dependencies('$PACKAGE_PATH')[,'Package']);pres_pckgs<-installed.packages()[,'Package'];install.packages(pckgs[!(pckgs %in% pres_pckgs)])" +# Get the package name based on the repository +RUN PACKAGE_NAME=$(echo $REPO_PATH | grep -oP '(?<=\/)[^\/]+(?=\.git)') # Assumes that the package name equals the repository name. +# Install all dependencies of PACKAGE_NAME but not the package itself +RUN R -e "renv::deactivate();pckgs<-unique(renv::dependencies('$PACKAGE_PATH')[,'Package']);pres_pckgs<-installed.packages()[,'Package'];install.packages(pckgs[!(pckgs %in% pres_pckgs) & !(pckgs == 'PACKAGE_NAME')])" From 3a4cbb5241f09f93a386e86ab23c0fcb72eaacf4 Mon Sep 17 00:00:00 2001 From: Matteo Delucchi Date: Mon, 24 Jun 2024 13:55:06 +0200 Subject: [PATCH 3/4] ignore vscode workspace config --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d855463..fa19686 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ .Rprofile renv.lock renv/ +*.code-workspace From 75dfd0b7a40b12b3d045aae06cf82440cd85c64a Mon Sep 17 00:00:00 2001 From: Matteo Delucchi Date: Mon, 24 Jun 2024 14:22:20 +0200 Subject: [PATCH 4/4] Receive target package name from DESCRIPTION file. --- containers/debian/Dockerfile | 6 +++--- containers/fedora/Dockerfile | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/containers/debian/Dockerfile b/containers/debian/Dockerfile index 946ff14..16d4e71 100644 --- a/containers/debian/Dockerfile +++ b/containers/debian/Dockerfile @@ -82,7 +82,7 @@ RUN git clone --depth=1 https://$REPO_PATH target WORKDIR target/ # get a list of all dependencies; install remaining packages # escape=\ -# Get the package name based on the repository -RUN PACKAGE_NAME=$(echo $REPO_PATH | grep -oP '(?<=\/)[^\/]+(?=\.git)') # Assumes that the package name equals the repository name. +# Get the package name based on the repository from the Description file +RUN PACKAGE_NAME=$(R -s -e "package<-desc::desc(file=file.path('${PACKAGE_PATH}','DESCRIPTION'))\$get_field('Package');writeLines(package)") # Install all dependencies of PACKAGE_NAME but not the package it self -RUN R -e "renv::deactivate();pckgs<-unique(renv::dependencies('$PACKAGE_PATH')[,'Package']);pres_pckgs<-installed.packages()[,'Package'];install.packages(pckgs[!(pckgs %in% pres_pckgs) & !(pckgs == 'PACKAGE_NAME')])" +RUN R -e "renv::deactivate();pckgs<-unique(renv::dependencies('$PACKAGE_PATH')[,'Package']);pres_pckgs<-installed.packages()[,'Package'];install.packages(pckgs[!(pckgs %in% pres_pckgs) & !(pckgs == '$PACKAGE_NAME')])" diff --git a/containers/fedora/Dockerfile b/containers/fedora/Dockerfile index 3987839..e43f96f 100644 --- a/containers/fedora/Dockerfile +++ b/containers/fedora/Dockerfile @@ -100,7 +100,7 @@ RUN git clone --depth=1 https://$REPO_PATH target WORKDIR target/ # get a list of all dependencies; install remaining packages # escape=\ -# Get the package name based on the repository -RUN PACKAGE_NAME=$(echo $REPO_PATH | grep -oP '(?<=\/)[^\/]+(?=\.git)') # Assumes that the package name equals the repository name. -# Install all dependencies of PACKAGE_NAME but not the package itself -RUN R -e "renv::deactivate();pckgs<-unique(renv::dependencies('$PACKAGE_PATH')[,'Package']);pres_pckgs<-installed.packages()[,'Package'];install.packages(pckgs[!(pckgs %in% pres_pckgs) & !(pckgs == 'PACKAGE_NAME')])" +# Get the package name based on the repository from the Description file +RUN PACKAGE_NAME=$(R -s -e "package<-desc::desc(file=file.path('${PACKAGE_PATH}','DESCRIPTION'))\$get_field('Package');writeLines(package)") +# Install all dependencies of PACKAGE_NAME but not the package it self +RUN R -e "renv::deactivate();pckgs<-unique(renv::dependencies('$PACKAGE_PATH')[,'Package']);pres_pckgs<-installed.packages()[,'Package'];install.packages(pckgs[!(pckgs %in% pres_pckgs) & !(pckgs == '$PACKAGE_NAME')])"