1#!/bin/sh 2# 3# $FreeBSD$ 4# 5 6main() { 7 desc= 8 comment= 9 debug= 10 uclsource= 11 while getopts "do:s:u:" arg; do 12 case ${arg} in 13 d) 14 debug=1 15 ;; 16 o) 17 outname="${OPTARG}" 18 origname="${OPTARG}" 19 ;; 20 s) 21 srctree="${OPTARG}" 22 ;; 23 u) 24 uclfile="${OPTARG}" 25 ;; 26 *) 27 echo "Unknown argument" 28 ;; 29 esac 30 done 31 32 shift $(( ${OPTIND} - 1 )) 33 34 vital="false" 35 36 case "${outname}" in 37 clibs) 38 vital="true" 39 # clibs should not have any dependencies or anything 40 # else imposed on it. 41 ;; 42 caroot) 43 pkgdeps="utilities" 44 ;; 45 utilities) 46 uclfile="${uclfile}" 47 vital="true" 48 ;; 49 runtime) 50 outname="runtime" 51 _descr="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESCR)" 52 vital="true" 53 ;; 54 *-lib32_dev) 55 outname="${outname%%-lib32_dev}" 56 _descr="32-bit Libraries, Development Files" 57 pkgdeps="${outname}" 58 ;; 59 *-lib32_dbg) 60 outname="${outname%%-lib32_dbg}" 61 _descr="32-bit Libraries, Debugging Symbols" 62 pkgdeps="${outname}" 63 ;; 64 *-lib32) 65 outname="${outname%%-lib32}" 66 _descr="32-bit Libraries" 67 pkgdeps="${outname}" 68 ;; 69 *-dev) 70 outname="${outname%%-dev}" 71 _descr="Development Files" 72 pkgdeps="${outname}" 73 ;; 74 *-dbg) 75 outname="${outname%%-dbg}" 76 _descr="Debugging Symbols" 77 pkgdeps="${outname}" 78 ;; 79 *-man) 80 outname="${outname%%-man}" 81 _descr="Manual Pages" 82 pkgdeps="${outname}" 83 ;; 84 ${origname}) 85 pkgdeps="runtime" 86 ;; 87 *) 88 uclfile="${outname##*}${origname}" 89 outname="${outname##*}${origname}" 90 ;; 91 esac 92 93 desc="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESC)" 94 comment="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_COMMENT)" 95 96 uclsource="${srctree}/release/packages/${outname}.ucl" 97 if [ ! -e "${uclsource}" ]; then 98 uclsource="${srctree}/release/packages/template.ucl" 99 fi 100 101 if [ ! -z "${debug}" ]; then 102 echo "" 103 echo "===============================================================" 104 echo "DEBUG:" 105 echo "_descr=${_descr}" 106 echo "outname=${outname}" 107 echo "origname=${origname}" 108 echo "srctree=${srctree}" 109 echo "uclfile=${uclfile}" 110 echo "desc=${desc}" 111 echo "comment=${comment}" 112 echo "vital=${vital}" 113 echo "cp ${uclsource} -> ${uclfile}" 114 echo "===============================================================" 115 echo "" 116 echo "" 117 echo "" 118 fi 119 120 [ -z "${comment}" ] && comment="${outname} package" 121 [ ! -z "${_descr}" ] && comment="${comment} (${_descr})" 122 [ -z "${desc}" ] && desc="${outname} package" 123 124 cp "${uclsource}" "${uclfile}" 125 if [ ! -z "${pkgdeps}" ]; then 126 cat <<EOF >> ${uclfile} 127deps: { 128 FreeBSD-${pkgdeps}: { 129 origin: "base", 130 version: "${PKG_VERSION}" 131 } 132} 133EOF 134 fi 135 cap_arg="$( make -f ${srctree}/share/mk/bsd.endian.mk -VCAP_MKDB_ENDIAN )" 136 sed -i '' -e "s/%VERSION%/${PKG_VERSION}/" \ 137 -e "s/%PKGNAME%/${origname}/" \ 138 -e "s/%COMMENT%/${comment}/" \ 139 -e "s/%DESC%/${desc}/" \ 140 -e "s/%VITAL%/${vital}/" \ 141 -e "s/%CAP_MKDB_ENDIAN%/${cap_arg}/g" \ 142 -e "s/%PKG_NAME_PREFIX%/${PKG_NAME_PREFIX}/" \ 143 -e "s|%PKG_WWW%|${PKG_WWW}|" \ 144 -e "s/%PKG_MAINTAINER%/${PKG_MAINTAINER}/" \ 145 ${uclfile} 146 return 0 147} 148 149main "${@}" 150