blob: 47dc0ea0d2f0aa7145af0d76e722cf6a4cef946c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#!/usr/bin/env bash
DOWNLOAD_DIR=`pwd`/downloads
DOWNLOAD_URL=http://build.openhpc.community/home:/xtcohpc:/OHPCARM/OpenHPC_1.3_Update1_Factory_CentOS_7/aarch64/
INSTALL_CMD="yum install "
PKG_LIST=package-list.txt
download_packages(){
local line
if [ ! -f "${PKG_LIST}" ]; then
echo "Can not find ${PKG_LIST}"
exit 1
fi
mkdir -p ${DOWNLOAD_DIR}
if [ ! -d ${DOWNLOAD_DIR} ]; then
echo "Can not create download dir:${DOWNLOAD_DIR}"
exit 1
fi
pushd ${DOWNLOAD_DIR}
rm -f *.rpm
popd
cat ${PKG_LIST}|sed -e "s@\#.*@@g"|while read line
do
echo "Download ${line} from ${DOWNLOAD_URL}"
pushd ${DOWNLOAD_DIR}
wget ${DOWNLOAD_URL}/${line}
popd
done
}
install_packages(){
local file
if [ ! -d ${DOWNLOAD_DIR} ]; then
echo "Can not create download dir:${DOWNLOAD_DIR}"
exit 1
fi
pushd ${DOWNLOAD_DIR}
ls -1 *.rpm|while read file
do
echo "Install ${file} ... "
${INSTALL_CMD} ${file}
done
popd
}
remove_downloaded_files(){
if [ ! -d ${DOWNLOAD_DIR} ]; then
echo "Download dir${DOWNLOAD_DIR} does not exist."
return
fi
pushd ${DOWNLOAD_DIR}
ls -1 *.rpm|while read file
do
echo "Remove ${file} ... "
rm -f ${file}
done
popd
if [ -z "$(ls -A ${DOWNLOAD_DIR}/)" ]; then
rmdir ${DOWNLOAD_DIR}
else
echo "Download dir ${DOWNLOAD_DIR} is not empty"
fi
}
main(){
download_packages
install_packages
remove_downloaded_files
}
main $@
|