summaryrefslogtreecommitdiff
path: root/testeAbhaengigkeiten
blob: 586ed46311d7093780424b32b94884d1d4f6c2b0 (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
158
159
160
161
162
163
164
165
#!/bin/bash

set -e

if [ $# -ne 1 ]
then
  >&2 echo "Verwendung: testeAbhaengigkeiten paket"
  exit 1
fi

substituiere() {
  dep="$1"
  name=${dep%>=*}
  dep=${dep#${name}}
  erg="$(
    cat "$(dirname "${me}")/perlSubstitutionen" | \
      sed 's|#.*$||' | \
      grep "\s${name}\(\s\|\$\)" | \
      sed "s|^\([^:]\+\):.*\$|perl-\1|" | \
      sed "s|^:.*\$|perl|"
  )"
  [ -z "${erg}" ] && erg="perl-${name}"
  if [ "${erg}" == "perl" ] && echo "${dep}" | grep -q "^[^.]*\.\(0[[:digit:]]\{2\}\)\{2\}"
  then
    dep="$(
      echo "${dep}" | \
        sed "s@^\([^.]*\....\)0\+@\1.@; s@^\([^.]*\.\)0\+@\1@"
    )"
  fi
  erg="${erg}${dep}"
}

paket="$1"

if [[ "${paket}" != "perl-"* ]]
then
# noch zu implementieren / zur Zeit unnötig
  exit 0
fi

me="$(readlink -f "$0")"
cd "$(dirname "${me}")"
cd "${paket}"

makepkg -f --verifysource

. PKGBUILD

if [ ! -r "${_distdir}.tar.gz" ]
then
  >&2 echo "Kann Datei '${_distdir}.tar.gz' nicht lesen!"
  exit 1
fi

echo "META.yml lesen ..."

meta="$(
  tar -Oxzf "${_distdir}.tar.gz" "${_distdir}/META.yml" | \
    grep -v "^    file:" | \
    grep -v "^    version:" | \
    sed '
      :begin;
        $!N;
        s@^\(\S.*\)\n\s\+\(\S.*\)$@\1 \2@;
      tbegin;
      P;
      D
    ' | \
    sed "/^provides: /s@:\(\s\|\$\)@: '0'\1@g" | \
    sed "s|^provides: '0' |provides: |"
)"

echo "... fertig, verarbeiten ..."

declare -A metaInfos
declare -A metaRegexe
declare -A metaSubst

metaRegexe["makedepends"]="\(build\|configure\)_requires"
metaSubst["makedepends"]=true
metaRegexe["depends"]="requires"
metaSubst["depends"]=true
metaRegexe["optdepends"]="recommends"
metaSubst["optdepends"]=true
metaRegexe["conflicts"]="conflicts"
metaSubst["conflicts"]=true
metaRegexe["provides"]="provides"
metaSubst["provides"]=false

set +e

for sucheWonach in "${!metaRegexe[@]}"
do
  metaInfos["${sucheWonach}"]=""
  for was in $(
    echo "${meta}" | \
      grep "^${metaRegexe["${sucheWonach}"]}:" | \
      sed "s@^${metaRegexe["${sucheWonach}"]}:\s*@@" | \
      sed "s@\(\S\+\):\s\+'\?\([0-9.]*\)'\?\(\s\|\$\)@\L\1>=\L\2\n@g" | \
      sed "s@\(\S\+\):\s\+'<\s*\([0-9.]\+\)'\(\s\|\$\)@\L\1<\L\2\n@g" | \
      sed "s@::@-@g" | \
      sed "s|>=0\$||" | \
      grep -v "^\({}\)\?$"
  )
  do
    if ${metaSubst["${sucheWonach}"]}
    then
      substituiere "${was}"
    else
      erg="perl-${was}"
    fi
    if [[ "${erg}" != "perl-%skip"* ]]
    then
      metaInfos["${sucheWonach}"]="${metaInfos["${sucheWonach}"]} '${erg}'"
    fi
  done
  metaInfos["${sucheWonach}"]="$(
    echo "${metaInfos["${sucheWonach}"]}" | \
      tr ' ' '\n' | \
      sort -u | \
      grep -v '^\s*$'
  )"
done

err=0

for wasAusgeben in "${!metaRegexe[@]}"
do
  eval pkgBuild=( '"${'${wasAusgeben}'[@]}"' )
  pkgBuild="$(
    echo "${pkgBuild[@]}" | \
      tr ' ' '\n' | \
      grep -v '^$' | \
      sed "s|^\(.*\)$|'\1'|" | \
      sort -u
  )"
  metaYml="$(
    echo "${metaInfos["${wasAusgeben}"]}" | \
      grep -v '^$' | \
      sort -u;
  )"
  probleme="$(
    (
      echo "${pkgBuild}"
      echo "${metaYml}"
    ) | \
      sort | \
      uniq -u
  )"
  if [ -n "${probleme}" ]
  then
    >&2 echo "${wasAusgeben} unterscheidet sich:"
    >&2 echo '-------------------------------------'
    >&2 echo "${metaYml}"
    >&2 echo '^^^ META.yml ^^^ vs. vvv PKGBUILD vvv'
    >&2 echo "${pkgBuild}"
    >&2 echo "====================================="
    >&2 echo "${probleme}"
    >&2 echo "====================================="
    err=1
  fi
done

echo "... fertig"
exit ${err}