Skip to content
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
composer.phar
composer.lock
/vendor/

# allow developer to have local config
/configs/localdev.config.php
125 changes: 109 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,26 @@ COMPOSER_ONLY_APPS = \
# App directories that need nothing to build (no changes made during build)
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 = \
notify_push

# Apps to be removed from final package (read from removed-apps.txt)
REMOVE_UNWANTED_APPS = $(shell [ -f IONOS/removed-apps.txt ] && sed '/^#/d;/^$$/d;s/^/apps\//' IONOS/removed-apps.txt || echo "")

# Generate build targets dynamically
FULL_BUILD_TARGETS = $(patsubst %,build_%_app,$(FULL_BUILD_APPS))
COMPOSER_ONLY_TARGETS = $(patsubst %,build_%_app,$(COMPOSER_ONLY_APPS))
NOTHING_TO_BUILD_TARGETS = $(patsubst %,build_%_app,$(NOTHING_TO_BUILD_APPS))
SPECIAL_BUILD_TARGETS = $(patsubst %,build_%_app,$(SPECIAL_BUILD_APPS))

# Core build targets
.PHONY: help
.PHONY: help .precheck
# Main Nextcloud build
.PHONY: build_ncw
# Applications - dynamically generated
.PHONY: build_all_external_apps build_notify_push_app build_notify_push_binary build_core_app_theming $(FULL_BUILD_TARGETS) $(COMPOSER_ONLY_TARGETS) $(NOTHING_TO_BUILD_TARGETS)
.PHONY: build_all_external_apps build_notify_push_binary build_core_app_theming $(FULL_BUILD_TARGETS) $(COMPOSER_ONLY_TARGETS) $(NOTHING_TO_BUILD_TARGETS) $(SPECIAL_BUILD_TARGETS)
# Configuration and packaging
.PHONY: add_config_partials patch_shipped_json version.json zip_dependencies
# Pipeline targets for GitLab workflow
Expand All @@ -83,7 +89,7 @@ NOTHING_TO_BUILD_TARGETS = $(patsubst %,build_%_app,$(NOTHING_TO_BUILD_APPS))
# Validation targets
.PHONY: validate_external_apps validate_all
# Matrix generation
.PHONY: generate_external_apps_matrix
.PHONY: generate_external_apps_matrix generate_external_apps_matrix_json

help: ## This help.
@echo "Usage: make [target]"
Expand All @@ -104,11 +110,52 @@ help: ## This help.
@echo " validate_all Run all validation tasks"
@echo "Matrix generation targets:"
@echo " generate_external_apps_matrix Generate external apps matrix YAML file"
@echo " generate_external_apps_matrix_json Generate external apps matrix JSON file"
# HELP
# This will output the help for each task
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.DEFAULT_GOAL := help

.precheck:
@{ \
if [ ! -d "apps-external" ]; then \
echo ""; \
echo "**********************************************************************"; \
echo "ERROR: apps-external/ directory not found!"; \
echo ""; \
echo "This Makefile must be executed from the Nextcloud project root."; \
echo "Usage: make -f IONOS/Makefile <target>"; \
echo "**********************************************************************"; \
echo ""; \
exit 1; \
fi; \
if ! test -f "version.php" || ! test -d "lib" || ! test -d "core"; then \
echo ""; \
echo "**********************************************************************"; \
echo "ERROR: Required Nextcloud directories/files not found!"; \
echo ""; \
echo "This doesn't appear to be a valid Nextcloud project directory."; \
echo "Usage: make -f IONOS/Makefile <target>"; \
echo "**********************************************************************"; \
echo ""; \
exit 1; \
fi; \
if ! command -v jq >/dev/null 2>&1; then \
echo ""; \
echo "**********************************************************************"; \
echo "ERROR: jq is not installed!"; \
echo ""; \
echo "jq is required for JSON processing in this Makefile."; \
echo "Please install jq:"; \
echo " - Ubuntu/Debian: sudo apt-get install jq"; \
echo " - macOS: brew install jq"; \
echo " - Other: https://jqlang.github.io/jq/download/"; \
echo "**********************************************************************"; \
echo ""; \
exit 1; \
fi; \
} >&2

# Common function to build apps with full build process
define build_full_app
@echo "[i] Building $(1) app..."
Expand All @@ -127,13 +174,13 @@ define build_composer_app
@echo "[✓] $(1) app built successfully"
endef

build_core_app_theming: ## Build theming app
build_core_app_theming: .precheck ## Build theming app
@echo "[i] Building theming app..."
cd apps/theming/composer && \
composer dump-autoload --optimize
@echo "[✓] theming app built successfully"

build_ncw: build_core_app_theming ## Build Nextcloud Workspace
build_ncw: .precheck build_core_app_theming ## Build Nextcloud Workspace
# composer install --no-dev -o && \
# npm ci && \
# NODE_OPTIONS="--max-old-space-size=4096" npm run build
Expand Down Expand Up @@ -173,16 +220,16 @@ $(NOTIFY_PUSH_DIR)/vendor/autoload.php: $(NOTIFY_PUSH_DIR)/composer.json
build_notify_push_binary: $(NOTIFY_PUSH_BINARY) ## Download notify_push binary
@echo "[i] notify_push binary ready"

add_config_partials: ## Copy custom config files to Nextcloud config
add_config_partials: .precheck ## Copy custom config files to Nextcloud config
@echo "[i] Copying config files..."
cp IONOS/configs/*.config.php config/
@echo "[✓] Config files copied successfully"

patch_shipped_json: ## Patch shipped.json to make core apps disableable
patch_shipped_json: .precheck ## Patch shipped.json to make core apps disableable
@echo "[i] Patching shipped.json..."
IONOS/apps-disable.sh

version.json: ## Generate version file
version.json: .precheck ## Generate version file
@echo "[i] Generating version.json..."
buildDate=$$(date +%s) && \
buildRef=$$(git rev-parse --short HEAD) && \
Expand Down Expand Up @@ -247,7 +294,7 @@ zip_dependencies: patch_shipped_json version.json ## Zip relevant files
@echo "[i] Package $(TARGET_PACKAGE_NAME) created successfully"

# Parallel build targets
build_all_external_apps: $(FULL_BUILD_TARGETS) $(COMPOSER_ONLY_TARGETS) $(NOTHING_TO_BUILD_TARGETS) build_notify_push_app ## Build all external apps
build_all_external_apps: $(FULL_BUILD_TARGETS) $(COMPOSER_ONLY_TARGETS) $(NOTHING_TO_BUILD_TARGETS) $(SPECIAL_BUILD_TARGETS) ## Build all external apps
@echo "[i] All external apps built successfully"

build_after_external_apps: build_ncw add_config_partials ## Build NCW and add configs after external apps are done
Expand All @@ -269,7 +316,7 @@ clean: ## Clean build artifacts
@rm -f $(NOTIFY_PUSH_BINARY) $(NOTIFY_PUSH_BINARY).sha256
@echo "[✓] Clean completed"

validate_external_apps: ## Validate and suggest proper categorization for external apps
validate_external_apps: .precheck ## Validate and suggest proper categorization for external apps
@echo "[i] Analyzing external apps to suggest proper build configuration..."
@echo "[i] Checking all apps in apps-external directory..."
@bash -c ' \
Expand Down Expand Up @@ -336,7 +383,7 @@ validate_external_apps: ## Validate and suggest proper categorization for extern
echo ""; \
echo "[i] Checking configured apps for missing submodules..."; \
\
for app in $(FULL_BUILD_APPS) $(COMPOSER_ONLY_APPS) $(NOTHING_TO_BUILD_APPS); do \
for app in $(FULL_BUILD_APPS) $(COMPOSER_ONLY_APPS) $(NOTHING_TO_BUILD_APPS) $(SPECIAL_BUILD_APPS); do \
if [ ! -d "apps-external/$$app" ]; then \
echo " ❌ ERROR: App $$app is configured but directory does not exist"; \
validation_failed=1; \
Expand Down Expand Up @@ -574,18 +621,20 @@ validate_external_apps: ## Validate and suggest proper categorization for extern
exit 1; \
fi'

validate_all: ## Run all validation tasks
validate_all: .precheck ## Run all validation tasks
@echo "[i] Running validation..."
@$(MAKE) -f IONOS/Makefile validate_external_apps
@echo "[✓] Validation completed successfully"

generate_external_apps_matrix: ## Generate external-apps-matrix.yml file with app configuration details
@echo "[i] Generating external apps matrix YAML file..."
generate_external_apps_matrix: .precheck ## Generate external-apps-matrix.yml file with app configuration details
@echo "[i] Generating external apps matrix YAML file..." >&2
@echo "apps-external:"
@bash -c ' \
# Process all configured apps \
all_configured_apps="$(FULL_BUILD_APPS) $(COMPOSER_ONLY_APPS) $(NOTHING_TO_BUILD_APPS) notify_push"; \
for app in $$all_configured_apps; do \
all_configured_apps="$(FULL_BUILD_APPS) $(COMPOSER_ONLY_APPS) $(NOTHING_TO_BUILD_APPS) $(SPECIAL_BUILD_APPS)"; \
# Sort apps alphabetically \
sorted_apps=$$(echo $$all_configured_apps | tr " " "\n" | sort | tr "\n" " "); \
for app in $$sorted_apps; do \
if [ -d "apps-external/$$app" ]; then \
echo " - name: $$app"; \
echo " path: apps-external/$$app"; \
Expand All @@ -610,3 +659,47 @@ generate_external_apps_matrix: ## Generate external-apps-matrix.yml file with ap
echo ""; \
fi; \
done'

generate_external_apps_matrix_json: .precheck ## Generate external-apps-matrix.json file with app configuration details
@echo "[i] Generating external apps matrix JSON file..." >&2
@bash -c ' \
# Process all configured apps \
all_configured_apps="$(FULL_BUILD_APPS) $(COMPOSER_ONLY_APPS) $(NOTHING_TO_BUILD_APPS) $(SPECIAL_BUILD_APPS)"; \
echo "["; \
first=true; \
found_any=false; \
for app in $$all_configured_apps; do \
if [ -d "apps-external/$$app" ]; then \
found_any=true; \
if [ "$$first" = true ]; then \
first=false; \
else \
echo " },"; \
fi; \
echo " {"; \
echo " \"name\": \"$$app\","; \
echo " \"path\": \"apps-external/$$app\","; \
\
# Check for npm (package.json) \
if [ -f "apps-external/$$app/package.json" ]; then \
echo " \"has_npm\": true,"; \
else \
echo " \"has_npm\": false,"; \
fi; \
\
# Check for composer (composer.json) \
if [ -f "apps-external/$$app/composer.json" ]; then \
echo " \"has_composer\": true,"; \
else \
echo " \"has_composer\": false,"; \
fi; \
\
# Determine makefile target \
makefile_target="build_$${app}_app"; \
echo " \"makefile_target\": \"$$makefile_target\""; \
fi; \
done; \
if [ "$$found_any" = true ]; then \
echo " }"; \
fi; \
echo "]"' | jq 'sort_by(.name)'
Loading