diff --git a/CONFIG.toml b/CONFIG.toml index b6ca9b4..7e69bae 100644 --- a/CONFIG.toml +++ b/CONFIG.toml @@ -169,6 +169,33 @@ PROJECT_SOURCE_GIT_REMOTE = 'origin' PROJECT_SOURCE_RELEASE_TAG_LATEST = 'latest' +# PROJECT_README +# The relative location of the project readme file from $PROJECT_PATH_ROOT +# (repository root directory). +# +# Default is 'README.md' +PROJECT_README = 'README.md' + + +# PROJECT_LICENSE_FILE +# The relative location of the project license file from $PROJECT_PATH_ROOT +# (repository root directory). +# +# Default is 'LICENSE.txt' +PROJECT_LICENSE_FILE = 'LICENSE.txt' + + +# PROJECT_LICENSE_ACCEPTANCE_REQUIRED +# The flag to indicate the license of the project **MUST** be explictly +# accepted. This is used in ecosystem like .NET nupkg where a special UI +# is available to interact with the end-users. +# +# Value is lowercase 'true' or 'false'. +# +# Default is 'true' +PROJECT_LICENSE_ACCEPTANCE_REQUIRED = 'true' + + # AUTOMATACI_LANG # Overrides AutomataCI to operate in 1 specific language. Otherwise, AutomataCI # shall query the system language settings. Only accepts language code complying diff --git a/automataCI/_package-npm_unix-any.sh b/automataCI/_package-lib_unix-any.sh similarity index 96% rename from automataCI/_package-npm_unix-any.sh rename to automataCI/_package-lib_unix-any.sh index ef5c70e..c9b6cbb 100644 --- a/automataCI/_package-npm_unix-any.sh +++ b/automataCI/_package-lib_unix-any.sh @@ -26,7 +26,7 @@ fi -PACKAGE_Run_NPM() { +PACKAGE_Run_LIB() { #__line="$1" @@ -50,7 +50,7 @@ PACKAGE_Run_NPM() { # copy all complimentary files to the workspace - cmd="PACKAGE_Assemble_NPM_Content" + cmd="PACKAGE_Assemble_LIB_Content" I18N_Check_Function "$cmd" OS_Is_Command_Available "$cmd" if [ $? -ne 0 ]; then diff --git a/automataCI/_package-npm_windows-any.ps1 b/automataCI/_package-lib_windows-any.ps1 similarity index 93% rename from automataCI/_package-npm_windows-any.ps1 rename to automataCI/_package-lib_windows-any.ps1 index 8a84999..f784801 100644 --- a/automataCI/_package-npm_windows-any.ps1 +++ b/automataCI/_package-lib_windows-any.ps1 @@ -25,7 +25,7 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { -function PACKAGE-Run-NPM { +function PACKAGE-Run-LIB { param ( [string]$__line ) @@ -41,7 +41,7 @@ function PACKAGE-Run-NPM { # copy all complimentary files to the workspace - $cmd = "PACKAGE-Assemble-NPM-Content" + $cmd = "PACKAGE-Assemble-LIB-Content" $null = I18N-Check-Function "$cmd" $___process = OS-Is-Command-Available "$cmd" if ($___process -ne 0) { @@ -50,7 +50,7 @@ function PACKAGE-Run-NPM { } $null = I18N-Assemble-Package - $___process = PACKAGE-Assemble-NPM-Content ` + $___process = PACKAGE-Assemble-LIB-Content ` "${_target}" ` "${_dest}" ` "${_target_filename}" ` diff --git a/automataCI/package_unix-any.sh b/automataCI/package_unix-any.sh index 2e01889..5b16835 100644 --- a/automataCI/package_unix-any.sh +++ b/automataCI/package_unix-any.sh @@ -35,8 +35,8 @@ fi . "${LIBS_AUTOMATACI}/_package-flatpak_unix-any.sh" . "${LIBS_AUTOMATACI}/_package-homebrew_unix-any.sh" . "${LIBS_AUTOMATACI}/_package-ipk_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-lib_unix-any.sh" . "${LIBS_AUTOMATACI}/_package-msi_unix-any.sh" -. "${LIBS_AUTOMATACI}/_package-npm_unix-any.sh" . "${LIBS_AUTOMATACI}/_package-pdf_unix-any.sh" . "${LIBS_AUTOMATACI}/_package-pypi_unix-any.sh" . "${LIBS_AUTOMATACI}/_package-rpm_unix-any.sh" @@ -253,9 +253,9 @@ ${__common}|${__log}|PACKAGE_Run_MSI return 1 fi - __log="${__log_directory}/npm_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - FS_Append_File "$__serial_control" "\ -${__common}|${__log}|PACKAGE_Run_NPM + __log="${__log_directory}/lib_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_LIB " if [ $? -ne 0 ]; then return 1 diff --git a/automataCI/package_windows-any.ps1 b/automataCI/package_windows-any.ps1 index e41163c..10c76ce 100644 --- a/automataCI/package_windows-any.ps1 +++ b/automataCI/package_windows-any.ps1 @@ -111,8 +111,8 @@ function SUBROUTINE-Package { $null = . "${env:LIBS_AUTOMATACI}\_package-flatpak_windows-any.ps1" $null = . "${env:LIBS_AUTOMATACI}\_package-homebrew_windows-any.ps1" $null = . "${env:LIBS_AUTOMATACI}\_package-ipk_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-lib_windows-any.ps1" $null = . "${env:LIBS_AUTOMATACI}\_package-msi_windows-any.ps1" - $null = . "${env:LIBS_AUTOMATACI}\_package-npm_windows-any.ps1" $null = . "${env:LIBS_AUTOMATACI}\_package-pdf_windows-any.ps1" $null = . "${env:LIBS_AUTOMATACI}\_package-pypi_windows-any.ps1" $null = . "${env:LIBS_AUTOMATACI}\_package-rpm_windows-any.ps1" @@ -268,9 +268,9 @@ ${__common}|${__log}|PACKAGE-Run-MSI return 1 } - $__log = "${__log_directory}\npm_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - $___process = FS-Append-File "${__serial_control}" @" -${__common}|${__log}|PACKAGE-Run-NPM + $__log = "${__log_directory}\lib_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-LIB "@ if ($___process -ne 0) { return 1 diff --git a/automataCI/services/compilers/rpm.ps1 b/automataCI/services/compilers/rpm.ps1 index b987e3d..35c4cac 100644 --- a/automataCI/services/compilers/rpm.ps1 +++ b/automataCI/services/compilers/rpm.ps1 @@ -1,4 +1,4 @@ -# Copyright 2023 (Holloway) Chew, Kean Ho +# Copyright 2023 (Holloway) Chew, Kean Ho # # 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 @@ -513,3 +513,65 @@ function RPM-Is-Valid { # report status return 1 } + + + + +function RPM-Register { + param( + [string]$___workspace, + [string]$___source, + [string]$___target, + [string]$___is_directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___workspace}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${___source}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___workspace}" + if ($___process -ne 0) { + return 1 + } + + + # execute + ## write into SPEC_INSTALL + $___spec = "${___workspace}/SPEC_INSTALL" + $___dir = "$(FS-Get-Directory "${___target}")" + $___content = "`n" + if ($___dir -ne $___target) { + $___content = "${___content}`nmkdir -p %{buildroot}/${___dir}`n" + } + $___content = "${___content}`ncp -r ${___source} %{buildroot}/${___target}`n" + $___process = FS-Append-File "${___spec}" "${___content}" + if ($___process -ne 0) { + return 1 + } + + ## write into SPEC_FILES + $___spec = "${___workspace}/SPEC_FILES" + $___content = "/${___content}" + if ($(STRINGS-Is-Empty "${___is_directory}") -ne 0) { + $___content = "${___content}/*" + } + $___content = "${___content}`n" + $___process = FS-Append-File "${___spec}" "${___content}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/rpm.sh b/automataCI/services/compilers/rpm.sh index ea7e947..a05d541 100644 --- a/automataCI/services/compilers/rpm.sh +++ b/automataCI/services/compilers/rpm.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright 2023 (Holloway) Chew, Kean Ho +# Copyright 2023 (Holloway) Chew, Kean Ho # # 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 @@ -524,3 +524,63 @@ RPM_Is_Valid() { # return status return 1 } + + + + +RPM_Register() { + #___workspace="$1" + #___source="$2" + #___target="$3" + #___is_directory="$4" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$3") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ## write into SPEC_INSTALL + ___spec="${1}/SPEC_INSTALL" + ___dir="$(FS_Get_Directory "$3")" + ___content="\n" + if [ "$___dir" != "$3" ]; then + ___content="${___content}\nmkdir -p %{buildroot}/${___dir}\n" + fi + ___content="${___content}\ncp -r ${2} %{buildroot}/${3}\n" + FS_Append_File "$___spec" "$___content" + if [ $? -ne 0 ]; then + return 1 + fi + + ## write into SPEC_FILES + ___spec="${___workspace}/SPEC_FILES" + ___content="/${3}" + if [ $(STRINGS_Is_Empty "$4") -ne 0 ]; then + ___content="${___content}/*\n" + fi + ___content="${___content}\n" + FS_Append_File "$___spec" "$___content" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/src/.ci/_package-archive_unix-any.sh b/src/.ci/_package-archive_unix-any.sh index 81c934b..04b4fee 100644 --- a/src/.ci/_package-archive_unix-any.sh +++ b/src/.ci/_package-archive_unix-any.sh @@ -51,12 +51,7 @@ PACKAGE_Assemble_ARCHIVE_Content() { return 1 fi elif [ $(FS_Is_Target_A_Library "$_target") -eq 0 ]; then - I18N_Assemble "$_target" "$_directory" - FS_Copy_File "$_target" "$_directory" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi + return 10 # handled by lib packager elif [ $(FS_Is_Target_A_WASM_JS "$_target") -eq 0 ]; then return 10 # handled by wasm instead elif [ $(FS_Is_Target_A_WASM "$_target") -eq 0 ]; then @@ -87,8 +82,6 @@ PACKAGE_Assemble_ARCHIVE_Content() { return 10 # not applicable elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then return 10 # not applicable - elif [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then - return 10 # not applicable else I18N_Assemble "$_target" "$_directory" FS_Copy_File "$_target" "$_directory" diff --git a/src/.ci/_package-archive_windows-any.ps1 b/src/.ci/_package-archive_windows-any.ps1 index 38b15bb..479ef83 100644 --- a/src/.ci/_package-archive_windows-any.ps1 +++ b/src/.ci/_package-archive_windows-any.ps1 @@ -52,12 +52,7 @@ function PACKAGE-Assemble-ARCHIVE-Content { return 1 } } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { - $null = I18N-Assemble "${_target}" "${_directory}" - $___process = FS-Copy-File "${_target}" "${_directory}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } + return 10 # handled by lib packager } elseif ($(FS-Is-Target-A-WASM-JS "${_target}") -eq 0) { return 10 # handled by wasm instead } elseif ($(FS-Is-Target-A-WASM "${_target}") -eq 0) { @@ -88,8 +83,6 @@ function PACKAGE-Assemble-ARCHIVE-Content { return 10 # not applicable } elseif ($(FS-Is-Target-A-PDF "${_target}") -eq 0) { return 10 # not applicable - } elseif ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { - return 10 # not applicable } else { $null = I18N-Assemble "${_target}" "${_directory}" $___process = FS-Copy-File "${_target}" "${_directory}" diff --git a/src/.ci/_package-deb_unix-any.sh b/src/.ci/_package-deb_unix-any.sh index 677cf8a..7cde15c 100644 --- a/src/.ci/_package-deb_unix-any.sh +++ b/src/.ci/_package-deb_unix-any.sh @@ -16,12 +16,14 @@ # initialize if [ "$PROJECT_PATH_ROOT" = "" ]; then - >&2 printf "[ ERROR ] - Please run from autoamtaCI/ci.sh.ps1 instead!\n" + >&2 printf "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!\n" return 1 fi . "${LIBS_AUTOMATACI}/services/io/fs.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/archive/zip.sh" . "${LIBS_AUTOMATACI}/services/compilers/copyright.sh" . "${LIBS_AUTOMATACI}/services/compilers/deb.sh" . "${LIBS_AUTOMATACI}/services/compilers/manual.sh" @@ -58,6 +60,18 @@ PACKAGE_Assemble_DEB_Content() { ;; esac + + # execute + ## determine base path + ## TIP: (1) by design, usually is: usr/local/ + ## (2) please avoid: usr/, usr/{TYPE}/, usr/bin/, & usr/lib{TYPE}/ + ## whenever possible for avoiding conflicts with your OS native + ## system packages. + _chroot="${_directory}/data/usr/" + if [ ! "$(STRINGS_To_Lowercase "$PROJECT_DEBIAN_IS_NATIVE")" = "true" ]; then + _chroot="${_chroot}/local" + fi + _gpg_keyring="$PROJECT_SKU" _package="$PROJECT_SKU" if [ $(FS_Is_Target_A_Source "$_target") -eq 0 ]; then @@ -65,17 +79,46 @@ PACKAGE_Assemble_DEB_Content() { elif [ $(FS_Is_Target_A_Docs "$_target") -eq 0 ]; then return 10 # not applicable elif [ $(FS_Is_Target_A_Library "$_target") -eq 0 ]; then - # copy main libary - # TIP: (1) usually is: usr/local/lib - # (2) please avoid: lib/, lib{TYPE}/ usr/lib/, and usr/lib{TYPE}/ - ___dest="${_directory}/data/usr/local/lib/${PROJECT_SKU}" - - I18N_Copy "$_target" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_File "$_target" "$___dest" - if [ $? -ne 0 ]; then - I18N_Copy_Failed - return 1 + ___dest="${_chroot}/lib/${PROJECT_SCOPE}/${PROJECT_SKU}" + + if [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_TARGZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$___dest" + FS_Make_Directory "$___dest" + TAR_Extract_GZ "$___dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_TARXZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$___dest" + FS_Make_Directory "$___dest" + TAR_Extract_XZ "$___dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_ZIP "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$___dest" + FS_Make_Directory "$___dest" + ZIP_Extract "$___dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + else + # copy library file + I18N_Assemble "$_target" "$___dest" + FS_Make_Directory "$___dest" + FS_Copy_File "$_target" "$___dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi fi _gpg_keyring="lib$PROJECT_SKU" @@ -94,32 +137,24 @@ PACKAGE_Assemble_DEB_Content() { return 10 # not applicable elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then return 10 # not applicable - elif [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then - return 10 # not applicable else # copy main program - # TIP: (1) usually is: usr/local/bin or usr/local/sbin - # (2) please avoid: bin/, usr/bin/, sbin/, and usr/sbin/ - ___dest="${_directory}/data/usr/local/bin" + ___dest="${_chroot}/bin/" - I18N_Copy "$_target" "$___dest" + I18N_Assemble "$_target" "$___dest" FS_Make_Directory "$___dest" FS_Copy_File "$_target" "$___dest" if [ $? -ne 0 ]; then - I18N_Copy_Failed + I18N_Assemble_Failed return 1 fi fi # NOTE: REQUIRED file - _changelog_path="${_directory}/data/usr/local/share/doc/${PROJECT_SKU}/changelog.gz" - if [ "$PROJECT_DEBIAN_IS_NATIVE" = "true" ]; then - _changelog_path="${_directory}/data/usr/share/doc/${PROJECT_SKU}/changelog.gz" - fi - - I18N_Create "$_changelog_path" - DEB_Create_Changelog "$_changelog_path" "$_changelog" "$PROJECT_SKU" + ___dest="${_chroot}/share/doc/${PROJECT_SCOPE}/${PROJECT_SKU}/changelog.gz" + I18N_Create "$___dest" + DEB_Create_Changelog "$___dest" "$_changelog" "$PROJECT_SKU" if [ $? -ne 0 ]; then I18N_Create_Failed return 1 @@ -127,14 +162,10 @@ PACKAGE_Assemble_DEB_Content() { # NOTE: REQUIRED file - _copyright="${_directory}/data/usr/local/share/doc/${PROJECT_SKU}/copyright" - if [ "$PROJECT_DEBIAN_IS_NATIVE" = "true" ]; then - _copyright="${_directory}/data/usr/share/doc/${PROJECT_SKU}/copyright" - fi - - I18N_Create "$_copyright" + ___dest="${_chroot}/share/doc/${PROJECT_SCOPE}/${PROJECT_SKU}/copyright" + I18N_Create "$___dest" COPYRIGHT_Create \ - "$_copyright" \ + "$___dest" \ "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/licenses/deb-copyright" \ "$PROJECT_SKU" \ "$PROJECT_CONTACT_NAME" \ @@ -147,14 +178,10 @@ PACKAGE_Assemble_DEB_Content() { # NOTE: REQUIRED file - _manual="${_directory}/data/usr/local/share/man/man1/${PROJECT_SKU}.1" - if [ "$PROJECT_DEBIAN_IS_NATIVE" = "true" ]; then - _manual="${_directory}/data/usr/share/man/man1/${PROJECT_SKU}.1" - fi - - I18N_Create "$_manual" + ___dest="${_chroot}/share/man/man1/${PROJECT_SCOPE}-${PROJECT_SKU}.1" + I18N_Create "$___dest" MANUAL_Create \ - "$_manual" \ + "$___dest" \ "$PROJECT_SKU" \ "$PROJECT_CONTACT_NAME" \ "$PROJECT_CONTACT_EMAIL" \ diff --git a/src/.ci/_package-deb_windows-any.ps1 b/src/.ci/_package-deb_windows-any.ps1 index c1b868e..68542ed 100644 --- a/src/.ci/_package-deb_windows-any.ps1 +++ b/src/.ci/_package-deb_windows-any.ps1 @@ -21,6 +21,8 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { . "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\zip.ps1" . "${env:LIBS_AUTOMATACI}\services\compilers\copyright.ps1" . "${env:LIBS_AUTOMATACI}\services\compilers\deb.ps1" . "${env:LIBS_AUTOMATACI}\services\compilers\manual.ps1" @@ -56,6 +58,18 @@ function PACKAGE-Assemble-DEB-Content { # accepted }} + + # execute + ## determine base path + ## TIP: (1) by design, usually is: usr/local/ + ## (2) please avoid: usr/, usr/{TYPE}/, usr/bin/, & usr/lib{TYPE}/ + ## whenever possible for avoiding conflicts with your OS native + ## system packages. + $_chroot = "${_directory}/data/usr/" + if ($(STRINGS-To-Lowercase "${env:PROJECT_DEBIAN_IS_NATIVE}") -ne "true") { + $_chroot = "${_chroot}/local/" + } + $_gpg_keyring = "${env:PROJECT_SKU}" $_package = "${env:PROJECT_SKU}" if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { @@ -63,22 +77,46 @@ function PACKAGE-Assemble-DEB-Content { } elseif ($(FS-Is-Target-A-Docs "${_target}") -eq 0) { return 10 # not applicable } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { - # copy main libary - # TIP: (1) usually is: usr/local/lib - # (2) please avoid: lib/, lib{TYPE}/ usr/lib/, and usr/lib{TYPE}/ - $___dest = "${_directory}\data\usr\local\lib\${env:PROJECT_SKU}" - - $null = I18N-Assemble "${_target}" "${___dest}" - $___process = FS-Make-Directory "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___process = FS-Copy-File "${_target}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 + $___dest = "${_chroot}\lib\${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + + if ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-TARGZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${___dest}" + $null = FS-Make-Directory "${___dest}" + $___process = TAR-Extract-GZ "${___dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-TARXZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${___dest}" + $null = FS-Make-Directory "${___dest}" + $___process = TAR-Extract-XZ "${___dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-ZIP "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${___dest}" + $null = FS-Make-Directory "${___dest}" + $___process = ZIP-Extract "${___dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } else { + # copy library file + $null = I18N-Assemble "${_target}" "${___dest}" + $null = FS-Make-Directory "${___dest}" + $___process = FS-Copy-File "${_target}" "${___dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } } $_gpg_keyring = "lib${env:PROJECT_SKU}" @@ -97,13 +135,9 @@ function PACKAGE-Assemble-DEB-Content { return 10 # not applicable } elseif ($(FS-Is-Target-A-PDF "${_target}") -eq 0) { return 10 # not applicable - } elseif ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { - return 10 # not applicable } else { # copy main program - # TIP: (1) usually is: usr/local/bin or usr/local/sbin - # (2) please avoid: bin/, usr/bin/, sbin/, and usr/sbin/ - $___dest = "${_directory}\data\usr\local\bin" + $___dest = "${_chroot}\bin\" $null = I18N-Assemble "${_target}" "${___dest}" $null = FS-Make-Directory "${___dest}" @@ -116,16 +150,9 @@ function PACKAGE-Assemble-DEB-Content { # NOTE: REQUIRED file - $_changelog_path = "${_directory}\data\usr\local\share\doc\${env:PROJECT_SKU}\changelog.gz" - if ("${env:PROJECT_DEBIAN_IS_NATIVE}" -eq "true") { - $_changelog_path = "${_directory}\data\usr\share\doc\${env:PROJECT_SKU}\changelog.gz" - } - - $null = I18N-Create "${_changelog_path}" - $___process = DEB-Create-Changelog ` - "${_changelog_path}" ` - "${_changelog}" ` - "${env:PROJECT_SKU}" + $___dest = "${_chroot}\share\doc\${env:PROJECT_SCOPE}\${env:PROJECT_SKU}\changelog.gz" + $null = I18N-Create "${___dest}" + $___process = DEB-Create-Changelog "${___dest}" "${_changelog}" "${env:PROJECT_SKU}" if ($___process -ne 0) { $null = I18N-Create-Failed return 1 @@ -133,14 +160,10 @@ function PACKAGE-Assemble-DEB-Content { # NOTE: REQUIRED file - $_copyright = "${_directory}\data\usr\local\share\doc\${env:PROJECT_SKU}\copyright" - if ("${env:PROJECT_DEBIAN_IS_NATIVE}" -eq "true") { - $_copyright = "${_directory}\data\usr\share\doc\${env:PROJECT_SKU}\copyright" - } - - $null = I18N-Create "${_copyright}" + $___dest = "${_chroot}\share\doc\${env:PROJECT_SCOPE}\${env:PROJECT_SKU}\copyright" + $null = I18N-Create "${___dest}" $___process = COPYRIGHT-Create ` - "${_copyright}" ` + "${___dest}" ` "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses\deb-copyright" ` "${env:PROJECT_SKU}" ` "${env:PROJECT_CONTACT_NAME}" ` @@ -153,14 +176,10 @@ function PACKAGE-Assemble-DEB-Content { # NOTE: REQUIRED file - $_manual = "${_directory}\data\usr\local\share\man\man1\${env:PROJECT_SKU}.1" - if ("${env:PROJECT_DEBIAN_IS_NATIVE}" -eq "true") { - $_manual = "${_directory}\data\usr\share\man\man1\${env:PROJECT_SKU}.1" - } - - $null = I18N-Create "${_manual}" + $___dest = "${_chroot}\share\man\man1\${env:PROJECT_SCOPE}-${env:PROJECT_SKU}.1" + $null = I18N-Create "${___dest}" $___process = MANUAL-Create ` - "${_manual}" ` + "${___dest}" ` "${env:PROJECT_DEBIAN_IS_NATIVE}" ` "${env:PROJECT_SKU}" ` "${env:PROJECT_CONTACT_NAME}" ` diff --git a/src/.ci/_package-docker_unix-any.sh b/src/.ci/_package-docker_unix-any.sh index a981810..cf3e477 100644 --- a/src/.ci/_package-docker_unix-any.sh +++ b/src/.ci/_package-docker_unix-any.sh @@ -55,8 +55,6 @@ PACKAGE_Assemble_DOCKER_Content() { return 10 # not applicable elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then return 10 # not applicable - elif [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then - return 10 # not applicable fi case "$_target_os" in diff --git a/src/.ci/_package-docker_windows-any.ps1 b/src/.ci/_package-docker_windows-any.ps1 index b106433..fdfedee 100644 --- a/src/.ci/_package-docker_windows-any.ps1 +++ b/src/.ci/_package-docker_windows-any.ps1 @@ -54,8 +54,6 @@ function PACKAGE-Assemble-DOCKER-Content { return 10 # not applicable } elseif ($(FS-Is-Target-A-MSI "${_target}") -eq 0) { return 10 # not applicable - } elseif ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { - return 10 # not applicable } switch ($_target_os) { diff --git a/src/.ci/_package-flatpak_unix-any.sh b/src/.ci/_package-flatpak_unix-any.sh index a9e3be3..4c7a151 100644 --- a/src/.ci/_package-flatpak_unix-any.sh +++ b/src/.ci/_package-flatpak_unix-any.sh @@ -63,8 +63,6 @@ PACKAGE_Assemble_FLATPAK_Content() { return 10 # not applicable elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then return 10 # not applicable - elif [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then - return 10 # not applicable elif [ ! "$_target_os" = "linux" ] && [ ! "$_target_os" = "any" ]; then return 10 # not applicable fi diff --git a/src/.ci/_package-flatpak_windows-any.ps1 b/src/.ci/_package-flatpak_windows-any.ps1 index e606222..574197e 100644 --- a/src/.ci/_package-flatpak_windows-any.ps1 +++ b/src/.ci/_package-flatpak_windows-any.ps1 @@ -63,8 +63,6 @@ function PACKAGE-Assemble-FLATPAK-Content { return 10 # not applicable } elseif ($(FS-Is-Target-A-PDF "${_target}") -eq 0) { return 10 # not applicable - } elseif ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { - return 10 # not applicable } elseif (($_target_os -ne "linux") -and ($_target_os -ne "any")) { return 10 # not applicable } diff --git a/src/.ci/_package-ipk_unix-any.sh b/src/.ci/_package-ipk_unix-any.sh index 6c85e03..42937c6 100644 --- a/src/.ci/_package-ipk_unix-any.sh +++ b/src/.ci/_package-ipk_unix-any.sh @@ -20,9 +20,10 @@ if [ "$PROJECT_PATH_ROOT" = "" ]; then return 1 fi -. "${LIBS_AUTOMATACI}/services/io/os.sh" . "${LIBS_AUTOMATACI}/services/io/fs.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/archive/zip.sh" . "${LIBS_AUTOMATACI}/services/compilers/ipk.sh" @@ -45,6 +46,18 @@ PACKAGE_Assemble_IPK_Content() { ;; esac + + # execute + ## determine base path + ## TIP: (1) by design, usually is: usr/local/ + ## (2) please avoid: usr/, usr/{TYPE}/, usr/bin/, & usr/lib{TYPE}/ + ## whenever possible for avoiding conflicts with your OS native + ## system packages. + _chroot="${_directory}/data/usr/" + if [ ! "$(STRINGS_To_Lowercase "$PROJECT_DEBIAN_IS_NATIVE")" = "true" ]; then + _chroot="${_chroot}/local" + fi + _gpg_keyring="$PROJECT_SKU" _package="$PROJECT_SKU" if [ $(FS_Is_Target_A_Source "$_target") -eq 0 ]; then @@ -52,16 +65,46 @@ PACKAGE_Assemble_IPK_Content() { elif [ $(FS_Is_Target_A_Docs "$_target") -eq 0 ]; then return 10 # not applicable elif [ $(FS_Is_Target_A_Library "$_target") -eq 0 ]; then - # copy main libary - # TIP: (1) usually is: usr/local/lib - # (2) please avoid: lib/, lib{TYPE}/ usr/lib/, and usr/lib{TYPE}/ - ___dest="${_directory}/data/usr/local/lib/${PROJECT_SKU}" - I18N_Copy "$_target" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_File "$_target" "$___dest" - if [ $? -ne 0 ]; then - I18N_Copy_Failed - return 1 + ___dest="${_chroot}/lib/${PROJECT_SCOPE}/${PROJECT_SKU}" + + if [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_TARGZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$___dest" + FS_Make_Directory "$___dest" + TAR_Extract_GZ "$___dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_TARXZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$___dest" + FS_Make_Directory "$___dest" + TAR_Extract_XZ "$___dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_ZIP "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$___dest" + FS_Make_Directory "$___dest" + ZIP_Extract "$___dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + else + # copy library file + I18N_Assemble "$_target" "$___dest" + FS_Make_Directory "$___dest" + FS_Copy_File "$_target" "$___dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi fi _gpg_keyring="lib$PROJECT_SKU" @@ -80,13 +123,9 @@ PACKAGE_Assemble_IPK_Content() { return 10 # not applicable elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then return 10 # not applicable - elif [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then - return 10 # not applicable else # copy main program - # TIP: (1) usually is: usr/local/bin or usr/local/sbin - # (2) please avoid: bin/, usr/bin/, sbin/, and usr/sbin/ - ___dest="${_directory}/data/usr/local/bin" + ___dest="${_chroot}/bin/" I18N_Assemble "$_target" "$___dest" FS_Make_Directory "$___dest" @@ -99,7 +138,7 @@ PACKAGE_Assemble_IPK_Content() { # WARNING: THIS REQUIRED FILE MUST BE THE LAST ONE - I18N_Create "control/control" + I18N_Create "${_directory}/control/control" IPK_Create_Control \ "$_directory" \ "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}" \ diff --git a/src/.ci/_package-ipk_windows-any.ps1 b/src/.ci/_package-ipk_windows-any.ps1 index 8d23c08..31cbc5b 100644 --- a/src/.ci/_package-ipk_windows-any.ps1 +++ b/src/.ci/_package-ipk_windows-any.ps1 @@ -19,10 +19,11 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { return 1 } -. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" . "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" -. "${env:LIBS_AUTOMATACI}\services\compilers\deb.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\zip.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\ipk.ps1" @@ -45,6 +46,18 @@ function PACKAGE-Assemble-IPK-Content { # accepted }} + + # execute + ## determine base path + ## TIP: (1) by design, usually is: usr/local/ + ## (2) please avoid: usr/, usr/{TYPE}/, usr/bin/, & usr/lib{TYPE}/ + ## whenever possible for avoiding conflicts with your OS native + ## system packages. + $_chroot = "${_directory}/data/usr/" + if ($(STRINGS-To-Lowercase "${env:PROJECT_DEBIAN_IS_NATIVE}") -ne "true") { + $_chroot = "${_chroot}/local/" + } + $_gpg_keyring = "${env:PROJECT_SKU}" $_package = "${env:PROJECT_SKU}" if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { @@ -52,17 +65,46 @@ function PACKAGE-Assemble-IPK-Content { } elseif ($(FS-Is-Target-A-Docs "${_target}") -eq 0) { return 10 # not applicable } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { - # copy main libary - # TIP: (1) usually is: usr/local/lib - # (2) please avoid: lib/, lib{TYPE}/ usr/lib/, and usr/lib{TYPE}/ - $___dest = "${_directory}\data\usr\local\lib\${env:PROJECT_SKU}" - - $null = I18N-Assemble "${_target}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-File "${_target}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 + $___dest = "${_chroot}\lib\${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + + if ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-TARGZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${___dest}" + $null = FS-Make-Directory "${___dest}" + $___process = TAR-Extract-GZ "${___dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-TARXZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${___dest}" + $null = FS-Make-Directory "${___dest}" + $___process = TAR-Extract-XZ "${___dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-ZIP "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${___dest}" + $null = FS-Make-Directory "${___dest}" + $___process = ZIP-Extract "${___dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } else { + # copy library file + $null = I18N-Assemble "${_target}" "${___dest}" + $null = FS-Make-Directory "${___dest}" + $___process = FS-Copy-File "${_target}" "${___dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } } $_gpg_keyring = "lib${env:PROJECT_SKU}" @@ -75,6 +117,8 @@ function PACKAGE-Assemble-IPK-Content { return 10 # not applicable } elseif ($(FS-Is-Target-A-Homebrew "${_target}") -eq 0) { return 10 # not applicable + } elseif ($(FS-Is-Target-A-Cargo "${_target}") -eq 0) { + return 10 # not applicable } elseif ($(FS-Is-Target-A-MSI "${_target}") -eq 0) { return 10 # not applicable } elseif ($(FS-Is-Target-A-PDF "${_target}") -eq 0) { @@ -83,9 +127,7 @@ function PACKAGE-Assemble-IPK-Content { return 10 # not applicable } else { # copy main program - # TIP: (1) usually is: usr/local/bin or usr/local/sbin - # (2) please avoid: bin/, usr/bin/, sbin/, and usr/sbin/ - $___dest = "${_directory}\data\usr\local\bin" + $___dest = "${_chroot}\bin\" $null = I18N-Assemble "${_target}" "${___dest}" $null = FS-Make-Directory "${___dest}" @@ -98,7 +140,7 @@ function PACKAGE-Assemble-IPK-Content { # WARNING: THIS REQUIRED FILE MUST BE THE LAST ONE - $null = I18N-Create "control\control" + $null = I18N-Create "${_directory}\control\control" $___process = IPK-Create-Control ` "${_directory}" ` "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}" ` diff --git a/src/.ci/_package-lib_unix-any.sh b/src/.ci/_package-lib_unix-any.sh new file mode 100644 index 0000000..c083d01 --- /dev/null +++ b/src/.ci/_package-lib_unix-any.sh @@ -0,0 +1,189 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# 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/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/archive/zip.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +PACKAGE_Assemble_LIB_Content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # validate project + if [ $(FS_Is_Target_A_Library "$_target") -ne 0 ]; then + return 10 # not applicable + fi + + + # execute + ## copy over known archived files + if [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then + __dest="lib${PROJECT_SKU}-NPM_${PROJECT_VERSION}_js-js.tgz" + __dest="${_directory}/${__dest}" + I18N_Copy "$_target" "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + return 0 + elif [ $(FS_Is_Target_A_TARGZ "$_target") -eq 0 ]; then + __dest="lib${PROJECT_SKU}_${PROJECT_VERSION}_${_target_os}-${target_arch}.tar.gz" + __dest="${_directory}/${__dest}" + I18N_Copy "$_target" "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + return 0 + elif [ $(FS_Is_Target_A_TARXZ "$_target") -eq 0 ]; then + __dest="lib${PROJECT_SKU}_${PROJECT_VERSION}_${_target_os}-${target_arch}.tar.xz" + __dest="${_directory}/${__dest}" + I18N_Copy "$_target" "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + return 0 + elif [ $(FS_Is_Target_A_ZIP "$_target") -eq 0 ]; then + __dest="lib${PROJECT_SKU}_${PROJECT_VERSION}_${_target_os}-${target_arch}.zip" + __dest="${_directory}/${__dest}" + I18N_Copy "$_target" "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + return 0 + fi + + ## assume standalone library file - manually package into .tar.xz, .zip, and .nupkg + __workspace="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/package-${_target_name}" + FS_Remake_Directory "$__workspace" + I18N_Copy "$_target" "$__workspace" + FS_Copy_File "$_target" "$__workspace" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + __source="${PROJECT_PATH_ROOT}/${PROJECT_README}" + I18N_Copy "$__source" "$__workspace" + FS_Copy_File "$__source" "$__workspace" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + __source="${PROJECT_PATH_ROOT}/${PROJECT_LICENSE_FILE}" + I18N_Copy "$__source" "$__workspace" + FS_Copy_File "$__source" "$__workspace" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + __current_path="$PWD" && cd "$__workspace" + ## package tar.xz + __dest="lib${PROJECT_SKU}_${PROJECT_VERSION}_${_target_os}-${_target_arch}.tar.xz" + I18N_Create_Package "$__dest" + __dest="${_directory}/${__dest}" + TAR_Create_XZ "$__dest" "." + if [ $? -ne 0 ]; then + I18N_Create_Failed + cd "$__current_path" && unset __current_path + return 1 + fi + + ## package zip + __dest="lib${PROJECT_SKU}_${PROJECT_VERSION}_${_target_os}-${_target_arch}.zip" + I18N_Create_Package "$__dest" + __dest="${_directory}/${__dest}" + ZIP_Create "$__dest" "." + if [ $? -ne 0 ]; then + I18N_Create_Failed + cd "$__current_path" && unset __current_path + return 1 + fi + + ## package nupkg + __dest="./Package.nuspec" + __acceptance="false" + if [ $(STRINGS_To_Lowercase "$PROJECT_LICENSE_ACCEPTANCE_REQUIRED") = "true" ]; then + __acceptance="true" + fi + + I18N_Create "$__dest" + FS_Write_File "$__dest" "\ + + + + ${PROJECT_SKU} + ${PROJECT_VERSION} + ${PROJECT_CONTACT_NAME} + ${PROJECT_CONTACT_NAME} + ${PROJECT_SOURCE_URL} + ${PROJECT_NAME} + ${PROJECT_PITCH} + ${PROJECT_LICENSE} + ${__acceptance} + ${PROJECT_README} + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + cd "$__current_path" && unset __current_path + return 1 + fi + + __dest="lib${PROJECT_SKU}_${PROJECT_VERSION}_${_target_os}-${_target_arch}.nupkg" + I18N_Create_Package "$__dest" + __dest="${_directory}/${__dest}" + ZIP_Create "$__dest" "." + if [ $? -ne 0 ]; then + I18N_Create_Failed + cd "$__current_path" && unset __current_path + return 1 + fi + + ## done - clean up + cd "$__current_path" && unset __current_path + + + # report status + return 0 +} diff --git a/src/.ci/_package-lib_windows-any.ps1 b/src/.ci/_package-lib_windows-any.ps1 new file mode 100644 index 0000000..2d40a41 --- /dev/null +++ b/src/.ci/_package-lib_windows-any.ps1 @@ -0,0 +1,202 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# 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\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\zip.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + exit 1 +} + + + + +function PACKAGE-Assemble-LIB-Content { + param ( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + Write-Host "DEBUG: before ${_target}" + + # validate project + if ($(FS-Is-Target-A-Library "${_target}") -ne 0) { + return 10 # not applicable + } + + Write-Host "DEBUG: after ${_target}" + + # execute + ## copy over known archived files + if ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { + $__dest = "lib${env:PROJECT_SKU}-NPM_${env:PROJECT_VERSION}_js-js.tgz" + $__dest = "${_directory}\${__dest}" + Write-Host "DEBUG: ${__dest}" + $null = I18N-Copy "${_target}" "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + return 0 + } elseif ($(FS-Is-Target-A-TARGZ "${_target}") -eq 0) { + $__dest = "lib${env:PROJECT_SKU}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}.tar.gz" + $__dest = "${_directory}\${__dest}" + $null = I18N-Copy "${_target}" "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + return 0 + } elseif ($(FS-Is-Target-A-TARXZ "${_target}") -eq 0) { + $__dest = "lib${env:PROJECT_SKU}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}.tar.xz" + $__dest = "${_directory}\${__dest}" + $null = I18N-Copy "${_target}" "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + return 0 + } elseif ($(FS-Is-Target-A-ZIP "${_target}") -eq 0) { + $__dest = "lib${env:PROJECT_SKU}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}.zip" + $__dest = "${_directory}\${__dest}" + $null = I18N-Copy "${_target}" "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + return 0 + } + + ## assume standalone library file - manually package into .tar.xz, .zip, and .nupkg + $__workspace = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\package-${_target_name}" + $null = FS-Remake-Directory "${__workspace}" + + $null = I18N-Copy "${_target}" "${__workspace}" + $___process = FS-Copy-File "${_target}" "${__workspace}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_README}" + $null = I18N-Copy "${__source}" "${__workspace}" + $___process = FS-Copy-File "${__source}" "${__workspace}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_LICENSE_FILE}" + $null = I18N-Copy "${__source}" "${__workspace}" + $___process = FS-Copy-File "${__source}" "${__workspace}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + $__current_path = Get-Location + $null = Set-Location -Path "${__workspace}" + ## package tar.xz + $__dest = "lib${env:PROJECT_SKU}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}.tar.xz" + $null = I18N-Create-Package "${__dest}" + $__dest = "${_directory}\${__dest}" + $___process = TAR-Create-XZ "${__dest}" "." + if ($___process -ne 0) { + $null = I18N-Create-Failed + $null = Set-Location -Path "${__current_path}" + $null = Remove-Variable -Name __current_path + return 1 + } + + ## package zip + $__dest = "lib${env:PROJECT_SKU}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}.zip" + $null = I18N-Create-Package "${__dest}" + $__dest = "${_directory}\${__dest}" + $___process = ZIP-Create "${__dest}" "." + if ($___process -ne 0) { + $null = I18N-Create-Failed + $null = Set-Location -Path "${__current_path}" + $null = Remove-Variable -Name __current_path + return 1 + } + + ## package nupkg + $__dest = ".\Package.nuspec" + $__acceptance = "false" + if ($(STRINGS-To-Lowercase "${env:PROJECT_LICENSE_ACCEPTANCE_REQUIRED}") -eq "true") { + $__acceptance = "true" + } + + $null = I18N-Create "${__dest}" + $___process = FS-Write-File "${__dest}" @" + + + + ${PROJECT_SKU} + ${PROJECT_VERSION} + ${PROJECT_CONTACT_NAME} + ${PROJECT_CONTACT_NAME} + ${PROJECT_SOURCE_URL} + ${PROJECT_NAME} + ${PROJECT_PITCH} + ${PROJECT_LICENSE} + ${__acceptance} + ${PROJECT_README} + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + $null = Set-Location -Path "${__current_path}" + $null = Remove-Variable -Name __current_path + return 1 + } + + + $__dest = "lib${env:PROJECT_SKU}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}.nupkg" + $null = I18N-Create-Package "${__dest}" + $__dest = "${_directory}\${__dest}" + $___process = ZIP-Create "${__dest}" "." + if ($___process -ne 0) { + $null = I18N-Create-Failed + $null = Set-Location -Path "${__current_path}" + $null = Remove-Variable -Name __current_path + return 1 + } + + ## done - clean up + $null = Set-Location -Path "${__current_path}" + $null = Remove-Variable -Name __current_path + + + # report status + return 0 +} diff --git a/src/.ci/_package-npm_unix-any.sh b/src/.ci/_package-npm_unix-any.sh deleted file mode 100644 index d3c40cd..0000000 --- a/src/.ci/_package-npm_unix-any.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# Copyright 2024 (Holloway) Chew, Kean Ho -# -# 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/io/fs.sh" -. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" - - - - -# initialize -if [ "$PROJECT_PATH_ROOT" = "" ]; then - >&2 printf "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!\n" - return 1 -fi - - - - -PACKAGE_Assemble_NPM_Content() { - _target="$1" - _directory="$2" - _target_name="$3" - _target_os="$4" - _target_arch="$5" - - - # validate project - if [ $(FS_Is_Target_A_NPM "$_target") -ne 0 ]; then - return 10 # not applicable - fi - - - # execute - __dest="${_directory}/lib${PROJECT_SKU}-npm_${PROJECT_VERSION}_js-js.tgz" - I18N_Copy "$_target" "$__dest" - FS_Copy_File "$_target" "$__dest" - if [ $? -ne 0 ]; then - I18N_Copy_Failed - return 1 - fi - - - # report status - return 0 -} diff --git a/src/.ci/_package-npm_windows-any.ps1 b/src/.ci/_package-npm_windows-any.ps1 deleted file mode 100644 index 0504243..0000000 --- a/src/.ci/_package-npm_windows-any.ps1 +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright 2024 (Holloway) Chew, Kean Ho -# -# 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\io\fs.ps1" -. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" - - - - -# initialize -if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" - exit 1 -} - - - - -function PACKAGE-Assemble-NPM-Content { - param ( - [string]$_target, - [string]$_directory, - [string]$_target_name, - [string]$_target_os, - [string]$_target_arch - ) - - - # validate project - if ($(FS-Is-Target-A-NPM "${_target}") -ne 0) { - return 10 # not applicable - } - - - # execute - $__dest = "${_directory}\lib${env:PROJECT_SKU}-npm_${env:PROJECT_VERSION}_js-js.tgz" - $null = I18N-Copy "${_target}" "${__dest}" - $___process = FS-Copy-File "${_target}" "${__dest}" - if ($___process -ne 0) { - $null = I18N-Copy-Failed - return 1 - } - - - # report status - return 0 -} diff --git a/src/.ci/_package-pdf_unix-any.sh b/src/.ci/_package-pdf_unix-any.sh index 3528282..34b1fe6 100644 --- a/src/.ci/_package-pdf_unix-any.sh +++ b/src/.ci/_package-pdf_unix-any.sh @@ -40,8 +40,9 @@ PACKAGE_Assemble_PDF_Content() { # execute - I18N_Copy "$_target" "${_directory}/$(FS_Get_File "$_target")" - FS_Copy_File "$_target" "${_directory}/$(FS_Get_File "$_target")" + ___dest="${_directory}/$(FS_Get_File "$_target")" + I18N_Copy "$_target" "$___dest" + FS_Copy_File "$_target" "$___dest" if [ $? -ne 0 ]; then I18N_Copy_Failed return 1 diff --git a/src/.ci/_package-pdf_windows-any.ps1 b/src/.ci/_package-pdf_windows-any.ps1 index a1d781a..561c81c 100644 --- a/src/.ci/_package-pdf_windows-any.ps1 +++ b/src/.ci/_package-pdf_windows-any.ps1 @@ -41,8 +41,9 @@ function PACKAGE-Assemble-PDF-Content { # execute - $null = I18N-Copy "${_target}" "${_directory}\$(FS-Get-File "${_target}")" - $___process = FS-Copy-File "${_target}" "${_directory}\$(FS-Get-File "${_target}")" + $___dest = "${_directory}\$(FS-Get-File "${_target}")" + $null = I18N-Copy "${_target}" "${___dest}" + $___process = FS-Copy-File "${_target}" "${___dest}" if ($___process -ne 0) { $null = I18N-Copy-Failed return 1 diff --git a/src/.ci/_package-rpm_unix-any.sh b/src/.ci/_package-rpm_unix-any.sh index 6328f01..ab83963 100644 --- a/src/.ci/_package-rpm_unix-any.sh +++ b/src/.ci/_package-rpm_unix-any.sh @@ -22,6 +22,9 @@ fi . "${LIBS_AUTOMATACI}/services/io/fs.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/archive/zip.sh" +. "${LIBS_AUTOMATACI}/services/compilers/rpm.sh" @@ -43,56 +46,102 @@ PACKAGE_Assemble_RPM_Content() { ;; esac + + # execute + ## determine base path + ## TIP: (1) by design, usually is: usr/local/ + ## (2) please avoid: usr/, usr/{TYPE}/, usr/bin/, & usr/lib{TYPE}/ + ## whenever possible for avoiding conflicts with your OS native + ## system packages. + _chroot="usr" + if [ ! "$(STRINGS_To_Lowercase "$PROJECT_DEBIAN_IS_NATIVE")" = "true" ]; then + _chroot="${_chroot}/local" + fi + _gpg_keyring="$PROJECT_SKU" if [ $(FS_Is_Target_A_Source "$_target") -eq 0 ]; then return 10 # not applicable elif [ $(FS_Is_Target_A_Docs "$_target") -eq 0 ]; then return 10 # not applicable elif [ $(FS_Is_Target_A_Library "$_target") -eq 0 ]; then - # copy main library - # TIP: (1) usually is: usr/local/lib - # (2) please avoid: lib/, lib{TYPE}/ usr/lib/, and usr/lib{TYPE}/ - _filepath="${_directory}/BUILD/lib${PROJECT_SKU}.a" - I18N_Copy "$_target" "$_filepath" - FS_Make_Housing_Directory "$_filepath" - if [ $? -ne 0 ]; then - I18N_Copy_Failed - return 1 - fi - - FS_Copy_File "$_target" "$_filepath" - if [ $? -ne 0 ]; then - I18N_Copy_Failed - return 1 - fi - - - # generate AutomataCI's required RPM spec instructions (INSTALL) - __file="${_directory}/SPEC_INSTALL" - I18N_Create "$__file" - FS_Write_File "$__file" "\ -install --directory %{buildroot}/usr/local/lib/${PROJECT_SKU} -install -m 0644 lib${PROJECT_SKU}.a %{buildroot}/usr/local/lib/${PROJECT_SKU} - -install --directory %{buildroot}/usr/local/share/doc/lib${PROJECT_SKU}/ -install -m 0644 copyright %{buildroot}/usr/local/share/doc/lib${PROJECT_SKU}/ -" - if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 - fi - - - # generate AutomataCI's required RPM spec instructions (FILES) - __file="${_directory}/SPEC_FILES" - I18N_Create "$__file" - FS_Write_File "$__file" "\ -/usr/local/lib/${PROJECT_SKU}/lib${PROJECT_SKU}.a -/usr/local/share/doc/lib${PROJECT_SKU}/copyright -" - if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 + if [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_TARGZ "$_target") -eq 0 ]; then + # unpack library + ___source="${PROJECT_SCOPE}/${PROJECT_SKU}" + ___dest="${_directory}/BUILD/${___source}" + ___target="${_chroot}/lib/${___source}" + + I18N_Assemble "$_target" "$___dest" + FS_Make_Directory "$___dest" + TAR_Extract_GZ "$___dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + RPM_Register "$_directory" "$___source" "$___target" "true" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_TARXZ "$_target") -eq 0 ]; then + # unpack library + ___source="${PROJECT_SCOPE}/${PROJECT_SKU}" + ___dest="${_directory}/BUILD/${___source}" + ___target="${_chroot}/lib/${___source}" + + I18N_Assemble "$_target" "$___dest" + FS_Make_Directory "$___dest" + TAR_Extract_XZ "$___dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + RPM_Register "$_directory" "$___source" "$___target" "true" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_ZIP "$_target") -eq 0 ]; then + # unpack library + ___source="${PROJECT_SCOPE}/${PROJECT_SKU}" + ___dest="${_directory}/BUILD/${___source}" + ___target="${_chroot}/lib/${___source}" + + I18N_Assemble "$_target" "$___dest" + FS_Make_Directory "$___dest" + ZIP_Extract "$___dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + RPM_Register "$_directory" "$___source" "$___target" "true" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + else + # copy library file + ___source="$(FS_Get_File "$_target")" + ___dest="${_directory}/BUILD/${___source}" + ___target="${_chroot}/lib/${___source}" + + I18N_Assemble "$_target" "$___dest" + FS_Make_Housing_Directory "$___dest" + FS_Copy_File "$_target" "$___dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + RPM_Register "$_directory" "$___source" "$___target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi fi _gpg_keyring="lib$PROJECT_SKU" @@ -111,53 +160,21 @@ install -m 0644 copyright %{buildroot}/usr/local/share/doc/lib${PROJECT_SKU}/ return 10 # not applicable elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then return 10 # not applicable - elif [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then - return 10 # not applicable else # copy main program - # TIP: (1) copy all files into "${__directory}/BUILD" directory. - _filepath="${_directory}/BUILD/${PROJECT_SKU}" - I18N_Copy "$_target" "$_filepath" - FS_Make_Housing_Directory "$_filepath" - if [ $? -ne 0 ]; then - I18N_Copy_Failed - return 1 - fi + ___source="$(FS_Get_File "$_target")" + ___dest="${_directory}/BUILD/${___source}" + ___target="${_chroot}/bin/${___source}" - FS_Copy_File "$_target" "$_filepath" + I18N_Assemble "$_target" "$___dest" + FS_Make_Housing_Directory "$___dest" + FS_Copy_File "$_target" "$___dest" if [ $? -ne 0 ]; then - I18N_Copy_Failed - return 1 - fi - - - # generate AutomataCI's required RPM spec instructions (INSTALL) - __file="${_directory}/SPEC_INSTALL" - I18N_Create "$__file" - FS_Write_File "$__file" "\ -install --directory %{buildroot}/usr/local/bin -install -m 0755 ${PROJECT_SKU} %{buildroot}/usr/local/bin - -install --directory %{buildroot}/usr/local/share/doc/${PROJECT_SKU}/ -install -m 0644 copyright %{buildroot}/usr/local/share/doc/${PROJECT_SKU}/ - -install --directory %{buildroot}/usr/local/share/man/man1/ -install -m 0644 ${PROJECT_SKU}.1.gz %{buildroot}/usr/local/share/man/man1/ -" - if [ $? -ne 0 ]; then - I18N_Create_Failed + I18N_Assemble_Failed return 1 fi - - # generate AutomataCI's required RPM spec instructions (FILES) - __file="${_directory}/SPEC_FILES" - I18N_Create "$__file" - FS_Write_File "$__file" "\ -/usr/local/bin/${PROJECT_SKU} -/usr/local/share/doc/${PROJECT_SKU}/copyright -/usr/local/share/man/man1/${PROJECT_SKU}.1.gz -" + RPM_Register "$_directory" "$___source" "$___target" if [ $? -ne 0 ]; then I18N_Create_Failed return 1 @@ -168,9 +185,12 @@ install -m 0644 ${PROJECT_SKU}.1.gz %{buildroot}/usr/local/share/man/man1/ # NOTE: REQUIRED file - I18N_Create "copyright.gz" + ___source="copyright" + ___dest="${_directory}/BUILD/${___source}" + ___target="${_chroot}/share/doc/${PROJECT_SCOPE}/${PROJECT_SKU}/${___source}" + I18N_Create "$___source" COPYRIGHT_Create \ - "${_directory}/BUILD/copyright" \ + "$___dest" \ "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/licenses/deb-copyright" \ "$PROJECT_SKU" \ "$PROJECT_CONTACT_NAME" \ @@ -181,11 +201,20 @@ install -m 0644 ${PROJECT_SKU}.1.gz %{buildroot}/usr/local/share/man/man1/ return 1 fi + RPM_Register "$_directory" "$___source" "$___target" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + # NOTE: REQUIRED file - I18N_Create "MAN PAGES" + ___source="${PROJECT_SCOPE}-${PROJECT_SKU}.1" + ___dest="${_directory}/BUILD/${___source}" + ___target="${_chroot}/share/man/man1/${___source}" + I18N_Create "$___source" MANUAL_Create \ - "${_directory}/BUILD/${PROJECT_SKU}.1" \ + "$___dest" \ "$PROJECT_SKU" \ "$PROJECT_CONTACT_NAME" \ "$PROJECT_CONTACT_EMAIL" \ @@ -195,6 +224,12 @@ install -m 0644 ${PROJECT_SKU}.1.gz %{buildroot}/usr/local/share/man/man1/ return 1 fi + RPM_Register "$_directory" "$___source" "$___target" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + # NOTE: OPTIONAL (Comment to turn it off) I18N_Create "source.repo" diff --git a/src/.ci/_package-rpm_windows-any.ps1 b/src/.ci/_package-rpm_windows-any.ps1 index 861c293..ebeceff 100644 --- a/src/.ci/_package-rpm_windows-any.ps1 +++ b/src/.ci/_package-rpm_windows-any.ps1 @@ -21,6 +21,9 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { . "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\zip.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\rpm.ps1" @@ -44,56 +47,113 @@ function PACKAGE-Assemble-RPM-Content { }} + # execute + ## determine base path + ## TIP: (1) by design, usually is: usr/local/ + ## (2) please avoid: usr/, usr/{TYPE}/, usr/bin/, & usr/lib{TYPE}/ + ## whenever possible for avoiding conflicts with your OS native + ## system packages. + $_chroot = "usr" + if ("$(STRINGS-To-Lowercase "$PROJECT_DEBIAN_IS_NATIVE")" -eq "true") { + $_chroot = "${_chroot}/local" + } + $_gpg_keyring = "${env:PROJECT_SKU}" if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { return 10 # not applicable } elseif ($(FS-Is-Target-A-Docs "${_target}") -eq 0) { return 10 # not applicable } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { - # copy main libary - # TIP: (1) usually is: usr/local/lib - # (2) please avoid: lib/, lib{TYPE}/ usr/lib/, and usr/lib{TYPE}/ - $_filepath = "${_directory}\BUILD\lib${env:PROJECT_SKU}.a" - $null = I18N-Copy "${_target}" "${_filepath}" - $___process = FS-Make-Housing-Directory "${_filepath}" - if ($___process -ne 0) { - $null = I18N-Copy-Failed - return 1 - } - - $___process = FS-Copy-File "${_target}" "${_filepath}" - if ($___process -ne 0) { - $null = I18N-Copy-Failed - return 1 - } - - - # generate AutomataCI's required RPM spec instructions (INSTALL) - $__file = "${_directory}\SPEC_INSTALL" - $null = I18N-Create "${__file}" - $___process = FS-Write-File "${__file}" @" -install --directory %{buildroot}/usr/local/lib/${env:PROJECT_SKU} -install -m 0644 lib${env:PROJECT_SKU}.a %{buildroot}/usr/local/lib/${env:PROJECT_SKU} - -install --directory %{buildroot}/usr/local/share/doc/lib${env:PROJECT_SKU}/ -install -m 0644 copyright %{buildroot}/usr/local/share/doc/lib${env:PROJECT_SKU}/ -"@ - if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 - } - - - # generate AutomataCI's required RPM spec instructions (FILES) - $__file = "${_directory}\SPEC_FILES" - $null = I18N-Create "${__file}" - $___process = FS-Write-File "${__file}" @" -/usr/local/lib/${env:PROJECT_SKU}/lib${env:PROJECT_SKU}.a -/usr/local/share/doc/lib${env:PROJECT_SKU}/copyright -"@ - if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 + if ($(FS-Is-Target-A-NPM "${_target}" -eq 0)) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-TARGZ "${_target}" -eq 0)) { + # unpack library + $___source = "${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + $___dest = "${_directory}\BUILD\${___source}" + $___target = "${_chroot}\lib\${___source}" + + $null = I18N-Assemble "${_target}" "${___dest}" + $null = FS-Make-Directory "${___dest}" + $___process = TAR-Extract-GZ "${___dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $___process = RPM-Register ` + "${_directory}" ` + "${___source}" ` + "${___target}" ` + "true" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-TARXZ "${_target}" -eq 0)) { + # unpack library + $___source = "${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + $___dest = "${_directory}\BUILD\${___source}" + $___target = "${_chroot}\lib\${___source}" + + $null = I18N-Assemble "${_target}" "${___dest}" + $null = FS-Make-Directory "${___dest}" + $___process = TAR-Extract-XZ "${___dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $___process = RPM-Register ` + "${_directory}" ` + "${___source}" ` + "${___target}" ` + "true" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-ZIP "${_target}" -eq 0)) { + # unpack library + $___source = "${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + $___dest = "${_directory}\BUILD\${___source}" + $___target = "${_chroot}\lib\${___source}" + + $null = I18N-Assemble "${_target}" "${___dest}" + $null = FS-Make-Directory "${___dest}" + $___process = ZIP-Extract "${___dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $___process = RPM-Register ` + "${_directory}" ` + "${___source}" ` + "${___target}" ` + "true" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } else { + # copy library file + $___source = "$(FS-Get-File "${_target}")" + $___dest = "${_directory}\BUILD\${___source}" + $___target = "${_chroot}\lib\${___source}" + + $null = I18N-Assemble "${_target}" "${___dest}" + $null = FS-Make-Directory "${___dest}" + $___process = FS-Copy-File "${_target}" "${___dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $___process = RPM-Register "${_directory}" "${___source}" "${___target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } } $_gpg_keyring = "lib${env:PROJECT_SKU}" @@ -112,56 +172,23 @@ install -m 0644 copyright %{buildroot}/usr/local/share/doc/lib${env:PROJECT_SKU} return 10 # not applicable } elseif ($(FS-Is-Target-A-PDF "${_target}") -eq 0) { return 10 # not applicable - } elseif ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { - return 10 # not applicable } else { # copy main program - # TIP: (1) usually is: usr/local/bin or usr/local/sbin - # (2) please avoid: bin/, usr/bin/, sbin/, and usr/sbin/ - $_filepath = "${_directory}\BUILD\${env:PROJECT_SKU}" - $null = I18N-Copy "${_target}" "${_filepath}" - $___process = FS-Make-Housing-Directory "${_filepath}" - if ($___process -ne 0) { - $null = I18N-Copy-Failed - return 1 - } + $___source = "$(FS-Get-File "${_target}")" + $___dest = "${_directory}\BUILD\${___source}" + $___target = "${_chroot}\lib\${___source}" - $___process = FS-Copy-File "${_target}" "${_filepath}" + $null = I18N-Assemble "${_target}" "${___dest}" + $null = FS-Make-Directory "${___dest}" + $___process = FS-Copy-File "${_target}" "${___dest}" if ($___process -ne 0) { - $null = I18N-Copy-Failed + $null = I18N-Assemble-Failed return 1 } - - # generate AutomataCI's required RPM spec instructions (INSTALL) - $__file = "${_directory}\SPEC_INSTALL" - $null = I18N-Create "${__file}" - $___process = FS-Write-File "${__file}" @" -install --directory %{buildroot}/usr/local/bin -install -m 0755 ${env:PROJECT_SKU} %{buildroot}/usr/local/bin - -install --directory %{buildroot}/usr/local/share/doc/${env:PROJECT_SKU}/ -install -m 644 copyright %{buildroot}/usr/local/share/doc/${env:PROJECT_SKU}/ - -install --directory %{buildroot}/usr/local/share/man/man1/ -install -m 644 ${env:PROJECT_SKU}.1.gz %{buildroot}/usr/local/share/man/man1/ -"@ + $___process = RPM-Register "${_directory}" "${___source}" "${___target}" if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 - } - - - # generate AutomataCI's required RPM spec instructions (FILES) - $__file = "${_directory}\SPEC_FILES" - $null = I18N-Create "${__file}" - $___process = FS-Write-File "${__file}" @" -/usr/local/bin/${env:PROJECT_SKU} -/usr/local/share/doc/${env:PROJECT_SKU}/copyright -/usr/local/share/man/man1/${env:PROJECT_SKU}.1.gz -"@ - if ($___process -ne 0) { - $null = I18N-Create-Failed + $null = I18N-Assemble-Failed return 1 } @@ -170,14 +197,23 @@ install -m 644 ${env:PROJECT_SKU}.1.gz %{buildroot}/usr/local/share/man/man1/ # NOTE: REQUIRED file - $null = I18N-Create "copyright.gz" + $___source = "copyright" + $___dest = "${_directory}/BUILD/${___source}" + $___target = "${_chroot}/share/doc/${env:PROJECT_SCOPE}/${env:PROJECT_SKU}/${___source}" + $null = I18N-Create "${___source}" $___process = COPYRIGHT-Create ` - "${_directory}\BUILD\copyright" ` + "${___dest}" ` "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses\deb-copyright" ` - ${env:PROJECT_SKU} ` - ${env:PROJECT_CONTACT_NAME} ` - ${env:PROJECT_CONTACT_EMAIL} ` - ${env:PROJECT_CONTACT_WEBSITE} + "${env:PROJECT_SKU}" ` + "${env:PROJECT_CONTACT_NAME}" ` + "${env:PROJECT_CONTACT_EMAIL}" ` + "${env:PROJECT_CONTACT_WEBSITE}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + $___process = RPM-Register "${_directory}" "${___source}" "${___target}" if ($___process -ne 0) { $null = I18N-Create-Failed return 1 @@ -185,13 +221,22 @@ install -m 644 ${env:PROJECT_SKU}.1.gz %{buildroot}/usr/local/share/man/man1/ # NOTE: REQUIRED file - $null = I18N-Create "MAN PAGES" + $___source = "${env:PROJECT_SCOPE}-${env:PROJECT_SKU}.1" + $___dest = "${_directory}/BUILD/${___source}" + $___target = "${_chroot}/share/man/man1/${___source}" + $null = I18N-Create "${___source}" $___process = MANUAL-Create ` - "${_directory}\BUILD\${env:PROJECT_SKU}.1" ` - ${env:PROJECT_SKU} ` - ${env:PROJECT_CONTACT_NAME} ` - ${env:PROJECT_CONTACT_EMAIL} ` - ${env:PROJECT_CONTACT_WEBSITE} + "${___dest}" ` + "${env:PROJECT_SKU}" ` + "${env:PROJECT_CONTACT_NAME}" ` + "${env:PROJECT_CONTACT_EMAIL}" ` + "${env:PROJECT_CONTACT_WEBSITE}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + $___process = RPM-Register "${_directory}" "${___source}" "${___target}" if ($___process -ne 0) { $null = I18N-Create-Failed return 1 diff --git a/src/.ci/package_unix-any.sh b/src/.ci/package_unix-any.sh index 83a6d86..e81727d 100644 --- a/src/.ci/package_unix-any.sh +++ b/src/.ci/package_unix-any.sh @@ -28,8 +28,8 @@ fi . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-flatpak_unix-any.sh" . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-homebrew_unix-any.sh" . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-ipk_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-lib_unix-any.sh" . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-msi_unix-any.sh" -. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-npm_unix-any.sh" . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-pdf_unix-any.sh" . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-pypi_unix-any.sh" . "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-rpm_unix-any.sh" diff --git a/src/.ci/package_windows-any.ps1 b/src/.ci/package_windows-any.ps1 index dfb0de3..6423336 100644 --- a/src/.ci/package_windows-any.ps1 +++ b/src/.ci/package_windows-any.ps1 @@ -27,8 +27,8 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-flatpak_windows-any.ps1" . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-homebrew_windows-any.ps1" . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-ipk_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-lib_windows-any.ps1" . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-msi_windows-any.ps1" -. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-npm_windows-any.ps1" . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-pdf_windows-any.ps1" . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-pypi_windows-any.ps1" . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-rpm_windows-any.ps1" diff --git a/srcNODE/.ci/build_unix-any.sh b/srcNODE/.ci/build_unix-any.sh index a8702d9..9e6dcad 100644 --- a/srcNODE/.ci/build_unix-any.sh +++ b/srcNODE/.ci/build_unix-any.sh @@ -191,8 +191,9 @@ if [ $___process -ne 0 ]; then fi ### IMPORTANT: npm only recognizes .tgz file extension so rename it accordingly. +### Also, keep the lib- prefix -NPM for CI identification purposes. ___source="$___dest" -___dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}/${PROJECT_SKU}_js-js.tgz" +___dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}/lib${PROJECT_SKU}-NPM_js-js.tgz" FS_Remove_Silently "$___dest" FS_Move "$___source" "$___dest" if [ $___process -ne 0 ]; then diff --git a/srcNODE/.ci/build_windows-any.ps1 b/srcNODE/.ci/build_windows-any.ps1 index dd228ad..f335960 100644 --- a/srcNODE/.ci/build_windows-any.ps1 +++ b/srcNODE/.ci/build_windows-any.ps1 @@ -186,8 +186,9 @@ if ($___process -ne 0) { } ### IMPORTANT: npm only recognizes .tgz file extension so rename it accordingly. +### Also, keep the lib- prefix -NPM for CI identification purposes. $___source = "${___dest}" -$___dest = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}\${env:PROJECT_SKU}_js-js.tgz" +$___dest = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}\lib${env:PROJECT_SKU}-NPM_js-js.tgz" $null = FS-Remove-Silently "${___dest}" $___process = FS-Move "${___source}" "${___dest}" if ($___process -ne 0) {