diff options
-rwxr-xr-x | build/create_repo.sh | 65 | ||||
-rwxr-xr-x | build/docker-entrypoint.sh | 84 | ||||
-rwxr-xr-x | build/package.py | 4 | ||||
-rw-r--r-- | docs/BuildGuide.rst | 16 |
4 files changed, 163 insertions, 6 deletions
diff --git a/build/create_repo.sh b/build/create_repo.sh new file mode 100755 index 00000000..8e12a16e --- /dev/null +++ b/build/create_repo.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +container_name="centos_repo" +# Path to folder with clonned offline-installer build directory with docker_entrypoint script +volume_directory="." +# Path inside container +container_volume="/mnt/" +# Docker image name and version +docker_image="centos:centos7.6.1810" + +# Getting input parametters +POSITIONAL=() +while [[ $# -gt 0 ]] +do + key="$1" + case $key in + -h|--help) + # Help parametter + echo -e "Script for run docker container with RPM repository\n" + echo "-h --help: Show this help" + echo -e "-d --directory: set root path with offline-installer directory and repository directory for RPM packages\n" + echo "If build folder from offline repository is not specified will be used default path of current folder." + shift # past argument + shift # past value + exit + ;; + -d|--directory) + # Directory parametter + # Sets path where is clonned offline-installer build directory + volume_directory="$2" + shift # past argument + shift # past value + ;; + --default) + DEFAULT=YES + shift # past argument + ;; + *) + # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; + esac +done + + +#Check if container "centos-repo" is running +if [ ! "$(docker ps -q -f name=$container_name)" ]; then + if [ "$(docker ps -aq -f status=exited -f name=$container_name)" ]; then + # cleanup + docker rm $container_name + fi + # run repo container + # name of container $container_name + # docker entrypoint script from mounted volume + # + docker run -d \ + --name $container_name \ + -v ${volume_directory}:${container_volume} \ + --entrypoint="${container_volume}offline-installer/build/docker-entrypoint.sh" \ + -it ${docker_image} \ + --rm \ + --directory ${container_volume}resources/pkg/rhel/ \ + --list ${container_volume}offline-installer/build/data_lists/ +fi diff --git a/build/docker-entrypoint.sh b/build/docker-entrypoint.sh new file mode 100755 index 00000000..798e1f0b --- /dev/null +++ b/build/docker-entrypoint.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash + +# Path where will be created repository (in container) +OOM_REPO_DIR="" + +# Path where is stored onap_rpm.list file +RPM_LIST_DIR="" + +# Getting input parametters +POSITIONAL=() +while [[ $# -gt 0 ]] +do + key="$1" + case $key in + -h|--help) + # Help parametter + echo -e "Docker entrypoint script for creating RPM repository\n" + echo "-h --help: Show this help" + echo "-d --directory: set path for repo directory in container" + echo -e "-l --list: set path where rpm list is stored in container\n" + echo "Both paths have to be set with shared volume between" + echo "container and host computer. Default path in container is: /tmp/" + echo "Repository will be created at: /<path>/resources/pkg/rhel/" + echo "RMP list is stored at: /<path>/offline-installer/build/data_list/" + shift # past argument + shift # past value + exit + ;; + -d|--directory) + # Directory parametter + # Sets path where will be created reposity + OOM_REPO_DIR="$2" + shift # past argument + shift # past value + ;; + -l|--list) + # List parametter + # Sets path where is stored onap_rpm.list file + RPM_LIST_DIR="$2" + shift # past argument + shift # past value + ;; + --default) + DEFAULT=YES + shift # past argument + ;; + *) + # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; + esac +done + +# Testing if directory parametter was used +# If not variable is sets to default value /tmp/resources/pkg/rhel +if test -z "$OOM_REPO_DIR" +then + OOM_REPO_DIR="/tmp/resources/pkg/rhel" +fi + +# Testing if list parametter was used +# If not variable is sets to default value /tmp/data-list +if test -z "$RPM_LIST_DIR" +then + RPM_LIST_DIR="/tmp/offline-installer/build/data_list/" + +fi + +# Create repo folder +mkdir $OOM_REPO_DIR -p + +# Install createrepo package for create repository in folder +# and yum-utils due to yum-config-manager for adding docker repository +yum install createrepo yum-utils -y + +# Add official docker repository +yum-config-manager --add-repo=https://download.docker.com/linux/centos/7/x86_64/stable/ + +# Download all packages from onap_rpm.list via yumdownloader to repository folder +for i in $(cat ${RPM_LIST_DIR}onap_rpm.list | awk '{print $1}');do yumdownloader --resolve --downloadonly --destdir=${OOM_REPO_DIR} $i -y; done + +# In repository folder create repository +createrepo $OOM_REPO_DIR diff --git a/build/package.py b/build/package.py index d30b40c1..ad921ed3 100755 --- a/build/package.py +++ b/build/package.py @@ -210,10 +210,6 @@ def build_offline_deliverables(build_version, os.chdir(script_location) # End of workaround - log.info('Create rhel repo') - createrepo = subprocess.run(['createrepo', os.path.join(resources_directory, 'pkg', 'rhel')]) - createrepo.check_returncode() - resources_package_tar_path = os.path.join(output_dir, 'resources_package' + build_version + '.tar') create_package(resources_content, resources_package_tar_path) diff --git a/docs/BuildGuide.rst b/docs/BuildGuide.rst index 41cfcfee..9b581cdf 100644 --- a/docs/BuildGuide.rst +++ b/docs/BuildGuide.rst @@ -110,7 +110,20 @@ Part 2. Download artifacts for offline installer .. note:: Skip this step if you have already all necessary resources and continue with Part 3. Populate local nexus -It's possible to download all artifacts in single ./download.py execution. Recently we improved reliability of download scripts +Before downloading artifacts with ./download.py script is necessary to create local repository with RPM packages. +This repository is created with docker container where is downloaded and stored in ../resources/pkg/rhel directory. + +:: + # run the docker container with actual directory of offline-installer and resources + ./offline-installer/build/create_repo.sh -d $(pwd) + +.. note:: + If script fails with permissions, problem could be with SeLinux. Issue is possible to solve by: + :: + # Change security context of directory + chcon -Rt svirt_sandbox_file_t $(pwd) + +It's possible to download rest artifacts in single ./download.py execution. Recently we improved reliability of download scripts so one might try following command to download most of the required artifacts in single shot. :: @@ -125,7 +138,6 @@ so one might try following command to download most of the required artifacts in --docker ./build/data_lists/onap_docker_images.list ../resources/offline_data/docker_images_for_nexus \ --git ./build/data_lists/onap_git_repos.list ../resources/git-repo \ --npm ./build/data_lists/onap_npm.list ../resources/offline_data/npm_tar \ - --rpm ./build/data_lists/onap_rpm.list ../resources/pkg/rhel \ --pypi ./build/data_lists/onap_pip_packages.list ../resources/offline_data/pypi \ --http ./build/data_lists/infra_bin_utils.list ../resources/downloads |