Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/scripts/pacman-db-upgrade.sh.in
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2014-10-06 04:16:36 -0400
committerAllan McRae <allan@archlinux.org>2014-10-06 19:00:34 +1000
commit5002227296b4de3c530690b38abab47dce83564d (patch)
treed033d556fed1f02a5eb1ae4f48106c0c4c4dfa89 /scripts/pacman-db-upgrade.sh.in
parent1e3c088c2e14c7211e77ad73201458418fd34091 (diff)
pacman-db-upgrade: do not mangle file lists
grep'ing out blank lines and sorting output thoroughly breaks any file lists with %BACKUP% entries which must be separated from the file list by a blank line. Adds a custom function to ensure that all paths printed are non-empty and unique. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'scripts/pacman-db-upgrade.sh.in')
-rw-r--r--scripts/pacman-db-upgrade.sh.in29
1 files changed, 22 insertions, 7 deletions
diff --git a/scripts/pacman-db-upgrade.sh.in b/scripts/pacman-db-upgrade.sh.in
index d2d317bf..f9bd101c 100644
--- a/scripts/pacman-db-upgrade.sh.in
+++ b/scripts/pacman-db-upgrade.sh.in
@@ -204,25 +204,40 @@ if [[ -z "$db_version" ]]; then
for f in "$dbroot"/local/*/files; do
awk -v "olddir=$olddir" -v "newdir=$newdir" -v "parents=$parents" '
+ function print_path(path) {
+ if (path != "" && !(path in seen)) {
+ seen[path] = 1
+ print path
+ }
+ }
BEGIN {
- i = length(olddir) + 1
+ oldlen = length(olddir) + 1
file = substr(newdir, 0, length(newdir) - 1)
}
{
- if ($0 == olddir) {
+ if ($0 == "") {
+ # end of section, clear seen paths and print as-is
+ for ( i in seen ) {
+ delete seen[i]
+ }
+ print
+ } else if ($0 == olddir) {
# replace symlink with its target, including parents
- printf("%s", parents)
- printf("%s\n", newdir)
+ split(parents, paths, "\n")
+ for (i in paths) {
+ print_path(paths[i])
+ }
+ print_path(newdir)
} else if ($0 == file) {
# newdir already existed as a file, skip it
} else if (index($0, olddir) == 1) {
# update paths that were under olddir
- printf("%s%s\n", newdir, substr($0, i))
+ print_path(newdir substr($0, oldlen))
} else {
# print everything else as-is
- print
+ print_path($0)
}
- }' "$f" | grep . | LC_ALL=C sort -u > "$f.tmp"
+ }' "$f" > "$f.tmp"
mv "$f.tmp" "$f"
done
done