From 50e3dc02bf1a99ec040988fde1425adba67da4cb Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 18 Oct 2008 21:27:00 -0500 Subject: repo-add: Use openssl instead of md5sum This is similar to the change we made in makepkg so it is cross-platform compatible and doesn't require coreutils. Signed-off-by: Dan McGee --- scripts/repo-add.sh.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index f3a3a4f4..be0859ea 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -121,7 +121,7 @@ db_write_delta() arch=${deltavars[3]} # get md5sum and size of delta - md5sum="$(md5sum "$deltafile" | cut -d ' ' -f 1)" + md5sum="$(openssl dgst -md5 "$deltafile" | awk '{print $NF}')" csize=$(@SIZECMD@ "$deltafile") # ensure variables were found @@ -201,7 +201,7 @@ db_write_entry() # compute checksums msg2 "$(gettext "Computing md5 checksums...")" - echo -e "%MD5SUM%\n$(md5sum "$pkgfile" | cut -d ' ' -f 1)\n" >>desc + echo -e "%MD5SUM%\n$(openssl dgst -md5 "$pkgfile" | awk '{print $NF}')\n" >>desc [ -n "$url" ] && echo -e "%URL%\n$url\n" >>desc write_list_entry "LICENSE" "$_licenses" "desc" -- cgit v1.2.3-70-g09d2 From 1e656c0a6a7f2dcf5dc40f1b1027161847b967b4 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Tue, 28 Oct 2008 21:22:05 +1000 Subject: makepkg: fix updating PKGBUILD when building SCM packages Fixes a bug and resets pkgrel to 1 when bumping pkgver Signed-off-by: Allan McRae Signed-off-by: Dan McGee --- scripts/makepkg.sh.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 1d70f39b..46173a77 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1069,6 +1069,7 @@ devel_check() { if [ "$newpkgver" != "" ]; then msg2 "$(gettext "Version found: %s")" "$newpkgver" pkgver=$newpkgver + pkgrel=1 fi else @@ -1088,8 +1089,9 @@ devel_update() { # _foo=pkgver # if [ "$newpkgver" != "" ]; then - if [ "newpkgver" != "$pkgver" ]; then + if [ "$newpkgver" != "$pkgver" ]; then sed -i "s/^pkgver=[^ ]*/pkgver=$newpkgver/" ./$BUILDSCRIPT + sed -i "s/^pkgrel=[^ ]*/pkgrel=1/" ./$BUILDSCRIPT source $BUILDSCRIPT fi fi -- cgit v1.2.3-70-g09d2 From a63aeed562c8bdd6604ec50e6a4b684f6edabda3 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 16 Oct 2008 19:47:54 -0500 Subject: Give pacman-optimize a refresher This patch addresses quite a few lingering issues in the pacman-optimize script. FS#11767 provoked this look-over and the following issues were noticed and fixed: * If an alternate dbroot was specified, then the lockfile location was never updated to reflect it. The lockfile location is now set after all dbpath initialization. * The inclusion of a trailing slash on dbroot was problematic and led to the following command being executed: bsdtar -xpf /tmp/pacman-optimize.p12Q4vAUWY/pacman-db.tar.gz \ -C /var/lib/pacman/.new/ It is doubtful we meant to create a hidden directory like this below our database root, only to go and delete it a second later and then re-extract. Fix the whole thing by ensuring our dbpath has its trailing slash stripped and then appending it when necessary. * The DB extraction was performed twice for no real apparent reason. This opens the door for extraction problems the second time around, leaving you with no original database to fall back to. Change the behavior so we only extract once, and then perform a directory shuffle once we verify the checksums are correct. * Perform an explicit sync after we drop the new database on the disk. It should work better this way. * Tighten up our check for a pacman lockfile and the time we create one. There is still a possible race condition but the window is shorter. Signed-off-by: Dan McGee --- scripts/pacman-optimize.sh.in | 55 ++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 21 deletions(-) (limited to 'scripts') diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in index 0cd108b7..dbb8ed00 100644 --- a/scripts/pacman-optimize.sh.in +++ b/scripts/pacman-optimize.sh.in @@ -25,7 +25,6 @@ export TEXTDOMAINDIR='@localedir@' myver='@PACKAGE_VERSION@' dbroot='@localstatedir@/lib/pacman/' -lockfile="${dbroot}db.lck" msg() { local mesg=$1; shift @@ -98,11 +97,6 @@ if ! type diff >/dev/null 2>&1; then die "$(gettext "diff tool was not found, please install diffutils.")" fi -# make sure pacman isn't running -if [ -f "$lockfile" ]; then - die "$(gettext "Pacman lock file was found. Cannot run while pacman is running.")" -fi - if [ ! -d "$dbroot" ]; then die "$(gettext "%s does not exist or is not a directory.")" "$dbroot" fi @@ -111,12 +105,21 @@ if [ ! -w "$dbroot" ]; then die "$(gettext "You must have correct permissions to optimize the database.")" fi -workdir=$(mktemp -d /tmp/pacman-optimize.XXXXXXXXXX) || - die_r "$(gettext "ERROR: Can not create temp directory for database building.")\n" >&2 +# strip any trailing slash from our dbroot +dbroot="${dbroot%/}" +# form the path to our lockfile location +lockfile="${dbroot}/db.lck" +# make sure pacman isn't running +if [ -f "$lockfile" ]; then + die "$(gettext "Pacman lock file was found. Cannot run while pacman is running.")" +fi # do not let pacman run while we do this touch "$lockfile" +workdir=$(mktemp -d /tmp/pacman-optimize.XXXXXXXXXX) || + die_r "$(gettext "ERROR: Can not create temp directory for database building.")\n" >&2 + # step 1: sum the old db msg "$(gettext "MD5sum'ing the old database...")" find "$dbroot" -type f | sort | xargs md5sum > "$workdir/pacsums.old" @@ -124,46 +127,56 @@ find "$dbroot" -type f | sort | xargs md5sum > "$workdir/pacsums.old" # step 2: tar it up msg "$(gettext "Tar'ing up %s...")" "$dbroot" cd "$dbroot" -bsdtar -czf "$workdir/pacmanDB.tgz" ./ +bsdtar -czf "$workdir/pacman-db.tar.gz" ./ if [ $? -ne 0 ]; then rm -rf "$workdir" die_r "$(gettext "Tar'ing up %s failed.")" "$dbroot" fi -# step 3: make and sum the new db -msg "$(gettext "Making and MD5sum'ing the new db...")" +# step 3: make and sum the new db side-by-side with the old +msg "$(gettext "Making and MD5sum'ing the new database...")" mkdir "$dbroot.new" -bsdtar -zxpf "$workdir/pacmanDB.tgz" -C "$dbroot.new/" +bsdtar -xpf "$workdir/pacman-db.tar.gz" -C "$dbroot.new" if [ $? -ne 0 ]; then rm -rf "$workdir" die_r "$(gettext "Untar'ing %s failed.")" "$dbroot" fi +# immediate sync following extraction should get it written continuously on HDD +msg "$(gettext "Syncing database to disk...")" +sync find "$dbroot.new" -type f | sort | \ - xargs md5sum | sed 's#.new/##' > "$workdir/pacsums.new" + xargs md5sum | sed 's#.new##' > "$workdir/pacsums.new" # step 4: compare the sums msg "$(gettext "Checking integrity...")" diff "$workdir/pacsums.old" "$workdir/pacsums.new" >/dev/null 2>&1 if [ $? -ne 0 ]; then # failed - # leave /tmp/pacsums.old and .new for checking to see what doesn't match up + # leave our pacman-optimize tmpdir for checking to see what doesn't match up rm -rf "$dbroot.new" die_r "$(gettext "Integrity check FAILED, reverting to old database.")" fi -# step 5: remove the new temporary database and the old one -# and use the .tgz to replace the old one -msg "$(gettext "Putting the new database in place...")" -rm -rf "$dbroot.new" "$dbroot"/* -bsdtar -zxpf "$workdir/pacmanDB.tgz" -C "$dbroot/" +# step 5: shuffle the newly extracted DB into the proper location +msg "$(gettext "Rotating database into place...")" + +fail=0 +mv "$dbroot" "$dbroot.old" || fail=1 +mv "$dbroot.new" "$dbroot" || fail=1 +chmod --reference="$dbroot.old" "$dbroot" || fail=1 +chown --reference="$dbroot.old" "$dbroot" || fail=1 +if [ $fail -ne 0 ]; then + # failure with our directory shuffle + die_r "$(gettext "New database substitution failed. Check for $dbroot,\n$dbroot.old, and $dbroot.new directories.")" +fi +rm -rf "$dbroot.old" -# remove the lock file, sum files, and .tgz of database +# remove the lock file and our working directory with sums and tarfile rm -f "$lockfile" rm -rf "$workdir" echo msg "$(gettext "Finished. Your pacman database has been optimized.")" -msg "$(gettext "For full benefits of pacman-optimize, run 'sync' now.")" echo exit 0 -- cgit v1.2.3-70-g09d2