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 libcompat-dev|liby-dev) 52 outname=${outname%%-dev} 53 _descr="Development Files" 54 ;; 55 libcompat-lib32_dev|liby-lib32_dev) 56 outname=${outname%%-lib32_dev} 57 _descr="32-bit Libraries, Development Files" 58 ;; 59 libcompat-man|libelftc-man) 60 outname=${outname%%-man} 61 _descr="Manual Pages" 62 ;; 63 utilities) 64 uclfile="${uclfile}" 65 ;; 66 runtime) 67 outname="runtime" 68 _descr="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESCR)" 69 vital="true" 70 ;; 71 *-lib32_dev) 72 outname="${outname%%-lib32_dev}" 73 _descr="32-bit Libraries, Development Files" 74 pkgdeps="${outname}" 75 ;; 76 *-lib32_dbg) 77 outname="${outname%%-lib32_dbg}" 78 _descr="32-bit Libraries, Debugging Symbols" 79 pkgdeps="${outname}" 80 ;; 81 *-lib32) 82 outname="${outname%%-lib32}" 83 _descr="32-bit Libraries" 84 pkgdeps="${outname}" 85 ;; 86 *-dev) 87 outname="${outname%%-dev}" 88 _descr="Development Files" 89 pkgdeps="${outname}" 90 ;; 91 *-dbg) 92 outname="${outname%%-dbg}" 93 _descr="Debugging Symbols" 94 pkgdeps="${outname}" 95 ;; 96 *-man) 97 outname="${outname%%-man}" 98 _descr="Manual Pages" 99 pkgdeps="${outname}" 100 ;; 101 ${origname}) 102 ;; 103 *) 104 uclfile="${outname##*}${origname}" 105 outname="${outname##*}${origname}" 106 ;; 107 esac 108 109 desc="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_DESC)" 110 comment="$(make -C ${srctree}/release/packages -f Makefile.package -V ${outname}_COMMENT)" 111 112 uclsource="${srctree}/release/packages/${outname}.ucl" 113 if [ ! -e "${uclsource}" ]; then 114 uclsource="${srctree}/release/packages/template.ucl" 115 fi 116 117 if [ ! -z "${debug}" ]; then 118 echo "" 119 echo "===============================================================" 120 echo "DEBUG:" 121 echo "_descr=${_descr}" 122 echo "outname=${outname}" 123 echo "origname=${origname}" 124 echo "srctree=${srctree}" 125 echo "uclfile=${uclfile}" 126 echo "desc=${desc}" 127 echo "comment=${comment}" 128 echo "vital=${vital}" 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/%VITAL%/${vital}/" \ 157 -e "s/%CAP_MKDB_ENDIAN%/${cap_arg}/g" \ 158 -e "s/%PKG_NAME_PREFIX%/${PKG_NAME_PREFIX}/" \ 159 -e "s|%PKG_WWW%|${PKG_WWW}|" \ 160 -e "s/%PKG_MAINTAINER%/${PKG_MAINTAINER}/" \ 161 ${uclfile} 162 return 0 163} 164 165main "${@}" 166