[pacman-dev] pacman-optimize updates
James Rosten
seinfeld90 at gmail.com
Wed Jan 3 19:36:21 EST 2007
On 1/3/07, Aaron Griffin <aaronmgriffin at gmail.com> wrote:
>
> This is in CVS. I haven't tested it, so let me know if it all looks
> ok from your end.
>
Okay, testing it from CVS showed me some bugs (mostly in how I did
error checking). But I fixed it and now it works.
Also, I noticed that I did not get colors from the stat_* functions so
I added USECOLOR="YES" to get colors before sourcing
/etc/rc.d/functions. I expect if an Arch user does not want colors
they are capable enough to edit that one line.
I am not entirely sure on where to put the "Signed Off" message
mentioned in submitting-patches.
~ Jamie / yankees26
Signed-off-by: James Rosten <seinfeld90 at gmail.com>
Index: pacman-optimize
===================================================================
RCS file: /home/cvs-pacman/pacman-lib/scripts/pacman-optimize,v
retrieving revision 1.5
diff -u -p -r1.5 pacman-optimize
--- ORIG/scripts/pacman-optimize 3 Jan 2007 05:45:18 -0000 1.5
+++ NEW/scripts/pacman-optimize 4 Jan 2007 00:34:17 -0000
@@ -23,9 +23,11 @@
myver='3.0.0'
error() {
- echo -e "\033[1;31m:: ERROR:\033[1;0m\033[1;1m$@\033[1;0m" >&2
+ echo -e "\033[1;31m:: ERROR: \033[1;0m\033[1;1m$@\033[1;0m" >&2
}
+# Set USECOLOR so the stat_* functions from /etc/rc.d/functions use color
+USECOLOR=YES
source /etc/rc.d/functions
usage() {
@@ -88,16 +90,24 @@ stat_done
# step 2: tar it up
stat_busy "Tar'ing up $dbroot"
cd $dbroot
-tar -czf /tmp/pacmanDB.tgz ./ || \
- stat_fail && die_r "tar'ing up $dbroot failed"
+tar -czf /tmp/pacmanDB.tgz ./
+if [ $? -ne 0 ]; then
+ stat_fail
+ rm -f /tmp/pacmanDB.tgz /tmp/pacsums.old
+ die_r "tar'ing up $dbroot failed"
+fi
stat_done
# step 3: make and sum the new db
stat_busy "Making and md5sum'ing the new db"
mkdir $dbroot.new
-tar -zxpf /tmp/pacmanDB.tgz -C $dbroot.new/ || \
- stat_fail && die_r "untar'ing $dbroot failed"
-find $dbroot.new -type -f | sort | xargs md5sum > /tmp/pacsums.new
+tar -zxpf /tmp/pacmanDB.tgz -C $dbroot.new/
+if [ $? -ne 0 ]; then
+ rm -f /tmp/pacmanDB.tgz /tmp/pacsums.old
+ rm -rf "$dbroot.new"
+ die_r "untar'ing $dbroot failed"
+fi
+find $dbroot.new -type f | sort | sed -e 's/pacman.new/pacman/g' |
xargs md5sum > /tmp/pacsums.new
stat_done
# step 4: compare the sums
@@ -110,6 +120,7 @@ if [ $? -ne 0 ]; then
rm -rf "$dbroot.new" /tmp/pacman.lck /tmp/pacmanDB.tgz
die_r "integrity check FAILED, reverting to old database"
fi
+stat_done
# step 5: remove the new temporary database and the old one
# and use the .tgz to replace the old one
@@ -119,7 +130,7 @@ tar -zxpf /tmp/pacmanDB.tgz -C "$dbroot"
stat_done
# remove the lock file, sum files, and .tgz of database
-rm -f /tmp/pacman.lck /tmp/pacmsums.old /tmp/pacmsums.new /tmp/pacmanDB.tgz
+rm -f /tmp/pacman.lck /tmp/pacsums.old /tmp/pacsums.new /tmp/pacmanDB.tgz
echo
echo "Finished. Your pacman database has been optimized."
More information about the pacman-dev
mailing list