Skip to content

Commit

Permalink
adminer: update to v4.7.6 (#3894)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hgy59 authored Mar 22, 2020
1 parent 7a1b805 commit 417fbe0
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 50 deletions.
35 changes: 23 additions & 12 deletions cross/adminer/Makefile
Original file line number Diff line number Diff line change
@@ -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 =
Expand All @@ -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
2 changes: 1 addition & 1 deletion cross/adminer/PLIST
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rsc:share/adminer
rsc:web
6 changes: 3 additions & 3 deletions cross/adminer/digests
Original file line number Diff line number Diff line change
@@ -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
38 changes: 28 additions & 10 deletions cross/adminer/patches/001-not-use-pgsql-extension.patch
Original file line number Diff line number Diff line change
@@ -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));
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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;

18 changes: 10 additions & 8 deletions spk/adminer/Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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<br/>2. Add wizard to configure networks for client access \(.htaccess\)<br/>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
4 changes: 4 additions & 0 deletions spk/adminer/src/dot-htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

Order Deny,Allow
Deny from all
Allow from @@_wizard_htaccess_allowed_from_@@
25 changes: 9 additions & 16 deletions spk/adminer/src/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
{
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
19 changes: 19 additions & 0 deletions spk/adminer/src/wizard/install_uifile
Original file line number Diff line number Diff line change
@@ -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 <strong>[ip_addr][ip_mask]</strong> 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"
}
}
}]
}]
}]
19 changes: 19 additions & 0 deletions spk/adminer/src/wizard/upgrade_uifile
Original file line number Diff line number Diff line change
@@ -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 <strong>[ip_addr][ip_mask]</strong> 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"
}
}
}]
}]
}]

0 comments on commit 417fbe0

Please sign in to comment.