3 # Set distribution family
4 distro_type=$(cat /etc/*-release | grep -w "ID" | awk -F'=' '{ print $2 }' | tr -d '"')
13 echo "Unknown type of linux distribution."
18 # Target path for created repository
21 # Path to directory containing onap_rpm.list and onap_deb.list files
24 # Path to additional packages lists
30 Docker entrypoint script for creating RPM/DEB repository based on container platform type
32 usage: create-repo.sh [OPTION]...
34 -d | --directory target repository path
35 -l | --list input rpm/deb list directory
36 -a | --additional-list additional packages list; can be used multiple times
37 -p | --packages-lists-path other additional packages lists
38 -h | --help show this help
40 Both paths have to be set with shared volume between
41 container and the host. Default path in container is: /tmp/
42 Repository will be created at: /<path>/resources/pkg/rhel/
43 RMP/DEB list is stored at: ./data_list/
47 # Getting input parameters
49 if [[ $# -eq 0 ]] ; then
63 # Set target reposity path
68 # Set path containing onap_rpm.list or onap_deb.list file
71 -p|--packages-lists-path)
73 # Set path for additional packages lists
77 # Array of additional packages lists
78 ADDITIONAL_LISTS+=("$2")
89 # Testing if directory parameter was used
90 # If not variable is set to /tmp/repo by default
91 if test -z "$OFFLINE_REPO_DIR"
93 OFFLINE_REPO_DIR="/tmp/repo/"
96 # Testing if list parameter was used
97 # If not variable is set to default value /tmp/offline/data-list
98 if test -z "$PCKG_LIST_DIR"
100 PCKG_LIST_DIR="/tmp/offline/data_list/"
103 # Testing if additional packages list parameter was used
104 # If not variable is set to default value /tmp/additional-lists
105 if test -z "$PCKG_LIST_DIR"
107 PCKG_LIST_DIR="/tmp/additional-lists/"
110 case "$distro_type" in
112 # Change current working dir
113 pushd $OFFLINE_REPO_DIR
115 # Install dpkg-deb package for create repository in folder
116 # Install software-properties-common to get add-apt-repository command
117 # Install apt-transport-https, ca-certificates, curl and gnupg-agent allowing apt to use a repository over HTTPS
119 apt-get install dpkg-dev apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
121 # Add Docker's official GPG key:
122 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
123 apt-key fingerprint 0EBFCD88
125 # Add docker repository
126 add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
128 # Temp fix of known bug
129 # https://bugs.launchpad.net/ubuntu/+source/aptitude/+bug/1543280
130 chown _apt $OFFLINE_REPO_DIR
132 # Download all packages from onap_deb.list via apt-get to repository folder
133 for i in $(cat ${PCKG_LIST_DIR}onap_deb.list | awk '{print $1}');do apt-get download $i -y; done
134 for i in $(cat ${PCKG_LIST_DIR}onap_deb.list | awk '{print $1}');
136 for depends in $(apt-cache depends $i | grep -E 'Depends' | cut -d ':' -f 2,3 | sed -e s/'<'/''/ -e s/'>'/''/);
137 do apt-get download $depends -y;
141 # Download all packages with dependencies from all additional packages lists via apt-get to repository folder
142 if ! [ ${#ADDITIONAL_LISTS[@]} -eq 0 ]; then
143 for list in ${ADDITIONAL_LISTS[@]}
145 for i in $(cat ${ADD_LIST_DIR}$list | awk '{print $1}');do apt-get download $i -y; done
146 for i in $(cat ${ADD_LIST_DIR}$list | awk '{print $1}');
148 for depends in $(apt-cache depends $i | grep -E 'Depends' | cut -d ':' -f 2,3 | sed -e s/'<'/''/ -e s/'>'/''/);
149 do apt-get download $depends -y;
155 # In repository folder create gz package with deb packages
156 dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
160 # Install createrepo package for create repository in folder,
161 # yum-utils due to yum-config-manager for adding docker repository
162 # and epel-release for additional packages (like jq etc.)
163 yum install createrepo yum-utils epel-release -y
165 # Add official docker repository
166 yum-config-manager --add-repo=https://download.docker.com/linux/centos/7/x86_64/stable/
168 # Download all packages from onap_rpm.list via yumdownloader to repository folder
169 for i in $(cat ${PCKG_LIST_DIR}onap_rpm.list | awk '{print $1}');do yumdownloader --resolve --downloadonly --destdir=${OFFLINE_REPO_DIR} $i -y; done
171 # Download all packages from all additional packages lists via apt-get to repository folder
172 if ! [ ${#ADDITIONAL_LISTS[@]} -eq 0 ]; then
173 for list in ${ADDITIONAL_LISTS[@]}
175 for i in $(cat ${ADD_LIST_DIR}$list | awk '{print $1}');do yumdownloader --resolve --downloadonly --destdir=${OFFLINE_REPO_DIR} $i -y; done
180 createrepo $OFFLINE_REPO_DIR
184 echo "Unknown type of linux distribution."