Changeset 2c5afdb


Ignore:
Timestamp:
05/06/14 08:11:35 (14 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, enter/10, releng/10.0.2, releng/10.0.3, releng/10.1, releng/10.1.1, releng/10.1.2
Children:
3305db9
Parents:
bcf5744
Message:

Add support to pc-updatemanager for the -j <jail> flag when doing
package updates / checks. This will allow doing jail package updates
via the AppCafe? and CLI, using our custom package conflict solver

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-sh/pc-updatemanager/pc-updatemanager

    r5f3d3fe r2c5afdb  
    6060IGNDIR="${DBDIR}/ignored" 
    6161 
     62# PKG_CMD to use 
     63PKG_CMD="/usr/sbin/pkg" 
     64 
     65# Make sure we don't keep these from system environment 
     66unset INJAIL PKG_FLAG 
     67 
    6268ISOTMP="/usr/local/tmp/pcbsd-update.iso" 
    6369 
     
    7076 
    7177show_usage() { 
    72         echo "$0 - Usage 
     78        echo "pc-updatemanager: Usage 
    7379---- 
    7480  branches              - List available system branches 
     
    503509  clear 
    504510  echo "Removing packages...This may take a while..." 
    505   pkg delete -afy 
     511  ${PKG_CMD} delete -afy 
    506512  if [ $? -ne 0 ] ; then 
    507513     echo "Warning: Failed to remove all packages" 
     
    653659 
    654660  # Now update pkgng 
    655   pkg-static update -f 
     661  ${PKG_CMD} update -f 
    656662  if [ $? -ne 0 ] ; then 
    657663     echo "Failed updating pkgng repo..." 
     
    662668  if [ "$SYSTYPE" = "desktop" ] ; then 
    663669    echo "Installing desktop packages..." 
    664     pkg-static install -y pcbsd-base 
     670    ${PKG_CMD} install -y pcbsd-base 
    665671    if [ $? -ne 0 ] ; then 
    666672       PKGSTATUS=1 
     
    674680  else 
    675681    echo "Installing server packages..." 
    676     pkg-static install -y trueos-base 
     682    ${PKG_STATIC} install -y trueos-base 
    677683    if [ $? -ne 0 ] ; then 
    678684       PKGSTATUS=1 
     
    697703    for i in $pkgDeps 
    698704    do 
    699       pkg-static info -e ${i} 
     705      ${PKG_CMD} info -e ${i} 
    700706      if [ $? -eq 0 ] ; then continue ; fi 
    701707 
    702       pkg-static install -y ${i} 
     708      ${PKG_CMD} install -y ${i} 
    703709      if [ $? -ne 0 ] ; then 
    704710         METASTATUS=1 
     
    717723  do 
    718724    # Make sure package isn't already installed 
    719     pkg-static info -e ${userpkg} 
     725    ${PKG_CMD} info -e ${userpkg} 
    720726    if [ $? -eq 0 ] ; then continue ; fi 
    721727 
    722728    # Nope, lets try to load it now 
    723     pkg-static install -y ${userpkg} 
     729    ${PKG_CMD} install -y ${userpkg} 
    724730    if [ $? -ne 0 ] ; then 
    725731       USERPKGSTATUS=1 
     
    870876 
    871877  local i 
    872   for i in `pkg query '%do' ${1}` 
     878  for i in `${PKG_CMD} query '%do' ${1}` 
    873879  do 
    874880     echo "$i" >> ${2} 
     
    919925 
    920926  # Now lets build some lists of what is present on this system now 
    921   pkg info > /root/pcbsd-pkg-before-update 
     927  ${PKG_CMD} info > /root/pcbsd-pkg-before-update 
    922928  pbi_info > /root/pcbsd-pbi-before-update.tmp 
    923929  pc-metapkgmanager list-installed > /root/pcbsd-meta-before-update 
     
    969975 
    970976  # Build a list of *all* package origins 
    971   pkg query -a '%o' | sort > ${mOriginFile}.system 
     977  ${PKG_CMD} query -a '%o' | sort > ${mOriginFile}.system 
    972978 
    973979  # Save a list of packages that the user installed from elsewhere than our meta-packages 
     
    11371143 
    11381144  # Update the repo DB 
    1139   rc_halt "pkg-static update" 
    1140  
    1141   pkg-static upgrade -n >/tmp/.pkgData.$$ 
     1145  rc_halt "${PKG_CMD} update" 
     1146 
     1147  ${PKG_CMD} ${PKG_FLAG} upgrade -n >/tmp/.pkgData.$$ 
    11421148  if [ $? -ne 0 ] ; then 
    11431149     echo "Error checking for package updates..." 
     
    11631169  rm /tmp/.pkgData.$$ 
    11641170  echo "" 
    1165   echo "To start the upgrade run \"${0} pkgupdate\"" 
     1171  echo "To start the upgrade run \"${0} ${PKG_FLAG} pkgupdate\"" 
    11661172  if [ -e "/usr/local/bin/pc-systemflag" ]; then 
    11671173    pc-systemflag PKGUPDATE UPDATE #set the system flag that updates available 
     
    11851191 
    11861192  # Update the DB first 
    1187   pkg-static update -f 
     1193  ${PKG_CMD} ${PKG_FLAG} update -f 
    11881194 
    11891195  # Enable EVENT_PIPE again 
     
    11951201 
    11961202  # Look for conflicts 
    1197   check_pkg_conflicts "upgrade -FUy $1" 
     1203  check_pkg_conflicts "upgrade -FUy $1" "$PKG_FLAG" 
    11981204  if [ $? -ne 0 ] ; then 
    11991205     exit 1 
     
    12041210 
    12051211  # Start the package update! 
    1206   pkg-static upgrade -U -y ${1} 
     1212  ${PKG_CMD} ${PKG_FLAG} upgrade -U -y ${1} 
    12071213  result=$? 
    12081214 
    1209   # Lets now re-extract our overlay data to grab any adjusted port files 
    1210   pc-extractoverlay ports >/dev/null 2>/dev/null 
    1211  
    1212   # Now re-extract overlay files to ensure we do file fixing / massaging  
    1213   if [ "$SYSTYPE" = "PCBSD" ]; then  
    1214     pc-extractoverlay desktop 
    1215   fi 
    1216   if [ "$SYSTYPE" = "TRUEOS" ]; then  
    1217     pc-extractoverlay server 
     1215  if [ -z "$INJAIL" ] ; then 
     1216    # Lets now re-extract our overlay data to grab any adjusted port files 
     1217    pc-extractoverlay ports >/dev/null 2>/dev/null 
     1218    # Now re-extract overlay files to ensure we do file fixing / massaging  
     1219    if [ "$SYSTYPE" = "PCBSD" ]; then pc-extractoverlay desktop; fi 
     1220    if [ "$SYSTYPE" = "TRUEOS" ]; then pc-extractoverlay server; fi 
    12181221  fi 
    12191222 
     
    12321235} 
    12331236 
     1237# Make sure this is a valid jail 
     1238set_jail_mode() 
     1239{ 
     1240        # Check if this is a JID 
     1241        jls | grep -v "JID" | tr -s ' ' | sed 's,^[ \t]*,,' | grep -q "^$1 " 
     1242        if [ $? -eq 0 ] ; then 
     1243                INJAIL="$1" 
     1244                PKG_FLAG="-j $1" 
     1245                return 
     1246        fi 
     1247         
     1248        # Is this a hostname? 
     1249        line=`jls | grep -v "JID" | tr -s ' ' | sed 's,^[ \t]*,,' | grep -w "$1" | head -n 1` 
     1250        if [ -n "$line" ] ; then 
     1251                INJAIL="`echo $line | awk '{print $1}'`"         
     1252                PKG_FLAG="-j $INJAIL" 
     1253                return 
     1254        fi 
     1255 
     1256        exit_err "No such jail: $1" 
     1257} 
     1258 
    12341259if [ "`id -u`" = "0" ] ; then 
    12351260  # Make the installed directory for this version 
     
    12401265fi 
    12411266 
    1242 case $1 in 
    1243            check) get_update_file 
    1244                   do_check ;; 
     1267if [ $# -eq 0 ] ; then 
     1268   show_usage 
     1269   exit 1 
     1270fi 
     1271 
     1272while [ $# -gt 0 ] ; do 
     1273 
     1274   case $1 in 
     1275           check) if [ -n "$INJAIL" ] ; then 
     1276                     exit_err "Cannot run this inside a jail..." 
     1277                  fi 
     1278                  get_update_file 
     1279                  do_check ; break ;; 
    12451280        branches) get_update_file 
    1246                   list_branches ;; 
     1281                  list_branches ; break ;; 
    12471282        chbranch) get_update_file 
    1248                   do_branch "${2}" ;; 
    1249         pkgcheck) checkup_pkgs ;; 
    1250        pkgupdate) update_pkgs "$2" ;; 
    1251 finish-major-update) finish_major_fbsd_update ;; 
    1252          install) get_update_file 
    1253                   do_install "${2}" ;; 
     1283                  do_branch "${2}" ; break ;; 
     1284        pkgcheck) checkup_pkgs ; break ;; 
     1285       pkgupdate) update_pkgs "$2" ; break ;; 
     1286finish-major-update) finish_major_fbsd_update ; break ;; 
     1287         install) if [ -n "$INJAIL" ] ; then 
     1288                     exit_err "Cannot run this inside a jail..." 
     1289                  fi 
     1290                  get_update_file 
     1291                  do_install "${2}" ; break ;; 
     1292       -j) shift  
     1293           set_jail_mode "$1" 
     1294           ;; 
    12541295        *) show_usage ;; 
    1255 esac 
     1296   esac 
     1297   shift 
     1298done 
    12561299 
    12571300exit 0 
Note: See TracChangeset for help on using the changeset viewer.