This document describes the method of constructing installation scripts of download_archive.sh
, download_src.sh
, install_archive.sh
, install_src.sh
, is_installed.sh
and packages_cpm.txt
with a concrete example.
-
Choose the base script
Constructing these scripts from scratch can be laborious. Check the existingcpm/packages/<architecture>/<libName>
and see them.- Case 1: The archive file for installation is over 100MB. And the archive file to download is split to multiple files.
Seecpm/packages/amd64/gcc/12.1.0
to refer - Case 2: The archive file for installation is not over 100MB. And the archive file to download is Not split to multiple files.
Seecpm/packages/amd64/sstd/2.0.1
to refer - Case 3: Use the latest source code from the internet
Seecpm/packages/amd64/sstd/latest
to refer. (This installation scripts downloads the source code from the latest commit ofsstd
main branch and compilessstd
and installssstd
tocpm_env/local
).
- Case 1: The archive file for installation is over 100MB. And the archive file to download is split to multiple files.
-
Make base directory for installation scripts
cd <prj>/cpm/packages/<architecture>/ mkdir <libName>
NOTE: In this document, <prj> is a project directory.
-
Copy
common_fn.sh
,common_fn_envDependents.sh
,download_archive.sh
,download_src.sh
,init_path.sh
,install_archive.sh
,install_src.sh
andis_installed.sh
files from the installation scripts directory of the referencing library.cd <prj>/cpm/packages/<architecture>/<libName of the referencing library>/ cp common_fn.sh common_fn_envDependents.sh download_archive.sh download_src.sh init_path.sh install_archive.sh install_src.sh is_installed.sh ../<libName>
-
Make a blank
packages_cpm.txt
file and write the dependencies.cd <prj>/cpm/packages/<architecture>/<libName> touch packages_cpm.txt nano packages_cpm.txt # write the dependencies
-
Edit
download_src.sh
file
The role ofdownload_src.sh
file is to download the source file and its hash file to theCPM_CACHE_DIR
directory and to check the hash value of source file. TheCPM_CACHE_DIR
which is a environment variable is provided by cpm/exe. The user needs to edit the shell variables ofURL
andURL_hash
at least. The user also need to editfName
,fName_hash
, etc. as needed.cd <prj>/cpm/packages/<architecture>/<libName> nano download_src.sh # edit `URL` and `URL_hash` for installation library
-
Edit
install_src.sh
file
The role ofinstall_src.sh
file is to unpack the archived source file toCPM_BUILD_DIR
directory, to build source file and to install toCPM_INST_WDIR
directory. TheCPM_INST_WDIR
which is a environment variable is provided by cpm/exe.cd <prj>/cpm/packages/<architecture>/<libName> nano install_src.sh # edit installation process for installation library
NOTE: Dependent libraries are installed in the
CPM_DLIB_PATH
directory. Not inCPM_INST_WDIR
. The concrete path ofCPM_DLIB_PATH
directory is usuallycpm_env/local
, and the concrete path ofCPM_INST_WDIR
direcotry is usuallycpm_env/local_work
. -
Edit
common_fn_envDependents.sh
foris_installed.sh
file
The role ofis_installed.sh
file is to notify cpm/exe of the library's installation status. And the substance of theis_installed.sh
file is in thecommon_fn_envDependents.sh
file.The user needs to edit the shell function of
cfn_isInstalled()
in thecommon_fn_envDependents.sh
file called from theis_installed.sh
file.cd <prj>/cpm/packages/<architecture>/<libName> nano common_fn_envDependents.sh # edit `cfn_isInstalled()` for installation library
-
Check the edited source installation script works correctly
- Make a
packages_cpm.txt
file to check the edited installation scriptcd <prj> echo -e 'ARCHITECTURE, <architecture>;' >> packages_cpm.txt echo -e 'INSTALL_MODE, archive;' >> packages_cpm.txt echo -e 'BUILD_ENV, SYSTEM_ENV;' >> packages_cpm.txt echo -e 'gcc, >=12.*.*;' >> packages_cpm.txt echo -e 'INSTALL_MODE, source;' >> packages_cpm.txt echo -e 'BUILD_ENV, CPM_ENV;' >> packages_cpm.txt echo -e '<libName>, ==<version>' >> packages_cpm.txt
- Run cpm/exe
cd <prj> cpm/exe -p ./packages_cpm.txt
NOTE: If you are referencing the
Case 3
scripts, this is the end of the construction. - Make a
-
Generate archive file for archive installation
- Run cpm/exe with archive option
cd <prj> cpm/exe -a true -p ./packages_cpm.txt
- Check the archive file is in
cpm_env/archive
directory
- Run cpm/exe with archive option
-
Upload the generated archive files and get its URL
Usually, uploading file is<architecture>-<libName>-<version>-sha256sum.txt
and<architecture>-<libName>-<version>.tar.xz
. When the file size is over 100 MB, cpm/exe also generates splitted archive file like*.tar.xz-00
,*.tar.xz-01
, ...*.tar.xz-XX
. Upload the best file for your situation. -
Edit
common_fn_envDependents.sh
fordownload_archive.sh
file andinstall_archive.sh
file
About thedownload_archive.sh
file:
The role ofdownload_archive.sh
file is to download the archive file (*.tar.xz
) and its hash file (*-sha256sum.txt
) to theCPM_CACHE_DIR
directory and to check the hash value of archive file. TheCPM_CACHE_DIR
which is a environment variable is provided by cpm/exe. A substance of thedownload_archive.sh
file is in thecommon_fn.sh
file and the configuration of thedownload_archive.sh
file is in thecommon_fn_envDependents.sh
file.The user needs to edit the shell function of
cfn_set_archive_URL()
in thecommon_fn_envDependents.sh
file called from thedownload_archive.sh
file.About the
install_archive.sh
file:
The role ofinstall_archive.sh
file is to unpack and install the archived source file toCPM_INST_WDIR
directory. TheCPM_INST_WDIR
which is a environment variable is provided by cpm/exe.The user needs to edit the shell function of
cfn_set_archive_fName()
in thecommon_fn_envDependents.sh
file called from theinstall_archive.sh
file.cd <prj>/cpm/packages/<architecture>/<libName> nano common_fn_envDependents.sh # edit `cfn_set_archive_URL()` and `cfn_set_archive_fName()` for installation library
-
Check the edited archive installation script works correctly (1)
- Make a
packages_cpm.txt
file to check the edited installation scriptcd <prj> echo -e 'ARCHITECTURE, <architecture>;' >> packages_cpm.txt echo -e 'INSTALL_MODE, archive;' >> packages_cpm.txt echo -e 'BUILD_ENV, SYSTEM_ENV;' >> packages_cpm.txt echo -e 'gcc, >=12.*.*;' >> packages_cpm.txt echo -e 'BUILD_ENV, CPM_ENV;' >> packages_cpm.txt echo -e '<libName>, ==<version>' >> packages_cpm.txt
- Run cpm/exe
cd <prj> cpm/exe -p ./packages_cpm.txt
- Make a
-
Check the edited archive installation script works correctly (2)
When using the docker, ckeck using theDOCKER_ENV
option.- Make a
packages_cpm.txt
file to check the edited installation scriptcd <prj> echo -e 'ARCHITECTURE, <architecture>;' >> packages_cpm.txt echo -e 'INSTALL_MODE, archive;' >> packages_cpm.txt echo -e 'BUILD_ENV, SYSTEM_ENV;' >> packages_cpm.txt echo -e 'gcc, >=12.*.*;' >> packages_cpm.txt echo -e 'BUILD_ENV, DOCKER_ENV, ./cpm/build_env/docker/ubuntu18.04_for_build_gcc;' >> packages_cpm.txt echo -e '<libName>, ==<version>' >> packages_cpm.txt
- Run cpm/exe
cd <prj> cpm/exe -p ./packages_cpm.txt
- Make a