summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Benedikt <j.benedikt@partner.samsung.com>2020-02-10 13:46:52 +0100
committerJan Benedikt <j.benedikt@partner.samsung.com>2020-04-21 22:17:23 +0200
commit77459fe1b39eb7d6c5736adedbd021c8bd45615b (patch)
treec740a7845f63b6da00617d45d535a50828ec3f38
parent6ac532c0d6cd76dd5fef7cee280fdc1f43ea9222 (diff)
Adding support for Ubuntu in create_repo and docker_entrypoint scripts
Extend script for creating repository with adding Ubuntu platform support. Issue-ID: OOM-1671 Change-Id: I6b1c63cda18e53277fc2aad6dfa3eceefc9a0023 Signed-off-by: Jan Benedikt <j.benedikt@partner.samsung.com>
-rwxr-xr-xbuild/create_repo.sh78
-rw-r--r--build/data_lists/onap_deb.list57
-rwxr-xr-xbuild/docker-entrypoint.sh104
-rw-r--r--docs/BuildGuide.rst6
4 files changed, 207 insertions, 38 deletions
diff --git a/build/create_repo.sh b/build/create_repo.sh
index eaf0ee30..4403a4e3 100755
--- a/build/create_repo.sh
+++ b/build/create_repo.sh
@@ -1,34 +1,63 @@
#!/usr/bin/env bash
-container_name="centos_repo"
+# Set type of distribution
+distro_type="$(cat /etc/*-release | grep -w "ID" | awk -F'=' '{ print $2 }' | tr -d '"')"
+
# Path to folder with cloned offline-installer build directory with docker_entrypoint script
volume_offline_directory="$(readlink -f $(dirname ${0}))"
+
# Path for directory where repository will be created
volume_repo_directory="$(pwd)"
+
# Path inside container with cloned offline-installer build directory
container_offline_volume="/mnt/offline/"
+
# Path inside container where will be created repository
container_repo_volume="/mnt/repo/"
-# Docker image name and version
-docker_image="centos:centos7.6.1810"
-# Expected directory for RPM packages
-expected_dir="resources/pkg/rpm"
+# Show help for using this script
help () {
- echo "Script for run docker container with RPM repository"
- echo "usage: create_repo.sh [-d|--destination-repository output directory] [-c|--cloned-directory input directory]"
+ echo "Script for run docker container creating DEB or RPM repository"
+ echo "Type of repository is created based on user input or if input is empty type of host OS"
+ echo "usage: create_repo.sh [-d|--destination-repository output directory] [-c|--cloned-directory input directory] [-t|--target-platform (ubuntu/rhel/centos) target platform for repository]"
echo "-h --help: Show this help"
echo "-d --destination-repository: set path where will be stored RPM packages. Default value is current directory"
echo "-c --cloned-directory: set path where is stored this script and docker-entrypoint script (offline-installer/build directory). Fill it just when you want to use different script/datalists"
+ echo "-t --target-platform: set target platform for repository"
echo "If build folder from offline repository is not specified will be used default path of current folder."
}
+# Get type of distribution
+# Set Docker image name and version based on type of linux distribution
+# Set expected directory for RPM/DEB packages
+set_enviroment () {
+ case "$1" in
+ ubuntu)
+ distro_type="ubuntu"
+ docker_image="ubuntu:18.04"
+ expected_dir="resources/pkg/deb"
+ container_name=$1"_repo"
+ ;;
+ centos|rhel)
+ distro_type="rhel"
+ docker_image="centos:centos7.6.1810"
+ expected_dir="resources/pkg/rpm"
+ container_name=$1"_repo"
+ ;;
+ *)
+ echo "Unknown type of linux distribution."
+ exit 1
+ ;;
+ esac
+}
+
# Getting input parametters
POSITIONAL=()
if [[ $# -eq 0 ]] ; then
help # show help
exit 0
fi
+
while [[ $# -gt 0 ]]
do
case "$1" in
@@ -47,6 +76,11 @@ do
# Sets path where will be repository created
volume_repo_directory="$2"
;;
+ -t|--type)
+ # Repository type (rpm/deb)
+ # Sets target platform for repository
+ target_input="$2"
+ ;;
*)
# unknown option
help # show help
@@ -56,10 +90,28 @@ do
shift;shift
done
-# Check if path contains expected path "resources/pkg/rpm"
+# Check if user specified type of repository
+# This settings have higher priority, then type of distribution
+if ! test -z "$target_input"
+then
+ set_enviroment "$target_input"
+else
+ set_enviroment "$distro_type"
+fi
+
+# Check if path contains expected path:
+# "resources/pkg/rpm" for Rhel/CentOS or
+# "resources/pkg/deb" for Ubuntu/Debian
if ! [[ "/$volume_repo_directory/" = *"/$expected_dir/"* ]]; then
# Create repo folder if it not exists
- volume_repo_directory="$volume_repo_directory"/resources/pkg/rpm
+ case "$distro_type" in
+ ubuntu)
+ volume_repo_directory="$volume_repo_directory"/resources/pkg/deb
+ ;;
+ rhel)
+ volume_repo_directory="$volume_repo_directory"/resources/pkg/rhel
+ ;;
+ esac
[ ! -d "$volume_repo_directory" ] && mkdir -p $volume_repo_directory
fi
@@ -79,8 +131,8 @@ if [ ! "$(docker ps -q -f name=$container_name)" ]; then
-v ${volume_repo_directory}:${container_repo_volume} \
--rm \
--entrypoint="${container_offline_volume}docker-entrypoint.sh" \
- -it ${docker_image} \
- --directory ${container_repo_volume} \
- --list ${container_offline_volume}data_lists/
- docker logs $(docker ps --filter "name=centos_repo" --format '{{.ID}}' -a) -f
+ -it ${docker_image} \
+ --directory ${container_repo_volume} \
+ --list ${container_offline_volume}data_lists/
+ docker logs $(docker ps --filter "name=${container_name}" --format '{{.ID}}' -a) -f
fi
diff --git a/build/data_lists/onap_deb.list b/build/data_lists/onap_deb.list
new file mode 100644
index 00000000..fcc6391d
--- /dev/null
+++ b/build/data_lists/onap_deb.list
@@ -0,0 +1,57 @@
+docker-ce=5:18.09.5~3-0~ubuntu-bionic
+docker-ce-cli=5:18.09.5~3-0~ubuntu-bionic
+containerd.io=1.2.2-3
+pigz
+libltdl7
+cgroupfs-mount
+aufs-tools
+bridge-utils
+runc
+ubuntu-fan
+golang-docker-credential-helpers
+libsecret-common
+python3-docker
+python3-dockerpycreds
+python3-websocket
+gssproxy
+libbasicobjects0
+libcollection4
+libgssrpc4
+libini-config5
+libpath-utils1
+libref-array1
+libverto1
+libverto-libevent1
+keyutils
+libnfsidmap2
+libtirpc1
+nfs-common
+nfs-kernel-server
+rpcbind
+chrony
+libnspr4
+build-essential
+cpp
+dpkg-dev
+g++
+g++-7
+libcc-0
+libcc-7-dev
+libgomp1
+libitm1
+libatomic1
+libasan4
+liblsan0
+libtsan0
+libubsan0
+libcilkrts5
+libmpx2
+libquadmath0
+libc6-dev
+gcc
+gcc-7
+libc6-dev
+libc-dev
+make
+binutils
+resolvconf
diff --git a/build/docker-entrypoint.sh b/build/docker-entrypoint.sh
index 14f6aaa7..a36eb9e2 100755
--- a/build/docker-entrypoint.sh
+++ b/build/docker-entrypoint.sh
@@ -1,21 +1,36 @@
#!/usr/bin/env bash
+# Set type of distribution where script is running
+distro_type=$(cat /etc/*-release | grep -w "ID" | awk -F'=' '{ print $2 }' | tr -d '"')
+case "$distro_type" in
+ ubuntu)
+ distro_type="ubuntu"
+ ;;
+ rhel|centos)
+ distro_type="rhel"
+ ;;
+ *)
+ echo "Unknown type of linux distribution."
+ exit 1
+ ;;
+esac
+
# Path where will be created repository (in container)
OFFLINE_REPO_DIR=""
-# Path where is stored onap_rpm.list file
-RPM_LIST_DIR=""
+# Path where is stored onap_rpm.list and onap_deb.list file
+PCKG_LIST_DIR=""
help () {
- echo -e "Docker entrypoint script for creating RPM repository\n"
- echo "usage: create-repo.sh [-d|--directory output directory] [-l|--list input rpm list directory]"
+ echo -e "Docker entrypoint script for creating RPM/DEB repository based on linux distribution where script is running\n"
+ echo "usage: create-repo.sh [-d|--directory output directory] [-l|--list input rpm/deb list directory]"
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 -e "-l --list: set path where rpm or deb 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/rpm/"
- echo "RMP list is stored at: ./data_list/"
+ echo "Repository will be created at: /<path>/resources/pkg/rhel/"
+ echo "RMP/DEB list is stored at: ./data_list/"
}
# Getting input parametters
@@ -39,8 +54,8 @@ do
;;
-l|--list)
# List parametter
- # Sets path where is stored onap_rpm.list file
- RPM_LIST_DIR="$2"
+ # Sets path where is stored onap_rpm.list or onap_deb.list file
+ PCKG_LIST_DIR="$2"
;;
*)
# unknown option
@@ -52,7 +67,10 @@ do
done
# Testing if directory parametter was used
-# If not variable is sets to default value /tmp/repo/resources/pkg/rpm
+# If not variable is sets to default value:
+# /tmp/repo/resources/pkg/rpm
+# or
+# /tmp/repo/resources/pkg/deb
if test -z "$OFFLINE_REPO_DIR"
then
OFFLINE_REPO_DIR="/tmp/repo/"
@@ -60,21 +78,63 @@ fi
# Testing if list parametter was used
# If not variable is sets to default value /tmp/offline/data-list
-if test -z "$RPM_LIST_DIR"
+if test -z "$PCKG_LIST_DIR"
then
- RPM_LIST_DIR="/tmp/offline/data_list/"
-
+ PCKG_LIST_DIR="/tmp/offline/data_list/"
fi
-# 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
+case "$distro_type" in
+ ubuntu)
+ # Change current working dir
+ pushd $OFFLINE_REPO_DIR
+
+ # Install dpkg-deb package for create repository in folder
+ # Install software-properties-common to get add-apt-repository command
+ # Install apt-transport-https, ca-certificates, curl and gnupg-agent allowing apt to use a repository over HTTPS
+ apt-get update -y
+ apt-get install dpkg-dev apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
+
+ # Add Docker's official GPG key:
+ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
+ apt-key fingerprint 0EBFCD88
+
+ # Add docker repository
+ add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
+
+ # Temp fix of known bug
+ # https://bugs.launchpad.net/ubuntu/+source/aptitude/+bug/1543280
+ chown _apt $OFFLINE_REPO_DIR
+
+ # Download all packages from onap_deb.list via apt-get to repository folder
+ for i in $(cat ${PCKG_LIST_DIR}onap_deb.list | awk '{print $1}');do apt-get download $i -y; done
+ for i in $(cat ${PCKG_LIST_DIR}onap_deb.list | awk '{print $1}');
+ do
+ for depends in $(apt-cache depends $i | grep -E 'Depends' | cut -d ':' -f 2,3 | sed -e s/'<'/''/ -e s/'>'/''/);
+ do apt-get download $depends -y;
+ done;
+ done
+
+ # In repository folder create gz package with deb packages
+ dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
+ ;;
+
+ rhel)
+ # 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/
-# 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 ${PCKG_LIST_DIR}onap_rpm.list | awk '{print $1}');do yumdownloader --resolve --downloadonly --destdir=${OFFLINE_REPO_DIR} $i -y; done
-# 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=${OFFLINE_REPO_DIR} $i -y; done
+ # In repository folder create repositor
+ createrepo $OFFLINE_REPO_DIR
+ ;;
-# In repository folder create repository
-createrepo $OFFLINE_REPO_DIR
+ *)
+ echo "Unknown type of linux distribution."
+ exit 1
+ ;;
+esac
diff --git a/docs/BuildGuide.rst b/docs/BuildGuide.rst
index 5b2e2486..5d985b6d 100644
--- a/docs/BuildGuide.rst
+++ b/docs/BuildGuide.rst
@@ -111,12 +111,12 @@ 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
-A RPM repository containing packages to be installed on all nodes needs to be created:
+Repository containing packages to be installed on all nodes needs to be created:
::
- # run the docker container with -d parameter for destination directory with RPM packages
- ./offline-installer/build/create_repo.sh -d $(pwd)
+ # run the docker container with -d parameter for destination directory with RPM packages and optionally use -t parameter for target platform. Supported target platforms are centos|rhel|ubuntu. If -t parameter is not given, default platform is based on host platform where script is running.
+ ./offline-installer/build/create_repo.sh -d $(pwd) -t centos|rhel|ubuntu
.. note:: If script fails due to permissions issue, it could be a problem with SeLinux. It can be fixed by running:
::