5 # Set distribution family
6 distro_type=$(cat /etc/*-release | grep -w "ID" | awk -F'=' '{ print $2 }' | tr -d '"')
15 echo "Unknown type of linux distribution."
20 # Target path for created repository
23 # Path to directory containing onap_rpm.list and onap_deb.list files
26 # Path to additional packages lists
32 Docker entrypoint script for creating RPM/DEB repository based on container platform type
34 usage: create-repo.sh [OPTION]...
36 -d | --directory target repository path
37 -l | --list input rpm/deb list directory
38 -a | --additional-list additional packages list; can be used multiple times
39 -p | --packages-lists-path other additional packages lists
40 -h | --help show this help
42 Both paths have to be set with shared volume between
43 container and the host. Default path in container is: /tmp/
44 Repository will be created at: /<path>/resources/pkg/rhel/
45 RMP/DEB list is stored at: ./data_list/
49 # Getting input parameters
50 if [[ $# -eq 0 ]] ; then
64 # Set target reposity path
69 # Set path containing onap_rpm.list or onap_deb.list file
72 -p|--packages-lists-path)
74 # Set path for additional packages lists
78 # Array of additional packages lists
79 ADDITIONAL_LISTS+=("$2")
90 # Testing if directory parameter was used
91 # If not variable is set to /tmp/repo by default
92 if test -z "$OFFLINE_REPO_DIR"
94 OFFLINE_REPO_DIR="/tmp/repo/"
97 # Testing if list parameter was used
98 # If not variable is set to default value /tmp/offline/data-list
99 if test -z "$PCKG_LIST_DIR"
101 PCKG_LIST_DIR="/tmp/offline/data_list/"
104 # Testing if additional packages list parameter was used
105 # If not variable is set to default value /tmp/additional-lists
106 if test -z "$PCKG_LIST_DIR"
108 PCKG_LIST_DIR="/tmp/additional-lists/"
111 # Clean target repo dir for idempotency
112 rm -rf ${OFFLINE_REPO_DIR}/*
114 case "$distro_type" in
116 # Change current working dir
117 pushd $OFFLINE_REPO_DIR
119 # Install dpkg-deb package for create repository in folder
120 # Install software-properties-common to get add-apt-repository command
121 # Install apt-transport-https, ca-certificates, curl and gnupg-agent allowing apt to use a repository over HTTPS
123 apt-get install dpkg-dev apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
125 # Add Docker's official GPG key:
126 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
127 apt-key fingerprint 0EBFCD88
129 # Add docker repository
130 add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
132 # Temp fix of known bug
133 # https://bugs.launchpad.net/ubuntu/+source/aptitude/+bug/1543280
134 chown _apt $OFFLINE_REPO_DIR
136 # Download all packages from onap_deb.list via apt-get to repository folder
137 for i in $(cat ${PCKG_LIST_DIR}onap_deb.list | awk '{print $1}');do apt-get download $i -y; done
138 for i in $(cat ${PCKG_LIST_DIR}onap_deb.list | awk '{print $1}');
140 for depends in $(apt-cache depends $i | grep -E 'Depends' | cut -d ':' -f 2,3 | sed -e s/'<'/''/ -e s/'>'/''/);
141 do apt-get download $depends -y;
145 # Download all packages with dependencies from all additional packages lists via apt-get to repository folder
146 if ! [ ${#ADDITIONAL_LISTS[@]} -eq 0 ]; then
147 for list in ${ADDITIONAL_LISTS[@]}
149 for i in $(cat ${ADD_LIST_DIR}$list | awk '{print $1}');do apt-get download $i -y; done
150 for i in $(cat ${ADD_LIST_DIR}$list | awk '{print $1}');
152 for depends in $(apt-cache depends $i | grep -E 'Depends' | cut -d ':' -f 2,3 | sed -e s/'<'/''/ -e s/'>'/''/);
153 do apt-get download $depends -y;
159 # In repository folder create gz package with deb packages
160 dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
164 # Install createrepo package for create repository in folder,
165 # yum-utils due to yum-config-manager for adding docker repository
166 # and epel-release for additional packages (like jq etc.)
167 yum install createrepo yum-utils epel-release -y
169 # Add official docker repository
170 yum-config-manager --add-repo=https://download.docker.com/linux/centos/7/x86_64/stable/
172 # Download all packages from onap_rpm.list via yumdownloader to repository folder
173 for i in $(cat ${PCKG_LIST_DIR}onap_rpm.list | awk '{print $1}');do yumdownloader --resolve --downloadonly --destdir=${OFFLINE_REPO_DIR} $i -y; done
175 # Download all packages from all additional packages lists via apt-get to repository folder
176 if ! [ ${#ADDITIONAL_LISTS[@]} -eq 0 ]; then
177 for list in ${ADDITIONAL_LISTS[@]}
179 for i in $(cat ${ADD_LIST_DIR}$list | awk '{print $1}');do yumdownloader --resolve --downloadonly --destdir=${OFFLINE_REPO_DIR} $i -y; done
184 createrepo $OFFLINE_REPO_DIR
188 echo "Unknown type of linux distribution."