forked from analogdevicesinc/scopy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflatpak_deps_licenses.sh
51 lines (47 loc) · 1.35 KB
/
flatpak_deps_licenses.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
#!/bin/sh
#set -x
echo "<table>"
for f in $(find ./outdir -name "*.so*" -type f | awk -F/ '{print $NF}' | sed -e 's/\.debug//g' | sort | uniq) ; do
name=$(basename $f)
loop=1
while [ ${loop} -eq 1 ] ; do
# echo looking for $name
attempt=1
while [ ${attempt} -le 5 ] ; do
wget -o test.url -O test "https://packages.ubuntu.com/search?suite=xenial&arch=amd64&mode=filename&searchon=contents&keywords=${name}"
if [ $(cat test | wc -l) -ne 0 ] ; then
break
fi
sleep 1
attempt=$(expr $attempt + 1)
done
url=$(sed '/<\/table>/Q' test | sed -n '/<table>/,$p' | \
sed '/^[[:space:]]*$/d' | grep -v \<th\> | \
grep href | sort | uniq -c | head -1 | \
sed -e 's/^.*href=\"//' -e 's/\".*$//')
# echo found $url
if [ $(echo -n $url | wc -c) -eq 0 ] ; then
# echo trying again
if [ "${name}" = "$(echo ${name} | sed -e 's/\.[0-9]*$//')" ] ; then
echo fail with ${name}
break
else
name=$(echo $name | sed -e 's/\.[0-9]*$//')
fi
else
# echo found
break
fi
done
if [ $(echo -n $url | wc -c) -eq 0 ] ; then
home="not unstream"
else
wget -o /dev/null -O test "https://packages.ubuntu.com/${url}"
home=$(grep Homepage test | grep \<li\> | sed -e 's:<li>::' -e 's:<\/li>::')
fi
if [ $(echo -n $home | wc -c) -eq 0 ] ; then
home="unknown"
fi
echo "<tr><td>$name</td><td>$home</td></tr>"
done
echo "</table>"