|
1 | 1 | #!/usr/bin/make -f |
2 | 2 |
|
| 3 | +PKG_VERSION := $(shell dpkg-parsechangelog -S Version | sed 's/~.*//') |
| 4 | +PKG_SOURCE := $(shell jq -r '.name' composer.json) |
| 5 | +PKG_TYPE := $(shell jq -r '.type' composer.json) |
| 6 | + |
| 7 | +BUNDLED := debian/csas-authorize/usr/lib/csas-authorize/vendor |
| 8 | + |
3 | 9 | %: |
4 | 10 | dh $@ |
5 | 11 |
|
6 | 12 | override_dh_install: |
7 | | - mkdir -p debian/tmp/ |
8 | | - jq '.version = "'`dpkg-parsechangelog | sed -n 's/^Version: //p'| sed 's/~.*//'`'"' debian/conf/composer.json |sponge debian/tmp/composer.json |
9 | 13 | dh_install |
10 | | - sed -i -e 's/\.\.\/i18n/\/usr\/share\/locale/g' debian/csas-authorize/usr/share/csas-authorize/init.php |
11 | | - mkdir -p debian/csas-authorize-sqlite/usr/lib/csas-authorize |
12 | | - cp debian/conf/.env.template debian/csas-authorize-sqlite/usr/lib/csas-authorize |
13 | | - mkdir -p debian/csas-authorize-mysql/usr/lib/csas-authorize |
14 | | - cp debian/conf/.env.template debian/csas-authorize-mysql/usr/lib/csas-authorize |
15 | | - sed -i '/DB_DATABASE/c\DB_DATABASE=_DBC_DBNAME_' debian/csas-authorize-*sql/usr/lib/csas-authorize/.env.template |
16 | | - sed -i '/DB_CONNECTION/c\DB_CONNECTION=sqlite' debian/csas-authorize-sqlite/usr/lib/csas-authorize/.env.template |
17 | | - sed -i '/DB_CONNECTION/c\DB_CONNECTION=mysql' debian/csas-authorize-mysql/usr/lib/csas-authorize/.env.template |
18 | | - touch debian/csas-authorize-sqlite/var/lib/dbconfig-common/sqlite3/csas-authorize/csas-authorize |
19 | | - sed -i -e 's/..\/vendor/\/var\/lib\/composer\/csas-authorize/g' debian/csas-authorize/usr/*/csas-authorize/*.php |
20 | | - sed -i -e 's/\.\.\/\.env/\/etc\/csas-authorize\/csas-authorize\.env/g' debian/csas-authorize/usr/*/csas-authorize/*.php |
21 | | - sed -i -e 's/\.\.\/src\/init\.php/\/usr\/share\/csas-authorize\/init\.php/g' debian/csas-authorize/usr/*/csas-authorize/*.php |
22 | | - sed -i -e 's/..\/i18n/\/usr\/share\/locale/g' debian/csas-authorize/usr/share/csas-authorize/init.php |
| 14 | + # Bundle vendor packages that have no Debian equivalent |
| 15 | + install -d $(BUNDLED)/League/OAuth2 |
| 16 | + cp -r vendor/league/oauth2-client/src $(BUNDLED)/League/OAuth2/Client |
| 17 | + cp -r vendor/guzzlehttp/guzzle/src $(BUNDLED)/GuzzleHttp |
| 18 | + cp -r vendor/guzzlehttp/psr7/src $(BUNDLED)/GuzzleHttp/Psr7 |
| 19 | + cp -r vendor/guzzlehttp/promises/src $(BUNDLED)/GuzzleHttp/Promise |
| 20 | + install -d $(BUNDLED)/Psr/Http |
| 21 | + cp -r vendor/psr/http-message/src $(BUNDLED)/Psr/Http/Message |
| 22 | + cp vendor/psr/http-factory/src/*.php $(BUNDLED)/Psr/Http/Message/ |
| 23 | + install -d $(BUNDLED)/Psr/Http/Client |
| 24 | + cp vendor/psr/http-client/src/*.php $(BUNDLED)/Psr/Http/Client/ |
| 25 | + cp vendor/ralouphie/getallheaders/src/getallheaders.php $(BUNDLED)/getallheaders.php |
| 26 | + cp -r vendor/kint-php/kint/src $(BUNDLED)/Kint |
| 27 | + cp vendor/kint-php/kint/init.php $(BUNDLED)/kint_init.php |
| 28 | + # Install static autoloader |
| 29 | + install -m 644 debian/autoload.php \ |
| 30 | + debian/csas-authorize/usr/share/csas-authorize/autoload.php |
| 31 | + # Fix path references in installed PHP files |
| 32 | + sed -i -e "s|require_once '../vendor/autoload.php'|require_once '/usr/share/csas-authorize/autoload.php'|g" \ |
| 33 | + debian/csas-authorize/usr/share/csas-authorize/*.php \ |
| 34 | + debian/csas-authorize/usr/libexec/csas-authorize/*.php |
| 35 | + sed -i -e 's/\.\.\/i18n/\/usr\/share\/locale/g' \ |
| 36 | + debian/csas-authorize/usr/share/csas-authorize/init.php |
| 37 | + sed -i -e 's/\.\.\/\.env/\/etc\/csas-authorize\/csas-authorize\.env/g' \ |
| 38 | + debian/csas-authorize/usr/share/csas-authorize/*.php \ |
| 39 | + debian/csas-authorize/usr/libexec/csas-authorize/*.php |
| 40 | + sed -i -e 's/\.\.\/src\/init\.php/\/usr\/share\/csas-authorize\/init\.php/g' \ |
| 41 | + debian/csas-authorize/usr/libexec/csas-authorize/*.php |
| 42 | + # Inject APP_NAME, APP_VERSION and InstalledVersions at build time |
| 43 | + sed -i "1a defined('APP_NAME') || define('APP_NAME', '$(PKG_SOURCE)');" \ |
| 44 | + debian/csas-authorize/usr/share/csas-authorize/autoload.php |
| 45 | + sed -i "s|'unknown'|'$(PKG_SOURCE)'|" \ |
| 46 | + debian/csas-authorize/usr/share/csas-authorize/autoload.php |
| 47 | + sed -i "s|'0.0.0'|'$(PKG_VERSION)'|" \ |
| 48 | + debian/csas-authorize/usr/share/csas-authorize/autoload.php |
| 49 | + sed -i "s|'library'|'$(PKG_TYPE)'|g" \ |
| 50 | + debian/csas-authorize/usr/share/csas-authorize/autoload.php |
| 51 | + sed -i "2a defined('APP_VERSION') || define('APP_VERSION', '$(PKG_VERSION)');" \ |
| 52 | + debian/csas-authorize/usr/share/csas-authorize/autoload.php |
| 53 | + |
| 54 | +override_dh_auto_test: |
| 55 | + appstreamcli validate --pedantic --no-net \ |
| 56 | + debian/io.github.spoje_net.csas_authorize.metainfo.xml |
23 | 57 |
|
24 | 58 | override_dh_clean: |
25 | 59 | debconf-updatepo |
|
0 commit comments