fix(secubox): improve Makefile install and add postinst verification

Enhanced package installation to ensure appstore files are properly
installed with correct permissions during both fresh installs and upgrades.

Changes to Makefile:
1. Added explicit PKG_FILE_MODES for all data directories and files:
   - /usr/share/secubox: 755
   - /usr/share/secubox/appstore: 755
   - /usr/share/secubox/appstore/apps.json: 644
   - /usr/share/secubox/profiles: 755

2. Improved install section:
   - Added file existence check before installing profiles
   - Added install verification message for appstore catalog
   - Better comments for clarity

3. Added postinst script:
   - Verifies appstore catalog exists after installation
   - Sets proper permissions on all data directories/files
   - Reloads RPCD service to pick up new methods
   - Provides installation feedback to user
   - Fails with warning if appstore catalog missing

This ensures the appstore will be populated on fresh firmware installs
and properly updated during package upgrades.

Version: 0.7.0-3

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2025-12-31 13:05:33 +01:00
parent edd29ad481
commit 0edb6ef69a

View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-secubox
PKG_VERSION:=0.7.0
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_LICENSE:=Apache-2.0
PKG_MAINTAINER:=CyberMind <contact@cybermind.fr>
@ -16,20 +16,62 @@ LUCI_PKGARCH:=all
# - RPCD scripts: 755 (executable by root, required for ubus calls)
# - Helper scripts: 755 (if executable)
# - Config files: 644 (readable by all, writable by root)
# - Data directories: 755 (readable/searchable by all)
# - Data files: 644 (readable by all)
# - CSS/JS files: 644 (set automatically by luci.mk)
PKG_FILE_MODES:=/usr/libexec/rpcd/luci.secubox:root:root:755 \
/usr/libexec/secubox/fix-permissions.sh:root:root:755
/usr/libexec/secubox/fix-permissions.sh:root:root:755 \
/usr/share/secubox:root:root:755 \
/usr/share/secubox/appstore:root:root:755 \
/usr/share/secubox/appstore/apps.json:root:root:644 \
/usr/share/secubox/profiles:root:root:755
include $(TOPDIR)/feeds/luci/luci.mk
define Package/$(PKG_NAME)/install
$(call Package/luci/install,$(1))
# Install SecuBox profiles
$(INSTALL_DIR) $(1)/usr/share/secubox/profiles
for file in $(CURDIR)/profiles/*.json; do \
$(INSTALL_DATA) $$file $(1)/usr/share/secubox/profiles/$$(basename $$file); \
[ -f "$$file" ] && $(INSTALL_DATA) $$file $(1)/usr/share/secubox/profiles/$$(basename $$file); \
done
# Install AppStore catalog (CRITICAL: Required for app store functionality)
$(INSTALL_DIR) $(1)/usr/share/secubox/appstore
$(INSTALL_DATA) $(CURDIR)/appstore/apps.json $(1)/usr/share/secubox/appstore/apps.json
# Verify appstore file was installed
@echo "SecuBox: Installed appstore catalog to /usr/share/secubox/appstore/apps.json"
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
# SecuBox post-installation script
# Ensures appstore catalog and permissions are correct
[ -n "$${IPKG_INSTROOT}" ] || {
# Verify appstore catalog exists
if [ ! -f /usr/share/secubox/appstore/apps.json ]; then
echo "WARNING: SecuBox appstore catalog not found!"
echo "Expected: /usr/share/secubox/appstore/apps.json"
exit 1
fi
# Set proper permissions
chmod 755 /usr/share/secubox 2>/dev/null || true
chmod 755 /usr/share/secubox/appstore 2>/dev/null || true
chmod 644 /usr/share/secubox/appstore/apps.json 2>/dev/null || true
chmod 755 /usr/share/secubox/profiles 2>/dev/null || true
# Reload RPCD to pick up new methods
/etc/init.d/rpcd reload 2>/dev/null || true
echo "SecuBox: Installation complete"
echo " - Appstore catalog: /usr/share/secubox/appstore/apps.json"
echo " - RPCD methods available via: ubus call luci.secubox"
}
exit 0
endef
# call BuildPackage - OpenWrt buildroot