Skip to content

Commit

Permalink
Debianized for Debian buster and php7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
alextwl committed Jul 20, 2021
1 parent ebf7c21 commit f660f0e
Show file tree
Hide file tree
Showing 13 changed files with 275 additions and 0 deletions.
7 changes: 7 additions & 0 deletions debian/README.Debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
php-qrencode for Debian
--------------------------

This extension has been created with dh-make-pecl which is part
of dh-make-php.

-- Wei-Li Tang <[email protected]>, Mon, 19 Jul 2021 15:36:21 +0800
26 changes: 26 additions & 0 deletions debian/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# php-qrencode for Debian

This extension has been debianized with dh-make-pecl plus
modifications which is more similar to `dh_make --native`.

The dependencies are based on Debian buster and php7.3.

## Build dependencies

Install development packages before building the extension:

```
apt install php-dev libqrencode-dev libpng-dev build-essential dpkg-dev dh-make-php xsltproc
```

## Build command

Run command below to build package from root of the repository:

```
dpkg-buildpackage -rfakeroot -uc -b
```

## TODO

* The upstream documentations are not yet included in the debian package.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
php-qrencode (0.7-1) unstable; urgency=low

* Debianized for Debian buster and php7.3

-- Wei-Li Tang <[email protected]> Mon, 19 Jul 2021 15:36:21 +0800

122 changes: 122 additions & 0 deletions debian/changelog.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:util="urn:xslt:functions:util" xmlns:func="http://exslt.org/functions" xmlns:str="http://exslt.org/strings" extension-element-prefixes="func str">
<xsl:output method="text"/>

<func:function name="util:maximize">
<xsl:param name="string"/>
<xsl:param name="line-length"/>

<func:result>
<xsl:variable name="tmp" select="string-length(substring-before($string,' '))"/>
<xsl:choose>
<xsl:when test="($tmp &gt; $line-length) or (not(contains($string, ' ')))">0</xsl:when>
<xsl:when test="(substring($string,$line-length,1) = ' ')">
<xsl:value-of select="$line-length"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="util:maximize(substring-after($string, ' '), $line-length - $tmp - 1) + 1 + $tmp"/>
</xsl:otherwise>
</xsl:choose>
</func:result>
</func:function>

<func:function name="util:format">
<xsl:param name="string"/>
<xsl:param name="indent" select="2"/>
<xsl:param name="line-length" select="76"/>

<func:result>
<xsl:choose>
<xsl:when test="contains($string,'&#xA;') or contains($string,'&#xD;')">
<xsl:for-each select="str:tokenize($string,'&#xA;&#xD;')">
<xsl:value-of select="util:format(., $indent, $line-length)"/>
</xsl:for-each>
</xsl:when>
<xsl:when test="string-length($string) &gt; $line-length">
<xsl:variable name="tmp" select="util:maximize($string, $line-length)"/>
<xsl:value-of select="str:padding($indent,' ')"/>
<xsl:value-of select="substring($string, 1, $tmp)"/>
<xsl:text>&#xA;</xsl:text>
<xsl:value-of select="util:format(substring($string, $tmp + 1))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="str:padding($indent,' ')"/>
<xsl:value-of select="$string"/>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</func:result>
</func:function>

<func:function name="util:norm">
<xsl:param name="num"/>
<xsl:param name="length" select="4"/>

<xsl:choose>
<xsl:when test="$length &gt; string-length($num)">
<func:result select="concat('0',util:norm($num, $length - 1))"/>
</xsl:when>
<xsl:otherwise>
<func:result select="$num"/>
</xsl:otherwise>
</xsl:choose>
</func:function>

<func:function name="util:extractnum">
<xsl:param name="string"/>

<xsl:choose>
<xsl:when test="$string = ''">
<func:result select="0"/>
</xsl:when>
<xsl:when test="$string &lt;= '9' and $string &gt;= '0'">
<func:result select="$string"/>
</xsl:when>
<xsl:otherwise>
<func:result select="util:extractnum(substring($string,1,string-length($string)-1))"/>
</xsl:otherwise>
</xsl:choose>
</func:function>

<func:function name="util:ver2num">
<xsl:param name="version"/>

<xsl:choose>
<xsl:when test="contains($version,'.')">
<func:result select="concat(util:norm(substring-before($version,'.')), util:ver2num(substring-after($version,'.')))"/>
</xsl:when>
<xsl:when test="$version = number($version)">
<func:result select="concat(util:norm($version), util:norm(0))"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="tmp" select="util:extractnum($version)"/>
<func:result select="concat(util:norm($tmp),' ', substring($version, string-length($tmp) + 1))"/>
</xsl:otherwise>
</xsl:choose>
</func:function>

<xsl:template match="package">
<xsl:apply-templates select="release">
<xsl:sort order="descending" select="util:ver2num(normalize-space(version))" data-type="text"/>
</xsl:apply-templates>
<xsl:apply-templates select="changelog/release">
<xsl:sort order="descending" select="util:ver2num(normalize-space(version))" data-type="text"/>
</xsl:apply-templates>
</xsl:template>

<xsl:template match="release">
<xsl:text>Version </xsl:text>
<xsl:value-of select="version"/>
<xsl:text> - </xsl:text>
<xsl:value-of select="date"/>
<xsl:if test="state">
<xsl:text> (</xsl:text>
<xsl:value-of select="state"/>
<xsl:text>)</xsl:text>
</xsl:if>
<xsl:text>&#xA;----------------------------------------&#xA;Notes:&#xA;</xsl:text>
<xsl:value-of select="util:format(notes)"/>
<xsl:text>&#xA;</xsl:text>
</xsl:template>

</xsl:stylesheet>
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7
14 changes: 14 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Source: php-qrencode
Section: web
Priority: optional
Maintainer: Wei-Li Tang <[email protected]>
Build-Depends: debhelper (>= 7), po-debconf, xsltproc , php-dev , libqrencode-dev, libpng-dev
Standards-Version: 3.9.1

Package: php-qrencode
Architecture: any
Depends: ${shlibs:Depends}, ${php:Depends}, ${misc:Depends}, libqrencode4, libpng16-16
Description: qrencode module for PHP 7.3
php qrencode is the wrapper of libqrencode to generate qr code.


20 changes: 20 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
This package was debianized by Wei-Li Tang <[email protected]> using dh-make-pecl
on Mon, 19 Jul 2021 15:36:21 +0800.

It was downloaded from https://github.com/vanillahsu/pecl-qrencode

Upstream Author(s):

Vanilla (San Tai) Hsu

Copyright:

Copyright (C) 2007 Vanilla (San Tai) Hsu

License:

BSD

The Debian packaging is copyright 2009, Wei-Li Tang <[email protected]> and
is licensed under the GPL, see `/usr/share/common-licenses/GPL'.

2 changes: 2 additions & 0 deletions debian/docs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
README
CREDITS
1 change: 1 addition & 0 deletions debian/pecl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
modules/qrencode.so
1 change: 1 addition & 0 deletions debian/php-qrencode.dirs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usr/lib/php7.3
9 changes: 9 additions & 0 deletions debian/php-qrencode.postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

set -e

[ "$1" = "configure" ] && phpenmod qrencode

#DEBHELPER#

exit 0
3 changes: 3 additions & 0 deletions debian/qrencode.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
; configuration for php qrencode module
; priority=20
extension=qrencode.so
63 changes: 63 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/make -f
# template debian/rules provided by dh-make-php.
# GNU copyright 2005 by Uwe Steinmann.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

# Needed for the extension make install
export INSTALL_ROOT:=debian/$(BIN_PACKAGE_NAME)

CFLAGS = -O2 -Wall
CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
CFLAGS += -g
DEBUG := --enable-debug
else
DEBUG := --disable-debug
endif

PECL_PKG_NAME=qrencode
PECL_PKG_REALNAME=qrencode
BIN_PACKAGE_NAME=php-qrencode
PHPIZE=/usr/bin/phpize
PHPCONFIG=/usr/bin/php-config
EXT_DIR=$(shell $(PHPCONFIG) --extension-dir | sed -e "s-/--")
BINARYTARGETS=binary-arch-v7.3
BUILDTARGETS=build-v7.3
CLEANTARGETS=clean-v7.3
PHPAPIVER=$(shell /usr/bin/php-config --phpapi)
PHPCONFD=$(shell echo "/etc/php/7.3/mods-available" | sed -e "s-/--")

%:
dh $@

override_dh_auto_configure:
$(PHPIZE);
./configure --with-php-config=$(PHPCONFIG) --prefix=/usr --with-qrencode

override_dh_strip:
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
dh_strip
endif

override_dh_auto_test:
# do not run tests

override_dh_genconf:
$(shell /usr/share/dh-make-php/phppkginfo . changelog > debian/changelog)
$(shell echo "php:Depends=phpapi-$(PHPAPIVER)" >> debian/$(BIN_PACKAGE_NAME).substvars)

override_dh_auto_install:
dh_install modules/$(PECL_PKG_NAME).so $(EXT_DIR)
dh_install debian/$(PECL_PKG_NAME).ini $(PHPCONFD)
dh_auto_install

override_dh_clean:
# Add here commands to clean up after the build process.
($(MAKE) clean; \
$(PHPIZE) --clean)
dh_clean

0 comments on commit f660f0e

Please sign in to comment.