From 6d0196314688241ee0376e6cc649a2fae2c5f923 Mon Sep 17 00:00:00 2001 From: linggao Date: Tue, 1 May 2012 15:34:01 +0000 Subject: [PATCH] added --keeprepo flag for ospkgs posctscript git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.7@12418 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT/postscripts/ospkgs | 105 +++++++++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 39 deletions(-) diff --git a/xCAT/postscripts/ospkgs b/xCAT/postscripts/ospkgs index 2651b1373..5e0db3841 100755 --- a/xCAT/postscripts/ospkgs +++ b/xCAT/postscripts/ospkgs @@ -54,6 +54,20 @@ if [ -z "$OSPKGS" ]; then exit 0 fi + +argnum=$#; +args=$@ +keeprepo=0 +if [ $argnum -gt 0 ]; then + if ( pmatch "$args" "*keeprepo*" ); then + keeprepo=1 + fi + if ( pmatch "$args" "*debug*" ); then + debug=1 + fi +fi + + if [ -z "$NFSSERVER" ]; then NFSSERVER=$MASTER fi @@ -162,16 +176,18 @@ if ( pmatch "$OSVER" "sles10*" ); then exit 1 fi - #remove old repo - old_repo=`rug sl |grep -e "^[0-9]" | cut -f2 -d '|'` - for x in $old_repo - do - result=`rug sd $x` - done - result=`rug refresh 2>&1` - if [ $debug -ne 0 ]; then - echo "rug refresh" - echo $result + if [ $keeprepo -ne 1 ]; then + #remove old repo + old_repo=`rug sl |grep -e "^[0-9]" | cut -f2 -d '|'` + for x in $old_repo + do + result=`rug sd $x` + done + result=`rug refresh 2>&1` + if [ $debug -ne 0 ]; then + echo "rug refresh" + echo $result + fi fi #add new repo @@ -265,15 +281,17 @@ elif ( pmatch "$OSVER" "sles11*" ); then echo "Please install zypper on $NODE." exit 1 fi - old_repo=`zypper lr |grep -e "^[0-9]" | cut -f2 -d '|'` - for x in $old_repo - do - result=`zypper rr $x` - done - result=`zypper --non-interactive refresh 2>&1` - if [ $debug -ne 0 ]; then - echo "zypper --non-interactive refresh" - echo $result + if [ $keeprepo -ne 1 ]; then + old_repo=`zypper lr |grep -e "^[0-9]" | cut -f2 -d '|'` + for x in $old_repo + do + result=`zypper rr $x` + done + result=`zypper --non-interactive refresh 2>&1` + if [ $debug -ne 0 ]; then + echo "zypper --non-interactive refresh" + echo $result + fi fi if [ $mounted -eq 0 ]; then @@ -281,11 +299,13 @@ elif ( pmatch "$OSVER" "sles11*" ); then else path="file://$OSPKGDIR" fi - result=`zypper ar $path $OSVER` + result=`zypper ar $path $OSVER 2>&1` if [ $? -ne 0 ]; then - logger -t xcat "ospkgs: zypper ar $path $OSVER\n $result" - echo "ospkgs: zypper ar $path $OSVER" - echo " $result" + if ( ! pmatch "$result" "*exists*" ); then + logger -t xcat "ospkgs: zypper ar $path $OSVER\n $result" + echo "ospkgs: zypper ar $path $OSVER" + echo " $result" + fi fi if [ "$SDKDIR" != "" ]; then @@ -294,12 +314,14 @@ elif ( pmatch "$OSVER" "sles11*" ); then else SDKDIR="file://$SDKDIR" fi - result=`zypper ar $SDKDIR $OSVER-sdk` + result=`zypper ar $SDKDIR $OSVER-sdk 2>&1` if [ $? -ne 0 ]; then - logger -t xcat "ospkgs: zypper ar $SDKDIR $OSVER-sdk\n $result" - echo "ospkgs: zypper ar $SDKDIR $OSVER-sdk" - echo " $result" - fi + if ( ! pmatch "$result" "*exists*" ); then + logger -t xcat "ospkgs: zypper ar $SDKDIR $OSVER-sdk\n $result" + echo "ospkgs: zypper ar $SDKDIR $OSVER-sdk" + echo " $result" + fi + fi fi result=`zypper --non-interactive refresh 2>&1` @@ -422,22 +444,27 @@ else exit 1; fi - #remove old repo - mkdir -p /etc/yum.repos.d - result=`rm /etc/yum.repos.d/*.repo 2>&1` + if [ $keeprepo -ne 1 ]; then + #remove old repo + mkdir -p /etc/yum.repos.d + result=`rm /etc/yum.repos.d/*.repo 2>&1` + fi + result=`yum clean all` #create new repo file REPOFILE="/etc/yum.repos.d/$OSVER.repo" - echo "[$OSVER]" > $REPOFILE - echo "name=$OSVER" >> $REPOFILE - if [ $mounted -eq 0 ]; then - echo "baseurl=http://$OSPKGDIR" >> $REPOFILE - else - echo "baseurl=file://$OSPKGDIR" >> $REPOFILE + 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 - echo "enabled=1" >> $REPOFILE - echo "gpgcheck=0" >> $REPOFILE #import the release key? #my $key = "$installDIR/$os/$arch/RPM-GPG-KEY-redhat-release";