3 # Set type of distribution where script is running
4 distro_type=$(cat /etc/*-release | grep -w "ID" | awk -F'=' '{ print $2 }' | tr -d '"')
13 echo "Unknown type of linux distribution."
18 # Path where will be created repository (in container)
21 # Path where is stored onap_rpm.list and onap_deb.list file
24 # Path where is stored additional packages lists
27 # Show help for using this script
30 Docker entrypoint script for creating RPM/DEB repository based on linux distribution where script is running
32 usage: create-repo.sh [-d|--directory output directory] [-l|--list input rpm/deb list directory] [-a|--additional-lists list1.list]
33 -h --help: Show this help
34 -d --directory: set path for repo directory in container
35 -l --list: set path where rpm or deb list is stored in container
36 -a --additional-list: add name of additional packages list
37 can be used multiple times for more additional lists
38 -p --packages-lists-path: set path for other additional packages lists
40 Both paths have to be set with shared volume between
41 container and host computer. 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 parametters
49 if [[ $# -eq 0 ]] ; then
62 # Directory parametter
63 # Sets path where will be created reposity
68 # Sets path where is stored onap_rpm.list or onap_deb.list file
71 -p|--packages-lists-path)
73 # Sets path where is stored additional packages lists
77 # Array of additional packages lists
78 ADDITIONAL_LISTS+=("$2")
89 # Testing if directory parametter was used
90 # If not variable is sets to default value:
91 # /tmp/repo/resources/pkg/rpm
93 # /tmp/repo/resources/pkg/deb
94 if test -z "$OFFLINE_REPO_DIR"
96 OFFLINE_REPO_DIR="/tmp/repo/"
99 # Testing if list parametter was used
100 # If not variable is sets to default value /tmp/offline/data-list
101 if test -z "$PCKG_LIST_DIR"
103 PCKG_LIST_DIR="/tmp/offline/data_list/"
106 # Testing if additional packages list parametter was used
107 # If not variable is sets to default value /tmp/additional-lists
108 if test -z "$PCKG_LIST_DIR"
110 PCKG_LIST_DIR="/tmp/additional-lists/"
113 case "$distro_type" in
115 # Change current working dir
116 pushd $OFFLINE_REPO_DIR
118 # Install dpkg-deb package for create repository in folder
119 # Install software-properties-common to get add-apt-repository command
120 # Install apt-transport-https, ca-certificates, curl and gnupg-agent allowing apt to use a repository over HTTPS
122 apt-get install dpkg-dev apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
124 # Add Docker's official GPG key:
125 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
126 apt-key fingerprint 0EBFCD88
128 # Add docker repository
129 add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
131 # Temp fix of known bug
132 # https://bugs.launchpad.net/ubuntu/+source/aptitude/+bug/1543280
133 chown _apt $OFFLINE_REPO_DIR
135 # Download all packages from onap_deb.list via apt-get to repository folder
136 for i in $(cat ${PCKG_LIST_DIR}onap_deb.list | awk '{print $1}');do apt-get download $i -y; done
137 for i in $(cat ${PCKG_LIST_DIR}onap_deb.list | awk '{print $1}');
139 for depends in $(apt-cache depends $i | grep -E 'Depends' | cut -d ':' -f 2,3 | sed -e s/'<'/''/ -e s/'>'/''/);
140 do apt-get download $depends -y;
144 # Download all packages with dependecies from all additional packages lists via apt-get to repository folder
145 if ! [ ${#ADDITIONAL_LISTS[@]} -eq 0 ]; then
146 for list in ${ADDITIONAL_LISTS[@]}
148 for i in $(cat ${ADD_LIST_DIR}$list | awk '{print $1}');do apt-get download $i -y; done
149 for i in $(cat ${ADD_LIST_DIR}$list | awk '{print $1}');
151 for depends in $(apt-cache depends $i | grep -E 'Depends' | cut -d ':' -f 2,3 | sed -e s/'<'/''/ -e s/'>'/''/);
152 do apt-get download $depends -y;
158 # In repository folder create gz package with deb packages
159 dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
163 # Install createrepo package for create repository in folder,
164 # yum-utils due to yum-config-manager for adding docker repository
165 # and epel-release for additional packages (like jq etc.)
166 yum install createrepo yum-utils epel-release -y
168 # Add official docker repository
169 yum-config-manager --add-repo=https://download.docker.com/linux/centos/7/x86_64/stable/
171 # Download all packages from onap_rpm.list via yumdownloader to repository folder
172 for i in $(cat ${PCKG_LIST_DIR}onap_rpm.list | awk '{print $1}');do yumdownloader --resolve --downloadonly --destdir=${OFFLINE_REPO_DIR} $i -y; done
174 # Download all packages from all additional packages lists via apt-get to repository folder
175 if ! [ ${#ADDITIONAL_LISTS[@]} -eq 0 ]; then
176 for list in ${ADDITIONAL_LISTS[@]}
178 for i in $(cat ${ADD_LIST_DIR}$list | awk '{print $1}');do yumdownloader --resolve --downloadonly --destdir=${OFFLINE_REPO_DIR} $i -y; done
182 # In repository folder create repositor
183 createrepo $OFFLINE_REPO_DIR
187 echo "Unknown type of linux distribution."