-
Notifications
You must be signed in to change notification settings - Fork 0
1. Getting Started
SCSPKG provides an infrastructures for installing packages manually. We will go through an example which installs zlib.
A package is a space where source code and configuration files will be stored. To create a package, run the following command:
scspkg create zlib
Packages have two important directories and one file:
- The root directory: where the compiled objects will be installed. It will be created at
${SCSPKG_ROOT}/packages/${PACKAGE_NAME}
- The source directory: where compilation will occur and where source code is stored. It will be created at
${SCSPKG_ROOT}/pacakges/${PACKAGE_NAME}/src
- The modulefile: the modulefile for this package. It will be created at
${SCSPKG_ROOT}/modulefiles/${PACKAGE_NAME}
First, we cd into the package's source directory and unpack zlib
cd `scspkg pkg src zlib`
wget https://www.zlib.net/zlib-1.3.tar.gz
tar -xzf zlib-1.3.tar.gz
cd zlib-1.3
Next, we configure zlib to store the installed files in the package's root directory.
./configure --prefix=`scspkg pkg root zlib`
Lastly, we compile and install zlib.
make -j8
make install
We can then view the installed files here:
ls `scspkg pkg root zlib`/lib
You can then load the produced modulefile as follows:
module load zlib
You will now be able to link against zlib
To undo:
module unload zlib
The modulefile primarily stores environment variables. The modulefile will store the following by default: PATH, LD_LIBRARY_PATH, LIBRARY_PATH, INCLUDE, CPATH, CFLAGS, LDFLAGS.
If other environment variables are needed, they'll have to be added manually.
To view the modulefile contents:
scspkg module show zlib
To get the modulefile path:
scspkg module path zlib
There two ways to set environment variables:
- Set environment variable
- Prepend environment variable
scspkg env prepend zlib MYPREPEND '25' '26' '27'
scspkg env set zlib MYSET='25'
module load zlib
echo $MYPREPEND
echo $MYSET
module unload zlib
Output:
27:26:25
25
There are two ways to remove environment variables
- Remove environment variable
- Remove path prepend
scspkg env unset zlib MYSET
scspkg env pop zlib MYPREPEND 25 26
module load zlib
echo $MYSET
echo $MYPREPEND
module unload zlib
Output:
27
Sometimes modulefiles may depend on other modules to be loaded.
For example, let's say we have the following two packages:
scspkg create app1
scspkg env set app1 APP1='APP1'
scspkg create app2
scspkg env set app2 APP2='APP2'
scspkg create app3
scspkg env set app3 APP3='APP3'
Let's say app3 depends on app1 and app2
scspkg dep add app3 app1 app2
We can then load all app1, app2, and app3 as follows:
module load app3
We can verify this works:
module load app3
echo $APP1 $APP2 $APP3
module unload app3
Output:
APP1 APP2 APP3
Continuing from 1.6., we can remove module dependencies as follows
We can remove app1 as a dependency of app3 as follows:
scspkg dep pop app3 app1
module load app3
echo $APP1 $APP2 $APP3
module unload app3
Output:
APP2 APP3
scspkg dep list
To destroy the contents of a package (including source code):
scspkg create test
scspkg destroy test
The following will collect relevant environment variables (LD_LIBRARY_PATH, etc) and then dump them into the modulefile. This can help avoid calling spack load repeatedly.
scspkg create test
scspkg build profile test
The following will print the current environment and store it in a way that is accessible by an IDE:
scspkg build profile