#!/bin/sh # # $FreeBSD: stable/11/release/packages/generate-ucl.sh 318249 2017-05-12 18:37:08Z gjb $ # proc main { setglobal desc = '' setglobal comment = '' setglobal debug = '' setglobal uclsource = '' while getopts "do:s:u:" arg { match $(arg) { with d setglobal debug = '1' with o setglobal outname = $(OPTARG) setglobal origname = $(OPTARG) with s setglobal srctree = $(OPTARG) with u setglobal uclfile = $(OPTARG) with * echo "Unknown argument" } } shift $shExpr(' ${OPTIND} - 1 ') setglobal outname = $[echo $(outname) | tr '-' '_] match $(outname) { with runtime setglobal outname = '"runtime'" setglobal uclfile = $(uclfile) with runtime_manuals setglobal outname = $(origname) setglobal pkgdeps = '"runtime'" with runtime_* setglobal outname = $(origname) setglobal uclfile = ""$(outname##*)$(uclfile)"" setglobal pkgdeps = '"runtime'" setglobal _descr = $[make -C $(srctree)/release/packages -f Makefile.package -V $(outname)_DESCR] with jail_* setglobal outname = $(origname) setglobal uclfile = ""$(outname##*)$(uclfile)"" setglobal pkgdeps = '"runtime'" setglobal _descr = $[make -C $(srctree)/release/packages -f Makefile.package -V $(outname)_DESCR] with *_lib32_development setglobal outname = $(outname%%_lib32_development) setglobal _descr = '"32-bit Libraries, Development Files'" setglobal pkgdeps = $(outname) with *_lib32_debug setglobal outname = $(outname%%_lib32_debug) setglobal _descr = '"32-bit Libraries, Debugging Symbols'" setglobal pkgdeps = $(outname) with *_lib32_profile setglobal outname = $(outname%%_lib32_profile) setglobal _descr = '"32-bit Libraries, Profiling'" setglobal pkgdeps = $(outname) with *_lib32 setglobal outname = $(outname%%_lib32) setglobal _descr = '"32-bit Libraries'" setglobal pkgdeps = $(outname) with *_development setglobal outname = $(outname%%_development) setglobal _descr = '"Development Files'" setglobal pkgdeps = $(outname) with *_profile setglobal outname = $(outname%%_profile) setglobal _descr = '"Profiling Libraries'" setglobal pkgdeps = $(outname) with *_debug setglobal outname = $(outname%%_debug) setglobal _descr = '"Debugging Symbols'" setglobal pkgdeps = $(outname) with ${origname} setglobal pkgdeps = '"runtime'" with * setglobal uclfile = ""$(outname##*)$(origname)"" setglobal outname = ""$(outname##*)$(origname)"" } setglobal outname = $(outname%%_*) setglobal desc = $[make -C $(srctree)/release/packages -f Makefile.package -V $(outname)_DESC] setglobal comment = $[make -C $(srctree)/release/packages -f Makefile.package -V $(outname)_COMMENT] setglobal uclsource = ""$(srctree)/release/packages/$(outname).ucl"" if test ! -e $(uclsource) { setglobal uclsource = ""$(srctree)/release/packages/template.ucl"" } if test ! -z $(debug) { echo "" echo "===============================================================" echo "DEBUG:" echo "_descr=$(_descr)" echo "outname=$(outname)" echo "origname=$(origname)" echo "srctree=$(srctree)" echo "uclfile=$(uclfile)" echo "desc=$(desc)" echo "comment=$(comment)" echo "cp $(uclsource) -> $(uclfile)" echo "===============================================================" echo "" echo "" echo "" } test -z $(comment) && setglobal comment = ""$(outname) package"" test ! -z $(_descr) && setglobal comment = ""$(comment) ($(_descr))"" test -z $(desc) && setglobal desc = ""$(outname) package"" cp $(uclsource) $(uclfile) setglobal cap_arg = $[make -C $(srctree)/etc -VCAP_MKDB_ENDIAN] setglobal pwd_arg = $[make -C $(srctree)/etc -VPWD_MKDB_ENDIAN] sed -i '' -e "s/%VERSION%/$(PKG_VERSION)/" \ -e "s/%PKGNAME%/$(origname)/" \ -e "s/%COMMENT%/$(comment)/" \ -e "s/%DESC%/$(desc)/" \ -e "s/%CAP_MKDB_ENDIAN%/$(cap_arg)/g" \ -e "s/%PWD_MKDB_ENDIAN%/$(pwd_arg)/g" \ -e "s/%PKGDEPS%/$(pkgdeps)/" \ $(uclfile) return 0 } main $(@)