The spec generator only supports Requires, Conflicts and Provides from the [pkg.requires.*], [pkg.conflicts.*] and [pkg.provides.*] sections of make/project.conf. A package that works without but is better with another package, like jw-amavis-run without jw-clamav-run, must hard-require it, so the dependency is pulled in on every install and cannot be removed without dragging the depending package along. This commit adds Recommends support to the spec generation chain: - CmdPkgRecommends: new pkg-recommends command that reads the [pkg.recommends.<flavour>] sections, same base as pkg-requires - pkg-dist.mk: compute PKG_RECOMMENDS_RUN and pass it to pkg.sh via a new -E option - pkg.sh: accept -E and forward it to the mkspec wrapper - mkspec-wrapper.sh: accept -E and export RECOMMENDS_RUN - create-mkspec.sh: emit a Recommends: line when RECOMMENDS_<subpkg> is set - create-mkdebian.sh: emit a Recommends: field in the debian control file Projects without a [pkg.recommends.*] section generate unchanged specs: every new line is guarded by a non-empty test. zypper follows Recommends by default, so existing OpenSUSE installations are unaffected; a recommended package can be removed without dragging the depending package along. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.85.1 Signed-off-by: Jan Lindemann <jan@janware.com>
161 lines
3.5 KiB
Shell
161 lines
3.5 KiB
Shell
#!/bin/bash
|
|
|
|
_cat()
|
|
{
|
|
sed 's/^ *|//'
|
|
}
|
|
|
|
cfg_section()
|
|
{
|
|
ini_section "$inifile" "$@"
|
|
}
|
|
|
|
cfg_value()
|
|
{
|
|
ini_value "$inifile" "$@"
|
|
}
|
|
|
|
cfg_escape()
|
|
{
|
|
sed 's/\\/\\\\/g; s/\$/\\$/g; s/`/\\`/g'
|
|
}
|
|
|
|
# unneeded but kept, because it might come in handy in the future
|
|
have_pkg()
|
|
{
|
|
echo "$subpackages" | grep -q "\(^[ ]*\|[ ]\+\)$1\([ ]\+\|$\)"
|
|
return $?
|
|
}
|
|
|
|
subpackage_description()
|
|
{
|
|
case $1 in
|
|
run)
|
|
echo "Runtime files"
|
|
;;
|
|
devel)
|
|
echo "Development files"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
os_cascade()
|
|
{
|
|
/usr/bin/python3 $JWB_SCRIPT_DIR/jw-pkg.py platform info --format '%{cascade}'
|
|
}
|
|
|
|
# -- here we go
|
|
|
|
echo "== running $0" "$@" >&2
|
|
export LANG=POSIX
|
|
export JWB_SCRIPT_DIR=$JWB_SCRIPT_DIR
|
|
dir=`dirname $0`
|
|
inifile="$1"
|
|
. $dir/ini-tools.sh
|
|
|
|
subpackages=`cfg_value global.subpackages | sed 's/,/ /g'`
|
|
license=`cfg_value global.license`
|
|
[ "$license" ] || license="janware GmbH proprietary license"
|
|
vendor=`cfg_value global.vendor`
|
|
[ "$vendor" ] || vendor="janware GmbH"
|
|
url=`cfg_value global.url`
|
|
[ "$url" ] || url="https://janware.com"
|
|
|
|
_cat <<- EOT
|
|
|echo "%define debug_package %{nil}"
|
|
|# ---------------------------------------
|
|
|echo "Name: \$NAME"
|
|
|echo "Summary: `cfg_value summary`"
|
|
|echo "Version: \$VERSION"
|
|
|echo "Release: \$RELEASE"
|
|
|echo "License: $license"
|
|
|echo "Group: System/Libraries"
|
|
|[ -n "\$SOURCE" ] && echo "Source: \$SOURCE"
|
|
|echo "Vendor: $vendor"
|
|
|echo "URL: $url"
|
|
|echo "BuildRoot: /var/tmp/%{name}-buildroot"
|
|
|echo "Distribution: jw / openSUSE Tumbleweed"
|
|
|echo ""
|
|
|echo "%description"
|
|
|echo "`cfg_value description`"
|
|
|echo ""
|
|
|# ---------------------------------------
|
|
|echo "%prep"
|
|
|echo "%setup -q -n \$NAME-\$V"
|
|
|echo ""
|
|
|echo "%build"
|
|
|echo 'pwd'
|
|
|echo 'make config'
|
|
|echo 'make'
|
|
|echo ""
|
|
|echo "%install"
|
|
|echo 'rm -rf \$RPM_BUILD_ROOT'
|
|
|echo "export ENV_PREFIX=\\\$RPM_BUILD_ROOT"
|
|
|echo "export INSTALL_LOG=\$INSTALL_LOG"
|
|
|echo "mkdir -p \`dirname \$INSTALL_LOG\`"
|
|
|echo "> \$INSTALL_LOG"
|
|
|echo "make install"
|
|
|echo "export PATH=$JWB_SCRIPT_DIR:\\\$PATH"
|
|
|echo "/bin/bash pkg.sh milk-install-log -p \\\$ENV_PREFIX -n \$NAME -t rpm -s \\"$subpackages\\" \$INSTALL_LOG \`dirname \$INSTALL_LOG\`"
|
|
|echo "exit 0" # <- Cut short CentOS magic appended to install scriptlet, which would generate .pyo files and other cruft.
|
|
EOT
|
|
|
|
for p in $subpackages; do
|
|
|
|
P=${p^^}
|
|
|
|
_cat <<- EOT
|
|
|echo ""
|
|
|echo "# --------------------------------------- subpackage $p"
|
|
|echo ""
|
|
|echo "%package -n \$NAME-$p"
|
|
|echo "Summary: `cfg_value summary`"
|
|
|echo "Group: `cfg_value global.group`"
|
|
|[ "\$REQUIRES_$P" ] && echo "Requires: \$REQUIRES_$P"
|
|
|[ "\$RECOMMENDS_$P" ] && echo "Recommends: \$RECOMMENDS_$P"
|
|
|[ "\$CONFLICTS_$P" ] && echo "Conflicts: \$CONFLICTS_$P"
|
|
|[ "\$PROVIDES_$P" ] && echo "Provides: \$PROVIDES_$P"
|
|
|echo ""
|
|
EOT
|
|
|
|
descr=`subpackage_description $p`
|
|
if [ "$descr" ]; then
|
|
_cat <<- EOT
|
|
|echo ""
|
|
|echo "%description -n \$NAME-$p"
|
|
|echo "$descr"
|
|
EOT
|
|
fi
|
|
|
|
for stage in pre preun post postun; do
|
|
echo "== processing stage $stage: cfg_section pkg.$p.$stage" >&2
|
|
out=""
|
|
for os in '' `os_cascade`; do
|
|
sec=pkg.$p.$stage
|
|
if [ "$os" ]; then
|
|
sec="$sec.$os"
|
|
head="\n# --- $os\n"
|
|
else
|
|
head=""
|
|
fi
|
|
cfg_section $sec | grep -q . || continue
|
|
out="$out$head`cfg_section $sec`"
|
|
done
|
|
if [ "$out" ]; then
|
|
echo -e "$out" >&2
|
|
_cat <<- EOT
|
|
|echo ""
|
|
|echo "%$stage -n \$NAME-$p"
|
|
EOT
|
|
echo "cat << EOT"
|
|
echo -e "$out" | cfg_escape
|
|
echo "EOT"
|
|
fi
|
|
done
|
|
|
|
_cat <<- EOT
|
|
|echo ""
|
|
|echo "%files -n \$NAME-$p -f \$INSTALL_LOG.\$NAME-$p"
|
|
|echo '%defattr (-, root, root)'
|
|
EOT
|
|
done
|