-
Notifications
You must be signed in to change notification settings - Fork 3
/
dl_pkgs.org_JBs.sh
executable file
·124 lines (103 loc) · 3.99 KB
/
dl_pkgs.org_JBs.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
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
#!/bin/bash
#
# Autor= João Batista Ribeiro
# Bugs, Agradecimentos, Críticas "construtivas"
# me envie um e-mail. Ficarei Grato!
# e-mail: joao42lbatista@gmail.com
#
# Este programa é um software livre; você pode redistribui-lo e/ou
# modifica-lo dentro dos termos da Licença Pública Geral GNU como
# publicada pela Fundação do Software Livre (FSF); na versão 2 da
# Licença, ou (na sua opinião) qualquer versão.
#
# Este programa é distribuído na esperança que possa ser útil,
# mas SEM NENHUMA GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a
# qualquer MERCADO ou APLICAÇÃO EM PARTICULAR.
#
# Veja a Licença Pública Geral GNU para mais detalhes.
# Você deve ter recebido uma cópia da Licença Pública Geral GNU
# junto com este programa, se não, escreva para a Fundação do Software
#
# Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script: Download Slackware packages (txz/tgz) from a https://pkgs.org/ website
#
# Last update: 19/06/2023
#
programName=$1
justUrl=$2
echo -e "\n# Download Slackware packages (txz/tgz) from a https://pkgs.org/ website #"
echo -e "\nTip1 use: $(basename "$0") \"programName\" to not be asked about the program name"
echo "Tip2 use: $(basename "$0") \"programName\" \"url\" to only print the link to download the package"
if [ "$programName" == '' ]; then
echo -en "\nProgram name: "
read -r programName
fi
if [ "$programName" == '' ]; then
echo -e "\nThe name of the program/package can't be blank\n"
else
echo -en "\nSlackware version (hit enter to insert 15.0): "
read -r slackwareVersion
if [ "$slackwareVersion" == '' ]; then
slackwareVersion="15.0"
fi
echo
wget -U firefox -c "https://pkgs.org/download/$programName" -O "$programName"
packagesLink=$(grep -E "txz|tgz" < "$programName" | grep "$slackwareVersion" | grep -o 'http[^"]*')
rm "$programName"
if [ "$packagesLink" != '' ]; then
echo -e "\nPackage(s) found: "
countPackage=1
for package in $packagesLink; do
if [ "$countPackage" -lt 10 ]; then
echo -n " "
fi
echo -n "$countPackage - "
echo "$package" | cut -d '/' -f4-
echo -e "\t ### $package\n"
((countPackage++))
done
((countPackage--))
echo "# Pay attention to the architecture wanted #"
echo -e "\nWhich package do you want download?"
echo -n "Valid numbers 1 to $countPackage: "
read -r packageNumber
((countPackage++))
if [ "$packageNumber" -lt "$countPackage" ]; then
countTmp=1
for package in $packagesLink; do
if [ "$countTmp" == "$packageNumber" ]; then
packagePageLink=$package
fi
((countTmp++))
done
echo
wget -U firefox -c "$packagePageLink" -O "$programName"
linkDl=$(grep -C 10 "[b|B]inary [p|P]ackage" < "$programName" | grep -o 'http[^"]*' | cut -d '<' -f1)
rm "$programName"
if [ "$justUrl" == "url" ]; then
continueDl='n'
else
echo -e "\nDownload the package or Just show the link to download?"
echo -n "(y)es to download the package or (n)o to only show the link (hit enter to yes): "
read -r continueDl
fi
echo
if [ "$continueDl" != 'n' ]; then
wget -c "$linkDl"
wget -c "${linkDl}.md5"
fileName=$(echo "$linkDl" | rev | cut -d '/' -f1 | rev)
md5sum -c "${fileName}.md5"
rm "${fileName}.md5"
else
echo "Link to download the package:"
echo "$linkDl"
fi
echo -e "\nSo Long, and Thanks for All the Fish\n"
else
echo -e "\nPackage number selected is big than the total of packages found\n"
fi
else
echo -e "\nNone package found\n"
fi
fi