Merge "Fix relative path in package.py"
[oom/offline-installer.git] / build / docker-entrypoint.sh
1 #!/usr/bin/env bash
2
3 # Path where will be created repository (in container)
4 OFFLINE_REPO_DIR=""
5
6 # Path where is stored onap_rpm.list file
7 RPM_LIST_DIR=""
8
9 help () {
10     echo -e "Docker entrypoint script for creating RPM repository\n"
11     echo "usage: create-repo.sh [-d|--directory output directory] [-l|--list input rpm list directory]"
12     echo "-h --help: Show this help"
13     echo "-d --directory: set path for repo directory in container"
14     echo -e "-l --list: set path where rpm list is stored in container\n"
15     echo "Both paths have to be set with shared volume between"
16     echo "container and host computer. Default path in container is: /tmp/"
17     echo "Repository will be created at: /<path>/resources/pkg/rpm/"
18     echo "RMP list is stored at: ./data_list/"
19 }
20
21 # Getting input parametters
22 POSITIONAL=()
23 if [[ $# -eq 0 ]] ; then
24     help # show help
25     exit 0
26 fi
27 while [[ $# -gt 0 ]]
28 do
29     case "$1" in
30         -h|--help)
31             # Help parametter
32             help # show help
33             exit
34             ;;
35         -d|--directory)
36             # Directory parametter
37             # Sets path where will be created reposity
38             OFFLINE_REPO_DIR="$2"
39             ;;
40         -l|--list)
41             # List parametter
42             # Sets path where is stored onap_rpm.list file
43             RPM_LIST_DIR="$2"
44             ;;
45         *)
46             # unknown option
47             help # show help
48             exit
49             ;;
50     esac
51     shift;shift
52 done
53
54 # Testing if directory parametter was used
55 # If not variable is sets to default value /tmp/repo/resources/pkg/rpm
56 if test -z "$OFFLINE_REPO_DIR"
57 then
58     OFFLINE_REPO_DIR="/tmp/repo/"
59 fi
60
61 # Testing if list parametter was used
62 # If not variable is sets to default value /tmp/offline/data-list
63 if test -z "$RPM_LIST_DIR"
64 then
65     RPM_LIST_DIR="/tmp/offline/data_list/"
66
67 fi
68
69 # Install createrepo package for create repository in folder
70 # and yum-utils due to yum-config-manager for adding docker repository
71 yum install createrepo yum-utils -y
72
73 # Add official docker repository
74 yum-config-manager --add-repo=https://download.docker.com/linux/centos/7/x86_64/stable/
75
76 # Download all packages from onap_rpm.list via yumdownloader to repository folder
77 for i in $(cat ${RPM_LIST_DIR}onap_rpm.list | awk '{print $1}');do yumdownloader --resolve --downloadonly --destdir=${OFFLINE_REPO_DIR} $i -y; done
78
79 # In repository folder create repository
80 createrepo $OFFLINE_REPO_DIR