Subversion Repositories ALCASAR

Compare Revisions

No changes between revisions

Ignore whitespace Rev 2476 → Rev 2477

/iso/scripts/download_needed_rpm.sh
0,0 → 1,105
#!/bin/bash
#
# Author: Hamza ESSAYEGH (Querdos)
#
# Script used to download all needed package
# for Alcasar.
#
# It must be run on a virtual Mageia 5,
# with ALCASAR installed.
#
 
function print_percentage() {
local percent=$1
if [ ${percent} -lt 5 ]; then
echo -ne "Downloading... [ ] ${percent}%\r"
elif [ ${percent} -lt 10 ]; then
echo -ne "Downloading... [ # ] ${percent}%\r"
elif [ ${percent} -lt 15 ]; then
echo -ne "Downloading... [ ## ] ${percent}%\r"
elif [ ${percent} -lt 20 ]; then
echo -ne "Downloading... [ ### ] ${percent}%\r"
elif [ ${percent} -lt 25 ]; then
echo -ne "Downloading... [ #### ] ${percent}%\r"
elif [ ${percent} -lt 30 ]; then
echo -ne "Downloading... [ ##### ] ${percent}%\r"
elif [ ${percent} -lt 35 ]; then
echo -ne "Downloading... [ ###### ] ${percent}%\r"
elif [ ${percent} -lt 40 ]; then
echo -ne "Downloading... [ ####### ] ${percent}%\r"
elif [ ${percent} -lt 45 ]; then
echo -ne "Downloading... [ ######## ] ${percent}%\r"
elif [ ${percent} -lt 50 ]; then
echo -ne "Downloading... [ ######### ] ${percent}%\r"
elif [ ${percent} -lt 55 ]; then
echo -ne "Downloading... [ ########## ] ${percent}%\r"
elif [ ${percent} -lt 60 ]; then
echo -ne "Downloading... [ ########### ] ${percent}%\r"
elif [ ${percent} -lt 65 ]; then
echo -ne "Downloading... [ ############ ] ${percent}%\r"
elif [ ${percent} -lt 70 ]; then
echo -ne "Downloading... [ ############# ] ${percent}%\r"
elif [ ${percent} -lt 75 ]; then
echo -ne "Downloading... [ ############## ] ${percent}%\r"
elif [ ${percent} -lt 80 ]; then
echo -ne "Downloading... [ ############### ] ${percent}%\r"
elif [ ${percent} -lt 85 ]; then
echo -ne "Downloading... [ ################ ] ${percent}%\r"
elif [ ${percent} -lt 90 ]; then
echo -ne "Downloading... [ ################# ] ${percent}%\r"
elif [ ${percent} -lt 95 ]; then
echo -ne "Downloading... [ ################## ] ${percent}%\r"
elif [ ${percent} -lt 100 ]; then
echo -ne "Downloading... [ ################### ] ${percent}%\r"
elif [ ${percent} == 100 ]; then
echo -ne "Downloading... [ #################### ] ${percent}%\r"
fi
}
 
# Colors parameters
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'
 
# Config and RPMS directory
#CONFIG_DIR=$(pwd)"/config"
RPMS_DIR=$(pwd)"/rpms"
CONFIG_FILE=$(pwd)"/alcasar_rpms_x86_64"
 
# Retrieving list of installed RPMS
rpm -qa > ${CONFIG_FILE}
 
# Checking if RPMS dir exists and create it if needed
[[ ! -d ${RPMS_DIR} ]] && mkdir ${RPMS_DIR}
 
# Retrieving files in configuration file
files=$(cat ${CONFIG_FILE})
 
# params for percentage
total=$(wc -l < ${CONFIG_FILE})
count=0
 
# for each package in configuration file
echo -e "${YELLOW}This step may take some time, depending on your connection ...${NC}"
for pckg in ${files}; do
let percent="${count} * 100 / ${total}"
print_percentage ${percent}
 
url=$(urpmq --ignorearch --sources ${pckg} | grep 'updates\|release' | uniq)
wget -P "${RPMS_DIR}" "${url}" --quiet
 
let count="${count}+1"
done
 
echo "Creating the tarball ..."
 
# Creating the tarball
cd ${RPMS_DIR} && tar -czf rpms-x86_64.tar.gz *
 
# Moving it in the root directory
mv rpms-x86_64.tar.gz ../
rm -rf ${RPMS_DIR}
 
echo "Done"
echo
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:executable
+*
\ No newline at end of property