jw-pkg/scripts/mkspec-wrapper.sh
Jan Lindemann d7da4f1cb8 mkspec-wrapper.sh: Fix append() for special characters
The append() shell function was unable to cope with special
characters, notably with () in RPM provides libnnz12.so()(64bit),
this commit fixes that. And introduces some (disabled) debug code
into projects.py.

Signed-off-by: Jan Lindemann <jan@janware.com>
2019-01-30 16:23:03 +00: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`
ID=`whoami`
[ ! "$INSTALL_LOG" ] && INSTALL_LOG=/tmp/rpmbuild-$ID/install.log
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
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