-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfix-builddeps
More file actions
executable file
·96 lines (92 loc) · 2.98 KB
/
fix-builddeps
File metadata and controls
executable file
·96 lines (92 loc) · 2.98 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
#!/bin/sh
json() {
python -c "
import json,sys
try:
print(json.load(sys.stdin)$@)
except IndexError:
pass
"
}
addDep() {
local SPEC="$1"
shift
local DEPS="$(echo $@ |tr ' ' '\n' |tac |tr '\n' ' ')"
local i
for i in $DEPS; do
if ! grep -qE "^[Bb][Uu][Ii][Ll][Dd][Rr][Ee][Qq][Uu][Ii][Rr][Ee][Ss][[:space:]]*:.*$i.*" $SPEC; then
if grep -qE '^[Bb][Uu][Ii][Ll][Dd][Rr][Ee][Qq][Uu][Ii][Rr][Ee][Ss][[:space:]]*:' $SPEC; then
sed -i "0,/^[Bb][Uu][Ii][Ll][Dd][Rr][Ee][Qq][Uu][Ii][Rr][Ee][Ss][[:space:]]*:/s//BuildRequires: $i\n&/" $SPEC
else
sed -i "0,/^%description/s//BuildRequires: $i\n&/" $SPEC
fi
fi
done
}
if [ -z "$PACKAGES" ]; then
if [ "$#" -gt 0 ]; then
PACKAGES="$@"
else
if [ -z "$OAUTH_TOKEN" ]; then
echo "For updating all packages to work,"
echo " export OAUTH_TOKEN=\"token\""
echo "where \"token\" is a github authentication token"
echo "generated at https://github.com/settings/token"
exit 1
fi
PACKAGES=""
PERPAGE=100
COUNT=0
START=""
org=OpenMandrivaAssociation
echo -n "Getting list of packages "
while true; do
echo -n .
QUERY="{\"query\": \"query {organization(login:\\\"$org\\\") { id name repositories(first:$PERPAGE $START) { edges { node { id name } cursor } pageInfo { endCursor hasNextPage } } } }\""
REPOS="$(curl -H "Authorization: token $OAUTH_TOKEN" -X POST -d "$QUERY" https://api.github.com/graphql 2>/dev/null)"
if [ -z "$REPOS" ]; then
echo "$QUERY failed" >&2
break
fi
for i in $(seq 0 $((PERPAGE-1))); do
R="$(echo $REPOS |json "['data']['organization']['repositories']['edges'][$i]['node']['name']").git"
if [ "$R" = ".git" ]; then
echo "No more repositories at $QUERY $i" >&2
break
fi
if [ "$R" = "abf-yml.git" -o "$R" = "secret-keys.git" -o "$R" = "OpenMandrivaAssociation.github.io.git" ]; then
# These repositories contain passwords and aren't public
# Since we aren't authenticated, can't mirror them
continue
fi
COUNT=$((COUNT+1))
PKG="$(echo $R |sed -e 's,\.git$,,')"
if ! echo " $BLACKLIST " |grep -q " $PKG "; then
PACKAGES="$PACKAGES $PKG"
fi
done
[ "$(echo $REPOS |json "['data']['organization']['repositories']['pageInfo']['hasNextPage']")" != "True" ] && break
START="after:\\\"$(echo $REPOS |json "['data']['organization']['repositories']['pageInfo']['endCursor']")\\\""
done
echo
fi
fi
TEMPDIR="$(mktemp -d /tmp/fix-builddepXXXXXX)"
cd $TEMPDIR
for i in $PACKAGES; do
git clone "[email protected]:OpenMandrivaAssociation/$i.git"
cd "$i"
if ! grep -qiE '^BuildSystem[[:space:]]+:' *.spec; then
if grep -qE '^(%configure|%{configure}|./configure|autoconf)' *.spec; then
addDep *.spec autoconf automake libtool-base slibtool make
elif grep -qE '^(make|%{make}|%make$|%make |%make_build|%{make_build})' *.spec; then
addDep *.spec make
fi
echo $i >>/tmp/not-declarative.list
fi
git commit -am "Add build dependencies that used to be implicit"
git push origin master
cd ..
rm -rf "$i"
done
rm -rf "$TEMPDIR"