#! /bin/sh # $Id$ # vim:et:ft=sh:sts=2:sw=2 # # Copyright 2008 Kate Ward. All Rights Reserved. # Copyright 2013 Mario Fetka. All Rights Reserved. # Released under the LGPL (GNU Lesser General Public License) # # Author: Mario Fetka # # treat unset variables as an error set -u die() { [ $# -gt 0 ] && echo "error: $@" | boxes -d shell >&2 exit 1 } BASE_DIR="`dirname $0`/.." LIB_DIR="${BASE_DIR}/lib" # load libraries . ${LIB_DIR}/shflags || die 'unable to load shflags library' . ${LIB_DIR}/shlib || die 'unable to load shlib library' . ${LIB_DIR}/versions || die 'unable to load versions library' # Source local build configuration (must be done AFTER sourcing the builder-product.cfg.cfg) test -f $HOME/.opsi-administration.cfg && . $HOME/.opsi-administration.cfg # define flags DEFINE_string 'name' '' 'the name of the package' 'n' DEFINE_string 'version' 'latest' 'the version of the package' 'v' DEFINE_string 'type' 'public' 'type of package' 'y' DEFINE_string 'from' '' 'source level of package' 'f' DEFINE_string 'to' '' 'output file to write to' 't' DEFINE_string 'root' '' 'output file to write to' 'r' DEFINE_string 'show' 'integration' 'show a list of the' 's' DEFINE_boolean 'delete' true 'delete old versions of the package' 'd' FLAGS_HELP="USAGE: ${ARGV0} [flags]" if [ `which 7z` ] || exit show() { local show_dir=$1 local show_name=$2 # Find all revision files and sort them local file_list=`mktemp /tmp/opsi-administration.show.XXXXXXXXXXX` local file_list_version=`mktemp /tmp/opsi-administration.show.version.XXXXXXXXXXX` local file_list_release=`mktemp /tmp/opsi-administration.show.release.XXXXXXXXXXX` local file_list_final=`mktemp /tmp/opsi-administration.show.final.XXXXXXXXXXX` local show_list=`mktemp /tmp/opsi-administration.show.list.XXXXXXXXXXX` echo "Web Root: ${show_dir} Package Name: ${show_name}" >> $show_list echo "" >> $show_list for cfg_file in `find ${show_dir} -name "${show_name}-*.cfg" -print ` ; do . ${cfg_file} echo $REV_VERSION >> ${file_list} done sort -V ${file_list} | uniq > ${file_list_version} for pkg_version in `cat ${file_list_version}` ; do for cfg_file_ver in ${show_dir}/${show_name}-${pkg_version}-*.cfg ; do . ${cfg_file_ver} echo ${pkg_version}-$REV_CREATOR_TAG$REV_RELEASE >> ${file_list_release} done done sort -n ${file_list_release} | uniq > ${file_list_final} for release_file_list in `cat ${file_list_final}` ; do . ${show_dir}/${show_name}-${release_file_list}.cfg echo $REV_PN-$REV_VERSION-$REV_CREATOR_TAG$REV_RELEASE >> $show_list done boxes -d shell $show_list rm -f ${show_list} rm -f ${file_list} rm -f ${file_list_final} rm -f ${file_list_version} rm -f ${file_list_release} } main() { if [ -n "${FLAGS_root:-}" ];then OPSI_WEB_ROOT=${FLAGS_root:} fi # determine package dir local show_dir="${OPSI_WEB_ROOT}/${FLAGS_type:+${FLAGS_type}/}${FLAGS_show:+${FLAGS_show}/}" # checks [ -n "${FLAGS_name:-}" ] || die 'name flag missing' if [ -z "${FLAGS_from:-}" ]; then if [ -z "${FLAGS_from:-}" ]; then show $show_dir ${FLAGS_name:-} fi elif [ -z "${FLAGS_show:-}" ]; then show $show_dir ${FLAGS_name:-} fi # if [ ${FLAGS_dry_run} -eq ${FLAGS_FALSE} -a -f "${output}" ]; then # if [ ${FLAGS_force} -eq ${FLAGS_TRUE} ]; then # rm -f "${output}" # else # echo "not overwriting '${output}'" >&2 # exit ${FLAGS_ERROR} # fi # fi # if [ ${FLAGS_dry_run} -eq ${FLAGS_FALSE} ]; then # touch "${output}" 2>/dev/null || die "unable to write to '${output}'" # fi # run tests # ( # cd "${SRC_DIR}"; # if [ ${FLAGS_dry_run} -eq ${FLAGS_FALSE} ]; then # ./${FLAGS_suite} |tee "${output}" # else # ./${FLAGS_suite} # fi # ) # if [ ! ${FLAGS_dry_run} ]; then # echo >&2 # echo "output written to '${output}'" >&2 # fi } FLAGS "$@" || exit $? [ ${FLAGS_help} -eq ${FALSE} ] || exit eval set -- "${FLAGS_ARGV}" main "$@"