From c4e7fe9f029bde49d825e051a6be77f0227b8dd0 Mon Sep 17 00:00:00 2001 From: jjhua Date: Thu, 14 Mar 2013 07:47:28 +0000 Subject: [PATCH] Before adding the os repos and otherpkgs repos, check if the repos were already added by xCAT in the previous run, if yes, update these repos; otherwise, create these repos directly. For the os repo added by addsiteyum, it should be deleted by ospkgs and otherpkgs, the ospkg and otherpkgs will add the os repos point to more directories. After ospkg/otherpkgs is done, do not remove the repos. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15511 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT/postscripts/ospkgs | 84 +++++++++++++---------------------------- 1 file changed, 26 insertions(+), 58 deletions(-) diff --git a/xCAT/postscripts/ospkgs b/xCAT/postscripts/ospkgs index 5d311951b..1f87422c9 100755 --- a/xCAT/postscripts/ospkgs +++ b/xCAT/postscripts/ospkgs @@ -217,28 +217,13 @@ if [ $? -eq 0 ]; then fi if [ -z "$OSPKGDIR" ]; then - if [ $mounted -eq 0 ]; then - OSPKGDIR="$NFSSERVER$INSTALLDIR/$OSVER/$ARCH" - else - OSPKGDIR="$NFSSERVER/$OSVER/$ARCH" - fi - - if ( pmatch "$OSVER" "sles*" ); then - OSPKGDIR="$OSPKGDIR/1" - elif ( pmatch "$OSVER" "rhel*" ); then - OSPKGDIR="$OSPKGDIR/Server" - elif ( pmatch "$OSVER" "SL5*" ); then - OSPKGDIR="$OSPKGDIR/SL" - fi + OSPKGDIR="$INSTALLDIR/$OSVER/$ARCH" +fi -else +if [ "$KERNELDIR" != "" ]; then + OSPKGDIR="$OSPKGDIR,$KERNELDIR" +fi - if [ "$KERNELDIR" != "" ]; then - if [ $mounted -eq 0 ]; then - OSPKGDIR="$OSPKGDIR,$KERNELDIR" - fi - fi - OIFS=$IFS IFS=$',' if ( pmatch "$OSVER" "ubuntu*" ); then @@ -317,9 +302,8 @@ else index=$(expr $index + 1) - done + done -fi @@ -513,7 +497,7 @@ elif ( pmatch "$OSVER" "sles11*" ); then old_repo=`zypper lr |grep -e "^[0-9]" | cut -f2 -d '|'` for x in $old_repo do - result=`zypper rr $x` + result=`zypper rr "$x"` done result=`zypper --non-interactive refresh 2>&1` if [ $debug -ne 0 ]; then @@ -532,11 +516,11 @@ elif ( pmatch "$OSVER" "sles11*" ); then else path="file://$OSPKGDIR" fi - result=`zypper ar $path $OSVER 2>&1` + result=`zypper ar $path xCAT-$OSVER 2>&1` if [ $? -ne 0 ]; then if ( ! pmatch "$result" "*exists*" ); then - logger -t xcat -p local4.info "ospkgs: zypper ar $path $OSVER\n $result" - echo "ospkgs: zypper ar $path $OSVER" + logger -t xcat -p local4.info "ospkgs: zypper ar $path xCAT-$OSVER\n $result" + echo "ospkgs: zypper ar $path xCAT-OSVER" echo " $result" fi fi @@ -548,11 +532,11 @@ elif ( pmatch "$OSVER" "sles11*" ); then else path="file://$OSPKGDIR" fi - result=`zypper ar $path $OSVER-"path$i" 2>&1` + result=`zypper ar $path xCAT-$OSVER-"path$i" 2>&1` if [ $? -ne 0 ]; then if ( ! pmatch "$result" "*exists*" ); then - logger -t xcat -p local4.info "ospkgs: zypper ar $path $OSVER-path$i\n $result" - echo "ospkgs: zypper ar $path $OSVER-path$i" + logger -t xcat -p local4.info "ospkgs: zypper ar $path xCAT-$OSVER-path$i\n $result" + echo "ospkgs: zypper ar $path xCAT-$OSVER-path$i" echo " $result" fi fi @@ -567,11 +551,11 @@ elif ( pmatch "$OSVER" "sles11*" ); then else SDKDIR="file://$SDKDIR" fi - result=`zypper ar $SDKDIR $OSVER-sdk 2>&1` + result=`zypper ar $SDKDIR xCAT-$OSVER-sdk 2>&1` if [ $? -ne 0 ]; then if ( ! pmatch "$result" "*exists*" ); then - logger -t xcat -p local4.info "ospkgs: zypper ar $SDKDIR $OSVER-sdk\n $result" - echo "ospkgs: zypper ar $SDKDIR $OSVER-sdk" + logger -t xcat -p local4.info "ospkgs: zypper ar $SDKDIR xCAT-$OSVER-sdk\n $result" + echo "ospkgs: zypper ar $SDKDIR xCAT-$OSVER-sdk" echo " $result" fi fi @@ -716,7 +700,11 @@ else if [ $keeprepo -ne 1 ]; then #remove old repo mkdir -p /etc/yum.repos.d - result=`rm /etc/yum.repos.d/*.repo 2>&1` + if [ -r "/etc/yum.repos.d/local-repository.repo" ]; then + result=`rm /etc/yum.repos.d/local-repository.repo 2>&1` + fi + result=`rm /etc/yum.repos.d/xCAT*.repo 2>&1` + fi result=`yum clean all` @@ -724,32 +712,13 @@ else SUM=$(array_get_size os_path) i=0 - if [ $SUM -eq 0 ]; then - #create new repo file - REPOFILE="/etc/yum.repos.d/$OSVER.repo" - if [ ! -f $REPOFILE ]; then - echo "[$OSVER]" > $REPOFILE - echo "name=$OSVER" >> $REPOFILE - if [ $mounted -eq 0 ]; then - echo "baseurl=http://$OSPKGDIR" >> $REPOFILE - else - echo "baseurl=file://$OSPKGDIR" >> $REPOFILE - fi - echo "enabled=1" >> $REPOFILE - echo "gpgcheck=0" >> $REPOFILE - fi - else - - while [ $i -lt $SUM ]; do - REPOFILE="/etc/yum.repos.d/$OSVER-path$i.repo" + while [ $i -lt $SUM ]; do + REPOFILE="/etc/yum.repos.d/xCAT-$OSVER-path$i.repo" OSPKGDIR=$(array_get_element os_path $i) -# default_pkgdir="$INSTALLDIR/$OSVER/$ARCH" - - if [ ! -f $REPOFILE ]; then - echo "[$OSVER-path$i]" > $REPOFILE - echo "name=$OSVER-path$i" >> $REPOFILE + echo "[xCAT-$OSVER-path$i]" > $REPOFILE + echo "name=xCAT-$OSVER-path$i" >> $REPOFILE if [ $mounted -eq 0 ]; then echo "baseurl=http://$OSPKGDIR" >> $REPOFILE else @@ -759,8 +728,7 @@ else echo "gpgcheck=0" >> $REPOFILE fi i=$((i+1)) - done - fi + done #import the release key? #my $key = "$installDIR/$os/$arch/RPM-GPG-KEY-redhat-release";