Skip to content

Commit

Permalink
automataCI: backported changes to msi packaging function
Browse files Browse the repository at this point in the history
There were some new changes done and msi packaging function
was left out. Hence, let's backport them back to it.

This patch backports changes to msi packaging function in
automataCI/ directory.

Co-authored-by: Galyna, Cory <[email protected]>
Co-authored-by: (Holloway) Chew, Kean Ho <[email protected]>
Signed-off-by: (Holloway) Chew, Kean Ho <[email protected]>
  • Loading branch information
hollowaykeanho and corygalyna committed Dec 23, 2023
1 parent 6f460bf commit 917ce08
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 87 deletions.
20 changes: 12 additions & 8 deletions automataCI/_package-msi_unix-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ SUBROUTINE_Package_MSI() {

__subject="${__log##*/}"
__subject="${__subject%.*}"
__subject="${__subject#*msi-wxs_}"

__arch="${__subject##*windows-}"
__arch="${__arch%%_*}"
Expand Down Expand Up @@ -188,15 +189,13 @@ ${__recipe}|${_dest}|${__log}

I18N_Status_Print_Package_Parallelism_Run
FS::is_file "$__parallel_control"
if [ $? -ne 0 ]; then
I18N_Status_Print_Package_Parallelism_Run_Skipped
if [ $? -eq 0 ]; then
SYNC_Exec_Parallel "SUBROUTINE_Package_MSI" "$__parallel_control"
___process=$?
return 0
fi

SYNC_Exec_Parallel "SUBROUTINE_Package_MSI" "$__parallel_control"
if [ $? -ne 0 ]; then
I18N_Status_Print_Package_Parallelism_Run_Failed
return 1
else
I18N_Status_Print_Package_Parallelism_Run_Skipped
___process=0
fi

for __log in "${__control_directory}/"*.log; do
Expand All @@ -215,5 +214,10 @@ ${__recipe}|${_dest}|${__log}


# report status
if [ $? -ne 0 ]; then
I18N_Status_Print_Package_Parallelism_Run_Failed
return 1
fi

return 0
}
75 changes: 38 additions & 37 deletions automataCI/_package-msi_windows-any.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1"
. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1"
. "${env:LIBS_AUTOMATACI}\services\io\sync.ps1"
. "${env:LIBS_AUTOMATACI}\services\compilers\msi.ps1"

. "${env:LIBS_AUTOMATACI}\services\i18n\printer.ps1"
. "${env:LIBS_AUTOMATACI}\services\i18n\status-job-package.ps1"
Expand All @@ -23,7 +24,7 @@

# initialize
if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) {
Write-Error "[ ERROR ] - Please run from ci.cmd instead!\n"
Write-Error "[ ERROR ] - Please run from ci.cmd instead!`n"
return
}

Expand Down Expand Up @@ -51,18 +52,19 @@ function SUBROUTINE-Package-MSI {

$__subject = Split-Path -Leaf -Path "${__log}"
$__subject = FS-Extension-Remove "${__subject}" "*"
$__subject = $__subject -replace "^msi-wxs_", ""

$__arch = $__subject -replace '.*windows-',''
$__arch = $__arch -replace '_.*',''

$__lang = $__subject -split "_"
$__lang = $__lang[1]
$__lang = $__lang[2]


# execute
$null = I18N-Status-Print-Package-Exec "${__subject}"
$($__process = MSI-Compile "${__target}" "${__arch}" "${__lang}") *> "${__log}"
if ($__process -ne 0) {
$($___process = MSI-Compile "${__target}" "${__arch}" "${__lang}") *> "${__log}"
if ($___process -ne 0) {
$null = I18N-Status-Print-Package-Exec-Failed "${__subject}"
return 1
}
Expand All @@ -74,10 +76,10 @@ function SUBROUTINE-Package-MSI {
return 1
}

$__process = FS-Copy-File `
$___process = FS-Copy-File `
"${__target}" `
"${__dest}\$(Split-Path -Leaf -Path "${__target}")"
if ($__process -ne 0) {
if ($___process -ne 0) {
$null = I18N-Status-Print-Package-Export-Failed "${__subject}"
return 1
}
Expand Down Expand Up @@ -105,16 +107,11 @@ function PACKAGE-Run-MSI {
$_target_arch = $__list[4]


# NOTE: temporary disables MSI since we do not have a Windows OS to
# operate and GitHub Actions' Windows image is no longer usable.
return 0


# validate input
$null = I18N-Status-Print-MSI-Check-Availability
$__process = MSI-Is-Available
if ($__process -ne 0) {
$null = I18N-Status-Print-MSI-Check-Availability-Failed
$null = I18N-Status-Print-Check-Availability "MSI"
$___process = MSI-Is-Available
if ($___process -ne 0) {
$null = I18N-Status-Print-Check-Availability-Failed
return 0
}

Expand All @@ -124,16 +121,16 @@ function PACKAGE-Run-MSI {
$_src = "${_target_filename}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}"
$_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\msi_${_src}"
$null = I18N-Status-Print-Package-Workspace-Remake "${_src}"
$__process = FS-Remake-Directory "${_src}"
if ($__process -ne 0) {
$___process = FS-Remake-Directory "${_src}"
if ($___process -ne 0) {
$null = I18N-Status-Print-Package-Remake-Failed
return 1
}

$__control_directory = "${_src}\.automataCI"
$null = I18N-Status-Print-Package-Workspace-Remake-Control "${__control_directory}"
$null = FS-Remake-Directory "${__control_directory}"
if (-not (Test-Path -PathType Container -Path "${__control_directory}")) {
$___process = FS-Remake-Directory "${__control_directory}"
if ($___process -ne 0) {
$null = I18N-Status-Print-Package-Remake-Failed
return 1
}
Expand All @@ -144,23 +141,23 @@ function PACKAGE-Run-MSI {

# copy all complimentary files to the workspace
$null = I18N-Status-Print-Package-Assembler-Check "PACKAGE-Assemble-MSI-Content"
$__process = OS-Is-Command-Available "PACKAGE-Assemble-MSI-Content"
if ($__process -ne 0) {
$___process = OS-Is-Command-Available "PACKAGE-Assemble-MSI-Content"
if ($___process -ne 0) {
$null = I18N-Status-Print-Package-Check-Failed
return 1
}

$null = I18N-Status-Print-Package-Assembler-Exec
$__process = PACKAGE-Assemble-MSI-Content `
$___process = PACKAGE-Assemble-MSI-Content `
"${_target}" `
"${_src}" `
"${_target_filename}" `
"${_target_os}" `
"${_target_arch}"
switch ($__process) {
switch ($___process) {
10 {
$null = FS-Remove-Silently "${_src}"
$null = I18N-Status-Print-Package-Assembler-Exec-Skipped
$null = FS-Remove-Silently "${_src}"
return 0
} 0 {
# accepted
Expand All @@ -171,49 +168,53 @@ function PACKAGE-Run-MSI {


# archive the assembled payload
$null = FS-Remake-Directory "${__control_directory}"
foreach ($__recipe in (Get-ChildItem -Path "${_src}" -Filter "*.wxs")) {
$__process = FS-Is-File "${__recipe}"
if ($__process -ne 0) {
foreach ($__recipe in (Get-ChildItem -Path "${_src}" -Filter *.wxs)) {
$___process = FS-Is-File "${__recipe}"
if ($___process -ne 0) {
continue
}


# register for packaging in parallel
$null = I18N-Status-Print-Package-Parallelism-Register "${__recipe}"
$__log = Split-Path -Leaf -Path "${__recipe}"
$__log = FS-Extension-Remove "${__log}" "*"
$__log = "${__control_directory}\msi-wxs_${__log}.log"
$__process = FS-Append-File "${__parallel_control}" @"
$___process = FS-Append-File "${__parallel_control}" @"
${__recipe}|${_dest}|${__log}
"@
if ($__process -ne 0) {
if ($___process -ne 0) {
return 1
}
}

$null = I18N-Status-Print-Package-Parallelism-Run
if (Test-Path "${__parallel_control}") {
$__process = SYNC-Parallel-Exec `
$___process = FS-Is-File "${__parallel_control}"
if ($___process -eq 0) {
$___process = SYNC-Exec-Parallel `
${function:SUBROUTINE-Package-MSI}.ToString() `
"${__parallel_control}" `
"${__control_directory}" `
"$([System.Environment]::ProcessorCount)"
if ($__process -ne 0) {
$null = I18N-Status-Print-Package-Parallelism-Run-Failed
return 1
}
} else {
$null = I18N-Status-Print-Package-Parallelism-Run-Skipped
$___process = 0
}

foreach ($__log in (Get-ChildItem -Path "${__control_directory}" -Filter *.log)) {
$null = I18N-Status-Print-Package-Parallelism-Log "${__log}"
foreach ($__line in (Get-Content "${__control_directory}\${__log}")) {
foreach ($__line in (Get-Content "${__log}")) {
$null = I18N-Status-Print-Plain "${__line}"
}
$null = I18N-Status-Print-Newline
}


# report status
if ($___process -ne 0) {
$null = I18N-Status-Print-Package-Parallelism-Run-Failed
return 1
}

return 0
}
4 changes: 4 additions & 0 deletions automataCI/ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@ if (Test-Path ".\ci.ps1") {
${env:LIBS_AUTOMATACI} = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}"




# import fundamental libraries
. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1"
. "${env:LIBS_AUTOMATACI}\services\i18n\status-get-help.ps1"
. "${env:LIBS_AUTOMATACI}\services\i18n\status-init.ps1"
. "${env:LIBS_AUTOMATACI}\services\publishers\microsoft.ps1"




# determine os
$env:PROJECT_OS = (Get-ComputerInfo).OsName.ToLower()
if (-not ($env:PROJECT_OS -match "microsoft" -or $env:PROJECT_OS -match "windows")) {
Expand Down
7 changes: 6 additions & 1 deletion automataCI/services/compilers/msi.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ function MSI-Compile {
return 1
}

if (($(STRINGS-Is-Empty "${___target}") -eq 0) -or (-not (Test-Path "${___target}"))) {
if ($(STRINGS-Is-Empty "${___target}") -eq 0) {
return 1
}

$___process = FS-Is-File "${___target}"
if ($___process -ne 0) {
return 1
}

Expand Down
35 changes: 24 additions & 11 deletions automataCI/services/compilers/msi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +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/publishers/microsoft.sh"
. "${LIBS_AUTOMATACI}/services/io/os.sh"
. "${LIBS_AUTOMATACI}/services/io/fs.sh"
. "${LIBS_AUTOMATACI}/services/io/strings.sh"
. "${LIBS_AUTOMATACI}/services/publishers/microsoft.sh"




MSI_Compile() {
#__target="$1"
#__arch="$2"
#___target="$1"
#___arch="$2"


# validate input
Expand All @@ -28,18 +29,23 @@ MSI_Compile() {
return 1
fi

if [ -z "$1" ] || [ ! -f "$1" ]; then
if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then
return 1
fi

__arch="$(MICROSOFT_Arch_Get "$2")"
if [ -z "$__arch" ]; then
FS::is_file "$1"
if [ $? -ne 0 ]; then
return 1
fi

___arch="$(MICROSOFT_Arch_Get "$2")"
if [ -z "$___arch" ]; then
return 1
fi


# execute
wixl --verbose --arch "${__arch}" --output "${1%.wxs*}.msi" "$1"
wixl --verbose --arch "${___arch}" --output "${1%.wxs*}.msi" "$1"
if [ $? -ne 0 ]; then
return 1
fi
Expand All @@ -54,7 +60,13 @@ MSI_Compile() {

MSI_Is_Available() {
# execute
if [ -z "$(type -t wixl)" ] || [ -z "$(type -t wixl-heat)" ]; then
OS::is_command_available "wixl"
if [ $? -ne 0 ]; then
return 1
fi

OS::is_command_available "wixl-heat"
if [ $? -ne 0 ]; then
return 1
fi

Expand All @@ -68,7 +80,8 @@ MSI_Is_Available() {

MSI_Setup() {
# validate input
if [ -z "$(type -t brew)" ]; then
OS::is_command_available "brew"
if [ $? -ne 0 ]; then
return 1
fi

Expand Down
7 changes: 4 additions & 3 deletions src/.ci/_package-msi_unix-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ Unfortunately, you can only install this package on a 32-bit Windows."


# generate all i18n variables and validate readiness for compilation
_wxs="${PROJECT_SKU}_${PROJECT_VERSION}"
case "$__i18n" in
zh-hans)
## Simplified Chinese (International)
Expand All @@ -217,7 +218,7 @@ Unfortunately, you can only install this package on a 32-bit Windows."
## NOTE: DO NOT change the format. AutomataCI relies on
## it to parse wix4 culture settings.
## https://wixtoolset.org/docs/tools/wixext/wixui/#localization
_wxs="${PROJECT_SKU}_zh-CN_windows-${__arch}.wxs"
_wxs="${_wxs}_zh-CN"

__var_INSTALLER_DESCRIPTION="\
${PROJECT_NAME} (${PROJECT_VERSION}) 安装包"
Expand Down Expand Up @@ -264,7 +265,7 @@ ${PROJECT_NAME} (${PROJECT_VERSION}) 安装包"
## NOTE: DO NOT change the format. AutomataCI relies on
## it to parse wix4 culture settings.
## https://wixtoolset.org/docs/tools/wixext/wixui/#localization
_wxs="${PROJECT_SKU}_en-US_windows-${__arch}.wxs"
_wxs="${_wxs}_en-US"

__var_INSTALLER_DESCRIPTION="\
${PROJECT_NAME} (${PROJECT_VERSION}) Installer"
Expand Down Expand Up @@ -301,7 +302,7 @@ Your ${PROJECT_NAME} is the same/later version. No further action is required. T
__var_FEATURE_DOCS_DESCRIPTION='All documentations components.'
;;
esac
_wxs="${_directory}/${_wxs}"
_wxs="${_directory}/${_wxs}_windows-${__arch}.wxs"


# check required files for packaging
Expand Down
Loading

0 comments on commit 917ce08

Please sign in to comment.