summaryrefslogtreecommitdiff
path: root/perlFunktionen
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2016-06-13 09:31:06 +0200
committerErich Eckner <git@eckner.net>2016-06-13 09:31:06 +0200
commit094a6a06d2aa6df704682bb4142195ba8ba91b9b (patch)
tree04567db983e4aee29cf53fba8abafd68377eadac /perlFunktionen
parent35d290fe1bfa1847cdfa5fa5b83417e4b4b124cd (diff)
downloadarchlinuxewe-094a6a06d2aa6df704682bb4142195ba8ba91b9b.tar.xz
perlFunktionen neu
Diffstat (limited to 'perlFunktionen')
-rwxr-xr-xperlFunktionen206
1 files changed, 206 insertions, 0 deletions
diff --git a/perlFunktionen b/perlFunktionen
new file mode 100755
index 000000000..0d53857ca
--- /dev/null
+++ b/perlFunktionen
@@ -0,0 +1,206 @@
+#!/bin/bash
+
+set -e
+
+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}"
+}
+
+versionsUniq() {
+ tr ' ' '\n' | \
+ sed 's|^perl$|perl>=0|' | \
+ sort -rV | \
+ sed 's@^\([^<=>]*\)\(\(>=\|=\|<\)[0-9.]*\)$@\1\2 \1@' | \
+ sed 's|^\(\S*\)$|\1 \1|' | \
+ uniq -f1 "$@" | \
+ awk '{print $1}' | \
+ sed 's|^perl>=0$|perl|' | \
+ sort | \
+ grep -v '^\s*$'
+}
+
+ladePkgbuild() {
+ paket="$1"
+
+ if [[ "${paket}" != "perl-"* ]]
+ then
+ return 1
+ fi
+
+ me="$(readlink -f "$0")"
+ cd "$(dirname "${me}")"
+ cd "${paket}"
+
+ makepkg -f --verifysource
+
+ . PKGBUILD
+}
+
+versteheMetaYml() {
+ archiv="${_distdir}.tar.gz"
+ [ -r "${archiv}" ] || archiv="${_distdir}.tgz"
+
+ if [ ! -r "${archiv}" ]
+ then
+ >&2 echo "Kann Quelldatei nicht finden!"
+ return 2
+ fi
+
+ if ! tar -tzf "${archiv}" "${_distdir}/META.yml"
+ then
+ return 1
+ fi
+
+ echo "META.yml lesen ..."
+
+ meta="$(
+ tar -Oxzf "${archiv}" "${_distdir}/META.yml" | \
+ tr '\r' ' ' | \
+ grep -v "^\s*file:" | \
+ grep -v "^version:" | \
+ sed '
+ :begin;
+ $!N;
+ s@^\(\S.*\)\n\s\+\(\S.*\)$@\1 \2@;
+ tbegin;
+ P;
+ D
+ ' | \
+ sed "/^provides: /s@\(\s\S\+\):\s\+version:\s\+'\?v\?\([0-9.]\+\)'\?@\L\1=\2@g" | \
+ sed "/^provides: /s@\s@ @g" | \
+ sed "/^provides: /s@\(\s[^= ]\+\):\+\(\s\|\$\)@\L\1=${pkgver}\2@g" | \
+ sed "s@\(\sperl:\s\+\)'\?\([[:digit:]]\+\)\.\([[:digit:]]\{3\}\)'\?\(\s\|\$\)@\1\2.\3.0\4@" | \
+ sed "s@\(\sperl:\s\+\)'\?\([[:digit:]]\+\)\.\([[:digit:]]\{3\}\)\([[:digit:]]\+\)'\?\(\s\|\$\)@\1\2.\3.\4\5@" | \
+ sed "s@\(\sperl:\s\+\)'\?\([[:digit:]]\+\)[._]0*\([1-9][[:digit:]]*\)[._]0*\([1-9][[:digit:]]*\)'\?\(\s\|\$\)@\1\2.\3.\4\5@" | \
+ sed "s@\(\sperl:\s\+\)'\?\([[:digit:]]\+\)[._]0*\([1-9][[:digit:]]*\)[._]0\+'\?\(\s\|\$\)@\1\2.\3.0\4@"
+ )"
+
+ echo "... fertig, verarbeiten ..."
+
+ 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\+'\?v\?\([0-9.]*\)'\?\(\s\|\$\)@\L\1>=\L\2\n@g" | \
+ sed "s@\(\S\+\):\s\+'\(<=\?\)\s*v\?\([0-9.]\+\)'\(\s\|\$\)@\L\1\2\L\3\n@g" | \
+ sed "s@::@-@g" | \
+ sed "s|>=0\$||" | \
+ grep -v "^\({}\)\?$"
+ )
+ do
+ if ${metaSubst["${sucheWonach}"]}
+ then
+ substituiere "${was}"
+ else
+ erg="perl-${was}"
+ if [[ "${erg}" == "${pkgname}="* ]]
+ then
+ erg="perl-%skip"
+ fi
+ fi
+ if [[ "${erg}" != "perl-%skip"* ]]
+ then
+ metaInfos["${sucheWonach}"]="${metaInfos["${sucheWonach}"]} ${erg}"
+ fi
+ done
+ metaInfos["${sucheWonach}"]="$(
+ echo "${metaInfos["${sucheWonach}"]}" | \
+ versionsUniq
+ )"
+ done
+
+ err=false
+
+ for wasAusgeben in "${!metaRegexe[@]}"
+ do
+ eval tmp=( '"${'${wasAusgeben}'[@]}"' )
+ pkgBuild["${wasAusgeben}"]="$(
+ echo "${tmp[@]}" | \
+ tr " '" '\n\n' | \
+ grep -v '^$' | \
+ sort -u
+ )"
+ if [ -z "${pkgBuild["${wasAusgeben}"]}" ] && \
+ [ "${wasAusgeben}" == "depends" ]
+ then
+ pkgBuild["${wasAusgeben}"]="perl"
+ fi
+
+ metaYml["${wasAusgeben}"]="$(
+ (
+ echo "${metaInfos["${wasAusgeben}"]}" | \
+ grep -v '^$' | \
+ grep '^\s*perl'
+ echo "${pkgBuild["${wasAusgeben}"]}" | \
+ grep -v '^\s*perl'
+ ) | \
+ versionsUniq
+ )"
+ if [ -z "${metaYml["${wasAusgeben}"]}" ] && \
+ [ "${wasAusgeben}" == "depends" ]
+ then
+ metaYml["${wasAusgeben}"]="perl"
+ fi
+ if [ "${wasAusgeben}" == "makedepends" ]
+ then
+ metaYml["${wasAusgeben}"]="$(
+ (
+ (
+ (
+ echo "${metaYml["${wasAusgeben}"]}"
+ echo "${metaYml["depends"]}"
+ ) | \
+ versionsUniq
+ echo "${metaYml["depends"]}"
+ ) | \
+ sort | \
+ uniq -d | \
+ sed 'p'
+ echo "${metaYml["${wasAusgeben}"]}"
+ ) | \
+ versionsUniq -u
+ )"
+ fi
+ done
+ echo "... fertig"
+}
+
+declare -A metaInfos
+declare -A metaRegexe
+declare -A metaSubst
+declare -A metaYml
+declare -A pkgBuild
+
+metaRegexe["depends"]="requires"
+metaSubst["depends"]=true
+metaRegexe["makedepends"]="\(build\|configure\)_requires"
+metaSubst["makedepends"]=true
+metaRegexe["optdepends"]="recommends"
+metaSubst["optdepends"]=true
+metaRegexe["conflicts"]="conflicts"
+metaSubst["conflicts"]=true
+metaRegexe["provides"]="provides"
+metaSubst["provides"]=false