-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
180 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,8 @@ | |
# shellcheck disable=2034 | ||
|
||
KNOWN_VARIABLE_LIST=(CI_PKGBUILD_SOURCE CI_GIT_COMMIT CI_PKGBUILD_TIMESTAMP CI_PACKAGE_BUMP CI_ON_TRIGGER CI_MANAGE_AUR) | ||
declare -A KNOWN_CONFIG_LIST=([BUILD_REPO]="chaotic-aur" [GIT_AUTHOR_EMAIL]="[email protected]" [GIT_AUTHOR_NAME]="chaotic-aur" [REDIS_SSH_HOST]="localhost" [REDIS_SSH_PORT]="22" [REDIS_SSH_USER]="redis" [REDIS_PORT]="6379" [REPO_NAME]="chaotic-aur" [CI_HUMAN_REVIEW]="false" [TEMPLATE_REPO]="https://github.com/chaotic-cx/chaotic-repository-template" [TEMPLATE_ENABLE_UPDATES]="true" [CI_MANAGE_AUR]="false") | ||
KNOWN_STATE_VARIABLE_LIST=(CI_GIT_COMMIT CI_PKGBUILD_TIMESTAMP) | ||
declare -A KNOWN_CONFIG_LIST=([BUILD_REPO]="chaotic-aur" [GIT_AUTHOR_EMAIL]="[email protected]" [GIT_AUTHOR_NAME]="chaotic-aur" [REDIS_SSH_HOST]="localhost" [REDIS_SSH_PORT]="22" [REDIS_SSH_USER]="redis" [REDIS_PORT]="6379" [REPO_NAME]="chaotic-aur" [CI_HUMAN_REVIEW]="true" [TEMPLATE_REPO]="https://github.com/chaotic-cx/chaotic-repository-template" [TEMPLATE_ENABLE_UPDATES]="true" [CI_MANAGE_AUR]="false" [CI_OVERWRITE_COMMITS]="true") | ||
|
||
EXCLUDE_FILES=(.CI .git .gitignore) | ||
|
||
|
@@ -13,28 +14,27 @@ function UTIL_GET_PACKAGES() { | |
mapfile -t GET_PACKAGES_ARRAY < <(find . -mindepth 1 -maxdepth 1 -type d -not -path '*/.*' -printf '%P\n') | ||
} | ||
|
||
function UTIL_PRUNE_UNKNOWN_VARIABLES() { | ||
set -euo pipefail | ||
local -n PRUNE_VARIABLES=${1:-VARIABLES} | ||
local -n PRUNE_VARIABLES_KNOWN=${2:-KNOWN_VARIABLE_LIST} | ||
for key in "${!PRUNE_VARIABLES[@]}"; do | ||
if [[ ! " ${PRUNE_VARIABLES_KNOWN[*]} " == *" ${key} "* ]]; then | ||
unset "PRUNE_VARIABLES[$key]" | ||
fi | ||
done | ||
} | ||
|
||
function UTIL_READ_VARIABLES_FROM_FILE() { | ||
# $1: File to read variables from | ||
# $2: Output associative array | ||
# $3: array of known variables | ||
function UTIL_READ_KNOWN_VARIABLES_FROM_FILE() { | ||
set -euo pipefail | ||
local file=$1 | ||
local -n READ_ASSOC_ARRAY=${2:-VARIABLES} | ||
if [ -v 3 ]; then | ||
local -n READ_KNOWN_ARRAY=${3} | ||
fi | ||
while IFS= read -r line || [ -n "$line" ]; do | ||
if [[ "$line" =~ ^[[:space:]]*([a-zA-Z0-9_]+)[[:space:]]*=[[:space:]]*(.*)[[:space:]]*$ ]]; then | ||
# Make sure the key is in the known variable list | ||
if [[ -v READ_KNOWN_ARRAY[@] ]] && [[ " ${READ_KNOWN_ARRAY[*]} " != *" ${BASH_REMATCH[1]} "* ]]; then | ||
continue | ||
fi | ||
READ_ASSOC_ARRAY["${BASH_REMATCH[1]}"]="${BASH_REMATCH[2]}" | ||
fi | ||
done < "$file" | ||
} | ||
|
||
function UTIL_WRITE_VARIABLES_TO_FILE() { | ||
set -euo pipefail | ||
local file=$1 | ||
|
@@ -70,22 +70,42 @@ function UTIL_WRITE_KNOWN_VARIABLES_TO_FILE() { | |
function UTIL_READ_MANAGED_PACAKGE() { | ||
set -euo pipefail | ||
local target_file="./${1}/.CI/config" | ||
local target_state_file="./.state/${1}" | ||
local ret=1 | ||
local -n READ_MANAGED_ASSOC_ARRAY=${2:-VARIABLES} | ||
if [ -f "$target_file" ]; then | ||
UTIL_READ_VARIABLES_FROM_FILE "$target_file" READ_MANAGED_ASSOC_ARRAY | ||
UTIL_READ_KNOWN_VARIABLES_FROM_FILE "$target_file" READ_MANAGED_ASSOC_ARRAY KNOWN_VARIABLE_LIST | ||
# Check if any variable at all was read | ||
if [ ${#READ_MANAGED_ASSOC_ARRAY[@]} -ne 0 ]; then | ||
UTIL_PRUNE_UNKNOWN_VARIABLES READ_MANAGED_ASSOC_ARRAY | ||
ret=0 | ||
else | ||
READ_MANAGED_ASSOC_ARRAY[CI_NO_CONFIG]=true | ||
fi | ||
else | ||
READ_MANAGED_ASSOC_ARRAY[CI_NO_CONFIG]=true | ||
fi | ||
|
||
# This file might or might not exist depending on the current state of the application | ||
if [ -f "$target_state_file" ]; then | ||
UTIL_READ_KNOWN_VARIABLES_FROM_FILE "$target_state_file" READ_MANAGED_ASSOC_ARRAY KNOWN_STATE_VARIABLE_LIST | ||
fi | ||
|
||
# shellcheck disable=2153 | ||
READ_MANAGED_ASSOC_ARRAY[PKGBASE]="$1" | ||
return $ret | ||
} | ||
|
||
function UTIL_WRITE_MANAGED_PACKAGE() { | ||
set -euo pipefail | ||
local target_file="./${1}/.CI/config" | ||
local target_state_file="./.newstate/${1}" | ||
local -n WRITE_MANAGED_ASSOC_ARRAY=${2:-VARIABLES} | ||
if [[ ! -v WRITE_MANAGED_ASSOC_ARRAY[CI_NO_CONFIG] ]]; then | ||
UTIL_WRITE_KNOWN_VARIABLES_TO_FILE "$target_file" WRITE_MANAGED_ASSOC_ARRAY KNOWN_VARIABLE_LIST | ||
fi | ||
UTIL_WRITE_KNOWN_VARIABLES_TO_FILE "$target_state_file" WRITE_MANAGED_ASSOC_ARRAY KNOWN_STATE_VARIABLE_LIST | ||
} | ||
|
||
# Extract both the normal url and the fragment | ||
function UTIL_GET_URI_PARTS() { | ||
set -euo pipefail | ||
|
@@ -248,8 +268,7 @@ function UTIL_READ_CONFIG_FILE() { | |
set -euo pipefail | ||
local -a UTIL_READ_CONFIG_FILE_KNOWN_VARIABLES=("${!KNOWN_CONFIG_LIST[@]}") | ||
declare -A UTIL_READ_CONFIG_FILE_ARRAY | ||
UTIL_READ_VARIABLES_FROM_FILE ".ci/config" UTIL_READ_CONFIG_FILE_ARRAY | ||
UTIL_PRUNE_UNKNOWN_VARIABLES UTIL_READ_CONFIG_FILE_ARRAY UTIL_READ_CONFIG_FILE_KNOWN_VARIABLES | ||
UTIL_READ_KNOWN_VARIABLES_FROM_FILE ".ci/config" UTIL_READ_CONFIG_FILE_ARRAY UTIL_READ_CONFIG_FILE_KNOWN_VARIABLES | ||
|
||
# Set all variables as global variables | ||
for key in "${!UTIL_READ_CONFIG_FILE_ARRAY[@]}"; do | ||
|
@@ -297,4 +316,4 @@ function UTIL_PRINT_ERROR() { | |
function UTIL_PRINT_INFO() { | ||
set -euo pipefail | ||
printf '\e[1;34mInfo:\e[0m %s\n' "$1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
CI_PKGBUILD_TIMESTAMP=1703994102 | ||
CI_PKGBUILD_SOURCE=aur | ||
CI_GIT_COMMIT=4c0c368e7ac8233b3fca848a25b42f0875a2494b | ||
CI_GIT_COMMIT=d28868855afd769209a7ac81692cdbaa67be2905 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
CI_PKGBUILD_TIMESTAMP=1705267394 | ||
CI_PKGBUILD_SOURCE=aur | ||
CI_GIT_COMMIT=2373f4f3c8a2a42074ea644b016caaabfcc3b89c | ||
CI_GIT_COMMIT=be68a51f4689bb2de15553b35fe5f5b5a55b8541 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
CI_PKGBUILD_TIMESTAMP=1697091397 | ||
CI_PKGBUILD_SOURCE=aur | ||
CI_GIT_COMMIT=83b9755993e39d3e46578bdef27180d37618c6b4 | ||
CI_GIT_COMMIT=7abaddd5cac23d9fd7a0f0aeccb7a0287456802b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
CI_PKGBUILD_TIMESTAMP=1622479548 | ||
CI_PKGBUILD_SOURCE=aur | ||
CI_GIT_COMMIT=252601a26feed3e19f5cde6c3dfc1ac35086e49c | ||
CI_GIT_COMMIT=700085e4396f4005ca3cd54a0cd5e0b036a1972e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
CI_PKGBUILD_TIMESTAMP=1705793787 | ||
CI_PKGBUILD_TIMESTAMP=1711910807 | ||
CI_PKGBUILD_SOURCE=aur |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
CI_PKGBUILD_TIMESTAMP=1702886397 | ||
CI_PKGBUILD_TIMESTAMP=1711792164 | ||
CI_PKGBUILD_SOURCE=aur |
Oops, something went wrong.