1#!/bin/sh 2# 3# 4 5main() { 6 desc= 7 comment= 8 debug= 9 uclsource= 10 while getopts "do:s:u:" arg; do 11 case ${arg} in 12 d) 13 debug=1 14 ;; 15 o) 16 outname="${OPTARG}" 17 origname="${OPTARG}" 18 ;; 19 s) 20 srctree="${OPTARG}" 21 ;; 22 u) 23 uclfile="${OPTARG}" 24 ;; 25 *) 26 echo "Unknown argument" 27 ;; 28 esac 29 done 30 31 shift $(( ${OPTIND} - 1 )) 32 33 case "${outname}" in 34 bootloader) 35 pkgdeps="" 36 ;; 37 certctl) 38 pkgdeps="caroot openssl" 39 ;; 40 clang) 41 pkgdeps="lld libcompiler_rt-dev" 42 ;; 43 periodic) 44 pkgdeps="cron" 45 ;; 46 47 # -dev packages that have no corresponding non-dev package 48 # as a dependency. 49 libcompat-dev|libcompiler_rt-dev|liby-dev) 50 outname=${outname%%-dev} 51 _descr="Development Files" 52 ;; 53 libcompat-lib32_dev|libcompiler_rt-lib32_dev|liby-lib32_dev) 54 outname=${outname%%-lib32_dev} 55 _descr="32-bit Libraries, Development Files" 56 ;; 57 libcompat-man|libelftc-man) 58 outname=${outname%%-man} 59 _descr="Manual Pages" 60 ;; 61 utilities) 62 uclfile="${uclfile}" 63 ;; 64 runtime) 65 outname="runtime" 66 _descr="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESCR)" 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/template.ucl" 110 111 if [ ! -z "${debug}" ]; then 112 echo "" 113 echo "===============================================================" 114 echo "DEBUG:" 115 echo "_descr=${_descr}" 116 echo "outname=${outname}" 117 echo "origname=${origname}" 118 echo "srctree=${srctree}" 119 echo "uclfile=${uclfile}" 120 echo "desc=${desc}" 121 echo "comment=${comment}" 122 echo "vital=${vital}" 123 echo "cp ${uclsource} -> ${uclfile}" 124 echo "===============================================================" 125 echo "" 126 echo "" 127 echo "" 128 fi 129 130 [ -z "${comment}" ] && comment="${outname} package" 131 [ ! -z "${_descr}" ] && comment="${comment} (${_descr})" 132 [ -z "${desc}" ] && desc="${outname} package" 133 134 cp "${uclsource}" "${uclfile}" 135 if [ ! -z "${pkgdeps}" ]; then 136 echo 'deps: {' >> ${uclfile} 137 for dep in ${pkgdeps}; do 138 cat <<EOF >> ${uclfile} 139 FreeBSD-${dep}: { 140 origin: "base", 141 version: "${PKG_VERSION}" 142 } 143EOF 144 done 145 echo '}' >> ${uclfile} 146 fi 147 cap_arg="$( make -f ${srctree}/share/mk/bsd.endian.mk -VCAP_MKDB_ENDIAN )" 148 ${srctree}/release/packages/generate-ucl.lua \ 149 VERSION "${PKG_VERSION}" \ 150 PKGNAME "${origname}" \ 151 PKGGENNAME "${outname}" \ 152 PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \ 153 COMMENT "${comment}" \ 154 DESC "${desc}" \ 155 CAP_MKDB_ENDIAN "${cap_arg}" \ 156 PKG_WWW "${PKG_WWW}" \ 157 PKG_MAINTAINER "${PKG_MAINTAINER}" \ 158 UCLFILES "${srctree}/release/packages/" \ 159 ${uclfile} ${uclfile} 160 161 return 0 162} 163 164main "${@}" 165