diff --git a/.gitignore b/.gitignore index 4c00505..317fcfb 100644 --- a/.gitignore +++ b/.gitignore @@ -130,6 +130,8 @@ ENV/ build/ !scripts/lib/build/ !services/kasm-base/scripts/build/ +!services/opencloud/scripts/build/ +!services/ocis/scripts/build/ develop-eggs/ dist/ downloads/ diff --git a/services/cernbox-revad/versions.nuon b/services/cernbox-revad/versions.nuon index 70b8933..d0afe7a 100644 --- a/services/cernbox-revad/versions.nuon +++ b/services/cernbox-revad/versions.nuon @@ -58,34 +58,6 @@ } } } - }, - { - "name": "sta-ocm-m6", - "latest": false, - "overrides": { - "sources": { - "revad": { - "url": "https://github.com/MahdiBaghbani/reva-opencloud.git", - "ref": "sta-milestone-6/ocm-code-flow" - } - }, - "platforms": { - "production": { - "dependencies": { - "revad-base": { - "version": "sta-ocm-m6-production" - } - } - }, - "development": { - "dependencies": { - "revad-base": { - "version": "sta-ocm-m6-development" - } - } - } - } - } } ] } diff --git a/services/nextcloud-contacts/versions.nuon b/services/nextcloud-contacts/versions.nuon index 090ba5d..aed23f8 100644 --- a/services/nextcloud-contacts/versions.nuon +++ b/services/nextcloud-contacts/versions.nuon @@ -32,6 +32,11 @@ "url": "https://github.com/MahdiBaghbani/nextcloud-contacts", "ref": "mahdi/fix/ui-optional-email" } + }, + "external_images": { + "build": { + "tag": "24-trixie-slim" + } } } }, diff --git a/services/ocis/scripts/build/reva-override.nu b/services/ocis/scripts/build/reva-override.nu new file mode 100644 index 0000000..e065d70 --- /dev/null +++ b/services/ocis/scripts/build/reva-override.nu @@ -0,0 +1,62 @@ +#!/usr/bin/env nu +# Reva override for the ocis build stage. +# Reads OCIS_REVA_* env vars; clones or copies reva when override is +# enabled; applies go mod replace and runs go mod download. + +def checkout-sha [work_dir: string, sha: string]: nothing -> nothing { + let first = (^git -C $work_dir checkout $sha | complete) + if $first.exit_code == 0 { + return + } + ^git -C $work_dir fetch --depth 1 origin $sha + let second = (^git -C $work_dir checkout $sha | complete) + if $second.exit_code != 0 { + error make { + msg: $"Failed to checkout SHA ($sha) in ($work_dir). The clone may be too shallow; ensure the SHA is reachable from REF or fetch with full depth." + } + } +} + +def main [] { + let mode = $env.OCIS_REVA_MODE? | default "" + let url = $env.OCIS_REVA_URL? | default "" + let ref_ = $env.OCIS_REVA_REF? | default "" + let sha = $env.OCIS_REVA_SHA? | default "" + let goproxy = $env.GO_BUILD_GOPROXY? | default "" + + let override_enabled = (($mode == "local") or (not ($url | is-empty))) + + if not $override_enabled { + return + } + + if (not ($url | is-empty)) and ($ref_ | is-empty) { + error make {msg: "OCIS_REVA_REF is required when OCIS_REVA_URL is set"} + } + + let work_dir = "/src/ocis-reva" + let git_cache = "/src/ocis-reva-git-cache" + + ^rm -rf $work_dir + ^mkdir -p $work_dir + + if $mode == "local" { + ^cp -a "/mnt/reva/." $work_dir + } else { + if not ($"($git_cache)/.git" | path exists) { + ^git clone --depth 1 --recursive --shallow-submodules --branch $ref_ $url $git_cache + } + ^cp -a $"($git_cache)/." $work_dir + if not ($sha | is-empty) { + checkout-sha $work_dir $sha + } + } + + ^go mod edit $"-replace=github.com/owncloud/reva/v2=($work_dir)" + + if not ($goproxy | is-empty) { + with-env {GOPROXY: $goproxy} { ^go mod download } + } else { + ^go mod download + } +} diff --git a/services/ocis/scripts/build/web-override.nu b/services/ocis/scripts/build/web-override.nu new file mode 100644 index 0000000..048766d --- /dev/null +++ b/services/ocis/scripts/build/web-override.nu @@ -0,0 +1,160 @@ +#!/usr/bin/env nu +# Web asset override for the ocis generate stage. +# Reads OCIS_WEB_* env vars; builds web from local or git source when +# override is enabled; always runs make ci-node-generate at /ocis. +# Makefile patching is inlined; no dependency on patch-web-makefile.nu. + +# Returns first line index after the recipe block beginning at rule_idx. +def find-recipe-end [lines: list, rule_idx: int]: nothing -> int { + let total = $lines | length + mut j = $rule_idx + 1 + while $j < $total { + if not ($lines | get $j | str starts-with "\t") { + return $j + } + $j = $j + 1 + } + $j +} + +# Returns true if line is a Makefile rule for the given target at column 0. +# Rejects variable assignments like target:= and target:= value. +def is-target-rule [line: string, target: string]: nothing -> bool { + let prefix = $"($target):" + if not ($line | str starts-with $prefix) { + return false + } + let prefix_len = $prefix | str length + let rest = $line | str substring $prefix_len.. + (($rest | is-empty) or ($rest | str starts-with " ") or ($rest | str starts-with "\t")) +} + +# Returns true if any .PHONY line in the file already declares the target. +def has-phony-target [lines: list, target: string]: nothing -> bool { + $lines | any {|l| + if not ($l | str starts-with ".PHONY:") { + false + } else { + let phony_targets = ( + $l + | str replace ".PHONY:" "" + | split row " " + | each {|t| $t | str trim} + | where {|t| not ($t | is-empty)} + ) + $target in $phony_targets + } + } +} + +# Replaces or stubs one target rule in lines. Ensures .PHONY is declared. +# If the target appears multiple times, keeps exactly one stub; removes extras. +def patch-target [ + lines: list + target: string + message: string +]: nothing -> list { + let phony_line = $".PHONY: ($target)" + let stub = [$"($target):", $"\t@echo \"($message)\""] + let has_phony = has-phony-target $lines $target + let has_target = $lines | any {|l| is-target-rule $l $target} + + if not $has_target { + mut result = $lines + if not $has_phony { + $result = ($result | append $phony_line) + } + $result = ($result | append $stub) + return $result + } + + mut result = [] + mut stub_placed = false + mut i = 0 + let total = $lines | length + + while $i < $total { + let line = $lines | get $i + if (is-target-rule $line $target) { + if not $stub_placed { + if not $has_phony { + $result = ($result | append $phony_line) + } + $result = ($result | append $stub) + $stub_placed = true + } + $i = find-recipe-end $lines $i + } else { + $result = ($result | append $line) + $i = $i + 1 + } + } + + $result +} + +# Patches a Makefile by replacing named target recipes with no-op stubs. +def patch-makefile [ + makefile: path + targets: list + message: string +]: nothing -> nothing { + mut lines = open --raw $makefile | split row "\n" + for target in $targets { + $lines = patch-target $lines $target $message + } + if ($lines | is-empty) or (($lines | last) != "") { + $lines = ($lines | append "") + } + $lines | str join "\n" | save --force $makefile +} + +def main [] { + let mode = $env.OCIS_WEB_MODE? | default "" + let url = $env.OCIS_WEB_URL? | default "" + let ref_ = $env.OCIS_WEB_REF? | default "" + let sha = $env.OCIS_WEB_SHA? | default "" + let node_opts = $env.OCIS_WEB_NODE_OPTIONS? | default "" + + let override_enabled = (($mode == "local") or (not ($url | is-empty))) + + if $override_enabled { + if (not ($url | is-empty)) and ($ref_ | is-empty) { + error make {msg: "OCIS_WEB_REF is required when OCIS_WEB_URL is set"} + } + + let work_dir = "/tmp/ocis-web" + let git_cache = "/src/ocis-web-git-cache" + + ^rm -rf $work_dir + ^mkdir -p $work_dir + + if $mode == "local" { + ^cp -a "/mnt/web/." $work_dir + } else { + ^mkdir -p $git_cache + if not ($"($git_cache)/.git" | path exists) { + ^git clone --depth 1 --recursive --shallow-submodules --branch $ref_ $url $git_cache + } + ^cp -a $"($git_cache)/." $work_dir + if not ($sha | is-empty) { + ^git -C $work_dir checkout $sha + } + } + + if not ($node_opts | is-empty) { + $env.NODE_OPTIONS = $node_opts + } + + ^make -C $work_dir dist + + let assets_core = "/ocis/services/web/assets/core" + ^rm -rf $assets_core + ^mkdir -p $assets_core + ^tar xzf $"($work_dir)/release/web.tar.gz" -C $assets_core + + patch-makefile "/ocis/services/web/Makefile" ["pull-assets"] "DockyPody: using preseeded ownCloud Web assets" + } + + ^make ci-node-generate +} diff --git a/services/opencloud/scripts/build/reva-override.nu b/services/opencloud/scripts/build/reva-override.nu new file mode 100644 index 0000000..68d7a7a --- /dev/null +++ b/services/opencloud/scripts/build/reva-override.nu @@ -0,0 +1,62 @@ +#!/usr/bin/env nu +# Reva override for the opencloud build stage. +# Reads OPENCLOUD_REVA_* env vars; clones or copies reva when override is +# enabled; applies go mod replace and runs go mod download. + +def checkout-sha [work_dir: string, sha: string]: nothing -> nothing { + let first = (^git -C $work_dir checkout $sha | complete) + if $first.exit_code == 0 { + return + } + ^git -C $work_dir fetch --depth 1 origin $sha + let second = (^git -C $work_dir checkout $sha | complete) + if $second.exit_code != 0 { + error make { + msg: $"Failed to checkout SHA ($sha) in ($work_dir). The clone may be too shallow; ensure the SHA is reachable from REF or fetch with full depth." + } + } +} + +def main [] { + let mode = $env.OPENCLOUD_REVA_MODE? | default "" + let url = $env.OPENCLOUD_REVA_URL? | default "" + let ref_ = $env.OPENCLOUD_REVA_REF? | default "" + let sha = $env.OPENCLOUD_REVA_SHA? | default "" + let goproxy = $env.GO_BUILD_GOPROXY? | default "" + + let override_enabled = (($mode == "local") or (not ($url | is-empty))) + + if not $override_enabled { + return + } + + if (not ($url | is-empty)) and ($ref_ | is-empty) { + error make {msg: "OPENCLOUD_REVA_REF is required when OPENCLOUD_REVA_URL is set"} + } + + let work_dir = "/src/opencloud-reva" + let git_cache = "/src/opencloud-reva-git-cache" + + ^rm -rf $work_dir + ^mkdir -p $work_dir + + if $mode == "local" { + ^cp -a "/mnt/reva/." $work_dir + } else { + if not ($"($git_cache)/.git" | path exists) { + ^git clone --depth 1 --recursive --shallow-submodules --branch $ref_ $url $git_cache + } + ^cp -a $"($git_cache)/." $work_dir + if not ($sha | is-empty) { + checkout-sha $work_dir $sha + } + } + + ^go mod edit $"-replace=github.com/opencloud-eu/reva/v2=($work_dir)" + + if not ($goproxy | is-empty) { + with-env {GOPROXY: $goproxy} { ^go mod download } + } else { + ^go mod download + } +} diff --git a/services/opencloud/scripts/build/web-override.nu b/services/opencloud/scripts/build/web-override.nu new file mode 100644 index 0000000..ff45333 --- /dev/null +++ b/services/opencloud/scripts/build/web-override.nu @@ -0,0 +1,160 @@ +#!/usr/bin/env nu +# Web asset override for the opencloud generate stage. +# Reads OPENCLOUD_WEB_* env vars; builds web from local or git source when +# override is enabled; always runs make node-generate-prod at /opencloud. +# Makefile patching is inlined; no dependency on patch-web-makefile.nu. + +# Returns first line index after the recipe block beginning at rule_idx. +def find-recipe-end [lines: list, rule_idx: int]: nothing -> int { + let total = $lines | length + mut j = $rule_idx + 1 + while $j < $total { + if not ($lines | get $j | str starts-with "\t") { + return $j + } + $j = $j + 1 + } + $j +} + +# Returns true if line is a Makefile rule for the given target at column 0. +# Rejects variable assignments like target:= and target:= value. +def is-target-rule [line: string, target: string]: nothing -> bool { + let prefix = $"($target):" + if not ($line | str starts-with $prefix) { + return false + } + let prefix_len = $prefix | str length + let rest = $line | str substring $prefix_len.. + (($rest | is-empty) or ($rest | str starts-with " ") or ($rest | str starts-with "\t")) +} + +# Returns true if any .PHONY line in the file already declares the target. +def has-phony-target [lines: list, target: string]: nothing -> bool { + $lines | any {|l| + if not ($l | str starts-with ".PHONY:") { + false + } else { + let phony_targets = ( + $l + | str replace ".PHONY:" "" + | split row " " + | each {|t| $t | str trim} + | where {|t| not ($t | is-empty)} + ) + $target in $phony_targets + } + } +} + +# Replaces or stubs one target rule in lines. Ensures .PHONY is declared. +# If the target appears multiple times, keeps exactly one stub; removes extras. +def patch-target [ + lines: list + target: string + message: string +]: nothing -> list { + let phony_line = $".PHONY: ($target)" + let stub = [$"($target):", $"\t@echo \"($message)\""] + let has_phony = has-phony-target $lines $target + let has_target = $lines | any {|l| is-target-rule $l $target} + + if not $has_target { + mut result = $lines + if not $has_phony { + $result = ($result | append $phony_line) + } + $result = ($result | append $stub) + return $result + } + + mut result = [] + mut stub_placed = false + mut i = 0 + let total = $lines | length + + while $i < $total { + let line = $lines | get $i + if (is-target-rule $line $target) { + if not $stub_placed { + if not $has_phony { + $result = ($result | append $phony_line) + } + $result = ($result | append $stub) + $stub_placed = true + } + $i = find-recipe-end $lines $i + } else { + $result = ($result | append $line) + $i = $i + 1 + } + } + + $result +} + +# Patches a Makefile by replacing named target recipes with no-op stubs. +def patch-makefile [ + makefile: path + targets: list + message: string +]: nothing -> nothing { + mut lines = open --raw $makefile | split row "\n" + for target in $targets { + $lines = patch-target $lines $target $message + } + if ($lines | is-empty) or (($lines | last) != "") { + $lines = ($lines | append "") + } + $lines | str join "\n" | save --force $makefile +} + +def main [] { + let mode = $env.OPENCLOUD_WEB_MODE? | default "" + let url = $env.OPENCLOUD_WEB_URL? | default "" + let ref_ = $env.OPENCLOUD_WEB_REF? | default "" + let sha = $env.OPENCLOUD_WEB_SHA? | default "" + let node_opts = $env.OPENCLOUD_WEB_NODE_OPTIONS? | default "" + + let override_enabled = (($mode == "local") or (not ($url | is-empty))) + + if $override_enabled { + if (not ($url | is-empty)) and ($ref_ | is-empty) { + error make {msg: "OPENCLOUD_WEB_REF is required when OPENCLOUD_WEB_URL is set"} + } + + let work_dir = "/tmp/opencloud-web" + let git_cache = "/src/opencloud-web-git-cache" + + ^rm -rf $work_dir + ^mkdir -p $work_dir + + if $mode == "local" { + ^cp -a "/mnt/web/." $work_dir + } else { + ^mkdir -p $git_cache + if not ($"($git_cache)/.git" | path exists) { + ^git clone --depth 1 --recursive --shallow-submodules --branch $ref_ $url $git_cache + } + ^cp -a $"($git_cache)/." $work_dir + if not ($sha | is-empty) { + ^git -C $work_dir checkout $sha + } + } + + if not ($node_opts | is-empty) { + $env.NODE_OPTIONS = $node_opts + } + + ^make -C $work_dir dist + + let assets_core = "/opencloud/services/web/assets/core" + ^rm -rf $assets_core + ^mkdir -p $assets_core + ^tar xzf $"($work_dir)/release/web.tar.gz" -C $assets_core + + patch-makefile "/opencloud/services/web/Makefile" ["pull-assets", "download-assets"] "DockyPody: using preseeded OpenCloud Web assets" + } + + ^make node-generate-prod +} diff --git a/services/revad-base/versions.nuon b/services/revad-base/versions.nuon index 4b6afa8..3aa8d15 100644 --- a/services/revad-base/versions.nuon +++ b/services/revad-base/versions.nuon @@ -40,18 +40,6 @@ }, "versions": [ - { - "name": "mahdi_fix_localhome", - "latest": false, - "overrides": { - "sources": { - "revad": { - "url": "https://github.com/MahdiBaghbani/reva-opencloud", - "ref": "feature/multi-reva-setup-with-localhome" - } - } - } - }, { "name": "master", "latest": false, @@ -73,18 +61,6 @@ } } } - }, - { - "name": "sta-ocm-m6", - "latest": false, - "overrides": { - "sources": { - "revad": { - "url": "https://github.com/MahdiBaghbani/reva-opencloud.git", - "ref": "sta-milestone-6/ocm-code-flow" - } - } - } } ] }