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