Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2008-10-28 22:20:09 -0500
committerDan McGee <dan@archlinux.org>2008-10-28 22:20:09 -0500
commitcd51abf0c8d04c72cc85b28cd45b33b9020c661e (patch)
tree18955197d51d579f319792fe473ef1df13dbf175 /scripts
parent2e431e1cc3c9bb445ea886521117f483e78aa84a (diff)
parenta63aeed562c8bdd6604ec50e6a4b684f6edabda3 (diff)
Merge branch 'maint'
Diffstat (limited to 'scripts')
-rw-r--r--scripts/makepkg.sh.in4
-rw-r--r--scripts/pacman-optimize.sh.in55
-rw-r--r--scripts/repo-add.sh.in4
3 files changed, 39 insertions, 24 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index ff05e481..266e214f 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1083,6 +1083,7 @@ devel_check() {
if [ "$newpkgver" != "" ]; then
msg2 "$(gettext "Version found: %s")" "$newpkgver"
pkgver=$newpkgver
+ pkgrel=1
fi
else
@@ -1102,8 +1103,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
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
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index d6d59eb7..4f9639ca 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"