summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres P <aepd87@gmail.com>2010-05-25 16:32:07 -0430
committerDan McGee <dan@archlinux.org>2010-05-27 09:18:52 -0500
commitfe1e3471f47d9da3bac4cedce250cd2ce04368b4 (patch)
treed363b4409a987b79fe846d8d81852a2287a81f67
parent3064f8d08d8f8048aa064aa07c47b3059df7b56e (diff)
downloadpacman-fe1e3471f47d9da3bac4cedce250cd2ce04368b4.tar.xz
makepkg: remove code duplication in buildscript parsing
Merges code in two almost identical chunks in create_srcpackage and check_sanity. Also discards the space kept by regex in ae73d75660 and earlier, since the for loop discards it later on. Signed-off-by: Andres P <aepd87@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--scripts/makepkg.sh.in51
1 files changed, 14 insertions, 37 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 8c0da8be..76b61833 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1107,31 +1107,19 @@ create_srcpackage() {
fi
done
- local install_files=( $(sed -n "s/^\([[:space:]]*\)install=/\1/p" "$BUILDSCRIPT") )
- if [[ -n $install_files ]]; then
- local file
- for file in ${install_files[@]}; do
- # evaluate any bash variables used
- eval file=${file}
- if [[ ! -f "${srclinks}/${pkgbase}/$file" ]]; then
- msg2 "$(gettext "Adding install script (%s)...")" "$file"
- ln -s "${startdir}/$file" "${srclinks}/${pkgbase}/"
- fi
- done
- fi
-
- local changelog_files=( $(sed -n "s/^\([[:space:]]*\)changelog=/\1/p" "$BUILDSCRIPT") )
- if [[ -n $changelog_files ]]; then
+ local i
+ for i in 'changelog' 'install'; do
+ local $i=$(sed -n "s/^[[:space:]]*$i=//p" "$BUILDSCRIPT")
local file
- for file in ${changelog_files[@]}; do
+ for file in ${!i}; do
# evaluate any bash variables used
- eval file=${file}
- if [[ ! -f "${srclinks}/${pkgbase}/$file" ]]; then
- msg2 "$(gettext "Adding package changelog (%s)...")" "$file"
+ eval file='${srclinks}/${pkgbase}/'${file}
+ if [[ ! -f $file ]]; then
+ msg2 "$(gettext "Adding %s file (%s)...")" "$i" "$file"
ln -s "${startdir}/$file" "${srclinks}/${pkgbase}/"
fi
done
- fi
+ done
local TAR_OPT
case "$SRCEXT" in
@@ -1250,30 +1238,19 @@ check_sanity() {
fi
done
- local install_files=( $(sed -n "s/^\([[:space:]]*\)install=/\1/p" "$BUILDSCRIPT") )
- if [[ -n $install_files ]]; then
+ local i
+ for i in 'changelog' 'install'; do
+ local $i=$(sed -n "s/^[[:space:]]*$i=//p" "$BUILDSCRIPT")
local file
- for file in ${install_files[@]}; do
- # evaluate any bash variables used
- eval file=${file}
- if [[ ! -f $file ]]; then
- error "$(gettext "Install scriptlet (%s) does not exist.")" "$file"
- return 1
- fi
- done
- fi
-
- local changelog_files=( $(sed -n "s/^\([[:space:]]*\)changelog=/\1/p" "$BUILDSCRIPT") )
- if [[ -n $changelog_files ]]; then
- for file in ${changelog_files[@]}; do
+ for file in ${!i}; do
# evaluate any bash variables used
eval file=${file}
if [[ ! -f $file ]]; then
- error "$(gettext "Changelog file (%s) does not exist.")" "$file"
+ error "$(gettext "%s file (%s) does not exist.")" "${i^}" "$file"
return 1
fi
done
- fi
+ done
local valid_options=1
local opt known kopt