File: dh-make-pear

package info (click to toggle)
dh-make-php 0.2.0
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 352 kB
  • ctags: 22
  • sloc: sh: 593; xml: 371; makefile: 182; perl: 47
file content (183 lines) | stat: -rwxr-xr-x 6,147 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/sh
#
# dh-make-pear creates a debian package from a pear package
#
# Copyright (C) 2005-2006 by Uwe Steinmann <steinm@debian.org>
# under the GNU GPL license version 2.0 or 2.1.
# You should have received a copy of the GPL license
# along with this program if you did not you can find it
# at http://www.gnu.org/.

PROGNAME=dh-make-pear
PROGVERSION=0.2.0
PREFIX=/usr

DEBPACKAGEPREFIX=php
DEBTEMPDIR=${PREFIX}/share/dh-make-php/pear.template
PACKAGEDOCFILES="README readme CREDITS TODO AUTHORS"
# if you change the examples directory make sure to adjust the
# regular expression to set the PACKAGEDOCFILES
PACKAGEEXPFILES="examples"
# There has been versions of xmlstarlet which were called xml
# instead of xmlstarlet
if [ -x /usr/bin/xmlstarlet ]; then
	XMLSTARLET=/usr/bin/xmlstarlet
else
	XMLSTARLET=/usr/bin/xml
fi
DEBMAINTAINER=
DEPENDS=
DEPARCH=all

. ${PREFIX}/share/dh-make-php/dh-make-php.lib

# usage() {{{
# print summary of options
usage()
{
	cat <<eof
This is ${PROGNAME} Version ${PROGVERSION}
Copyright (c) 2004-2005 Uwe Steinmann <steinm@debian.org>

Usage: ${PROGNAME} [options] pear-package

pear-package is a tgz file as it is downloaded by 'pear download'.
Options:
  --help | -h     show this usage information
  --version | -v  show version of program
  --maintainer    maintainer of the debian package
  --arch          set architecture (defaults to 'all')
  --depends       set more depends aside php
  --prefix        set prefix for package name (default is '${DEBPACKAGEPREFIX}')
  --templatedir   set alternative directory for templates
                  (default is ${DEBTEMPDIR})

eof
}
# }}}

# command line options {{{
if [ $# = 0 ]; then
	usage
	exit 0
fi

while
	case $1 in
		--help|-h) # print usage
			usage
			exit 0
			;;
		--version|-v) # show version
      echo ${PROGVERSION}
			exit 0
			;;
		--maintainer) # set maintainer of debian package
			DEBMAINTAINER="$2"; shift
			;;
		--arch) # set architecture of debian package
			DEBARCH="$2"; shift
			;;
		--depends) # set extra depends for debian package
			DEPENDS=", $2"; shift
			;;
		--prefix) # set prefix for name of debian package
			DEBPACKAGEPREFIX="$2"; shift
			;;
		--templatedir) # set alternative template dir
			DEBTEMPDIR="$2"; shift
			;;
		"")
			break
			;;
		*)
			PEARPACKAGENAME="$1"
			break
			;;
	esac
do test $# -gt 0 && shift; done
# }}}

if [ -n "${PEARPACKAGENAME}" ]; then
	if [ -f ${PEARPACKAGENAME} ]; then
		tar xzf ${PEARPACKAGENAME}
	else
		if TEMPMSG=$(pear download ${PEARPACKAGENAME} 2> /dev/null); then
			echo ${TEMPMSG}
			PEARPACKAGENAME=$(echo ${TEMPMSG} | awk -F ' ' '{print $2'})
			tar xzf ${PEARPACKAGENAME}
		else
			echo "Downloading pear package '${PEARPACKAGENAME}' failed!";
			echo "Check http://pear.php.net/ for available packages.";
			exit 0
		fi
	fi
else
	usage
	exit 0
fi

# get information about package from package.xml
eval_package

echo "Creating debian source package: ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}"
echo "Upstream is: ${UPSTREAM}"

get_maintainer

if [ -d ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION} ] ; then
	echo "Directory '${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}' already exits."
	exit
fi
ln -s ${PEARPACKAGENAME} ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}_${VERSION}.orig.tar.gz
mkdir ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}
mv ${PHP_PKG_NAME}-${VERSION} ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}
mv package.xml ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}
#tar czf ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}_${VERSION}.orig.tar.gz ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}
mkdir -p ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}/debian

cp ${DEBTEMPDIR}/compat ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}/debian
cp ${DEBTEMPDIR}/dirs ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}/debian

install_docfiles
install_expfiles

PACKAGEXML=${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}/package.xml

sed -e "s/##date##/`(LC_ALL=C; date -R)`/g" \
    -e "s/##maintainer##/${DEBMAINTAINER}/g" \
    -e "s/##upstream##/${UPSTREAM}/g" \
    -e "s/##license##/${LICENSE}/g" \
    -e "s/##pearpkgname##/${PHP_PKG_NAME}/g" \
		${DEBTEMPDIR}/copyright > ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}/debian/copyright
if [ -n "${LICENSEFILE}" ]; then
	cat "${LICENSEFILE}" >> ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}/debian/copyright
fi
sed -e "s/##packagename##/${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}/g" \
    -e "s/##maintainer##/${DEBMAINTAINER}/g" \
    -e "s##summary##${SUMMARY}g" \
    -e "s/##depends##/${DEPENDS}/g" \
    -e "s/##architecture##/${DEPARCH}/g" \
		${DEBTEMPDIR}/control > ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}/debian/control
		xsltproc --nonet --novalid  --param Element "/*/description" ${PREFIX}/share/dh-make-php/xslt/common.xsl ${PACKAGEXML} | fold -s -w 70|sed -e "s^[ \t]*$.g" -e "s^ g" >> ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}/debian/control
#		sgrep -e '"<description>"__"</description>"' ${PACKAGEXML} | fold -s -w 70|sed -e "s^[ \t]*$.g" -e "s^ g" >> ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}/debian/control
sed -e "s/##packagename##/${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}/g" \
    -e "s/##version##/${VERSION}/g" \
    -e "s/##pearpkgname##/${PHP_PKG_NAME}/g" \
		${DEBTEMPDIR}/rules > ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}/debian/rules
chmod 755 ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}/debian/rules

sed -e "s/##packagename##/${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}/g" \
    -e "s/##date##/`(LC_ALL=C; date -R)`/g" \
    -e "s/##maintainer##/${DEBMAINTAINER}/g" \
    -e "s/##version##/${VERSION}/g" \
		${DEBTEMPDIR}/changelog > ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}/debian/changelog

sed -e "s/##packagename##/${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}/g" \
    -e "s/##date##/`(LC_ALL=C; date -R)`/g" \
    -e "s/##maintainer##/${DEBMAINTAINER}/g" \
		${DEBTEMPDIR}/README.Debian > ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}/debian/README.Debian

sed -e "s/##pearpkgname##/${PHP_PKG_NAME}/g" \
		${DEBTEMPDIR}/watch > ${DEBPACKAGEPREFIX}-${PHP_PKG_LOWNAME}-${VERSION}/debian/watch