[pacman-dev] [PATCH 5/5] Extend database upgrade script to handle alpm db version 9
Allan McRae
allan at archlinux.org
Tue Jul 16 08:22:44 EDT 2013
Signed-off-by: Allan McRae <allan at archlinux.org>
---
scripts/pacman-db-upgrade.sh.in | 46 ++++++++++++++++++++++++++++++++---------
1 file changed, 36 insertions(+), 10 deletions(-)
diff --git a/scripts/pacman-db-upgrade.sh.in b/scripts/pacman-db-upgrade.sh.in
index a1630c5..d2cd78d 100644
--- a/scripts/pacman-db-upgrade.sh.in
+++ b/scripts/pacman-db-upgrade.sh.in
@@ -109,18 +109,44 @@ fi
# do not let pacman run while we do this
touch "$lockfile"
-# pacman-3.4 to 3.5 upgrade - merge depends into desc
-if [[ $(find "$dbroot"/local -name depends) ]]; then
- msg "$(gettext "Pre-3.5 database format detected - upgrading...")"
- for i in "$dbroot"/local/*; do
- if [[ -f "$i"/depends ]]; then
- cat "$i"/depends >> "$i"/desc
- rm "$i"/depends
- fi
- done
- msg "$(gettext "Done.")"
+if [[ -f "${dbroot}"/local/.alpm_db_version ]]; then
+ db_version=($(cat "${dbroot}"/local/.alpm_db_version))
fi
+if [[ -z "$db_version" ]]; then
+ # pacman-3.4 to 3.5 upgrade - merge depends into desc
+ if [[ $(find "$dbroot"/local -name depends) ]]; then
+ msg "$(gettext "Pre-3.5 database format detected - upgrading...")"
+ for i in "$dbroot"/local/*; do
+ if [[ -f "$i"/depends ]]; then
+ cat "$i"/depends >> "$i"/desc
+ rm "$i"/depends
+ fi
+ done
+ msg "$(gettext "Done.")"
+ fi
+
+ # pacman 4.1 to 4.2 upgrade - remove directory symlink support
+ dirlist=()
+
+ unset GREP_OPTIONS
+ while IFS= read -r dir; do
+ dirlist+=("/${dir%/}")
+ done < <(grep -h '/$' "$dbroot"/local/*/files | sort -u)
+
+ mapfile -t dirlist < <(find "${dirlist[@]}" -maxdepth 0 -type l)
+
+ if [[ ${#dirlist[@]} != 0 ]]; then
+ msg "$(gettext "Pre-4.2 database format detected - upgrading...")"
+ for dir in ${dirlist[@]}; do
+ realdir=( $(cd $dir; pwd -P) )
+ sed -i "s#^${dir#/}/#${realdir#/}/#" "$dbroot"/local/*/files
+ done
+ fi
+fi
+
+echo "9" > "$dbroot"/local/.alpm_db_version
+
# remove the lock file
rm -f "$lockfile"
--
1.8.3.3
More information about the pacman-dev
mailing list