/
fix-download64.sh
95 lines (76 loc) · 1.76 KB
/
fix-download64.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
#!/bin/bash
# This script changes the given package .info file so that the DOWNLOAD/MD5SUM
# entries are disabled in favor of DOWNLOAD_x86_64 and MD5SUM_x86_64
set -eEu
usage()
{
cat << EOF
Usage:
"$(basename "$0")" PACKAGE_NAME
or
"$(basename "$0")" FILE
In the first form, it will search for a package named PACKAGE_NAME in the
repository and fix the DOWNLOAD/MD5SUM entries so that the normal ones are
disabled and only the DOWNLOAD_x86_64/MD5SUM_x86_64 ones are active.
In the second form, it will read the package names from the given FILE (one per line)
and fix the DOWNLOAD/MD5SUM entries for each package
EOF
}
# Args:
# $1 - package name
fix_package()
{
local info pkgnam
pkgnam="${1:-'missing package name!'}"
echo "going to fix package $pkgnam"
info="$(find . -type f -name "$pkgnam.info")"
if [ -z "$info" ]
then
echo "could not find $pkgnam.info file!"
return 1
fi
. "$info"
if [ "$DOWNLOAD" = UNSUPPORTED ] && [ -z "$MD5SUM" ]
then
echo "DOWNLOAD already set to UNSUPPORTED and MD5SUM removed. Nothing to do."
return 0
fi
if [ "$DOWNLOAD_x86_64" ] || [ "$MD5SUM_x86_64" ]
then
echo "DOWNLOAD_x86_64 already set to $DOWNLOAD_x86_64 or MD5SUM_x86_64 already set to $MD5SUM_x86_64!"
return 2
fi
cat << EOF > "$info"
PRGNAM="$PRGNAM"
VERSION="$VERSION"
HOMEPAGE="$HOMEPAGE"
DOWNLOAD=UNSUPPORTED
MD5SUM=""
DOWNLOAD_x86_64="$DOWNLOAD"
MD5SUM_x86_64="$MD5SUM"
REQUIRES="$REQUIRES"
MAINTAINER="$MAINTAINER"
EMAIL="$EMAIL"
APPROVED="$APPROVED"
EOF
}
if [ $# -ne 1 ]
then
usage
exit 1
fi
firstArg="${1:-'missing package name or file!'}"
if [ ! -e "$firstArg" ]
then
fix_package "$firstArg"
else
while read -r pkg
do
if [[ ! "$pkg" =~ python3|half ]]
then
fix_package "$pkg"
else
echo "skipping package $pkg"
fi
done < "$firstArg"
fi