Re: Merging updates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 29, 2002 at 04:48:21AM +0800, John Summerfield wrote:
> I've seen the question asked, but I don't recall a good answer.
> 
> Does anyone have a reliable script that will take a package set (as 
> from the original CD collection) and merge in an updates tree, removing 
> old versions of packages?
> 
> 
> If not, I'm going to write one, and if I do that it will be in Perl.
> 
> -- 
> Cheers
> John Summerfield
> 

I have attached a portion of a bash script used to build cds.
This function uses rpm to query the packages for pertinent values.

BTW, it was originally plagarized from someone else script for RH 6.x.
I have rewritten the section but I still should find the original so I can
give the author credit.  I think it was from the mini-howto.

I'll try to reread the whole script shortly to figure out what the
variables need to set to but this should get you started.

Chuck


update_cd()
{
    echo "NOTICE: beginning to apply updated packages to ${RPM1DIR}"
    echo "NOTICE: from ${UPDATES_DIR} and ${EXTRA_DIR}"
    echo "NOTICE: this may take a few minutes"
    echo " "

    if [ ! -d $OLDDIR ] ; then
            echo making directory $OLDDIR
            mkdir $OLDDIR
    fi

    if [ $DEBUG ]
    then
	echo "in update_cd"
	echo "PWD = `pwd`"
	echo "RPM1DIR=$RPM1DIR"
	echo "RPM2DIR=$RPM2DIR"
	echo "ARCH=$ARCH"
	echo "UPDATES_DIR=$UPDATES_DIR"
    fi
    allow_null_glob_expansion=1

    for rpm in ${UPDATES_DIR}/*.rpm ${EXTRA_DIR}/*.rpm  ; do
	RPMDIR=${RPM1DIR}
        NAME=`rpm --queryformat "%{NAME}" -qp $rpm`
        ARCH=`rpm --queryformat "%{ARCH}" -qp $rpm`
        unset OLDNAME
        for oldrpm in ${RPM1DIR}/${NAME}*.${ARCH}.rpm ; do
            if [ "x`rpm --queryformat "%{NAME}" -qp $oldrpm`" = "x$NAME" ]; then
            	if [ "x`rpm --queryformat "%{ARCH}" -qp $oldrpm`" = "x$ARCH" ]; 		then
                	OLDNAME=$oldrpm;
			RPMDIR=${RPM1DIR}
                	break
		fi
            fi
        done
        for oldrpm in ${RPM2DIR}/${NAME}*.${ARCH}.rpm ; do
            if [ "x`rpm --queryformat "%{NAME}" -qp $oldrpm`" = "x$NAME" ]; then
            	if [ "x`rpm --queryformat "%{ARCH}" -qp $oldrpm`" = "x$ARCH" ];
 		then
                	OLDNAME=$oldrpm;
			RPMDIR=${RPM2DIR}
                	break
		fi
            fi
        done

        if [ -z "$OLDNAME" ]; then
            echo $NAME is new
            cp -pv $rpm $RPMDIR
        else
            if [ "x`basename $rpm`" != "x`basename $OLDNAME`" ]
	    then
		if [ $DEBUG ]
    		then
        		echo "mv $OLDNAME $OLDDIR"
                	echo "cp -pv $rpm $RPMDIR"
    		else
                	mv $OLDNAME $OLDDIR
                	#echo "removing $OLDNAME"
                	#rm $OLDNAME 
                	cp -pv $rpm $RPMDIR
		fi 
            else
	        echo "NOTICE:    `basename $rpm` already applied"
            fi
        fi
    done

    echo "NOTICE: done applying updated RPMS, hit return to continue"
    read junk


    # Copy new boot image files to the right place...
    for newfile in ${IMGDIR}/* ; do
        file=${OMGDIR}/$(basename ${newfile})
        if [ $newfile -nt $file ] ; then
           cp -pv $newfile $file
        fi
    done
}

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux