forked from ValveSoftware/steam-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-packages.sh
executable file
·84 lines (68 loc) · 1.95 KB
/
update-packages.sh
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
82
83
84
#!/bin/bash
#
# Script to update packages used by the Steam runtime
# The top level directory
TOP=$(cd "${0%/*}" && echo ${PWD})
cd "${TOP}"
# These are custom packages that can't be automatically downloaded
CUSTOM_PACKAGES="dummygl jasper libsdl1.2 libsdl2 libsdl2-image libsdl2-mixer libsdl2-net libsdl2-ttf"
valid_package()
{
PACKAGE=$1
for SOURCE_PACKAGE in $(cat packages.txt | egrep -v '^#' | awk '{print $1}'); do
if [ "${SOURCE_PACKAGE}" = "${PACKAGE}" ]; then
return 0
fi
done
echo "Couldn't find source package ${PACKAGE} in packages.txt" >&2
return 1
}
update_package()
{
PACKAGE=$1
DIR="${TOP}/packages/source/${PACKAGE}"
# Check for custom packages
for CUSTOM in ${CUSTOM_PACKAGES}; do
if [ "${PACKAGE}" = "${CUSTOM}" ]; then
echo "CUSTOM: ${PACKAGE}"
return
fi
done
echo "CHECKING: ${PACKAGE}"
# Download the new dsc file and see if it's a newer version
TMP="${DIR}/tmp"
rm -rf "${TMP}"
mkdir -p "${TMP}"; cd "${TMP}"
apt-get source --download-only --dsc-only "${PACKAGE}" >/dev/null || exit 3
DSC=$(echo *.dsc)
cd "${DIR}"
if [ ! -f "${DSC}" ]; then
echo "DOWNLOADING: ${PACKAGE}"
# Back up old files
OLD="${DIR}/old-versions"
mkdir -p "${OLD}"
for file in *.*; do
if [ -f "${file}" ]; then
mv -v "${file}" "${OLD}/"
fi
done
# Download new files
apt-get source --download-only "${PACKAGE}" || exit 4
touch .downloaded
fi
rm -rf "${TMP}"
cd "${TOP}"
}
# Update the packages
if [ "$1" != "" ]; then
for PACKAGE in "$@"; do
if valid_package "${PACKAGE}"; then
update_package "${PACKAGE}"
fi
done
else
for SOURCE_PACKAGE in $(cat packages.txt | egrep -v '^#' | awk '{print $1}'); do
update_package "${SOURCE_PACKAGE}"
done
fi
# vi: ts=4 sw=4 expandtab