repo-add: bashify reading of .PKGINFO file
grep and sed aren't needed here, and this removes the truly ugly manipulation of IFS. The process substituion could just as well be a herestring, but it breaks vim's syntax highlighting. Style over substance, mang. Signed-off-by: Dave Reisner <d@falconindy.com>
This commit is contained in:
parent
2d32a9a3a3
commit
522c94f168
1 changed files with 9 additions and 14 deletions
|
@ -19,6 +19,8 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
shopt -s extglob
|
||||||
|
|
||||||
# gettext initialization
|
# gettext initialization
|
||||||
export TEXTDOMAIN='pacman-scripts'
|
export TEXTDOMAIN='pacman-scripts'
|
||||||
export TEXTDOMAINDIR='@localedir@'
|
export TEXTDOMAINDIR='@localedir@'
|
||||||
|
@ -226,19 +228,14 @@ db_write_entry() {
|
||||||
_groups _licenses _replaces _depends _conflicts _provides _optdepends \
|
_groups _licenses _replaces _depends _conflicts _provides _optdepends \
|
||||||
md5sum sha256sum pgpsig
|
md5sum sha256sum pgpsig
|
||||||
|
|
||||||
local OLDIFS="$IFS"
|
|
||||||
# IFS (field separator) is only the newline character
|
|
||||||
IFS="
|
|
||||||
"
|
|
||||||
|
|
||||||
# read info from the zipped package
|
# read info from the zipped package
|
||||||
local line var val
|
local line var val
|
||||||
for line in $(bsdtar -xOqf "$pkgfile" .PKGINFO |
|
while read -r line; do
|
||||||
grep -v '^#' | sed 's|\(\w*\)\s*=\s*\(.*\)|\1 \2|'); do
|
[[ ${line:0:1} = '#' ]] && continue
|
||||||
# bash awesomeness here- var is always one word, val is everything else
|
IFS=' =' read -r var val < <(printf '%s\n' "$line")
|
||||||
var=${line%% *}
|
|
||||||
val=${line#* }
|
# normalize whitespace with an extglob
|
||||||
declare $var="$val"
|
declare "$var=${val//+([[:space:]])/ }"
|
||||||
case "$var" in
|
case "$var" in
|
||||||
group) _groups="$_groups$group\n" ;;
|
group) _groups="$_groups$group\n" ;;
|
||||||
license) _licenses="$_licenses$license\n" ;;
|
license) _licenses="$_licenses$license\n" ;;
|
||||||
|
@ -248,9 +245,7 @@ db_write_entry() {
|
||||||
provides) _provides="$_provides$provides\n" ;;
|
provides) _provides="$_provides$provides\n" ;;
|
||||||
optdepend) _optdepends="$_optdepends$optdepend\n" ;;
|
optdepend) _optdepends="$_optdepends$optdepend\n" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done< <(bsdtar -xOqf "$pkgfile" .PKGINFO)
|
||||||
|
|
||||||
IFS=$OLDIFS
|
|
||||||
|
|
||||||
csize=$(@SIZECMD@ "$pkgfile")
|
csize=$(@SIZECMD@ "$pkgfile")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue