Changeset 13483 in hybrid


Ignore:
Timestamp:
Nov 18, 2015, 9:40:00 PM (7 years ago)
Author:
rick
Message:

Migrating package building to poudriere [dry-coded]

https://www.wirelessleiden.nl/projects/nodefactory/wiki/Poudriere

Location:
branches/releng-10/nanobsd/tools
Files:
4 added
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/releng-10/nanobsd/tools/package-build.sh

    r13411 r13483  
    11#!/bin/sh
    2 # Install all required packages
    32#
    4 # XXX: Welcome to port hell, if /usr/ports has been updated, you actually want
    5 # to delete all installed packages and start over again, hence why people used
    6 # to run this stuff in jails, etc.
    7 #
    8 # TODO: Poudriere is mature and the way to go for these days:
    9 #     https://www.freebsd.org/doc/handbook/ports-poudriere.html
     3# Compile listing of required packages using poudriere and friends
    104#
    115# Rick van der Zwet <rick@wirelessleiden.nl>
    126#
    137
    14 . `dirname $0`/package-build.inc.sh
     8. `dirname $0`/common.inc.sh
    159
    16 DEBUG=${DEBUG:-'0'}
     10cfg_dir=`dirname $0`/../cfg
     11poudriere_pkglist_file=${cfg_dir}/wlpkgbuild10_2-default-node-pkglist
    1712
    18 # Find listing of packages to build
    19 PKG_TO_BUILD=${PKG_TO_BUILD:-${PACKAGE_LIST}}
    2013
    21 # make options, for package building
    22 LOGDIR=`mktemp -d /tmp/$(basename $0 .sh)-$(date '+%Y%m%d-%H:%M:%S')X`
     14packages_initenv() {
     15        config_dir=`dirname $0`
    2316
    24 p_info Log directory ${LOGDIR}
    25 p_info Make arguments are:
    26 p_info `p_list ${PKG_MAKE_ARGS}`
    27 p_info Make configuration is:
    28 echo "${PKG_MAKE_CONF}" | sed 's/^/## /'
     17        # Install required deamons
     18        pkg install poudriere dialog4ports portshaker
    2919
    30 # HACK: install our own ports _inside_ the normal ports dir
    31 cp -fR $WL_PORTSDIR/* $PORTSDIR || exit 1
     20        # Setup poudriere build environment
     21        poudriere jail -c -j wlpkgbuild10_2 -v 10.2-RELEASE -a i386
    3222
    33 # Cleanup of old packages
    34 if [ -d "${NANO_PACKAGE_DIR}" ]; then
    35         p_warn "Deleted all (old) packages at ${NANO_PACKAGE_DIR}"
    36         rm -R ${NANO_PACKAGE_DIR}/*
     23        # Setup portshaker
     24        cp ${config_dir}/portshaker.conf /usr/local/etc/
     25        cp ${config_dir}/portshaker.d/* /usr/local/etc/portshaker.d
     26
     27        # Update ports
     28        portshaker -U
     29        portshaker -M
     30
     31        # Setup poudriere ports environment
     32        poudriere ports -c -F -f none -p default -M /usr/local/poudriere/ports/default
     33
     34        # Build options
     35        poudriere options -j wlpkgbuild10_2 -p default -z node -f ${poudriere_pkglist_file}
     36}
     37
     38
     39package_build() {
     40        poudriere bulk -j wlpkgbuild10_2 -p default -z node -f ${poudriere_pkglist_file}
     41}
     42
     43# Make package list
     44. $cfg_dir/nanobsd.wleiden
     45echo $PACKAGE_LIST | tr " " "\n" > ${poudriere_pkglist_file}
     46
     47
     48if [ "x$1" = "xinitenv" ]; then
     49        packages_initenv
     50elif [ "x$1" = "xbuild" ]; then
     51        package_build
     52else
     53        echo "Usage $0 <initenv|build>"
     54        exit 128
    3755fi
    38 p_info Created target dir ${NANO_PACKAGE_DIR}
    39 mkdir -p ${NANO_PACKAGE_DIR}
    40 
    41 # Build required packages
    42 MAKE_CONF=`mktemp -t $(basename $0)`
    43 echo "${PKG_MAKE_CONF}" > $MAKE_CONF
    44 MAKE="make __MAKE_CONF=$MAKE_CONF ${PKG_MAKE_ARGS}"
    45 BUILD_LIST=''
    46 set `echo ${PKG_TO_BUILD} | xargs -n1 -I% echo $PORTSDIR/%`
    47 while [ "$1" ]; do
    48   PACKAGE=$1; shift
    49   BUILD_LIST="${BUILD_LIST} ${PACKAGE}"
    50 
    51   # Build new one
    52   LOGFILE="$LOGDIR/build_`echo $PACKAGE | tr '/' '_'`.log"
    53   echo ""
    54   p_info Packaging $PACKAGE
    55   cd $PACKAGE || exit 1
    56 
    57   # Check for build dependencies
    58   BUILDDEP_PKG=`${MAKE} build-depends-list | awk -F: '{print $2}'`
    59   if [ -n "${BUILDDEP_PKG}" ]; then
    60           p_info Build dependencies needed are:
    61           p_info `p_list ${BUILDDEP_PKG}`
    62   fi
    63 
    64   # Check for run dependencies
    65   PKGDEP_PKGS=`${MAKE} package-depends-list | awk '{print $2}'`
    66   if [ -n "${PKGDEP_PKGS}" ]; then
    67           p_info Package dependencies also packaged are:
    68           p_info `p_list ${PKGDEP_PKGS}`
    69   fi
    70 
    71   PKGNAME=`${MAKE} extract-message | awk '{print $NF}'`
    72   PKGBUILDLOG=/tmp/build.$$.`basename $PACKAGE`.log
    73   p_info Packaging $PACKAGE ... details at $PKGBUILDLOG
    74   ${MAKE} PACKAGES=/root/nanobsd/pkg clean package do-package 1>>$PKGBUILDLOG 2>>$PKGBUILDLOG
    75   if [ $? -ne 0 ]; then
    76     p_err "Failed to create $PKGNAME"
    77     exit 1
    78   fi
    79 
    80   p_info Checking dependencies
    81   for PKG in $PKGDEP_PKGS; do
    82      echo "${BUILD_LIST}" | grep -q "$PKG"
    83      if [ $? -eq 0 ]; then
    84        # Already packaged
    85        p_info ${PKG} Already packaged
    86      else
    87        echo $@  | grep -q "${PKG}"
    88        if [ $? -eq 0 ]; then
    89           p_info ${PKG} Already planned
    90        else
    91           set $@ ${PKG}
    92        fi
    93      fi
    94   done
    95   p_info Packaging $PACKAGE succesfull
    96 done
    97  
    98 p_info `echo ${BUILD_LIST} | wc -w` packages build succesfully
    99 
    100 if [ ${DEBUG} -eq 0 ]; then
    101   rm -R ${LOGDIR}
    102 else
    103   p_info Debugging enabled ${LOGDIR} saved
    104 fi
    105 
    106 # House keeping
    107 rm $MAKE_CONF
    108 
  • branches/releng-10/nanobsd/tools/write-image.sh

    r13482 r13483  
    22# Wrapper allowing to write image to card writer
    33
    4 . $(dirname $0)/package-build.inc.sh
     4. $(dirname $0)/common.inc.sh
    55
    66BASEDIR=`dirname $0`
Note: See TracChangeset for help on using the changeset viewer.