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_dev) 65 outname="${outname%%_lib32_dev}" 66 _descr="32-bit Libraries, Development Files" 67 pkgdeps="${outname}" 68 ;; 69 *_lib32_dbg) 70 outname="${outname%%_lib32_dbg}" 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 *_dev) 80 outname="${outname%%_dev}" 81 _descr="Development Files" 82 pkgdeps="${outname}" 83 ;; 84 *_dbg) 85 outname="${outname%%_dbg}" 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 pkgdeps="$(echo ${pkgdeps} | tr '_' '-')" 101 102 desc="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESC)" 103 comment="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_COMMENT)" 104 105 uclsource="${srctree}/release/packages/${outname}.ucl" 106 if [ ! -e "${uclsource}" ]; then 107 uclsource="${srctree}/release/packages/template.ucl" 108 fi 109 110 if [ ! -z "${debug}" ]; then 111 echo "" 112 echo "===============================================================" 113 echo "DEBUG:" 114 echo "_descr=${_descr}" 115 echo "outname=${outname}" 116 echo "origname=${origname}" 117 echo "srctree=${srctree}" 118 echo "uclfile=${uclfile}" 119 echo "desc=${desc}" 120 echo "comment=${comment}" 121 echo "cp ${uclsource} -> ${uclfile}" 122 echo "===============================================================" 123 echo "" 124 echo "" 125 echo "" 126 fi 127 128 [ -z "${comment}" ] && comment="${outname} package" 129 [ ! -z "${_descr}" ] && comment="${comment} (${_descr})" 130 [ -z "${desc}" ] && desc="${outname} package" 131 132 cp "${uclsource}" "${uclfile}" 133 if [ ! -z "${pkgdeps}" ]; then 134 cat <<EOF >> ${uclfile} 135deps: { 136 FreeBSD-${pkgdeps}: { 137 origin: "base", 138 version: "${PKG_VERSION}" 139 } 140} 141EOF 142 fi 143 cap_arg="$( make -f ${srctree}/share/mk/bsd.endian.mk -VCAP_MKDB_ENDIAN )" 144 sed -i '' -e "s/%VERSION%/${PKG_VERSION}/" \ 145 -e "s/%PKGNAME%/${origname}/" \ 146 -e "s/%COMMENT%/${comment}/" \ 147 -e "s/%DESC%/${desc}/" \ 148 -e "s/%CAP_MKDB_ENDIAN%/${cap_arg}/g" \ 149 -e "s/%PKG_NAME_PREFIX%/${PKG_NAME_PREFIX}/" \ 150 -e "s|%PKG_WWW%|${PKG_WWW}|" \ 151 -e "s/%PKG_MAINTAINER%/${PKG_MAINTAINER}/" \ 152 ${uclfile} 153 return 0 154} 155 156main "${@}" 157