jw-pkg/scripts/create-mkdebian.sh
2015-05-30 20:03:33 +00:00

126 lines
2.5 KiB
Bash

#!/bin/bash
export LANG=POSIX
dir=`dirname $0`
inifile=$1
. $dir/ini-tools.sh
cat << EOT
format_depends()
{
echo "\$@" | sed 's/ */,/g; s/,\([><=]\+\),*/\1/g; s/, *,*/,/g; s/, *$//; s/^ *,//; s/\([><=]\+\)\([0-9.-]\+\)/ (\1\2) /g'
}
#changelog()
#{
# #dch -c /dev/stdout --create -v \$VERSION-\$RELEASE --package \$NAME
#cat << EOF
#\$NAME (\$VERSION-\$RELEASE) UNRELEASED; urgency=medium
#
# * Initial release. (Closes: #XXXXXX)
#
# -- Jan Lindemann <jan@janware.com> `date -R`
#
#EOF
#}
compat()
{
echo -n 9
}
control()
{
cat << EOF
Source: \$NAME
Maintainer: Jan Lindemann <jan@janware.com>
Section: `ini_value global.group`
Priority: optional
Standards-Version: 3.9.2
Build-Depends: debhelper (>= 9)
EOT
ini_value global.subpackages | grep -q run && cat << EOT
Package: \$NAME-run
Architecture: any
Depends: \`format_depends "\${shlibs:Depends}, \${misc:Depends}, \$REQUIRES_RUN"\`
Description: `ini_value summary`
`ini_value description | sed 's/^/ /'`
EOT
ini_value global.subpackages | grep -q devel && cat << EOT
Package: \$NAME-devel
Architecture: any
Depends: \`format_depends "\$NAME-run = \$VERSION-\$RELEASE, \$REQUIRES_DEVEL"\`
Description: \$NAME Development Package
Development tools for \$NAME-run
EOT
cat << EOT
EOF
}
copyright()
{
echo -n ""
}
format()
{
echo "3.0 (quilt)"
}
rules()
{
cat << "EOF"
#!/usr/bin/make -f
# tip from https://pkg-perl.alioth.debian.org/debhelper.html
# PACKAGE = \$(firstword \$(shell dh_listpackages))
# TMP = \$(CURDIR)/debian/\$(PACKAGE)
NAME = \$(shell pwd | xargs basename | sed 's/-[0-9.-]\+//')
DEB_DIR = \$\$(pwd)/debian
ENV_PREFIX = \$\$(pwd)/debian/tmp/inst-root
EOF
echo INSTALL_LOG = \$INSTALL_LOG
cat << "EOF"
%:
EOF
echo -e "\tdh \$""@"
cat << EOF
override_dh_auto_clean:
override_dh_auto_test:
override_dh_auto_install:
mkdir -p \`dirname \$INSTALL_LOG\`
> \$INSTALL_LOG
\\\$(MAKE) ENV_PREFIX=\\\$(ENV_PREFIX) INSTALL_LOG=\\\$(INSTALL_LOG) install
/bin/bash milk-install-log.sh -p \\\$(ENV_PREFIX) -n \\\$(NAME) -t deb \$INSTALL_LOG \\\$(DEB_DIR)
override_dh_shlibdeps:
LD_LIBRARY_PATH=lib:\\\$(LD_LIBRARY_PATH) dh_shlibdeps
EOF
}
mkdir -p debian
#dch --create --empty
cd debian
for file in compat control copyright format rules; do
test -e \$file && continue
\$file > \$file
done
cd ..
dch --create --newversion \$VERSION-\$RELEASE --controlmaint --package \$NAME --distribution unstable "Release built by $0"
echo "Produced by $0, the output should be in the \"debian\" sub-directory."
EOT