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 outname="$(echo ${outname} | tr '-' '_')" 35 36 case "${outname}" in 37 clibs) 38 # clibs should not have any dependencies or anything 39 # else imposed on it. 40 ;; 41 caroot) 42 pkgdeps="utilities" 43 ;; 44 runtime) 45 outname="runtime" 46 uclfile="${uclfile}" 47 ;; 48 runtime_manuals) 49 outname="${origname}" 50 pkgdeps="runtime" 51 ;; 52 runtime_*) 53 outname="${origname}" 54 uclfile="${outname##*}${uclfile}" 55 pkgdeps="runtime" 56 _descr="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESCR)" 57 ;; 58 jail_*) 59 outname="${origname}" 60 uclfile="${outname##*}${uclfile}" 61 pkgdeps="runtime" 62 _descr="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESCR)" 63 ;; 64 *_lib32_development) 65 outname="${outname%%_lib32_development}" 66 _descr="32-bit Libraries, Development Files" 67 pkgdeps="${outname}" 68 ;; 69 *_lib32_debug) 70 outname="${outname%%_lib32_debug}" 71 _descr="32-bit Libraries, Debugging Symbols" 72 pkgdeps="${outname}" 73 ;; 74 *_lib32) 75 outname="${outname%%_lib32}" 76 _descr="32-bit Libraries" 77 pkgdeps="${outname}" 78 ;; 79 *_development) 80 outname="${outname%%_development}" 81 _descr="Development Files" 82 pkgdeps="${outname}" 83 ;; 84 *_debug) 85 outname="${outname%%_debug}" 86 _descr="Debugging Symbols" 87 pkgdeps="${outname}" 88 ;; 89 ${origname}) 90 pkgdeps="runtime" 91 ;; 92 *) 93 uclfile="${outname##*}${origname}" 94 outname="${outname##*}${origname}" 95 ;; 96 esac 97 98 outname="${outname%%_*}" 99 100 desc="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESC)" 101 comment="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_COMMENT)" 102 103 uclsource="${srctree}/release/packages/${outname}.ucl" 104 if [ ! -e "${uclsource}" ]; then 105 uclsource="${srctree}/release/packages/template.ucl" 106 fi 107 108 if [ ! -z "${debug}" ]; then 109 echo "" 110 echo "===============================================================" 111 echo "DEBUG:" 112 echo "_descr=${_descr}" 113 echo "outname=${outname}" 114 echo "origname=${origname}" 115 echo "srctree=${srctree}" 116 echo "uclfile=${uclfile}" 117 echo "desc=${desc}" 118 echo "comment=${comment}" 119 echo "cp ${uclsource} -> ${uclfile}" 120 echo "===============================================================" 121 echo "" 122 echo "" 123 echo "" 124 fi 125 126 [ -z "${comment}" ] && comment="${outname} package" 127 [ ! -z "${_descr}" ] && comment="${comment} (${_descr})" 128 [ -z "${desc}" ] && desc="${outname} package" 129 130 cp "${uclsource}" "${uclfile}" 131 if [ ! -z "${pkgdeps}" ]; then 132 cat <<EOF >> ${uclfile} 133deps: { 134 FreeBSD-${pkgdeps}: { 135 origin: "base", 136 version: "${PKG_VERSION}" 137 } 138} 139EOF 140 fi 141 cap_arg="$( make -f ${srctree}/share/mk/bsd.endian.mk -VCAP_MKDB_ENDIAN )" 142 sed -i '' -e "s/%VERSION%/${PKG_VERSION}/" \ 143 -e "s/%PKGNAME%/${origname}/" \ 144 -e "s/%COMMENT%/${comment}/" \ 145 -e "s/%DESC%/${desc}/" \ 146 -e "s/%CAP_MKDB_ENDIAN%/${cap_arg}/g" \ 147 ${uclfile} 148 return 0 149} 150 151main "${@}" 152