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 runtime) 38 outname="runtime" 39 uclfile="${uclfile}" 40 ;; 41 runtime_manuals) 42 outname="${origname}" 43 pkgdeps="runtime" 44 ;; 45 runtime_*) 46 outname="${origname}" 47 uclfile="${outname##*}${uclfile}" 48 pkgdeps="runtime" 49 _descr="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESCR)" 50 ;; 51 *_lib32_development) 52 outname="${outname%%_lib32_development}" 53 _descr="32-bit Libraries, Development Files" 54 pkgdeps="${outname}" 55 ;; 56 *_lib32_debug) 57 outname="${outname%%_lib32_debug}" 58 _descr="32-bit Libraries, Debugging Symbols" 59 pkgdeps="${outname}" 60 ;; 61 *_lib32_profile) 62 outname="${outname%%_lib32_profile}" 63 _descr="32-bit Libraries, Profiling" 64 pkgdeps="${outname}" 65 ;; 66 *_lib32) 67 outname="${outname%%_lib32}" 68 _descr="32-bit Libraries" 69 pkgdeps="${outname}" 70 ;; 71 *_development) 72 outname="${outname%%_development}" 73 _descr="Development Files" 74 pkgdeps="${outname}" 75 ;; 76 *_profile) 77 outname="${outname%%_profile}" 78 _descr="Profiling Libraries" 79 pkgdeps="${outname}" 80 ;; 81 *_debug) 82 outname="${outname%%_debug}" 83 _descr="Debugging Symbols" 84 pkgdeps="${outname}" 85 ;; 86 ${origname}) 87 pkgdeps="runtime" 88 ;; 89 *) 90 uclfile="${outname##*}${origname}" 91 outname="${outname##*}${origname}" 92 ;; 93 esac 94 95 outname="${outname%%_*}" 96 97 desc="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESC)" 98 comment="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_COMMENT)" 99 100 uclsource="${srctree}/release/packages/${outname}.ucl" 101 if [ ! -e "${uclsource}" ]; then 102 uclsource="${srctree}/release/packages/template.ucl" 103 fi 104 105 if [ ! -z "${debug}" ]; then 106 echo "" 107 echo "===============================================================" 108 echo "DEBUG:" 109 echo "_descr=${_descr}" 110 echo "outname=${outname}" 111 echo "origname=${origname}" 112 echo "srctree=${srctree}" 113 echo "uclfile=${uclfile}" 114 echo "desc=${desc}" 115 echo "comment=${comment}" 116 echo "cp ${uclsource} -> ${uclfile}" 117 echo "===============================================================" 118 echo "" 119 echo "" 120 echo "" 121 fi 122 123 [ -z "${comment}" ] && comment="${outname} package" 124 [ ! -z "${_descr}" ] && comment="${comment} (${_descr})" 125 [ -z "${desc}" ] && desc="${outname} package" 126 127 cp "${uclsource}" "${uclfile}" 128 cap_arg="$(make -C ${srctree}/etc -VCAP_MKDB_ENDIAN)" 129 pwd_arg="$(make -C ${srctree}/etc -VPWD_MKDB_ENDIAN)" 130 sed -i '' -e "s/%VERSION%/${PKG_VERSION}/" \ 131 -e "s/%PKGNAME%/${origname}/" \ 132 -e "s/%COMMENT%/${comment}/" \ 133 -e "s/%DESC%/${desc}/" \ 134 -e "s/%CAP_MKDB_ENDIAN%/${cap_arg}/g" \ 135 -e "s/%PWD_MKDB_ENDIAN%/${pwd_arg}/g" \ 136 -e "s/%PKGDEPS%/${pkgdeps}/" \ 137 ${uclfile} 138 return 0 139} 140 141main "${@}" 142