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