mirrored from https://gitlab.freedesktop.org/gstreamer/cerbero.git
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathcerbero-uninstalled
More file actions
executable file
·165 lines (149 loc) · 5.18 KB
/
Copy pathcerbero-uninstalled
File metadata and controls
executable file
·165 lines (149 loc) · 5.18 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/sh
#
# This file is an abomination. It executes as both a shell script and a python
# script, and does the same thing in both cases.
#
# Note that this script uses bash syntax but the shebang is `#!/bin/sh` on
# purpose. This is because the bash code only runs on MSYS and `/bin/sh` is
# bash there. macOS will stop shipping bash at some point (post-Catalina), so
# we should not use `#!/bin/bash` as the shebang. Current code is compatible
# on non-MSYS platforms with: bash, dash, zsh.
#
# This is needed because on Windows, python3 is actually `py -3` since all
# Python installations have `python.exe`. We used to use `python3` in the
# shebang, but then Windows folks couldn't use `./cerbero-uninstalled` and had
# to call `py -3 ./cerbero-uninstalled` or `python ./cerbero-uninstalled`
# depending on their python installation.
#
# Now we automatically use `py -3` or `python3` depending on the system.
#
# For backwards-compatibility, we now support all those variants.
"""":
ARGS=$@
SCRIPTDIR="`dirname $0`"
# https://www.msys2.org/news/#2025-02-14-moving-msys2-closer-to-cygwin
if [ "$OSTYPE" = "msys" ] || [ "$OSTYPE" = "cygwin" ]; then
if [ -f "/mingw/bin/mingw-get.exe" ]; then
MSYS_VERSION=1
elif [ -f "/usr/bin/pacman" ]; then
MSYS_VERSION=2
if [ "$MSYSTEM" != "UCRT64" ]; then
echo "MSYS2 must use the UCRT64 environment instead of $MSYSTEM. https://www.msys2.org/docs/environments/";
exit 1;
fi
fi
fi
find_non_msys2_python() {
which -a python | while read i; do
if (( $(echo $i | cut -f2 -d/ | wc -c) > 2 )); then
continue
fi
echo $i
break
done
}
case "$MSYS_VERSION" in
1)
if type -p py &>/dev/null; then
PYTHON="py -3"
else
PYTHON="python"
fi
;;
2)
if type -p py &>/dev/null; then
PYTHON="py -3"
else
PYTHON="$(find_non_msys2_python)"
fi
if test -z "$PYTHON"; then
echo "Could not find a non-MSYS2 Python"
exit 1
fi
# winpty is needed to get stdin working in many cases, but it will
# immediately bail out if run in an environment without stdin, such as
# on CI.
if [ -z "$CI" ]; then
PYTHON="winpty $PYTHON"
fi
;;
*) PYTHON="python3";;
esac
# Use `msysmnt` to get a list of MSYS mount points that the MinGW shell uses.
# That's our reference point for translating from MSYS paths to Win32 paths.
# We assume that the MSYS mount point directories are only in the filesystem
# root. This will break if people add their own custom mount points beyond what
# MSYS automatically creates, which is highly unlikely.
#
# /d -> d:/
# /c -> c:/
# /d/projects/cerbero -> d:/projects/cerbero/
# /home/USERNAME/cerbero -> C:\\MinGW\\msys\\1.0/home/USERNAME/
# /mingw -> C:\\MinGW/
# /mingw/bin/foobar -> C:\\MinGW\\bin/foobar/
# /tmp/baz -> C:\\Users\\USERNAME\\AppData\\Local\\Temp/baz/
msys_dir_to_win32() {
set -e
local msys_path stripped_path mount_point path mounted_path
# If the path is already a native path, just return that
if [[ $1 == ?':/'* ]] || [[ $1 == ?':\\'* ]]; then
echo $1
return
fi
# Convert /c or /mingw etc to /c/ or /mingw/ etc; gives us a necessary
# anchor to split the path into components
msys_path="$1/"
# Strip leading slash
stripped_path="${msys_path#/}"
# Get the first path component, which may be a mount point
mount_point="/${stripped_path%%/*}"
# Get the path inside the mountp oint
path="/${stripped_path#*/}"
mounted_path="$(msysmnt | sed -n "s|\(.*\) on $mount_point type.*|\1|p")"
# If it's not a mounted path (like /c or /tmp or /mingw), then it's in the
# general MSYS root mount
if [[ -z $mounted_path ]]; then
mounted_path="$(msysmnt | sed -n "s|\(.*\) on / type.*|\1|p")"
path="$1"
fi
echo ${mounted_path}${path}
}
get_scriptdir() {
case "$MSYS_VERSION" in
*1) msys_dir_to_win32 "$SCRIPTDIR";;
*2) cygpath -m -C ANSI "$SCRIPTDIR";;
*) echo $SCRIPTDIR;;
esac
}
$PYTHON -c """
import os
import sys
import shlex
os.environ['CERBERO_UNINSTALLED'] = '1'
if not sys.version_info >= (3, 9, 0):
print('We require Python 3.9 or newer, but you have {}'.format(sys.version), file=sys.stderr)
sys.exit(1)
# __file__ is not set when we're called with -c
if '__file__' in locals():
curdir = os.path.dirname(__file__)
else:
curdir = '`get_scriptdir`'
sys.path.insert(0, os.path.abspath(curdir))
# Need to set sys.argv since we can't pass args when called with -c
if sys.argv == ['-c']:
sys.argv = ['$0'] + shlex.split('$ARGS')
# Env vars that can affect our build
cleanup = (
'GIO_EXTRA_MODULES', 'PYGI_DLL_DIRS', 'GI_TYPELIB_PATH',
'GST_PLUGIN_SCANNER', 'GST_PLUGIN_SCANNER_1_0', 'GST_REGISTRY_1_0',
'GST_REGISTRY', 'GST_PLUGIN_SYSTEM_PATH', 'GST_PLUGIN_SYSTEM_PATH_1_0',
'GST_PLUGIN_PATH', 'GST_PLUGIN_PATH_1_0', 'GST_PYTHONPATH',
'GST_PYTHONPATH_1_0', 'LD_LIBRARY_PATH', 'DYLD_LIBRARY_PATH',
'PKG_CONFIG_PATH', 'PKG_CONFIG_LIBDIR',
)
for v in cleanup:
if v in os.environ:
os.environ.pop(v)
from cerbero.main import main
main()
#"""