Re: backup to vmlinuz.fou4s ?

Lars Ellenberg <[email protected]> Thu, 14 Oct 2004 17:45:27 +0200
Newsgroups gmane.linux.suse.fou4s.devel
Message-ID <[email protected]>
/ 2004-10-12 20:31:29 +0200
\ Kai Schaetzl:
> When upgrading the kernel I see the following backup message in the latest 
> fou4s releases:
> Creating backup of old Kernel (to /boot/vmlinuz.fou4s)
> 
> But when I look in /boot there's nothing.

note that, if /boot/vmlinuz is a symlink, it will still not be copied by
the previous patch. I'd chose to "test -e ... && cat < ... > ...",
see below.

btw, why not do
"rpm -ihv" if pgk == $KERNELPKG ?
I mean, for most packages it is best to do -Uhv.
but for some, like the kernel, it is probably good to do -ihv.

ok, you then rely on the package to do the proper backup and
adjustments, but I think they do so pretty well.

and, while looking at the code in rpmInstall(), I saw this strange
prefix="su - -c" handling.  I assume this whole thing is to get rid of
the gid=fou4s on install, while still have --test intstalls as normal
user possible?

  test -n "$prefix" && $prefix \"$cmd\" || $cmd

if $cmd has an exit code != 0, it now will be executed twice,
once with su -c, once without.

I think the below patch does this slightly better in this regard, too.

	lge


--- fou4s.orig	2004-10-03 17:14:14.000000000 +0200
+++ fou4s	2004-10-14 17:42:59.000000000 +0200
@@ -1366,7 +1366,8 @@
 	myNote 0 "Remember to create an appropriate entry in your grub or lilo configuration."
 	for i in vmlinuz System.map initrd ; do
 		rm -f /boot/$i.fou4s
-		test -f $i && cp /boot/$i /boot/$i.fou4s
+		#test -e /boot/$i && cp --dereference /boot/$i /boot/$i.fou4s
+		test -e /boot/$i && cat < /boot/$i > /boot/$i.fou4s
 	done
 	rm -rf /lib/modules/[23].[0-9]*.fou4s
 	cp -a /lib/modules/$KERNELVER /lib/modules/$KERNELVER.fou4s
@@ -1389,13 +1390,22 @@
 	fi
 }
 
+do_it()
+{
+	if [ $EUID = 0 ] ; then
+		su - root -c "$*"
+	else
+		"$@"
+	fi
+}
+
 
 ################################ rpmInstall
 # parameter:
 # $*: filename1.rpm filename2.rpm ...
 function rpmInstall()
 {
-	local allpkgs="$*" count=$# output p lang gnal currentdir prefix cmd 
+	local allpkgs="$*" count=$# output p lang gnal currentdir cmd 
 	local postKernel=0 # do kernel-update post-install operations (backup)
 	if [ -n "$EXPORTFILE" -a $EXPORT -eq 1 ] ; then
 		for p in $allpkgs ; do
@@ -1425,14 +1435,12 @@
 	#we can use -U in favor of -F because the package is either already
 	#installed, or HAS to be installed (because of -f option)
 	test $TESTMODE -eq 1 && test=--test
-	test $EUID -eq 0 && prefix="su - -c"
 	cmd="rpm -Uvh $test $GLOBALRPMOPTS $allpkgs"
 	if [ $VERBOSE -ge 1 ] ; then
 		rpmresult=""
-		test -n "$prefix" && eval $prefix \"$cmd\" || $cmd
+		do_it $cmd
 	else
-		test -n "$prefix" && rpmresult="`eval $prefix \"$cmd\" 2>&1`" || \
-			rpmresult="`$cmd 2>&1`"
+		rpmresult="`do_it $cmd 2>&1`"
 	fi
 	if [ "$?" -eq 0 ] ; then
 		test $postKernel -eq 1 && postKernelUpdate
--