Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
2477 richard 1
#!/bin/bash
2
#
3
# Author: Hamza ESSAYEGH (Querdos)
4
#
5
# Script used to download all needed package
6
# for Alcasar.
7
#
8
# It must be run on a virtual Mageia 5,
9
# with ALCASAR installed.
10
#
11
 
12
function print_percentage() {
13
    local percent=$1
14
    if [ ${percent} -lt 5 ]; then
15
        echo -ne "Downloading... [                      ] ${percent}%\r"
16
    elif [ ${percent} -lt 10 ]; then
17
        echo -ne "Downloading... [ #                    ] ${percent}%\r"
18
    elif [  ${percent} -lt 15  ]; then
19
        echo -ne "Downloading... [ ##                   ] ${percent}%\r"
20
    elif [  ${percent} -lt 20  ]; then
21
        echo -ne "Downloading... [ ###                  ] ${percent}%\r"
22
    elif [  ${percent} -lt 25  ]; then
23
        echo -ne "Downloading... [ ####                 ] ${percent}%\r"
24
    elif [  ${percent} -lt 30  ]; then
25
        echo -ne "Downloading... [ #####                ] ${percent}%\r"
26
    elif [  ${percent} -lt 35  ]; then
27
        echo -ne "Downloading... [ ######               ] ${percent}%\r"
28
    elif [  ${percent} -lt 40  ]; then
29
        echo -ne "Downloading... [ #######              ] ${percent}%\r"
30
    elif [  ${percent} -lt 45  ]; then
31
        echo -ne "Downloading... [ ########             ] ${percent}%\r"
32
    elif [  ${percent} -lt 50  ]; then
33
        echo -ne "Downloading... [ #########            ] ${percent}%\r"
34
    elif [  ${percent} -lt 55  ]; then
35
        echo -ne "Downloading... [ ##########           ] ${percent}%\r"
36
    elif [  ${percent} -lt 60  ]; then
37
        echo -ne "Downloading... [ ###########          ] ${percent}%\r"
38
    elif [  ${percent} -lt 65  ]; then
39
        echo -ne "Downloading... [ ############         ] ${percent}%\r"
40
    elif [  ${percent} -lt 70  ]; then
41
        echo -ne "Downloading... [ #############        ] ${percent}%\r"
42
    elif [  ${percent} -lt 75  ]; then
43
        echo -ne "Downloading... [ ##############       ] ${percent}%\r"
44
    elif [  ${percent} -lt 80  ]; then
45
        echo -ne "Downloading... [ ###############      ] ${percent}%\r"
46
    elif [  ${percent} -lt 85  ]; then
47
        echo -ne "Downloading... [ ################     ] ${percent}%\r"
48
    elif [  ${percent} -lt 90  ]; then
49
        echo -ne "Downloading... [ #################    ] ${percent}%\r"
50
    elif [  ${percent} -lt 95  ]; then
51
        echo -ne "Downloading... [ ##################   ] ${percent}%\r"
52
    elif [  ${percent} -lt 100  ]; then
53
        echo -ne "Downloading... [ ###################  ] ${percent}%\r"
54
    elif [  ${percent} == 100  ]; then
55
        echo -ne "Downloading... [ #################### ] ${percent}%\r"
56
    fi
57
}
58
 
59
# Colors parameters
60
RED='\033[0;31m'
61
GREEN='\033[0;32m'
62
YELLOW='\033[0;33m'
63
NC='\033[0m'
64
 
65
# Config and RPMS directory
66
#CONFIG_DIR=$(pwd)"/config"
67
RPMS_DIR=$(pwd)"/rpms"
68
CONFIG_FILE=$(pwd)"/alcasar_rpms_x86_64"
69
 
70
# Retrieving list of installed RPMS
71
rpm -qa > ${CONFIG_FILE}
72
 
73
# Checking if RPMS dir exists and create it if needed
74
[[ ! -d ${RPMS_DIR} ]] && mkdir ${RPMS_DIR}
75
 
76
# Retrieving files in configuration file
77
files=$(cat ${CONFIG_FILE})
78
 
79
# params for percentage
80
total=$(wc -l < ${CONFIG_FILE})
81
count=0
82
 
83
# for each package in configuration file
84
echo -e "${YELLOW}This step may take some time, depending on your connection ...${NC}"
85
for pckg in ${files}; do
86
    let percent="${count} * 100 / ${total}"
87
    print_percentage ${percent}
88
 
89
    url=$(urpmq --ignorearch --sources ${pckg} | grep 'updates\|release' | uniq)
90
    wget -P "${RPMS_DIR}" "${url}" --quiet
91
 
92
    let count="${count}+1"
93
done
94
 
95
echo "Creating the tarball ..."
96
 
97
# Creating the tarball
98
cd ${RPMS_DIR} && tar -czf rpms-x86_64.tar.gz * 
99
 
100
# Moving it in the root directory
101
mv rpms-x86_64.tar.gz ../
102
rm -rf ${RPMS_DIR}
103
 
104
echo "Done"
105
echo