Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ NOTHING_TO_BUILD_APPS = \
# Apps with special build targets (not in the standard categories above)
# These apps have dedicated build_<app>_app targets with custom build logic
SPECIAL_BUILD_APPS = \
gdatavaas \
notify_push

# App folders to add to shipped.json (makes apps non-removable)
Expand Down Expand Up @@ -263,6 +264,42 @@ $(NOTIFY_PUSH_BINARY): $(NOTIFY_PUSH_DIR)/appinfo/info.xml
chmod +x $@
@echo "[i] notify_push binary v$(NOTIFY_PUSH_VERSION) downloaded and verified successfully"

# gdatavaas app target with php-scoper namespace scoping
# amphp/amp v3 (used by gdata/vaas) conflicts with amphp/amp v2 (used by mail via rubix/ml).
# php-scoper rewrites vendor namespaces (e.g. Amp\ -> OCA\GDataVaas\Vendor\Amp\) to avoid conflicts.
GDATAVAAS_DIR = apps-external/gdatavaas
GDATAVAAS_SCOPED_DIR = $(GDATAVAAS_DIR)/build/scoped
PHP_SCOPER_PHAR = $(GDATAVAAS_DIR)/build/php-scoper.phar
PHP_SCOPER_VERSION = 0.18.17

$(PHP_SCOPER_PHAR):
@mkdir -p $(dir $(PHP_SCOPER_PHAR))
@echo "[i] Downloading php-scoper $(PHP_SCOPER_VERSION) PHAR..."
@curl -sL -o $(PHP_SCOPER_PHAR) \
https://github.com/humbug/php-scoper/releases/download/$(PHP_SCOPER_VERSION)/php-scoper.phar
Comment on lines +271 to +279

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP_SCOPER_VERSION can change without forcing a re-download because the output path $(PHP_SCOPER_PHAR) is versionless. This can leave an old php-scoper binary in place while the Makefile claims a newer version. Consider versioning the filename (or using a stamp file tied to PHP_SCOPER_VERSION) so Make reliably fetches the requested version.

Copilot uses AI. Check for mistakes.
@chmod +x $(PHP_SCOPER_PHAR)
Comment on lines +274 to +280

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The php-scoper PHAR is downloaded and executed without any integrity verification (checksum/signature) and curl isn’t using --fail, so a 404/HTML error page could be saved and later executed. Consider pinning a SHA256 (or GPG signature) for the exact PHAR and using curl --fail --location (optionally with retries) before chmod +x/execution.

Suggested change
$(PHP_SCOPER_PHAR):
@mkdir -p $(dir $(PHP_SCOPER_PHAR))
@echo "[i] Downloading php-scoper $(PHP_SCOPER_VERSION) PHAR..."
@curl -sL -o $(PHP_SCOPER_PHAR) \
https://github.com/humbug/php-scoper/releases/download/$(PHP_SCOPER_VERSION)/php-scoper.phar
@chmod +x $(PHP_SCOPER_PHAR)
# Expected SHA256 checksum for php-scoper $(PHP_SCOPER_VERSION) PHAR.
# Update this value whenever PHP_SCOPER_VERSION is changed.
PHP_SCOPER_SHA256 = 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
$(PHP_SCOPER_PHAR):
@mkdir -p $(dir $(PHP_SCOPER_PHAR))
@echo "[i] Downloading php-scoper $(PHP_SCOPER_VERSION) PHAR..."
@tmp="$@.tmp" ; \
curl --fail --location --show-error --silent \
-o "$$tmp" \
"https://github.com/humbug/php-scoper/releases/download/$(PHP_SCOPER_VERSION)/php-scoper.phar" ; \
echo "$(PHP_SCOPER_SHA256) $$tmp" | sha256sum -c - ; \
chmod +x "$$tmp" ; \
mv "$$tmp" "$@"

Copilot uses AI. Check for mistakes.

build_gdatavaas_app: $(PHP_SCOPER_PHAR) ## Build gdatavaas app with php-scoper namespace isolation
@echo "[i] Building gdatavaas app..."
Comment on lines +270 to +283

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

php-scoper.phar is stored under apps-external/gdatavaas/build/ and is not removed after the build. Since the packaging target zips apps-external/ and doesn’t exclude **/build/**, this will likely ship the PHAR inside the release artifact unintentionally. Consider deleting the PHAR after use or adding an explicit zip exclude for app build tooling directories.

Copilot uses AI. Check for mistakes.
@cd $(GDATAVAAS_DIR) && \
$(COMPOSER_INSTALL) && \
$(NPM_INSTALL) && \
$(NPM_BUILD)
@echo "[i] Running php-scoper to isolate vendor namespaces..."
@rm -rf $(GDATAVAAS_SCOPED_DIR)
@cd $(GDATAVAAS_DIR) && \
php build/php-scoper.phar add-prefix --output-dir=build/scoped --force --quiet
@echo "[i] Regenerating autoloader for scoped build..."
@composer dump-autoload --working-dir $(GDATAVAAS_SCOPED_DIR) --classmap-authoritative --quiet
@echo "[i] Replacing original sources with scoped versions..."
@rm -rf $(GDATAVAAS_DIR)/lib.orig $(GDATAVAAS_DIR)/vendor.orig
@mv $(GDATAVAAS_DIR)/lib $(GDATAVAAS_DIR)/lib.orig
@mv $(GDATAVAAS_DIR)/vendor $(GDATAVAAS_DIR)/vendor.orig
@mv $(GDATAVAAS_SCOPED_DIR)/lib $(GDATAVAAS_DIR)/lib
@mv $(GDATAVAAS_SCOPED_DIR)/vendor $(GDATAVAAS_DIR)/vendor
@rm -rf $(GDATAVAAS_DIR)/lib.orig $(GDATAVAAS_DIR)/vendor.orig $(GDATAVAAS_SCOPED_DIR)

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This target mutates the app in-place by moving lib/ and vendor/ out of the way and replacing them with the scoped output, then deletes the backups. That makes the build non-idempotent for local development and leaves the working tree irreversibly modified if a later step fails. Consider keeping the original directories (or backups) until the end, and/or producing the scoped artifact in a separate staging directory that packaging consumes instead of overwriting the sources.

Suggested change
@rm -rf $(GDATAVAAS_DIR)/lib.orig $(GDATAVAAS_DIR)/vendor.orig $(GDATAVAAS_SCOPED_DIR)
@rm -rf $(GDATAVAAS_SCOPED_DIR)

Copilot uses AI. Check for mistakes.
@echo "[✓] gdatavaas app built successfully with scoped namespaces"

build_notify_push_app: $(NOTIFY_PUSH_DIR)/vendor/autoload.php $(NOTIFY_PUSH_BINARY) ## Install and build notify_push app
@echo "[i] notify_push app built successfully"

Expand Down
Loading