Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automataCI: added i18n feature to release deb function
Browse files Browse the repository at this point in the history
Since we want i18n feature to be applied across all package CI job,
we should first deal with release deb function. Hence, let's do
this.

This patch applies i18n feature to release deb function in automataCI/
directory.

Co-authored-by: Galyna, Cory <124406765+corygalyna@users.noreply.github.com>
Co-authored-by: (Holloway) Chew, Kean Ho <hollowaykeanho@gmail.com>
Signed-off-by: (Holloway) Chew, Kean Ho <hollowaykeanho@gmail.com>
hollowaykeanho and corygalyna committed Dec 17, 2023
1 parent 0c8214b commit 90e2ec7
Showing 9 changed files with 266 additions and 111 deletions.
39 changes: 21 additions & 18 deletions automataCI/_release-deb_unix-any.sh
Original file line number Diff line number Diff line change
@@ -10,15 +10,17 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh"
. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/fs.sh"
. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/compilers/deb.sh"
. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/publishers/reprepro.sh"
. "${LIBS_AUTOMATACI}/services/io/fs.sh"
. "${LIBS_AUTOMATACI}/services/compilers/deb.sh"
. "${LIBS_AUTOMATACI}/services/publishers/reprepro.sh"

. "${LIBS_AUTOMATACI}/services/i18n/status-file.sh"
. "${LIBS_AUTOMATACI}/services/i18n/status-run.sh"



RELEASE::run_deb() {

RELEASE_Run_DEB() {
__target="$1"
__directory="$2"

@@ -29,52 +31,53 @@ RELEASE::run_deb() {
return 0
fi

OS::print_status info "checking required reprepro availability...\n"
REPREPRO::is_available
I18N_Status_Print_Check_Availability "REPREPRO"
REPREPRO_Is_Available
if [ $? -ne 0 ]; then
OS::print_status warning "Reprepro is unavailable. Skipping...\n"
I18N_Status_Print_Check_Availability_Failed "REPREPRO"
return 0
fi


# execute
__conf="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/deb"
FS::is_file "${__conf}/conf/distributions"
__file="${__conf}/conf/distributions"
FS::is_file "$__file"
if [ $? -ne 0 ]; then
OS::print_status info "create reprepro configuration file...\n"
REPREPRO::create_conf \
I18N_Status_Print_File_Create "$__file"
REPREPRO_Create_Conf \
"$__conf" \
"$PROJECT_REPREPRO_CODENAME" \
"$PROJECT_DEBIAN_DISTRIBUTION" \
"$PROJECT_REPREPRO_COMPONENT" \
"$PROJECT_REPREPRO_ARCH" \
"$PROJECT_GPG_ID"
if [ $? -ne 0 ]; then
OS::print_status error "create failed.\n"
I18N_Status_Print_File_Create_Failed
return 1
fi
fi

__dest="${2}/deb"
OS::print_status info "creating destination path: ${__dest}\n"
I18N_Status_Print_File_Create "$__dest"
FS::make_directory "${__dest}"
if [ $? -ne 0 ]; then
OS::print_status error "create failed.\n"
I18N_Status_Print_File_Create_Failed
return 1
fi

OS::print_status info "publishing with reprepro...\n"
I18N_Status_Print_Run_Publish "REPREPRO"
if [ ! -z "$PROJECT_SIMULATE_RELEASE_REPO" ]; then
OS::print_status warning "Simulating reprepro release...\n"
I18N_Status_Print_Run_Publish_Simulated "REPREPRO"
else
REPREPRO::publish \
REPREPRO_Publish \
"$__target" \
"$__dest" \
"$__conf" \
"${__conf}/db" \
"$PROJECT_REPREPRO_CODENAME"
if [ $? -ne 0 ]; then
OS::print_status error "publish failed.\n"
I18N_Status_Print_Run_Publish_Failed
return 1
fi
fi
53 changes: 28 additions & 25 deletions automataCI/_release-deb_windows-any.ps1
Original file line number Diff line number Diff line change
@@ -9,10 +9,12 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1"
. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1"
. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\compilers\deb.ps1"
. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\publishers\reprepro.ps1"
. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1"
. "${env:LIBS_AUTOMATACI}\services\compilers\deb.ps1"
. "${env:LIBS_AUTOMATACI}\services\publishers\reprepro.ps1"

. "${env:LIBS_AUTOMATACI}\services\i18n\status-file.ps1"
. "${env:LIBS_AUTOMATACI}\services\i18n\status-run.ps1"



@@ -25,57 +27,58 @@ function RELEASE-Run-DEB {


# validate input
$__process = DEB-Is-Valid "${__target}"
if ($__process -ne 0) {
$___process = DEB-Is-Valid "${__target}"
if ($___process -ne 0) {
return 0
}

OS-Print-Status info "checking required reprepro availability..."
$__process = REPREPRO-Is-Available
if ($__process -ne 0) {
OS-Print-Status warning "Reprepro is unavailable. Skipping..."
$null = I18N-Status-Print-Check-Availability "REPREPRO"
$___process = REPREPRO-Is-Available
if ($___process -ne 0) {
$null = I18N-Status-Print-Check-Availability-Failed "REPREPRO"
return 0
}


# execute
$__conf = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\deb"
$__process = FS-Is-File "${__conf}\conf\distributions"
if ($__process -ne 0) {
OS-Print-Status info "create reprepro configuration file..."
$__process = REPREPRO-Create-Conf `
$__file = "${__conf}\conf\distributions"
$___process = FS-Is-File "${__file}"
if ($___process -ne 0) {
$null = I18N-Status-Print-File-Create "${__file}"
$___process = REPREPRO-Create-Conf `
"${__conf}" `
"${env:PROJECT_REPREPRO_CODENAME}" `
"${env:PROJECT_DEBIAN_DISTRIBUTION}" `
"${env:PROJECT_REPREPRO_COMPONENT}" `
"${env:PROJECT_REPREPRO_ARCH}" `
"${env:PROJECT_GPG_ID}"
if ($__process -ne 0) {
OS-Print-Status error "create failed."
if ($___process -ne 0) {
$null = I18N-Status-Print-File-Create-Failed
return 1
}
}

$__dest = "${__directory}/deb"
OS-Print-Status info "creating destination path: ${__dest}"
$__process = FS-Make-Directory "${__dest}"
if ($__process -ne 0) {
OS-Print-Status error "create failed."
$null = I18N-Status-Print-File-Create "${__dest}"
$___process = FS-Make-Directory "${__dest}"
if ($___process -ne 0) {
$null = I18N-Status-Print-File-Create-Failed
return 1
}

OS-Print-Status info "publishing with reprepro..."
$null = I18N-Status-Print-Run-Publish "REPREPRO"
if ([string]::IsNullOrEmpty(${env:PROJECT_SIMULATE_RELEASE_REPO})) {
OS-Print-Status warning "Simulating reprepro release..."
$null = I18N-Status-Print-Run-Publish-Simulated "REPREPRO"
} else {
$__process = REPREPRO-Publish `
$___process = REPREPRO-Publish `
"${__target}" `
"${__dest}" `
"${__conf}" `
"${__conf}\db" `
"${env:PROJECT_REPREPRO_CODENAME}"
if ($__process -ne 0) {
OS-Print-Status error "publish failed."
if ($___process -ne 0) {
$null = I18N-Status-Print-Run-Publish-Failed
return 1
}
}
2 changes: 1 addition & 1 deletion automataCI/release_unix-any.sh
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ for TARGET in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}"/*; do
fi
OS::print_status info "processing ${TARGET}\n"

RELEASE::run_deb "$TARGET" "$STATIC_REPO"
RELEASE_Run_DEB "$TARGET" "$STATIC_REPO"
if [ $? -ne 0 ]; then
return 1
fi
14 changes: 7 additions & 7 deletions automataCI/services/compilers/deb.ps1
Original file line number Diff line number Diff line change
@@ -9,13 +9,13 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1"
. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1"
. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\strings.ps1"
. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\disk.ps1"
. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\archive\tar.ps1"
. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\archive\ar.ps1"
. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\checksum\md5.ps1"
. "${env:LIBS_AUTOMATACI}\services\io\os.ps1"
. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1"
. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1"
. "${env:LIBS_AUTOMATACI}\services\io\disk.ps1"
. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1"
. "${env:LIBS_AUTOMATACI}\services\archive\ar.ps1"
. "${env:LIBS_AUTOMATACI}\services\checksum\md5.ps1"



72 changes: 72 additions & 0 deletions automataCI/services/i18n/_status-run-publish.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright 2023 (Holloway) Chew, Kean Ho <hollowaykeanho@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy
# of the License at:
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
. "${env:LIBS_AUTOMATACI}\services\i18n\printer.ps1"




function I18N-Status-Print-Run-Publish {
param(
[string]$___subject
)


# execute
switch (${env:AUTOMATACI_LANG}) {
default {
# fallback to default english
$___subject = I18N-Status-Param-Process "${___subject}"
$null = I18N-Status-Print info "publishing ${___subject}...`n"
}}


# report status
return 0
}




function I18N-Status-Print-Run-Publish-Failed {
# execute
switch (${env:AUTOMATACI_LANG}) {
default {
# fallback to default english
$null = I18N-Status-Print error "publish failed.`n`n"
}}


# report status
return 0
}




function I18N-Status-Print-Run-Publish-Simulated {
param(
[string]$___subject
)


# execute
switch (${env:AUTOMATACI_LANG}) {
default {
# fallback to default english
$___subject = I18N-Status-Param-Process "${___subject}"
$null = I18N-Status-Print warning "simulating ${___subject} publications...`n"
}}


# report status
return 0
}
71 changes: 71 additions & 0 deletions automataCI/services/i18n/_status-run-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright 2023 (Holloway) Chew, Kean Ho <hollowaykeanho@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy
# of the License at:
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
. "${LIBS_AUTOMATACI}/services/i18n/printer.sh"




I18N_Status_Print_Run_Publish() {
___subject="$1"


# execute
case "$AUTOMATACI_LANG" in
*)
# fallback to default english
___subject="$(I18N_Status_Param_Process "${___subject}")"
I18N_Status_Print info "publishing ${___subject}...\n"
;;
esac


# report status
return 0
}




I18N_Status_Print_Run_Publish_Failed() {
# execute
case "$AUTOMATACI_LANG" in
*)
# fallback to default english
I18N_Status_Print error "publish failed.\n\n"
;;
esac


# report status
return 0
}




I18N_Status_Print_Run_Publish_Simulated() {
___subject="$1"


# execute
case "$AUTOMATACI_LANG" in
*)
# fallback to default english
___subject="$(I18N_Status_Param_Process "${___subject}")"
I18N_Status_Print warning "simulating ${___subject} publications...\n"
;;
esac


# report status
return 0
}
1 change: 1 addition & 0 deletions automataCI/services/i18n/status-run.ps1
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
. "${env:LIBS_AUTOMATACI}\services\i18n\_status-run-check-availability.ps1"
. "${env:LIBS_AUTOMATACI}\services\i18n\_status-run-clean.ps1"
. "${env:LIBS_AUTOMATACI}\services\i18n\_status-run-login.ps1"
. "${env:LIBS_AUTOMATACI}\services\i18n\_status-run-publish.ps1"



1 change: 1 addition & 0 deletions automataCI/services/i18n/status-run.sh
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
. "${LIBS_AUTOMATACI}/services/i18n/_status-run-check-availability.sh"
. "${LIBS_AUTOMATACI}/services/i18n/_status-run-clean.sh"
. "${LIBS_AUTOMATACI}/services/i18n/_status-run-login.sh"
. "${LIBS_AUTOMATACI}/services/i18n/_status-run-publish.sh"



124 changes: 64 additions & 60 deletions automataCI/services/publishers/reprepro.sh
Original file line number Diff line number Diff line change
@@ -10,62 +10,63 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh"
. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/fs.sh"
. "${LIBS_AUTOMATACI}/services/io/os.sh"
. "${LIBS_AUTOMATACI}/services/io/fs.sh"
. "${LIBS_AUTOMATACI}/services/io/strings.sh"




REPREPRO::create_conf() {
__directory="$1"
__codename="$2"
__suite="$3"
__components="$4"
__architectures="$5"
__gpg="$6"
REPREPRO_Create_Conf() {
___directory="$1"
___codename="$2"
___suite="$3"
___components="$4"
___architectures="$5"
___gpg="$6"


# validate input
if [ -z "$__directory" ] ||
[ -z "$__codename" ] ||
[ -z "$__suite" ] ||
[ -z "$__components" ]; then
if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] ||
[ $(STRINGS_Is_Empty "$___codename") -eq 0 ] ||
[ $(STRINGS_Is_Empty "$___suite") -eq 0 ] ||
[ $(STRINGS_Is_Empty "$___components") -eq 0 ]; then
return 1
fi


# execute
__filename="${__directory}/conf/distributions"
FS::make_housing_directory "$__filename"
FS::remove_silently "$__filename"
if [ -z "$__gpg" ]; then
FS::write_file "$__filename" "\
Codename: ${__codename}
Suite: ${__suite}
Components: ${__components}
___filename="${___directory}/conf/distributions"
FS::make_housing_directory "$___filename"
FS::remove_silently "$___filename"
if [ $(STRINGS_Is_Empty "$___gpg") -eq 0 ]; then
FS::write_file "$___filename" "\
Codename: ${___codename}
Suite: ${___suite}
Components: ${___components}
Architectures:"
if [ $? -ne 0 ]; then
return 1
fi
else
FS::write_file "$__filename" "\
Codename: ${__codename}
Suite: ${__suite}
Components: ${__components}
SignWith: ${__gpg}
FS::write_file "$___filename" "\
Codename: ${___codename}
Suite: ${___suite}
Components: ${___components}
SignWith: ${___gpg}
Architectures:"
if [ $? -ne 0 ]; then
return 1
fi
fi


if [ -z "$__architectures" ]; then
old_IFS="$IFS"
while IFS="" read -r __arch || [ -n "$__arch" ]; do
FS::append_file "$__filename" " ${__arch}"
while IFS="" read -r __os || [ -n "$__os" ]; do
FS::append_file "$__filename" " ${__os}-${__arch}"
if [ $(STRINGS_Is_Empty "$___architectures") -eq 0 ]; then
___old_IFS="$IFS"
while IFS= read -r ___arch || [ -n "$___arch" ]; do
FS::append_file "$___filename" " $___arch"
while IFS= read -r ___os || [ -n "$___os" ]; do
FS::append_file "$___filename" " ${___os}-${___arch}"
done << EOF
linux
kfreebsd
@@ -128,10 +129,10 @@ sparc
sparc64
tilegx
EOF
IFS="$old_IFS" && unset line old_IFS
FS::append_file "$__filename" "\n"
IFS="$___old_IFS" && unset ___line ___old_IFS
FS::append_file "$___filename" "\n"
else
FS::append_file "$__filename" " ${__architectures}\n"
FS::append_file "$___filename" " ${___architectures}\n"
fi


@@ -142,7 +143,7 @@ EOF



REPREPRO::is_available() {
REPREPRO_Is_Available() {
# execute
OS::is_command_available "reprepro"
if [ $? -ne 0 ]; then
@@ -157,39 +158,42 @@ REPREPRO::is_available() {



REPREPRO::publish() {
__target="$1"
__directory="$2"
__datastore="$3"
__db_directory="$4"
__codename="$5"
REPREPRO_Publish() {
___target="$1"
___directory="$2"
___datastore="$3"
___db_directory="$4"
___codename="$5"


# validate input
if [ -z "$__target" ] ||
[ -z "$__directory" ] ||
[ -z "$__datastore" ] ||
[ -z "$__codename" ] ||
[ ! -d "$__directory" ]; then
if [ $(STRINGS_Is_Empty "$___target") -eq 0 ] ||
[ $(STRINGS_Is_Empty "$___directory") -eq 0 ] ||
[ $(STRINGS_Is_Empty "$___datastore") -eq 0 ] ||
[ $(STRINGS_Is_Empty "$___codename") -eq 0 ]; then
return 1
fi

FS::is_directory "$___directory"
if [ $? -ne 0 ]; then
return 1
fi


# execute
FS::make_directory "${__db_directory}"
FS::make_directory "${__directory}"
FS::make_directory "${__datastore}"
reprepro --basedir "${__datastore}" \
--dbdir "${__db_directory}" \
--outdir "${__directory}" \
includedeb "${__codename}" \
"$__target"
FS::make_directory "${___db_directory}"
FS::make_directory "${___directory}"
FS::make_directory "${___datastore}"
reprepro --basedir "${___datastore}" \
--dbdir "${___db_directory}" \
--outdir "${___directory}" \
includedeb "${___codename}" \
"$___target"
if [ $? -ne 0 ]; then
return 1
fi


# report status
if [ $? -eq 0 ]; then
return 0
fi

return 1
return 0
}

0 comments on commit 90e2ec7

Please sign in to comment.