Misplaced quotes
[fbsd-stable-mgmt.git] / update_stage0.sh
index 2a299b585a93910c75248a2fa02bfc549202a223..bc10a0fa116ef13eff982d95b2861122cb34cdb4 100755 (executable)
@@ -2,6 +2,7 @@
 
 usage() {
        echo 'Usage: ...'
+       echo '-c        clean obj'
        echo '-u        svn update'
        echo '-j        jobs to be handled'
        echo 'default to ' ${jarg}
@@ -11,11 +12,14 @@ usage() {
 parse() {
        RED='\033[0;31m'
        NC='\033[0m' # No Color
-       while getopts "uj:" option 
+       while getopts "cuj:" option 
        do
                case ${option} in
+                       c)
+                               CLEANING=1
+                               ;;
                        u)
-                               update="1"
+                               UPDATE=1
                                ;;
                        j)
                                case ${OPTARG} in 
@@ -27,28 +31,31 @@ parse() {
                                        ;;
                                esac
                                ;;
+                       *)
+                               usage;;
                esac
        done
 }
 
 
 jarg=`sysctl -n hw.ncpu`
+usrsrc=${USRSRC:-/usr/src}
 
+parse ${*} 
 
-if [ $? -ne 0 ] 
-then 
-       usage 
-else
-       parse ${*} 
+if [ ${UPDATE:=-0} -eq 1 ]; then 
+       echo "updating ..." 
+       svnlite update ${usrsrc}
+       [ ${?} == 1 ] && exit 1
 fi
 
-[ ${update} ] && svn update /usr/src
 
-echo Cleaning
-chflags -R noschg /usr/obj/* && rm -rf /usr/obj
-echo building process on ${jarg} jobs
-cd /usr/src && \
-make -j${jarg} buildworld && make -j${jarg} kernel KERNCONF=PEPINS && \
-echo "Reboot the system."
+if [ ${CLEANING:=-0} -eq 1 ]; then 
+       echo Cleaning
+       chflags -R noschg /usr/obj/* && sync && rm -rf /usr/obj && sync
+fi
 
+echo building process on ${jarg} jobs
+make -C ${usrsrc} -j${jarg} buildworld && make -C ${usrsrc} -j${jarg} kernel KERNCONF=PEPINS \
+       && echo "Reboot the system."