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_profile) 75 outname="${outname%%_lib32_profile}" 76 _descr="32-bit Libraries, Profiling" 77 pkgdeps="${outname}" 78 ;; 79 *_lib32) 80 outname="${outname%%_lib32}" 81 _descr="32-bit Libraries" 82 pkgdeps="${outname}" 83 ;; 84 *_development) 85 outname="${outname%%_development}" 86 _descr="Development Files" 87 pkgdeps="${outname}" 88 ;; 89 *_profile) 90 outname="${outname%%_profile}" 91 _descr="Profiling Libraries" 92 pkgdeps="${outname}" 93 ;; 94 *_debug) 95 outname="${outname%%_debug}" 96 _descr="Debugging Symbols" 97 pkgdeps="${outname}" 98 ;; 99 ${origname}) 100 pkgdeps="runtime" 101 ;; 102 *) 103 uclfile="${outname##*}${origname}" 104 outname="${outname##*}${origname}" 105 ;; 106 esac 107 108 outname="${outname%%_*}" 109 110 desc="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESC)" 111 comment="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_COMMENT)" 112 113 uclsource="${srctree}/release/packages/${outname}.ucl" 114 if [ ! -e "${uclsource}" ]; then 115 uclsource="${srctree}/release/packages/template.ucl" 116 fi 117 118 if [ ! -z "${debug}" ]; then 119 echo "" 120 echo "===============================================================" 121 echo "DEBUG:" 122 echo "_descr=${_descr}" 123 echo "outname=${outname}" 124 echo "origname=${origname}" 125 echo "srctree=${srctree}" 126 echo "uclfile=${uclfile}" 127 echo "desc=${desc}" 128 echo "comment=${comment}" 129 echo "cp ${uclsource} -> ${uclfile}" 130 echo "===============================================================" 131 echo "" 132 echo "" 133 echo "" 134 fi 135 136 [ -z "${comment}" ] && comment="${outname} package" 137 [ ! -z "${_descr}" ] && comment="${comment} (${_descr})" 138 [ -z "${desc}" ] && desc="${outname} package" 139 140 cp "${uclsource}" "${uclfile}" 141 if [ ! -z "${pkgdeps}" ]; then 142 cat <<EOF >> ${uclfile} 143deps: { 144 FreeBSD-${pkgdeps}: { 145 origin: "base", 146 version: "${PKG_VERSION}" 147 } 148} 149EOF 150 fi 151 cap_arg="$( make -f ${srctree}/share/mk/bsd.endian.mk -VCAP_MKDB_ENDIAN )" 152 sed -i '' -e "s/%VERSION%/${PKG_VERSION}/" \ 153 -e "s/%PKGNAME%/${origname}/" \ 154 -e "s/%COMMENT%/${comment}/" \ 155 -e "s/%DESC%/${desc}/" \ 156 -e "s/%CAP_MKDB_ENDIAN%/${cap_arg}/g" \ 157 ${uclfile} 158 return 0 159} 160 161main "${@}" 162