[pacman-dev] [PATCH] WIP: Upgrade pacman local db for removal of symlink directory support

Allan McRae allan at archlinux.org
Mon Jun 3 23:29:02 EDT 2013


Detect directories in the local pacman database that are symlinks to
directories in the filesystem and update the paths in the local database
as needed.

Also add a fine into the local directory with the libalpm version
required for the database so we can more effectively the database
version for future updates.

Signed-off-by: Allan McRae <allan at archlinux.org>
---

Very much a work in progress, but provided here so people using pacman-git can
update their database to remove directory symlink support.

 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..e4f92a4 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_version ]]; then
+	db_version=($(cat "${dbroot}"/local/.alpm_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.0" > "$dbroot"/local/.alpm_version
+
 # remove the lock file
 rm -f "$lockfile"
 
-- 
1.8.3



More information about the pacman-dev mailing list