blob: 739681ee6d499ed633788f8d0044af1a405f6785 (
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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
#!/bin/bash
# Copyright 2010 Nicolás Reynolds, Joshua Ismael
# ---------- GNU General Public License 3 ----------
# This file is part of Parabola.
# Parabola is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# Parabola is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
. libremessages
cmd=${0##*/}
usage() {
echo "Usage: $cmd [-h] pkgname-from-aur1 [pkgname-from-aur2 ...]"
echo
echo "This script will download packages from AUR to the current"
echo "directory and check their license for nonfree issues. This does"
echo "not mean that they are free; they may be incorrectly labeled, or"
echo "have other freedom issues. It's a tool to help Parabola"
echo "packagers, not to help users install things directly from AUR."
}
main() {
while getopts 'h' arg; do
case $arg in
h) usage; return 0;;
*) usage >&2; return 1;;
esac
done
if [[ $# -lt 1 ]]; then
usage >&2
return 1
fi
. $(librelib conf.sh)
load_files libretools
check_vars libretools DIFFTOOL
local missing_deps=()
for _pkg in "$@"; do
# Remove the version
_pkg="${_pkg%%[<>=]*}"
if [[ -f "${_pkg}/PKGBUILD" ]]; then
warning "${_pkg} already existed."
# Store our copy of the PKGBUILD dir
_diff="${PWD}/${_pkg}"
pushd $(mktemp --tmpdir -d ${_pkg}.XXXX) &>/dev/null
msg2 "Downloading PKGBUILD into ${PWD} for diff"
fi
msg "Downloading $_pkg..."
local url=https://aur.archlinux.org/packages/${_pkg:0:2}/${_pkg}/$_pkg.tar.gz
if ! wget -O - -q "$url" | tar xzf - >&2; then
error "Couldn't get $_pkg"
continue
fi
pushd $_pkg &>/dev/null
if [[ ! -z $_diff ]]; then
msg2 "Diffing files"
# Diff all files with our difftool
for file in *; do
"${DIFFTOOL}" "${_diff}/${file}" "${file}"
done
read -p "Press enter to continue."
# Go back to our copy to continue working
pushd "${_diff}" &>/dev/null
fi
. PKGBUILD
################################################################
pkgbuild-check-nonfree
case $? in
0) :;;
15) warning "This PKGBUILD links to known unfree packages";;
*) warning "pkgbuild-check-nonfree failed to run";;
esac
################################################################
msg2 "Checking license..."
local free=0
for _license in "${license[@]}"; do
if [[ ! -e "/usr/share/licenses/common/$_license" ]]; then
case "${_license#custom:}" in
WTFPL)
# accept as common, I think it should be in the licenses package.
:;;
BSD1|BSD2|BSD3|MIT|X11)
# accept these as common; they can't be included in the licenses package because some of the text must be customized
:;;
BSD4)
warning "The 4-clause BSD license is free but has practical problems.";;
BSD)
warning "License \"BSD\" is ambiguous, please use one of \"BSD{1..4}\" to specify the number of clauses."
free=1
;;
*)
warning "License \"$_license\" is not a common license"
free=1
;;
esac
fi
done
if [[ $free -eq 1 ]]; then
plain "Please check that the license is included in the package and *specially* that it respects your freedom."
fi
################################################################
_deps=(
# depends
"${depends[@]}" "${makedepends[@]}" "${checkdepends[@]}"
# mksource depends
"${mkdepends[@]}" "${mkmakedepends[@]}" "${mkcheckdepends[@]}"
)
for _dep in "${_deps[@]}"; do
_dep=${_dep/[<>=]*/}
if ! is_built $_dep; then
if ! pacman -Sddp "$_dep" &>/dev/null ; then
msg2 "$_dep will be get from AUR"
missing_deps+=($_dep)
fi
else
msg2 "$_dep is on repos"
fi
done
popd &>/dev/null
done
if [[ ${#missing_deps[*]} -gt 0 ]]; then
msg2 "Retrieving missing deps: %s" "${missing_deps[*]}"
"$0" "${missing_deps[@]}"
fi
}
main "$@"
|