jw-pkg/scripts/mkspec-wrapper.sh
Jan Lindemann c893584e5e make: Replace RPM -> PKG
jw-pkg supports more than RPM-based package managers, but for
historic reasons, lots of its Makefile variables still have "RPM" in
their names. This is misleading. Replace "RPM" in variable names by
the more generic "PKG" where appropriate.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-16 14:57:50 +01:00

130 lines
2.2 KiB
Bash

#!/bin/bash
usage()
{
echo usage: $MYNAME /path/to/mkspec.sh -h [-N name] [-T topdir] [-V version] [-S source] [-R requires] [-P project] >&2
[ "$1" ] && exit $1
}
append()
{
local var=$1
shift
local tmp=`eval echo \"\\$$var $@\" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//'`
eval $var=\"$tmp\"
}
# -- here we go
#set -x
MYNAME=`basename $0`
eval set -- `getopt -l "provides-run:" -l "provides-devel:" -o "P:T:V:S:N:hR:D:X:Y:d:" -- "$@"`
while [ "$1" != -- ]; do
echo checking "$1=$2" >&2
case $1 in
-h)
usage 0;;
-T)
TOPDIR="$2"
shift;;
-V)
V="$2"
shift;;
-S)
SOURCE="$2"
shift;;
-N)
NAME="$2"
shift;;
-R)
append REQUIRES_RUN "$2"
shift
;;
-X)
append CONFLICTS_RUN "$2"
shift
;;
-D)
append REQUIRES_DEVEL "$2"
shift
;;
-Y)
append CONFLICTS_DEVEL "$2"
shift
;;
--provides-run)
append PROVIDES_RUN "$2"
shift
;;
--provides-devel)
append PROVIDES_DEVEL "$2"
shift
;;
-P)
PROJECT="$2"
shift;;
-d)
DISTRIBUTION="$2"
shift;;
*)
usage 1;;
esac
shift
done
shift
ID=`whoami`
[ ! "$INSTALL_LOG" ] && INSTALL_LOG=/tmp/pkg-build-$ID-$NAME/install.log
MKSPEC_SH="$1"
shift
[ -z "$TOPDIR" ] && TOPDIR=.
if [ -z "$V" ]; then
if [ -f $TOPDIR/VERSION ]; then
VERSION="`cat $TOPDIR/VERSION | cut -d- -f1`"
RELEASE="`cat $TOPDIR/VERSION | cut -d- -f2- | sed 's/[-_].*//'`"
else
VERSION=noversion
RELEASE=norelease
fi
else
VERSION="`echo $V | cut -d- -f1`"
RELEASE="`cat $TOPDIR/VERSION | cut -d- -f2- | sed 's/[-_].*//'`"
fi
if [ -z "$NAME" ]; then
NAME=`pwd | xargs basename`
fi
REQUIRES="$REQUIRES_RUN $REQUIRES_DEVEL"
CONFLICTS="$CONFLICTS_RUN $CONFLICTS_DEVEL"
#if [ -n "$REQUIRES" ]; then
# REQUIRES_RUN=`echo $REQUIRES |
# sed -e '
# s/\([a-zA-Z-]\+\) *\([<>=]*\) *\([a-zA-Z0-9\.-]*\)/\1-run \2 \3,/g
# s/,$//
# s/-run-run/-run/
# '`
# REQUIRES_DEVEL="$REQUIRES_RUN, $NAME-run = $VERSION-$RELEASE, `echo $REQUIRES_RUN | sed -e 's/-run/-devel/g'`"
#fi
#echo "REQUIRES_RUN=\"$REQUIRES_RUN\""
#exit
export \
REQUIRES REQUIRES_RUN REQUIRES_DEVEL \
CONFLICTS CONFLICTS_RUN CONFLICTS_DEVEL \
PROVIDES PROVIDES_RUN PROVIDES_DEVEL \
TOPDIR \
PROJECT NAME \
SOURCE \
VERSION RELEASE V \
INSTALL_LOG \
DISTRIBUTION
bash $MKSPEC_SH