From 417fbe01c35834964e8e721358335241a4162873 Mon Sep 17 00:00:00 2001 From: hgy59 Date: Sun, 22 Mar 2020 09:47:09 +0100 Subject: [PATCH] adminer: update to v4.7.6 (#3894) * Update adminer #3888 - update adminer to version 4.7.6 - use design "rmsoft_blue" due design "nette" is outdated - use design (adminer.css) from source package instead of download from git - add ui wizards to allow configuration of allowed networks in .htaccess - replace target dir 'share/adminer' by 'web' - use source package containing externals folder * incorporate code review --- cross/adminer/Makefile | 35 +++++++++++------ cross/adminer/PLIST | 2 +- cross/adminer/digests | 6 +-- .../patches/001-not-use-pgsql-extension.patch | 38 ++++++++++++++----- spk/adminer/Makefile | 18 +++++---- spk/adminer/src/dot-htaccess | 4 ++ spk/adminer/src/installer.sh | 25 +++++------- spk/adminer/src/wizard/install_uifile | 19 ++++++++++ spk/adminer/src/wizard/upgrade_uifile | 19 ++++++++++ 9 files changed, 116 insertions(+), 50 deletions(-) create mode 100644 spk/adminer/src/dot-htaccess create mode 100644 spk/adminer/src/wizard/install_uifile create mode 100644 spk/adminer/src/wizard/upgrade_uifile diff --git a/cross/adminer/Makefile b/cross/adminer/Makefile index f7becce7236..ca69fab45ad 100644 --- a/cross/adminer/Makefile +++ b/cross/adminer/Makefile @@ -1,9 +1,8 @@ PKG_NAME = adminer -PKG_VERS = 4.2.5 +PKG_VERS = 4.7.6 PKG_EXT = tar.gz -PKG_DIST_NAME = v$(PKG_VERS).$(PKG_EXT) -PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) -PKG_DIST_SITE = https://github.com/vrana/adminer/archive +PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT) +PKG_DIST_SITE = https://github.com/vrana/adminer/releases/download/v$(PKG_VERS) PKG_DIR = $(PKG_NAME)-$(PKG_VERS) DEPENDS = @@ -14,15 +13,27 @@ LICENSE = Apache License 2.0 or GPL 2 CONFIGURE_TARGET = nop COMPILE_TARGET = nop -INSTALL_TARGET = myInstall +INSTALL_TARGET = adminer_install + +# previous used design "nette" does not contain changes since Adminer 4.6.x +PKG_DESIGN = rmsoft_blue + +# Option to install all design files +# To use a different design manually overwrite adminer.css +# on the target system by one found in the designs sub folders +INSTALL_DESIGNS = 0 + include ../../mk/spksrc.cross-cc.mk -.PHONY: myInstall -myInstall: +.PHONY: adminer_install +adminer_install: (cd $(WORK_DIR)/$(PKG_DIR) && php compile.php && mv $(PKG_NAME)-$(PKG_VERS).php index.php) - mkdir -p $(STAGING_INSTALL_PREFIX)/share/$(PKG_NAME) - (cd $(WORK_DIR)/$(PKG_DIR) && wget -O $(PKG_NAME).css https://raw.githubusercontent.com/vrana/adminer/master/designs/nette/adminer.css) - tar -cf - -C $(WORK_DIR)/$(PKG_DIR) ./index.php | tar -xf - -C $(STAGING_INSTALL_PREFIX)/share/$(PKG_NAME) - tar -cf - -C $(WORK_DIR)/$(PKG_DIR) ./$(PKG_NAME).css | tar -xf - -C $(STAGING_INSTALL_PREFIX)/share/$(PKG_NAME) - echo 'Order Deny,Allow\nDeny from all\nAllow from 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8' > $(STAGING_INSTALL_PREFIX)/share/$(PKG_NAME)/.htaccess + install -m 755 -d $(STAGING_INSTALL_PREFIX)/web + install -m 644 $(WORK_DIR)/$(PKG_DIR)/index.php $(STAGING_INSTALL_PREFIX)/web + install -m 644 $(WORK_DIR)/$(PKG_DIR)/designs/$(PKG_DESIGN)/adminer.css $(STAGING_INSTALL_PREFIX)/web + @if [ "$(INSTALL_DESIGNS)" = "1" ]; \ + then \ + $(MSG) "Install design files" ; \ + tar -cf - -C $(WORK_DIR)/$(PKG_DIR) ./designs | tar -xf - -C $(STAGING_INSTALL_PREFIX)/web ; \ + fi diff --git a/cross/adminer/PLIST b/cross/adminer/PLIST index 8b23d2e4490..fae5c759720 100644 --- a/cross/adminer/PLIST +++ b/cross/adminer/PLIST @@ -1 +1 @@ -rsc:share/adminer +rsc:web diff --git a/cross/adminer/digests b/cross/adminer/digests index c6830676a08..1894af03a46 100644 --- a/cross/adminer/digests +++ b/cross/adminer/digests @@ -1,3 +1,3 @@ -adminer-4.2.5.tar.gz SHA1 d84d3d52da80982cde5bfb984670d1b026393e9f -adminer-4.2.5.tar.gz SHA256 aacc85398ffc4a666d80311ffb2a2e01cbb12e8d672f495383766725becd8283 -adminer-4.2.5.tar.gz MD5 73fc007ee4e773ef5eed862e690626c0 +adminer-4.7.6.tar.gz SHA1 9fa32f6170934ed1759be4dba7fb2d1ea3831656 +adminer-4.7.6.tar.gz SHA256 f1766dd7e41c42253025d093bf0bd8e2f803137a4d5c88d4c3624c793ed3fbfd +adminer-4.7.6.tar.gz MD5 32bfd7303b395af5bd68039771f9e2c8 diff --git a/cross/adminer/patches/001-not-use-pgsql-extension.patch b/cross/adminer/patches/001-not-use-pgsql-extension.patch index ed798cb45c5..6fc31bf9e47 100644 --- a/cross/adminer/patches/001-not-use-pgsql-extension.patch +++ b/cross/adminer/patches/001-not-use-pgsql-extension.patch @@ -1,15 +1,15 @@ # See https://github.com/SynoCommunity/spksrc/issues/2662 # Remove the extension pgsql because the extension pgsql does not work with the PostgreSQL server from DSM. The Extension pdo_pgsql works perfectly. ---- adminer/drivers/pgsql.inc.php.old 2015-11-29 14:59:46.433067414 +0100 -+++ adminer/drivers/pgsql.inc.php 2015-11-29 14:59:52.581069610 +0100 -@@ -4,128 +4,7 @@ +--- adminer/drivers/pgsql.inc.php.org 2020-01-31 10:23:04.000000000 +0000 ++++ adminer/drivers/pgsql.inc.php 2020-02-23 16:59:43.482304615 +0000 +@@ -4,146 +4,8 @@ if (isset($_GET["pgsql"])) { $possible_drivers = array("PgSQL", "PDO_PgSQL"); define("DRIVER", "pgsql"); - if (extension_loaded("pgsql")) { - class Min_DB { -- var $extension = "PgSQL", $_link, $_result, $_string, $_database = true, $server_info, $affected_rows, $error; -- +- var $extension = "PgSQL", $_link, $_result, $_string, $_database = true, $server_info, $affected_rows, $error, $timeout; + - function _error($errno, $error) { - if (ini_bool("html_errors")) { - $error = html_entity_decode(strip_tags($error)); @@ -39,7 +39,15 @@ - } - - function quote($string) { -- return "'" . pg_escape_string($this->_link, $string) . "'"; //! bytea +- return "'" . pg_escape_string($this->_link, $string) . "'"; +- } +- +- function value($val, $field) { +- return ($field["type"] == "bytea" ? pg_unescape_bytea($val) : $val); +- } +- +- function quoteBinary($string) { +- return "'" . pg_escape_bytea($this->_link, $string) . "'"; - } - - function select_db($database) { @@ -63,12 +71,18 @@ - $this->error = ""; - if (!$result) { - $this->error = pg_last_error($this->_link); -- return false; +- $return = false; - } elseif (!pg_num_fields($result)) { - $this->affected_rows = pg_affected_rows($result); -- return true; +- $return = true; +- } else { +- $return = new Min_Result($result); +- } +- if ($this->timeout) { +- $this->timeout = 0; +- $this->query("RESET statement_timeout"); - } -- return new Min_Result($result); +- return $return; - } - - function multi_query($query) { @@ -91,6 +105,10 @@ - } - return pg_fetch_result($result->_result, 0, $field); - } +- +- function warnings() { +- return h(pg_last_notice($this->_link)); // second parameter is available since PHP 7.1.0 +- } - } - - class Min_Result { @@ -130,5 +148,5 @@ - } elseif (extension_loaded("pdo_pgsql")) { + if (extension_loaded("pdo_pgsql")) { class Min_DB extends Min_PDO { - var $extension = "PDO_PgSQL"; + var $extension = "PDO_PgSQL", $timeout; diff --git a/spk/adminer/Makefile b/spk/adminer/Makefile index d2efb72b051..2ee3dec11c2 100644 --- a/spk/adminer/Makefile +++ b/spk/adminer/Makefile @@ -1,6 +1,6 @@ SPK_NAME = adminer -SPK_VERS = 4.2.5 -SPK_REV = 2 +SPK_VERS = 4.7.6 +SPK_REV = 3 SPK_ICON = src/adminer.png DSM_UI_DIR = app @@ -12,28 +12,30 @@ DESCRIPTION_FRE = Adminer est un outil de gestion de base de données complet di ADMIN_URL = /adminer/ RELOAD_UI = yes DISPLAY_NAME = Adminer -CHANGELOG = Update to 4.2.5 +CHANGELOG = "1. Update to 4.7.6
2. Add wizard to configure networks for client access \(.htaccess\)
3. Switch to design \'rmsoft_blue\', due design \'nette\' is outdated" -HOMEPAGE = https://www.adminer.org -LICENSE = Apache License 2.0 or GPL 2 +HOMEPAGE = https://www.adminer.org +LICENSE = Apache License 2.0 or GPL 2 INSTALLER_SCRIPT = src/installer.sh -SSS_SCRIPT = src/dsm-control.sh +SSS_SCRIPT = src/dsm-control.sh +WIZARDS_DIR = src/wizard/ INSTALL_DEP_SERVICES = apache-web START_DEP_SERVICES = apache-web INSTUNINST_RESTART_SERVICES = apache-web -INSTALL_PREFIX = /usr/local/$(SPK_NAME) - POST_STRIP_TARGET = adminer_extra_install # Pure PHP package, make sure ARCH is not defined override ARCH= + include ../../mk/spksrc.spk.mk .PHONY: adminer_extra_install adminer_extra_install: install -m 755 -d $(STAGING_DIR)/app install -m 644 src/app/config $(STAGING_DIR)/app/config + install -m 755 -d $(STAGING_DIR)/web + install -m 644 src/dot-htaccess $(STAGING_DIR)/web/.htaccess diff --git a/spk/adminer/src/dot-htaccess b/spk/adminer/src/dot-htaccess new file mode 100644 index 00000000000..7374817cfe4 --- /dev/null +++ b/spk/adminer/src/dot-htaccess @@ -0,0 +1,4 @@ + +Order Deny,Allow +Deny from all +Allow from @@_wizard_htaccess_allowed_from_@@ diff --git a/spk/adminer/src/installer.sh b/spk/adminer/src/installer.sh index 0d47dbb3103..95b213b0749 100644 --- a/spk/adminer/src/installer.sh +++ b/spk/adminer/src/installer.sh @@ -3,16 +3,12 @@ # Package PACKAGE="adminer" DNAME="Adminer" -SHORTNAME="adminer" -PACKAGE_NAME="com.synocommunity.packages.${SHORTNAME}" # Others -INSTALL_DIR="/usr/local/${PACKAGE}" +INSTALL_DIR=${SYNOPKG_PKGDEST}/web WEB_DIR="/var/services/web" -TMP_DIR="${SYNOPKG_PKGDEST}/../../@tmp" -BUILDNUMBER="$(/bin/get_key_value /etc.defaults/VERSION buildnumber)" -USER="$([ "${BUILDNUMBER}" -ge "4418" ] && echo -n http || echo -n nobody)" +HTACCESS_FILE=${INSTALL_DIR}/.htaccess preinst () { @@ -21,14 +17,11 @@ preinst () postinst () { - # Link - ln -s ${SYNOPKG_PKGDEST} ${INSTALL_DIR} + # Edit .htaccess according to the wizard + sed -i -e "s|@@_wizard_htaccess_allowed_from_@@|${wizard_htaccess_allowed_from}|g" ${HTACCESS_FILE} # Install the web interface - cp -pR ${INSTALL_DIR}/share/${SHORTNAME} ${WEB_DIR} - - # Fix permissions - chown -R ${USER} ${WEB_DIR}/${SHORTNAME} + cp -pR ${INSTALL_DIR} ${WEB_DIR}/adminer exit 0 } @@ -40,11 +33,8 @@ preuninst () postuninst () { - # Remove link - rm -f ${INSTALL_DIR} - # Remove the web interface - rm -fr ${WEB_DIR}/${SHORTNAME} + rm -rf ${WEB_DIR}/adminer exit 0 } @@ -56,5 +46,8 @@ preupgrade () postupgrade () { + # Edit .htaccess according to the wizard + sed -i -e "s|@@_wizard_htaccess_allowed_from_@@|${wizard_htaccess_allowed_from}|g" ${HTACCESS_FILE} + exit 0 } diff --git a/spk/adminer/src/wizard/install_uifile b/spk/adminer/src/wizard/install_uifile new file mode 100644 index 00000000000..b75d06282aa --- /dev/null +++ b/spk/adminer/src/wizard/install_uifile @@ -0,0 +1,19 @@ +[{ + "step_title": "Configure network(s) to access Adminer", + "items": [{ + "type": "textfield", + "desc": "Configure networks for clients that are allowed to access Adminer on this DiskStation. Choose one ore multiple networks of the format [ip_addr][ip_mask] separated by space.", + "subitems": [{ + "key": "wizard_htaccess_allowed_from", + "desc": "Allowed networks", + "defaultValue": "192.168.0.0/16 172.16.0.0/12 10.0.0.0/8", + "validator": { + "allowBlank": false, + "regex": { + "expr": "/^[0-9 \\.\\\/]*$/", + "errorText": "invalid network definition" + } + } + }] + }] +}] diff --git a/spk/adminer/src/wizard/upgrade_uifile b/spk/adminer/src/wizard/upgrade_uifile new file mode 100644 index 00000000000..b75d06282aa --- /dev/null +++ b/spk/adminer/src/wizard/upgrade_uifile @@ -0,0 +1,19 @@ +[{ + "step_title": "Configure network(s) to access Adminer", + "items": [{ + "type": "textfield", + "desc": "Configure networks for clients that are allowed to access Adminer on this DiskStation. Choose one ore multiple networks of the format [ip_addr][ip_mask] separated by space.", + "subitems": [{ + "key": "wizard_htaccess_allowed_from", + "desc": "Allowed networks", + "defaultValue": "192.168.0.0/16 172.16.0.0/12 10.0.0.0/8", + "validator": { + "allowBlank": false, + "regex": { + "expr": "/^[0-9 \\.\\\/]*$/", + "errorText": "invalid network definition" + } + } + }] + }] +}]