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
25 echo -e "Docker entrypoint script for creating RPM/DEB repository based on linux distribution where script is running\n"
26 echo "usage: create-repo.sh [-d|--directory output directory] [-l|--list input rpm/deb list directory]"
27 echo "-h --help: Show this help"
28 echo "-d --directory: set path for repo directory in container"
29 echo -e "-l --list: set path where rpm or deb list is stored in container\n"
30 echo "Both paths have to be set with shared volume between"
31 echo "container and host computer. Default path in container is: /tmp/"
32 echo "Repository will be created at: /<path>/resources/pkg/rhel/"
33 echo "RMP/DEB list is stored at: ./data_list/"
36 # Getting input parametters
38 if [[ $# -eq 0 ]] ; then
51 # Directory parametter
52 # Sets path where will be created reposity
57 # Sets path where is stored onap_rpm.list or onap_deb.list file
69 # Testing if directory parametter was used
70 # If not variable is sets to default value:
71 # /tmp/repo/resources/pkg/rpm
73 # /tmp/repo/resources/pkg/deb
74 if test -z "$OFFLINE_REPO_DIR"
76 OFFLINE_REPO_DIR="/tmp/repo/"
79 # Testing if list parametter was used
80 # If not variable is sets to default value /tmp/offline/data-list
81 if test -z "$PCKG_LIST_DIR"
83 PCKG_LIST_DIR="/tmp/offline/data_list/"
86 case "$distro_type" in
88 # Change current working dir
89 pushd $OFFLINE_REPO_DIR
91 # Install dpkg-deb package for create repository in folder
92 # Install software-properties-common to get add-apt-repository command
93 # Install apt-transport-https, ca-certificates, curl and gnupg-agent allowing apt to use a repository over HTTPS
95 apt-get install dpkg-dev apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
97 # Add Docker's official GPG key:
98 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
99 apt-key fingerprint 0EBFCD88
101 # Add docker repository
102 add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
104 # Temp fix of known bug
105 # https://bugs.launchpad.net/ubuntu/+source/aptitude/+bug/1543280
106 chown _apt $OFFLINE_REPO_DIR
108 # Download all packages from onap_deb.list via apt-get to repository folder
109 for i in $(cat ${PCKG_LIST_DIR}onap_deb.list | awk '{print $1}');do apt-get download $i -y; done
110 for i in $(cat ${PCKG_LIST_DIR}onap_deb.list | awk '{print $1}');
112 for depends in $(apt-cache depends $i | grep -E 'Depends' | cut -d ':' -f 2,3 | sed -e s/'<'/''/ -e s/'>'/''/);
113 do apt-get download $depends -y;
117 # In repository folder create gz package with deb packages
118 dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
122 # Install createrepo package for create repository in folder
123 # and yum-utils due to yum-config-manager for adding docker repository
124 yum install createrepo yum-utils -y
126 # Add official docker repository
127 yum-config-manager --add-repo=https://download.docker.com/linux/centos/7/x86_64/stable/
129 # Download all packages from onap_rpm.list via yumdownloader to repository folder
130 for i in $(cat ${PCKG_LIST_DIR}onap_rpm.list | awk '{print $1}');do yumdownloader --resolve --downloadonly --destdir=${OFFLINE_REPO_DIR} $i -y; done
132 # In repository folder create repositor
133 createrepo $OFFLINE_REPO_DIR
137 echo "Unknown type of linux distribution."