blob: f468e7294f74b1d4299fa8c6f01ca325b9b04a3c (
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
|
#!/bin/sh
[ -f /usr/lib/colors.sh ] && . /usr/lib/colors.sh
if [ $# = 0 ]; then
printf "Name of package: python-"
read name
else
name=$1
fi
json_url=https://pypi.org/pypi/$name/json
if [ "$(curl -s -o /dev/null -w "%{http_code}" $json_url)" != 200 ] ; then
echo "Failed to find $name"
exit 1
fi
json=$(curl -SsL $json_url)
version=$(printf "%s" "$json" | jq -r '.info.version')
desc=$(printf "%s" "$json" | jq -r '.info.summary')
#url=$(printf "%s" "$json" | jq -r '.urls[] | select((.version="1.0.3")) | .url' | grep -v "whl" | sed "s/$version/\$PKG_VER/g")
url="https://files.pythonhosted.org/packages/source/${name%${name#?}}/$name/$name-\$PKG_VER.tar.gz"
deps=$(printf "%s" "$json" | jq -r '.info.requires_dist | .[]' | cut -d' ' -f1 | tr '\n' ' ')
if [ ${#deps} != 0 ]; then
package_deps=$(echo $deps | sed 's/\(\w*\)/python-\1/g')
echo $package_deps
fi
echo PKG_VER: $version
echo DESC: $desc
echo SOURCE: $url
echo DEPS: $package_deps
file=repo/python-$name/python-$name.xibuild
inp=templates/pypi.xibuild
if [ -f $file ]; then
inp=$file
echo "replacing existing"
fi
tmp=/tmp/python-$name.xibuild
rm -f $tmp
cat $inp > $tmp
sed -i "s@^SOURCE=.*@SOURCE=$url@g" $tmp
sed -i "s@^PKG_VER=.*@PKG_VER=$version@g" $tmp
sed -i "s@^DESC=.*@DESC=\"$desc\"@g" $tmp
if [ ${#deps} != 0 ]; then
printf "${LIGHT_BLUE}Please ensure the following exist: ${BLUE}${deps}${RESET}\n"
sed -i "s/^DEPS=.*/DEPS=\"$package_deps\"/g" $tmp
fi
mkdir -p repo/python-$name
mv $tmp $file
printf "${GREEN}Written to $file${RESET}\n"
|