Skip to content

Commit

Permalink
cops: upgrade to 1.4.2 (#5817)
Browse files Browse the repository at this point in the history
* Upgrade cops to 1.4.3
* Upgrade PHP requirements to 7.4
* Fixed desktop icon
* (core) Use mustache to generate wizards
* Added missing apache 2.4 dependency
* Fixed installer check should be run in `validate_preinst`
* Add explicitly `zlib` PHP extension as a default
* Disabling jsonlinting on wizard templates
* Fixed service user

---------

Co-authored-by: hgy59 <[email protected]>
  • Loading branch information
smaarn and hgy59 authored Aug 28, 2023
1 parent 1a89ebe commit 9e8ab22
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 140 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
find spk/ \
-not -path "*work*" \
-not -path "spk/transmission/src/settings.json" \
-not -path "*/wizard_templates/install_uifile" \
-not -path "*/wizard_templates/upgrade_uifile" \
-regextype posix-extended \
-regex '.*(\.json|install_uifile\w*|upgrade_uifile\w*|app/config)' \
| xargs -i node_modules/jsonlint/lib/cli.js -q -c {};
7 changes: 4 additions & 3 deletions cross/cops/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
PKG_NAME = cops
PKG_VERS = 1.1.3
PKG_VERS = 1.4.2
PKG_EXT = zip
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://github.com/seblucas/cops/releases/download/$(PKG_VERS)
PKG_DIR =
PKG_DIST_SITE = https://github.com/mikespub-org/seblucas-cops/releases/download/$(PKG_VERS)
PKG_DIR = cops
EXTRACT_PATH = $(WORK_DIR)/$(PKG_DIR)

DEPENDS =

Expand Down
6 changes: 3 additions & 3 deletions cross/cops/digests
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cops-1.1.3.zip SHA1 43f4838b5c5f46cf9e57bc4a480f4579494bc7ec
cops-1.1.3.zip SHA256 68c9efb340ab30989cd89a19a173c45872d33ed85dd02674f8af08b7748cbc77
cops-1.1.3.zip MD5 461c2b2fdd6ae6be27ba192d97188fda
cops-1.4.2.zip SHA1 841183a5038f8f012d6c413ebb9c9e54b1cf176d
cops-1.4.2.zip SHA256 60542faade68764667ec142d1606c52f79d9b4818fa2407d40607d0abfd2d99b
cops-1.4.2.zip MD5 ed35a750fc449a52fb7e5229754426d2
4 changes: 2 additions & 2 deletions mk/spksrc.spk.mk
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ endif
ifneq ($(strip $(WIZARDS_TEMPLATES_DIR)),)
@$(MSG) "Generate DSM Wizards from templates"
@mkdir -p $(WIZARDS_DIR)
$(eval IS_DSM_6_OR_GREATER = $(if $(filter 1,$(call version_gt, $(TCVERSION), 6.0)),true,false))
$(eval IS_DSM_7_OR_GREATER = $(if $(filter 1,$(call version_gt, $(TCVERSION), 7.0)),true,false))
$(eval IS_DSM_6_OR_GREATER = $(if $(filter 1,$(call version_ge, $(TCVERSION), 6.0)),true,false))
$(eval IS_DSM_7_OR_GREATER = $(if $(filter 1,$(call version_ge, $(TCVERSION), 7.0)),true,false))
$(eval IS_DSM_7 = $(IS_DSM_7_OR_GREATER))
$(eval IS_DSM_6 = $(if $(filter true,$(IS_DSM_6_OR_GREATER)),$(if $(filter true,$(IS_DSM_7)),false,true),false))
@for template in `find $(WIZARDS_TEMPLATES_DIR) -maxdepth 1 -type f -and \( $(WIZARD_FILE_NAMES) \) -print`; do \
Expand Down
39 changes: 13 additions & 26 deletions spk/cops/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SPK_NAME = cops
SPK_VERS = 1.1.3
SPK_REV = 6
SPK_VERS = 1.4.2
SPK_REV = 7
SPK_ICON = src/cops.png
DSM_UI_DIR = app

Expand All @@ -11,50 +11,37 @@ DESCRIPTION = Calibre OPDS and HTML PHP Server : light alternative to Calibre co
DESCRIPTION_FRE = Calibre OPDS et HTML PHP Serveur : alternative légère au serveur de contenu de Calibre et à Calibre2OPDS.
ADMIN_URL = /cops/
DISPLAY_NAME = COPS
CHANGELOG = "1. Update to 1.1.3<br>2. Improved DSM7 compatibility"
CHANGELOG = "1. Update to 1.4.2<br />2. Upgrade PHP 7.4<br />3. Add .htaccess migration support"

SPK_DEPENDS=WebStation
include ../../mk/spksrc.common.mk
include ../../mk/spksrc.directories.mk

SYSTEM_GROUP = http
SPK_DEPENDS=WebStation:PHP7.4:Apache2.4

BETA=1
SYSTEM_GROUP = http

HOMEPAGE = https://blog.slucas.fr/en/oss/calibre-opds-php-server
LICENSE = GPL

REQUIRED_MIN_DSM = 6.0

WIZARDS_DIR = src/wizard/
WIZARDS_FRAGMENTS_DIR = $(WIZARDS_DIR)/fragments
DSM_UI_CONFIG = src/app/config

WIZARDS_TEMPLATES_DIR = src/wizard_templates
CONF_DIR = src/conf/

SERVICE_SETUP = src/service-setup.sh
SERVICE_USER = auto
STARTABLE = no

INSTALL_DEP_SERVICES = apache-web
START_DEP_SERVICES = apache-web
INSTUNINST_RESTART_SERVICES = apache-web

POST_STRIP_TARGET = cops_extra_install

# Pure PHP package, make sure ARCH is not defined
override ARCH=

include ../../mk/spksrc.spk.mk
ICON_DIR = $(STAGING_DIR)/$(DSM_UI_DIR)/images

.PHONY: customizing-wizards
customizing-wizards: wizards
ifeq ($(call version_lt, ${TCVERSION}, 7.0),1)
@$(MSG) "Adding pre-DSM 7 requirements"
jq --slurp "map(.[])" \
$(WIZARDS_DIR)/install_uifile \
$(WIZARDS_FRAGMENTS_DIR)/php_configuration_requirements.json > $(DSM_WIZARDS_DIR)/install_uifile
jq --slurp "map(.[])" \
$(WIZARDS_DIR)/install_uifile_fre \
$(WIZARDS_FRAGMENTS_DIR)/php_configuration_requirements_fre.json > $(DSM_WIZARDS_DIR)/install_uifile_fre
endif

$(SPK_FILE_NAME): customizing-wizards
include ../../mk/spksrc.spk.mk

.PHONY: cops_extra_install
cops_extra_install:
Expand Down
6 changes: 4 additions & 2 deletions spk/cops/src/conf/resource
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
"services": [{
"service": "cops",
"display_name": "COPS",
"icon": "app/images/cops-{0}.png",
"type": "apache_php",
"root": "cops",
"backend": 2,
"php": {
"profile_name": "cops",
"profile_desc": "PHP profile used by cops",
"backend": 6,
"backend": 8,
"extensions": [
"gd",
"pdo_sqlite",
"sqlite3",
"intl"
"intl",
"zlib"
],
"user": "sc-cops",
"group": "http"
Expand Down
23 changes: 15 additions & 8 deletions spk/cops/src/service-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ PACKAGE_NAME="com.synocommunity.packages.${SYNOPKG_PKGNAME}"

# Others
CFG_FILE_NAME="config_local.php"
SECURITY_SETTINGS_FILE_NAME=".htaccess"
DEFAULT_CFG_FILE="${SYNOPKG_PKGDEST}/${CFG_FILE_NAME}.synology"
DSM6_WEB_DIR="/var/services/web"
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -ge 7 ]; then
Expand All @@ -13,13 +14,14 @@ else
WEB_DIR="${DSM6_WEB_DIR}"
fi
CFG_FILE="${WEB_DIR}/${SYNOPKG_PKGNAME}/${CFG_FILE_NAME}"
SECURITY_SETTINGS_FILE="${WEB_DIR}/${SYNOPKG_PKGNAME}/${SECURITY_SETTINGS_FILE_NAME}"
BUILDNUMBER="$(/bin/get_key_value /etc.defaults/VERSION buildnumber)"

USER="http"
GROUP="http"
PHP_CONFIG_LOCATION="$([ "${BUILDNUMBER}" -ge "7135" ] && echo -n /usr/local/etc/php56/conf.d || echo -n /etc/php/conf.d)"

service_preinst ()
validate_preinst ()
{
if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then
if [ ! -f "${wizard_calibre_dir}/metadata.db" ]; then
Expand Down Expand Up @@ -66,7 +68,6 @@ service_postinst ()
service_postuninst ()
{
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then

# Remove link
rm -f "${SYNOPKG_PKGDEST}"

Expand All @@ -79,24 +80,30 @@ service_postuninst ()
fi
}

service_preupgrade ()
service_save ()
{
# Save some stuff
rm -fr "${TMP_DIR:?}/${SYNOPKG_PKGNAME}"
mkdir -p "${TMP_DIR}/${SYNOPKG_PKGNAME}"
mv "${CFG_FILE}" "${TMP_DIR}/${SYNOPKG_PKGNAME}/"
# Save cops configuration file
mv -v "${CFG_FILE}" "${TMP_DIR}/${SYNOPKG_PKGNAME}/"
# Save .htaccess file
mv -v "${SECURITY_SETTINGS_FILE}" "${TMP_DIR}/${SYNOPKG_PKGNAME}/"
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then
mv "${PHP_CONFIG_LOCATION}/${PACKAGE_NAME}.ini" "${TMP_DIR}/${SYNOPKG_PKGNAME}/"
mv -v "${PHP_CONFIG_LOCATION}/${PACKAGE_NAME}.ini" "${TMP_DIR}/${SYNOPKG_PKGNAME}/"
fi
}

service_postupgrade ()
service_restore ()
{
# Restore some stuff
rm -f "${CFG_FILE}"
mv "${TMP_DIR}/${SYNOPKG_PKGNAME}/${CFG_FILE_NAME}" "${CFG_FILE}"
# Restore cops configuration file
mv -v "${TMP_DIR}/${SYNOPKG_PKGNAME}/${CFG_FILE_NAME}" "${CFG_FILE}"
# Restore .htaccess file
mv -v "${TMP_DIR}/${SYNOPKG_PKGNAME}/${SECURITY_SETTINGS_FILE_NAME}" "${SECURITY_SETTINGS_FILE}"
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then
mv "${TMP_DIR}/${SYNOPKG_PKGNAME}/${PACKAGE_NAME}.ini" "${PHP_CONFIG_LOCATION}/"
fi
rm -fr "${TMP_DIR:?}/${SYNOPKG_PKGNAME}"
rm -d "${TMP_DIR}/${SYNOPKG_PKGNAME}" "${TMP_DIR}"
}
11 changes: 0 additions & 11 deletions spk/cops/src/wizard/fragments/php_configuration_requirements.json

This file was deleted.

This file was deleted.

37 changes: 0 additions & 37 deletions spk/cops/src/wizard/install_uifile

This file was deleted.

37 changes: 0 additions & 37 deletions spk/cops/src/wizard/install_uifile_fre

This file was deleted.

51 changes: 51 additions & 0 deletions spk/cops/src/wizard_templates/install_uifile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[{
"step_title": "{{{COPS_CONFIGURATION_FIRST_STEP_TITLE}}}",
"items": [{
"type": "textfield",
"desc": "{{{EXISTING_CALIBRE_DIRECTORY_DESCRIPTION}}}",
"subitems": [{
"key": "wizard_calibre_dir",
"defaultValue": "/volume1/calibre/",
"desc": "{{{EXISTING_CALIBRE_DIRECTORY_LABEL}}}"
}]
}, {
"type": "textfield",
"desc": "{{{COPS_CATALOG_TITLE_DESCRIPTION}}}",
"subitems": [{
"key": "wizard_cops_title",
"defaultValue": "COPS",
"desc": "{{{COPS_CATALOG_TITLE_LABEL}}}"
}]
}]
},{
"step_title": "{{{COPS_CONFIGURATION_SECOND_STEP_TITLE}}}",
"items": [{
"type": "multiselect",
"desc": "{{{DO_YOU_WANT_TO_USE_COPS_WITH_A_KOBO_DESCRIPTION}}}",
"subitems": [{
"key": "wizard_use_url_rewriting",
"desc": "{{{DO_YOU_WANT_TO_USE_COPS_WITH_A_KOBO_LABEL}}}"
}]
}]
},
{{#IS_DSM_6}}
{
"step_title": "{{{PHP_CONFIGURATION_REQUIREMENTS_TITLE}}}",
"items": [
{
"desc": "{{{PHP_CONFIGURATION_REQUIREMENTS_EXPLANATION}}}"
},
{
"desc": "<ul><li>gd</li><li>intl</li><li>pdo_sqlite</li><li>sqlite3</li><li>zlib</li></ul>"
}
]
},
{{/IS_DSM_6}}
{
"step_title": "{{{DSM_PERMISSIONS_TITLE}}}",
"items": [
{
"desc": "{{{DSM_PERMISSIONS_TEXT}}}"
}
]
}]
16 changes: 16 additions & 0 deletions spk/cops/src/wizard_templates/install_uifile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
COPS_CONFIGURATION_FIRST_STEP_TITLE: "COPS configuration"

EXISTING_CALIBRE_DIRECTORY_DESCRIPTION: "Existing Calibre library directory. WARNING: has to end with a / and never use your web directory"
EXISTING_CALIBRE_DIRECTORY_LABEL: "Calibre directory"
COPS_CATALOG_TITLE_DESCRIPTION: "Catalog title."
COPS_CATALOG_TITLE_LABEL: "Catalog title"

COPS_CONFIGURATION_SECOND_STEP_TITLE: "COPS configuration (next)"
DO_YOU_WANT_TO_USE_COPS_WITH_A_KOBO_DESCRIPTION: "Do you want to use COPS with a Kobo eReader?"
DO_YOU_WANT_TO_USE_COPS_WITH_A_KOBO_LABEL: "Kobo"

DSM_PERMISSIONS_TITLE: "Attention! DSM Permissions"
DSM_PERMISSIONS_TEXT: "Package user and group will not appear on most UI settings. Please read <a target=\\\"_blank\\\" href=\\\"https://github.com/SynoCommunity/spksrc/wiki/Permission-Management\\\">Permission Management</a> for details."

PHP_CONFIGURATION_REQUIREMENTS_TITLE: "PHP Configuration Requirements"
PHP_CONFIGURATION_REQUIREMENTS_EXPLANATION: "The below PHP extensions are required for COPS to operate (in WebStation):"
16 changes: 16 additions & 0 deletions spk/cops/src/wizard_templates/install_uifile_fre.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
COPS_CONFIGURATION_FIRST_STEP_TITLE: "Configuration de COPS"

EXISTING_CALIBRE_DIRECTORY_DESCRIPTION: "Répertoire existant contenant une bibliothèque Calibre. Attention : doit se terminer par un / et ne jamais utiliser le répertoire web."
EXISTING_CALIBRE_DIRECTORY_LABEL: "Répertoire contenant Calibre"
COPS_CATALOG_TITLE_DESCRIPTION: "Titre du catalogue."
COPS_CATALOG_TITLE_LABEL: "Titre du catalogue"

COPS_CONFIGURATION_SECOND_STEP_TITLE: "Configuration de COPS (suite)"
DO_YOU_WANT_TO_USE_COPS_WITH_A_KOBO_DESCRIPTION: "Voulez vous utiliser COPS avec votre liseuse Kobo ?"
DO_YOU_WANT_TO_USE_COPS_WITH_A_KOBO_LABEL: "Kobo"

DSM_PERMISSIONS_TITLE: "Attention! DSM Permissions"
DSM_PERMISSIONS_TEXT: "L'utilisateur et le group du package n'apparaîtront pas sur la plupart des UI réglages. Veuillez vous référrer à <a target=\\\"_blank\\\" href=\\\"https://github.com/SynoCommunity/spksrc/wiki/Permission-Management\\\">Permission Management</a> pour plus de détails."

PHP_CONFIGURATION_REQUIREMENTS_TITLE: "Configuration PHP requise"
PHP_CONFIGURATION_REQUIREMENTS_EXPLANATION: "Vous devriez activer les extensions PHP suivantes (au sein de WebStation):"

0 comments on commit 9e8ab22

Please sign in to comment.