summaryrefslogtreecommitdiff
path: root/aur
blob: 7c2860b6dd872befc7845ea3604b7ef9e81bf192 (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
#!/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/>. 

source /etc/libretools.conf
source /etc/abs.conf

function usage {
    echo "Usage: $0 pkgname-from-aur1 [pkgname-from-aur2 ...]"
    echo
    echo "This script will download packages from aur to the current dir"
    echo "and check their license for nonfree issues."
}

while getopts 'h' arg; do
    case $arg in
	h) usage; exit 0 ;;
	*) usage; exit 1 ;;
    esac
done

missing_deps=()
for _pkg in ${@}; do

# Remove the version
# TODO check downloaded PKGBUILD version
  _pkg="${_pkg%%[<>=]*}"

  msg "Downloading $_pkg..."
  wget -O - -q http://aur.archlinux.org/packages/$_pkg/$_pkg.tar.gz | \
    tar xzf - >/dev/null 2>&1

  [[ $? -ne 0 ]] && {
    error "Couldn't get $_pkg"
    continue
  }

  stdnull "pushd $_pkg"

  source PKGBUILD

  pkgbuild-check-nonfree || {
    if [ $? -eq 15 ]; then
      warning "This PKGBUILD links to known unfree packages"
    fi
  }

  msg2 "Checking license..."
  free=0
  for _license in ${license[@]}; do
    if [ ! -d /usr/share/licenses/common/$_license ]; then
      warning "License $_license is not a common license"
      free=1
    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

  for _dep in ${depends[@]} ${makedepends[@]}; do
    if ! is_built $_dep; then
      if ! find ${ABSROOT} -maxdepth 2 -type d -name "$_dep" | egrep "*" >/dev/null ; then
        missing_deps=(${missing_deps} $_dep)
      fi
    else
        msg2 "$_dep is on repos"
    fi
  done

  stdnull popd

done

[[ ${#missing_deps[*]} -gt 0 ]] && {
  msg2 "Retrieving missing deps: ${missing_deps[@]}"
  $0 ${missing_deps[@]}
}

exit 0