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