forked from libretro/Lakka-LibreELEC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_libretro_tarball.sh
executable file
·113 lines (92 loc) · 2.6 KB
/
get_libretro_tarball.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
# This script downloads a tarball of libretro package (packages/libretro) and extracts
# this tarball to sources/<package> folder.
# It is usefull in cases when the core repository was force-pushed and it is not possible
# to clone / checkout the the desired commit, which breaks the build.
# Where are the tarballs hosted
URL="https://nightly.builds.lakka.tv"
# Check arguments and print usage
[ $# -ne 1 ] && {
echo "Usage:"
echo "$0 <package>"
echo ""
echo "Download tarball from ${URL} and store it in sources/<package> folder"
exit 1
}
PKG=${1}
PKG_PATH=""
# Check if there is such package
for FINDPATH in packages/lakka/retroarch_base/${PKG} packages/lakka/libretro_cores/${PKG} ; do
if [ -d ${FINDPATH} ] ; then
PKG_PATH=${FINDPATH}
break
fi
done
[ -z "${PKG_PATH}" ] && {
echo "There is no package '${PKG}' in packages/lakka/retroarch_base and package/lakka/libretro_cores"
exit 2
}
# Check if we have package.mk
[ ! -f ${PKG_PATH}/package.mk ] && {
echo "Missing package.mk in ${PKG_PATH}"
exit 3
}
# Import package properties
source ${PKG_PATH}/package.mk 2>&1 >/dev/null
# Check for package version, URL and that URL is git repo
[ -z "${PKG_VERSION}" ] && {
echo "No PKG_VERSION set in ${PKG_PATH}/package.mk"
exit 4
}
[ -z "${PKG_URL}" ] && {
echo "No PKG_URL set in ${PKG_PATH}/package.mk"
exit 4
}
[ "${PKG_URL: -4}" = ".git" -o "${PKG_URL:0:6}" = "git://" ] || {
echo "PKG_URL (${PKG_URL}) is not a git repository"
exit 4
}
LINK=${URL}/sources/${PKG}/${PKG}-${PKG_VERSION}.tar.xz
FILENAME=sources/${PKG}/${PKG}-${PKG_VERSION}.tar.xz
STAMPFILE=${FILENAME}.gitstamp
# Do not continue when a tarball is already present in the sources folder
# (also safety catch in case this script is started on the server, where the tarballs are hosted)
[ -f ${FILENAME} ] && {
echo "There is already ${FILENAME} - remove it and try again"
exit 5
}
[ -f ${STAMPFILE} ] && {
echo "There is already ${STAMPFILE} - remove it and try again"
exit 5
}
# Create folder in case it does not exist already
if [ ! -d sources/${PKG} ]
then
if [ ! -f sources/${PKG} ]
then
mkdir -p sources/${PKG}
else
echo "Cannot create folder sources/$PKG - file exists"
exit 6
fi
fi
# Check if we have wget
[ -z "$(which ${PRG} 2>/dev/null)" ] && {
echo "Please install ${PRG}"
exit 7
}
# Download the tarball
echo "Downloading to ${FILENAME} ..."
wget --quiet -O ${FILENAME} ${LINK}
[ ${?} -gt 0 ] && {
echo "Error downloading ${LINK}"
exit 8
}
echo "Creating ${STAMPFILE} ..."
echo "${PKG_URL}|${PKG_VERSION}" > ${STAMPFILE}
[ ${?} -gt 0 ] && {
echo "Error creating ${STAMPFILE}"
exit 8
}
# And we are done
echo "Done"