Print this page
buildctl should honor opts and pass them to build.sh scripts
   1 #!/usr/bin/bash
   2 
   3 NOBANNER=1
   4 batch_flag=""

   5 if [ "${BATCH}" = 1 ]; then
   6     echo "Enabling batch mode."
   7     batch_flag="-b"
   8 fi
   9 . ../lib/functions.sh
  10 
  11 [ "${1}" == "licenses" ] && AUDIT_LICENSE=1
  12 
  13 # targets maps any valid package name to its build script.
  14 declare -A targets
  15 # fulltargets maps full package names to their build script.
  16 declare -A fulltargets
  17 declare -A licenses
  18 TCNT=0
  19 for build in */build*.sh
  20 do
  21     for PKG in $(grep -v '##IGNORE##' $build | sed -e 's/^ +//' -e 's/ +#.+//' -e 's/=/ /g' -e 's/^.+make_package/make_package/g' | awk '{if($1=="PKG"){PKG=$2; print $2;} if($1=="make_package"){print PKG"="$2;}}')
  22     do
  23         if [ -n "`echo ${PKG} | grep '.='`" ] ; then
  24             [ -z "${AUDIT_LICENSE}" ] && continue


 101                 echo "File archive found. Extracting..."
 102                 bzip2 -dc root.tar.bz2 | tar xf - || \
 103                     bail "Failed to extract root.tar.bz2"
 104                 echo "Publishing from $SCRIPT.final"
 105                 pkgsend -s $PKGSRVR publish -d $PKGROOT $SCRIPT.final || \
 106                     bail "pkgsend failed"
 107                 rm -rf $PKGROOT
 108             # In case we just have a tree of files and not a tarball
 109             elif [[ -d $PKGROOT ]]; then
 110                 echo "Publishing from $SCRIPT.final"
 111                 pkgsend -s $PKGSRVR publish -d $PKGROOT $SCRIPT.final || \
 112                     bail "pkgsend failed"
 113             # Else we just have a manifest to import
 114             else
 115                 echo "Simple manifest to import... importing to $PKGSRVR"
 116                 pkgsend -s $PKGSRVR publish $SCRIPT.final || \
 117                     bail "pkgsend failed"
 118                 rm $SCRIPT.final
 119             fi
 120         else
 121             PATH=$PATH:. $SCRIPT -r $PKGSRVR $batch_flag || \
 122                 logerr "Unable to run $SCRIPT"
 123         fi
 124     popd >/dev/null
 125 }
 126 
 127 licenses() {
 128     LCNT=0
 129     for target in "${!licenses[@]}"
 130     do
 131         if [[ -n "${licenses[$target]}" ]]; then
 132             echo " * $target     -> ${licenses[$target]}"
 133             LCNT=$(($LCNT + 1))
 134         fi
 135     done | sort
 136     if [ $LCNT -ne $TCNT ]; then
 137         echo
 138         echo "=== Packages missing license information ==="
 139         for target in "${!licenses[@]}"
 140         do
 141             if [[ -z "${licenses[$target]}" ]]; then
 142                 echo " * $target"
 143             fi
 144         done | sort
 145     fi
 146 }
 147 
 148 DEFAULT_PKGSRVR=$PKGSRVR
 149 DEFAULT_PKGPUBLISHER=$PKGPUBLISHER
 150 












 151 case "$1" in
 152     list)
 153         list $2
 154         exit
 155         ;;
 156 
 157     licenses)
 158         licenses
 159         exit
 160         ;;
 161 
 162     build)
 163         shift
 164         tobuild=$*
 165         if [ -z "$tobuild" ] || [ "$tobuild" == "all" ]; then
 166                 batch_flag="-b"
 167                 for tgt in "${!fulltargets[@]}"; do
 168                         # Uncomment the echo line if you want to see a
 169                         # one-package-per-line status of what's building in
 170                         # /tmp/debug.<PID>.
   1 #!/usr/bin/bash
   2 
   3 NOBANNER=1
   4 batch_flag=""
   5 lint_flag=""
   6 if [ "${BATCH}" = 1 ]; then
   7     echo "Enabling batch mode."
   8     batch_flag="-b"
   9 fi
  10 . ../lib/functions.sh
  11 
  12 [ "${1}" == "licenses" ] && AUDIT_LICENSE=1
  13 
  14 # targets maps any valid package name to its build script.
  15 declare -A targets
  16 # fulltargets maps full package names to their build script.
  17 declare -A fulltargets
  18 declare -A licenses
  19 TCNT=0
  20 for build in */build*.sh
  21 do
  22     for PKG in $(grep -v '##IGNORE##' $build | sed -e 's/^ +//' -e 's/ +#.+//' -e 's/=/ /g' -e 's/^.+make_package/make_package/g' | awk '{if($1=="PKG"){PKG=$2; print $2;} if($1=="make_package"){print PKG"="$2;}}')
  23     do
  24         if [ -n "`echo ${PKG} | grep '.='`" ] ; then
  25             [ -z "${AUDIT_LICENSE}" ] && continue


 102                 echo "File archive found. Extracting..."
 103                 bzip2 -dc root.tar.bz2 | tar xf - || \
 104                     bail "Failed to extract root.tar.bz2"
 105                 echo "Publishing from $SCRIPT.final"
 106                 pkgsend -s $PKGSRVR publish -d $PKGROOT $SCRIPT.final || \
 107                     bail "pkgsend failed"
 108                 rm -rf $PKGROOT
 109             # In case we just have a tree of files and not a tarball
 110             elif [[ -d $PKGROOT ]]; then
 111                 echo "Publishing from $SCRIPT.final"
 112                 pkgsend -s $PKGSRVR publish -d $PKGROOT $SCRIPT.final || \
 113                     bail "pkgsend failed"
 114             # Else we just have a manifest to import
 115             else
 116                 echo "Simple manifest to import... importing to $PKGSRVR"
 117                 pkgsend -s $PKGSRVR publish $SCRIPT.final || \
 118                     bail "pkgsend failed"
 119                 rm $SCRIPT.final
 120             fi
 121         else
 122             PATH=$PATH:. $SCRIPT -r $PKGSRVR $batch_flag $lint_flag || \
 123                 logerr "Unable to run $SCRIPT"
 124         fi
 125     popd >/dev/null
 126 }
 127 
 128 licenses() {
 129     LCNT=0
 130     for target in "${!licenses[@]}"
 131     do
 132         if [[ -n "${licenses[$target]}" ]]; then
 133             echo " * $target     -> ${licenses[$target]}"
 134             LCNT=$(($LCNT + 1))
 135         fi
 136     done | sort
 137     if [ $LCNT -ne $TCNT ]; then
 138         echo
 139         echo "=== Packages missing license information ==="
 140         for target in "${!licenses[@]}"
 141         do
 142             if [[ -z "${licenses[$target]}" ]]; then
 143                 echo " * $target"
 144             fi
 145         done | sort
 146     fi
 147 }
 148 
 149 DEFAULT_PKGSRVR=$PKGSRVR
 150 DEFAULT_PKGPUBLISHER=$PKGPUBLISHER
 151 
 152 # When we get here, honor any -l or -b flags from the buildctl command line,
 153 # or even the environment.
 154 
 155 if [ "${BATCH}" = 1 ]; then
 156     logmsg "Enabling batch mode."
 157     batch_flag="-b"
 158 fi
 159 if [ "${SKIP_PKGLINT}" = 1 ]; then
 160     logmsg "Disabling pkglint."
 161     lint_flag="-l"
 162 fi
 163 
 164 case "$1" in
 165     list)
 166         list $2
 167         exit
 168         ;;
 169 
 170     licenses)
 171         licenses
 172         exit
 173         ;;
 174 
 175     build)
 176         shift
 177         tobuild=$*
 178         if [ -z "$tobuild" ] || [ "$tobuild" == "all" ]; then
 179                 batch_flag="-b"
 180                 for tgt in "${!fulltargets[@]}"; do
 181                         # Uncomment the echo line if you want to see a
 182                         # one-package-per-line status of what's building in
 183                         # /tmp/debug.<PID>.