From 0b2ca38509210cb578d3c173927d07a0df588aa7 Mon Sep 17 00:00:00 2001 From: "Leo.C.Wu" Date: Wed, 7 Jan 2015 15:35:14 +0800 Subject: [PATCH] 1. fix error message when removing a package in ubuntu, 2. fix error message when update packages, 3. fix apt source not correct in ospkgs --- xCAT/postscripts/ospkgs | 36 ++++++++++++++++++++++++++++-------- xCAT/postscripts/otherpkgs | 4 ++-- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/xCAT/postscripts/ospkgs b/xCAT/postscripts/ospkgs index 6ba858a80..5b51e9996 100755 --- a/xCAT/postscripts/ospkgs +++ b/xCAT/postscripts/ospkgs @@ -338,12 +338,14 @@ groups='' #groups pkgs_d='' #packages to remove OIFS=$IFS -IFS=$'\n' +IFS=$',' if ( pmatch "$OSVER" "ubuntu*" ); then - IFS=$(printf '\n') + IFS=$(printf ',') fi +pkgarray=($OSPKGS) +IFS=$OIFS -for x in `echo "$OSPKGS" | tr "," "\n"` +for x in ${pkgarray[@]}; do #remove leading and trailing spaces x=`echo $x |sed 's/^ *//;s/ *$//'` @@ -370,7 +372,6 @@ do fi fi done -IFS=$OIFS if [ $debug -ne 0 ]; then echo "pkgs=$pkgs" @@ -658,12 +659,31 @@ elif ( pmatch "$OSVER" "ubuntu*" ); then exit 1 fi - # No need to setup a /etc/apt/sources.list.d/ file because installation - # should already lead to /etc/apt/sources.list including the xcat install - # media repository. + # setup apt source for os distro updates + # check whether the os package path in primary apt source (/etc/apt/sources.list) or not + # if the os package path does not exist in /etc/apt/sources.list, + # create apt source file in /etc/apt/sources.list.d + + prirepo=/etc/apt/sources.list + repoprefix=/etc/apt/sources.list.d/xCAT-${OSVER}-path + oldif=$IFS + IFS="," + pkgdirs=($OSPKGDIR) + IFS=$oldif + + repocount=0 + for dir in ${pkgdirs[@]}; do + if grep "^deb\ .*$dir" $prirepo; then + continue + fi + #create apt source file in /etc/apt/sources.list.d + echo "deb http://$NFSSERVER/$dir ./" > "${repoprefix}${repocount}.list" + repocount=$(($repocount+1)) + done # upgrade existing packages - command="apt-get -y upgrade" + apt-get -y update + command="DEBIAN_FRONTEND=noninteractive apt-get -y --allow-unauthenticated --force-yes -o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef' upgrade " echo "=== $command" eval $command R=$? diff --git a/xCAT/postscripts/otherpkgs b/xCAT/postscripts/otherpkgs index 1bfaddd35..c70af8d65 100755 --- a/xCAT/postscripts/otherpkgs +++ b/xCAT/postscripts/otherpkgs @@ -788,9 +788,9 @@ EOF` elif [ $hasapt -eq 1 ]; then apt_get_update_if_repos_changed $REPOFILE if [ $VERBOSE ]; then - echo "$envlist DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" + echo "$envlist DEBIAN_FRONTEND=noninteractive apt-get -y --allow-unauthenticated --force-yes -o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef' upgrade" fi - result=`eval $envlist DEBIAN_FRONTEND=noninteractive apt-get -y upgrade 2>&1` + result=`eval $envlist DEBIAN_FRONTEND=noninteractive apt-get -y --allow-unauthenticated --force-yes -o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef' upgrade 2>&1` R=$? if [ $R -ne 0 ]; then RETURNVAL=$R