diff --git a/.github/workflows/git-push.yml b/.github/workflows/git-push.yml index 0a86c720..b8f2960f 100644 --- a/.github/workflows/git-push.yml +++ b/.github/workflows/git-push.yml @@ -28,7 +28,7 @@ jobs: CONTAINER_PASSWORD: ${{ secrets.CONTAINER_PASSWORD }} TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - PROJECT_SIMULATE_RELEASE_REPO: true + PROJECT_SIMULATE_RUN: true PROJECT_ROBOT_RUN: true PROJECT_ROBOT_GITHUB_TOKEN: "${{ github.token }}" steps: diff --git a/CONFIG.toml b/CONFIG.toml index 9ff440be..42775cb9 100644 --- a/CONFIG.toml +++ b/CONFIG.toml @@ -20,14 +20,14 @@ # This is the known product ID used as a command, marketing brand, etc. # It should be in lowercase and should not be using dash ('-'), # underscore ('_'), and space (' ') for maximum compatibility. -PROJECT_SKU = "automataci" +PROJECT_SKU = 'automataci' # PROJECT_SKU_TITLECASE # The titlecase version of PROJECT_SKU. Used in certain packager control scripts # like Homebrew. Conditions is the same as PROJECT_SKU except it is in the # TitleCase representation. -PROJECT_SKU_TITLECASE = "AutomataCI" +PROJECT_SKU_TITLECASE = 'AutomataCI' # PROJECT_APP_ID @@ -36,7 +36,11 @@ PROJECT_SKU_TITLECASE = "AutomataCI" # must be a reversed domain with no dash ('-') and underscore ('_'). For GitHub # projects, it's advisable to use 'io.github.[owner].[project]' format instead # to avoid naming conflict. -PROJECT_APP_ID = "com.github.chewkeanho.automataci" +# +# Some examples: +# 1. 'com.github.[USERNAME].[PROJECT]' (https://github.com/[USERNAME]/[PROJECT]) +# 2. 'com.example.app' (https://app.example.com) +PROJECT_APP_ID = 'com.github.chewkeanho.automataci' # PRODUCT_APP_UUID @@ -60,7 +64,7 @@ PROJECT_APP_ID = "com.github.chewkeanho.automataci" # This is commonly used in product ID like MSI packaging where it is used as the # UPGRADE_CODE designating a possible upgrade installation against the same # product line or PRODUCT ID. -PRODUCT_APP_UUID = "76C7A54E-7360-CB70-1A5E-44D8A00CCB30" +PRODUCT_APP_UUID = '76C7A54E-7360-CB70-1A5E-44D8A00CCB30' # PROJECT_NAME @@ -72,7 +76,7 @@ PROJECT_NAME = "Chew Kean Ho's AutomataCI" # PROJECT_PITCH # A short elevator pitch about the project used as a short description. Max # Max: 60 characters. -PROJECT_PITCH = "A redistributable & semi-autonomous CI infrastructure." +PROJECT_PITCH = 'One Peaceful Frontend+Backend Software Library Suite.' # PROJECT_VERSION @@ -85,57 +89,62 @@ PROJECT_PITCH = "A redistributable & semi-autonomous CI infrastructure." # like '0.0.1~rc1' instead of dashes (-). Some distribution ecosystem have # strict and reserved rules for version sorting using dashes so tlide will be # the best choice. -PROJECT_VERSION = "2.2.0" +PROJECT_VERSION = '3.0.0' # PROJECT_CADENCE # The build cadence number usually to indicate the multiple builds of the same -# version like '12312' where some packager will generate the final version -# number as: '0.0.1-rc1-12312' or '0.0.1-12312'. +# version like '12312' where some packager (e.g. RPM) will generate the final +# version number as: '0.0.1-rc1-12312' or '0.0.1-12312'. # -# When it doubt or unused, set to 1 and use numerical increment only. -PROJECT_CADENCE = "1" +# When it doubt or unused, set/reset to 1 and only increment when there is an +# actual need. +PROJECT_CADENCE = '1' # PROJECT_LICENSE # The SPDX license tag. Refer https://spdx.org/licenses/ for finding or # constructing your license identifier. -PROJECT_LICENSE = "Apache-2.0" +PROJECT_LICENSE = 'Apache-2.0' # PROJECT_SCOPE -# The scope of the project being housed in (e.g. +# The ownership of the project being housed working as a scoping domain. (e.g. # GitHub Username|Organization Name, NPMJS scope, etc). This is required for -# certain packages' ecosystems such as but not limited to NPM. -PROJECT_SCOPE = "chewkeanho" +# certain packages' ecosystems such as but not limited to NPM. In certain cases, +# this field is commonly combined with PROJECT_SKU to form the full ID complying +# to '${PROJECT_SCOPE}-${PROJECT_SKU}' pattern. +# +# This field shall not be left empty. +PROJECT_SCOPE = 'chewkeanho' # PROJECT_CONTACT_BRAND # Contact Entity's short brand name. It should be in lowercase and should not be # using dash ('-'), underscore ('_'), and space (' ') for maximum compatibility. -PROJECT_CONTACT_BRAND = "chewkeanho" +PROJECT_CONTACT_BRAND = 'chewkeanho' # PROJECT_CONTACT_BRAND_TITLECASE # The titlecase version of PROJECT_CONTACT_BRAND. Used in certain packager # control scripts like MSI. Conditions is the same as PROJECT_CONTACT_BRAND # except it is in the TitleCase representation. -PROJECT_CONTACT_BRAND_TITLECASE = "ChewKeanHo" +PROJECT_CONTACT_BRAND_TITLECASE = 'ChewKeanHo' # PROJECT_CONTACT_NAME # Entity's full name for inquiries. -PROJECT_CONTACT_NAME = "(Holloway) Chew, Kean Ho" +PROJECT_CONTACT_NAME = '(Holloway) Chew, Kean Ho' # PROJECT_CONTACT_EMAIL # Entity's email channel for email communications. -PROJECT_CONTACT_EMAIL = "hello@hollowaykeanho.com" +PROJECT_CONTACT_EMAIL = 'hello@hollowaykeanho.com' # PROJECT_CONTACT_WEBSITE # Entity's website channel for sourcing information. -PROJECT_CONTACT_WEBSITE = "https://github.com/ChewKeanHo/AutomataCI" +PROJECT_CONTACT_WEBSITE = 'https://github.com/ChewKeanHo/AutomataCI' # PROJECT_SOURCE_URL @@ -147,7 +156,7 @@ PROJECT_CONTACT_WEBSITE = "https://github.com/ChewKeanHo/AutomataCI" # # Example: # 1. GitHub Packages : https://github.com/OWNER/REPO -PROJECT_SOURCE_URL = "https://github.com/ChewKeanHo/AutomataCI" +PROJECT_SOURCE_URL = 'https://github.com/ChewKeanHo/AutomataCI' # PROJECT_SOURCE_GIT_REMOTE @@ -181,8 +190,8 @@ PROJECT_README = 'README.md' # The relative location of the project license file from $PROJECT_PATH_ROOT # (repository root directory). # -# Default is 'LICENSE.txt' -PROJECT_LICENSE_FILE = 'LICENSE.txt' +# Default is 'LICENSE.pdf' +PROJECT_LICENSE_FILE = 'LICENSE.pdf' # PROJECT_LICENSE_ACCEPTANCE_REQUIRED @@ -202,11 +211,11 @@ PROJECT_LICENSE_ACCEPTANCE_REQUIRED = 'true' # to this format: # {iso639-1}[-{iso15954}] # Examples: -# en – International English. (Default & Fallback) -# fr – International French. -# zh-hans – International Simplified Chinese. -# zh-hant – International Traditional Chinese. -AUTOMATACI_LANG = "" +# 'en' – International English. (Default & Fallback) +# 'fr' – International French. +# 'zh-hans' – International Simplified Chinese. +# 'zh-hant' – International Traditional Chinese. +AUTOMATACI_LANG = '' @@ -239,7 +248,7 @@ PROJECT_ANGULAR = '' # # To enable it: simply supply the path (e.g. default is 'srcBOOK'). # To disable it: simply supply an empty path (e.g. default is ''). -PROJECT_BOOK = 'srcBOOK' +PROJECT_BOOK = '' @@ -259,6 +268,16 @@ PROJECT_BOOK = 'srcBOOK' PROJECT_C = '' +# PROJECT_C_BRANCH_TAG +# This is for technology tagging purposes such as but not limited to release +# branches identification. The value shall always be lowercase, short, and +# directly identify it is C technology. +# +# Default is: 'c' +# To disable: set it empty '' +PROJECT_C_BRANCH_TAG = 'c' + + ###################### @@ -270,14 +289,14 @@ PROJECT_C = '' # # To enable it, simply simply the supported version. Default is '1.2.0'. # To dsiable it, simply leave it empty. -PROJECT_CITATION="1.2.0" +PROJECT_CITATION='1.2.0' # PROJECT_CITATION_TYPE # The type's field value of the repository representing the content of it. # # Can only accept 'software' or 'dataset'. Default is 'software'. -PROJECT_CITATION_TYPE="software" +PROJECT_CITATION_TYPE='software' @@ -306,7 +325,7 @@ PROJECT_DOTNET = '' # PROJECT_PATH_DOTNET_ENGINE # This is a relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_TOOLS for # setting up .NET localized directory. -PROJECT_PATH_DOTNET_ENGINE = "dotnet-engine" +PROJECT_PATH_DOTNET_ENGINE = 'dotnet-engine' # PROJECT_DOTNET_CHANNEL @@ -317,7 +336,7 @@ PROJECT_PATH_DOTNET_ENGINE = "dotnet-engine" # https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script # # When in doubt, use "LTS" -PROJECT_DOTNET_CHANNEL = "LTS" +PROJECT_DOTNET_CHANNEL = 'LTS' # DOTNET_CLI_TELEMETRY_OPTOUT @@ -329,7 +348,7 @@ PROJECT_DOTNET_CHANNEL = "LTS" # # To enable: "1" # To disable: commit it out. -DOTNET_CLI_TELEMETRY_OPTOUT = "1" +DOTNET_CLI_TELEMETRY_OPTOUT = '1' # PROJECT_PATH_NUPKG @@ -337,7 +356,7 @@ DOTNET_CLI_TELEMETRY_OPTOUT = "1" # PROJECT_PATH_DOTNET_ENGINE for for housing .NET nupkg packages. At AutomataCI, # .nupkg (a zip file) can be downloaded without depending on downloading the # entire .Net framework. -PROJECT_PATH_NUPKG = "nupkg" +PROJECT_PATH_NUPKG = 'nupkg' @@ -468,6 +487,7 @@ GOOGLEAI_BLOCK_HARASSMENT = 'BLOCK_NONE' # Do note that should the following technologies are enabled, LibreOffice shall # be installed regardless of this control variable: # (1) PROJECT_RESEARCH - using Libreoffice by default. +# (2) PROJECT_BOOK - using Libreoffice by default. # # To enable it: simply supply the path (e.g. default is 'srcLIBREOFFICE'). # To disable it: simply supply an empty path (e.g. default is ''). @@ -482,7 +502,7 @@ PROJECT_LIBREOFFICE = '' # # Refer to the following mirror list for value selection: # (1) https://download.documentfoundation.org/mirmon/allmirrors.html -PROJECT_LIBREOFFICE_MIRROR = "https://download.documentfoundation.org/libreoffice" +PROJECT_LIBREOFFICE_MIRROR = 'https://download.documentfoundation.org/libreoffice' # PROJECT_LIBREOFFICE_VERSION # This is for defining the LibreOffice version to install into the local OS. @@ -491,13 +511,13 @@ PROJECT_LIBREOFFICE_MIRROR = "https://download.documentfoundation.org/libreoffic # (1) https://www.libreoffice.org/download/download-libreoffice/ # # Example: '24.4.3' for 'LibreOffice 24.4.3' -PROJECT_LIBREOFFICE_VERSION = "24.2.3" +PROJECT_LIBREOFFICE_VERSION = '24.2.3' # PROJECT_PATH_LIBREOFFICE_ENGINE # This is a relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_TOOLS for # setting up localized environment. -PROJECT_PATH_LIBREOFFICE_ENGINE = "libreoffice-engine" +PROJECT_PATH_LIBREOFFICE_ENGINE = 'libreoffice-engine' @@ -520,7 +540,7 @@ PROJECT_GO = '' # PROJECT_PATH_GO_ENGINE # This is a relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_TOOLS for # setting up localized environment. -PROJECT_PATH_GO_ENGINE = "go-engine" +PROJECT_PATH_GO_ENGINE = 'go-engine' @@ -543,7 +563,7 @@ PROJECT_NIM = '' # PROJECT_PATH_NIM_ENGINE # This is a relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_TOOLS for # setting up localized environment. -PROJECT_PATH_NIM_ENGINE = "nim-engine" +PROJECT_PATH_NIM_ENGINE = 'nim-engine' @@ -560,13 +580,13 @@ PROJECT_PATH_NIM_ENGINE = "nim-engine" # # To enable it: simply supply the path (e.g. default is 'srcNODE'). # To disable it: simply supply an empty path (e.g. default is ''). -PROJECT_NODE = 'srcNODE' +PROJECT_NODE = '' # PROJECT_PATH_NODE_ENGINE # This is a relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_TOOLS for # setting up localized virtual environment. -PROJECT_PATH_NODE_ENGINE = "node-engine" +PROJECT_PATH_NODE_ENGINE = 'node-engine' # PROJECT_NODE_VERSION @@ -637,25 +657,25 @@ PROJECT_PYTHON = '' # PROJECT_PATH_PYTHON_ENGINE # This is a relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_TOOLS for # setting up venv location. -PROJECT_PATH_PYTHON_ENGINE = "python-engine" +PROJECT_PATH_PYTHON_ENGINE = 'python-engine' # PROJECT_PYPI_REPO_URL # The PyPi upstream repo to push the PyPi package. The defualt PyPi values are: # Test Zone : https://test.pypi.org/legacy/ # Actual : https://upload.pypi.org/legacy/ -PROJECT_PYPI_REPO_URL = "https://test.pypi.org/legacy/" +PROJECT_PYPI_REPO_URL = 'https://test.pypi.org/legacy/' # PROJECT_PYPI_README # The PyPi README file relative to PROJECT_PATH_ROOT directory. Default is the # the common README.md. It **MUST** be a file. -PROJECT_PYPI_README = "README.md" +PROJECT_PYPI_README = 'README.md' # PROJECT_PYPI_README_MIME # The PyPi README file's MIME type data. Default is 'text/markdown'. -PROJECT_PYPI_README_MIME = "text/markdown" +PROJECT_PYPI_README_MIME = 'text/markdown' @@ -713,37 +733,37 @@ PROJECT_RUST_EDITION = '2021' # PROJECT_PATH_RUST_ENGINE # This is a relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_TOOLS for # setting up localized environment. -PROJECT_PATH_RUST_ENGINE = "rust-engine" +PROJECT_PATH_RUST_ENGINE = 'rust-engine' # PROJECT_CARGO_README # The Cargo README file relative to PROJECT_PATH_ROOT directory. Default is the # the common README.md. It **MUST** be a file. -PROJECT_CARGO_README = "README.md" +PROJECT_CARGO_README = 'README.md' # CARGO_REGISTRY # The Cargo registry. # # Default is: crates-io -CARGO_REGISTRY = "crates-io" +CARGO_REGISTRY = 'crates-io' ########################## -# DISTRIBUTION ECOSYSTEM # +# DISTRIBUTION - ALL # ########################## # PROJECT_CHANGELOG_TITLE # The title of the changelog file. -PROJECT_CHANGELOG_TITLE = "Changelog | 更新日志 | Endringslogg | Cacatan Perubahan | Ändringslogg | 変更履歴" +PROJECT_CHANGELOG_TITLE = 'Changelog | 更新日志 | Endringslogg | Cacatan Perubahan | Ändringslogg | 変更履歴' # PROJECT_RELEASE_SHA256 # Perform SHA256 checksum file generation in Release job. To disable it, simply # let it empty. # # Otherwise, as long as it's not empty, it is enabled. -PROJECT_RELEASE_SHA256 = "enabled" +PROJECT_RELEASE_SHA256 = 'enabled' # PROJECT_RELEASE_SHA512 @@ -751,19 +771,312 @@ PROJECT_RELEASE_SHA256 = "enabled" # empty. # # Otherwise, as long as it's not empty, it is enabled. -PROJECT_RELEASE_SHA512 = "enabled" +PROJECT_RELEASE_SHA512 = 'enabled' + + +# PROJECT_SIMULATE_RUN +# A flag to indicate this CI job run is to be simulated (or 'dry run'). +# Depending on job, this disables certain non-resersible, critical, or high +# stake tasks (e.g. gpg-signing, release conclusion etc) and replace it with a +# simple simulation run. +# +# It is made primarily for local CI job run testing and for full automated run +# like GitHub Actions or GitLab CI. +# +# To enable, simply declare the environment variable non-empty value (e.g. 'true'). +# To disable: leave it empty. +# +# PROJECT_SIMULATE_RUN = '' # Reserved - provided externally via environment variable. + + +# PROJECT_ROBOT_RUN +# A flag to indicate the run is operating inside a CI service by its +# autonomous robot. +# +# It is made primarily for local CI job run testing and for full automated run +# like GitHub Actions or GitLab CI. +# +# To enable, simply declare the environment variable non-empty value (e.g. 'true'). +# To disable: leave it empty. +# +# PROJECT_ROBOT_RUN = '' # Reserved - provided externally via environment variable. + + +# PROJECT_RELEASE_REPO_TYPE +# The type of release repository. Available options are: +# +# 1. 'git' - git repository +# 2. 'local' - a localized directory (for manual export elsewhere). +# +# Default is 'git'. +# Leaving it empty shall fallback to git repository. +PROJECT_RELEASE_REPO_TYPE = 'git' + + +# PROJECT_RELEASE_REPO +# The URL for setting the ${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE} directory +# as a single unified repository rather than manage each of the release repos +# individually. This is designed for Git-based publishing service providers like +# GitHub/GitLab Pages and etc. +# +# Setting this field shall overrides all the distributions' git url fields +# (e.g. PROJECT_RPM_REPO, PROJECT_DEB_REPO, etc) and will only push to this +# repo at the end of the release job conclusion. +# +# Default is empty '' (favoring flat-mode repositories) +PROJECT_RELEASE_REPO = '' + + +# PROJECT_RELEASE_REPO_KEY +# The git upstream key for PROJECT_RELEASE_REPO. This field cannot be left +# empty. +# +# Default is 'origin'. +PROJECT_RELEASE_REPO_KEY = 'origin' + + +# PROJECT_RELEASE_REPO_BRANCH +# The git upstream branch for PROJECT_RELEASE_REPO. This field cannot be left +# empty. +# +# Default is 'master' or 'main'. +PROJECT_RELEASE_REPO_BRANCH = 'master' + + +# PROJECT_RELEASE_ARCHIVE +# The flag to package archive (.tar.gz | .zip) files as output. +# +# To enable : fill in some string (e.g. 'enabled') +# To disable: leave it empty ('') +PROJECT_RELEASE_ARCHIVE = 'enabled' + + +# PROJECT_RELEASE_IPK +# The flag to package ipk pipeline. +# +# To enable : fill in some string (e.g. 'enabled') +# To disable: leave it empty ('') +PROJECT_RELEASE_IPK = 'enabled' + + +# PROJECT_RELEASE_MSI +# The flag to package msi pipeline. +# +# To enable : fill in some string (e.g. 'enabled') +# To disable: leave it empty ('') +PROJECT_RELEASE_IPK = 'enabled' + + + + +############################# +# DISTRIBUTION - CHOCOLATEY # +############################# +# PROJECT_CHOCOLATEY_URL +# The base URL for Chocolatey & end-users to source the .nupkg packages. This +# variable is also acting as a switch to enable/disable Chocolatey distribution +# pipeline. +# +# End user may track your upstream using this URL (as in the command: +# '$ choco source add -n name -s location'). More info: +# (1) https://docs.chocolatey.org/en-us/choco/commands/sources/ +# (2) https://docs.chocolatey.org/en-us/features/host-packages/ +# +# Some examples are: +# (1) GitHub Release: +# value: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download' +# actual URL: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download/[FILE]' +# +# To enable it: set the URL without the ending slash. +# To disable it: set it empty. +# +# !! IMPORTANT !! - Please avoid ending with the URL slash. +PROJECT_CHOCOLATEY_URL = 'https://github.com/ChewKeanHo/AutomataCI/releases/latest/download' + + + + +# PROJECT_CHOCOLATEY_VERSION +# The Chocolatey version as a dependency. This field SHALL NOT BE EMPTY. +# +# Default value is: '0.9.8.21' +PROJECT_CHOCOLATEY_VERSION = '0.9.8.21' + + + + +############################# +# DISTRIBUTION - CONTAINERS # +############################# +# PROJECT_CONTAINER_REGISTRY +# The container registry URI value without ending slash. This variable is also +# acting as a switch to enable/disable container distribution pipeline. +# +# Some examples: +# 1. DockerHub : registry.hub.docker.com/[ NAMESPACE ] +# 2. GitHub Package: ghcr.io/[ NAMESPACE ] +# 2. Local : localhost:5000/[ NAMESPACE ] +# +# To enable it: set the URI without the ending slash. +# To disable it: set it empty. +# +# !! IMPORTANT !! - Please avoid ending with the URL slash. +PROJECT_CONTAINER_REGISTRY = 'ghcr.io/chewkeanho' + + +# PROJECT_CONTAINER_BASE_WINDOWS +# The base Windows image of the container. If you wish to use bare scratch, set +# the value to 'scratch'. +# +# Default is: 'mcr.microsoft.com/windows/nanoserver:ltsc2022' +PROJECT_CONTAINER_BASE_WINDOWS = 'mcr.microsoft.com/windows/nanoserver:ltsc2022' + + +# PROJECT_CONTAINER_BASE_WINDOWS_ARCH +# The list of archiectures to be containerized and supported by the Windows base +# image. Leaving this field empty means accepts all which is usable for +# 'scratch' type base images. +# +# Each image is separated by a '|'. +# +# Default is: 'amd64' (mcr.microsoft.com/windows/nanoserver:ltsc2022) +PROJECT_CONTAINER_BASE_WINDOWS_ARCH = 'amd64' + + +# PROJECT_CONTAINER_BASE_LINUX +# The base Linux image of the container. If you wish to use bare scratch, set +# the value to 'scratch'. +# +# Default is: 'linuxcontainers/debian-slim:latest' +PROJECT_CONTAINER_BASE_LINUX = 'linuxcontainers/debian-slim:latest' + + +# PROJECT_CONTAINER_BASE_LINUX_ARCH +# The list of archiectures to be containerized and supported by the Linux base +# image. Leaving this field empty means accepts all which is usable for +# 'scratch' type base images. +# +# Each image is separated by a '|'. +# +# Default is: '386|amd64|arm64|ppc64le|s390x' (linuxcontainers/debian-slim:latest) +PROJECT_CONTAINER_BASE_LINUX_ARCH = '386|amd64|arm64|ppc64le|s390x' + + +# DOCKER_CLI_EXPERIMENTAL +# Enable the Docker's experimental CLI features for using buildx. If disabled, +# is shall break many of the CI job. +DOCKER_CLI_EXPERIMENTAL = 'enabled' + + + + +########################## +# DISTRIBUTION - DEB # +########################## +# PROJECT_DEB_URL +# The .debs' downloadable apt URL used for generating the +# /etc/apt/source.list.d/ source file. More info: +# (1) https://wiki.debian.org/DebianRepository/Format +# +# For flat repository mode (e.g. GitHub Release / GitLab Release), +# simply supply the URL without the last section of the pathing. For example: +# (1) GitHub Release: +# value: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest' +# actual URL: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download/[FILE]' +# +# This field also acts as the flag for enabling or disabling the deb pipeline. +# +# To enable : fill in the end-user downloadable URL without ending slash. +# To disable: leave this field empty (''). +# +# !! IMPORTANT !! - Please avoid ending with the URL slash. +PROJECT_DEB_URL = 'https://github.com/ChewKeanHo/AutomataCI/releases/latest' + + +# PROJECT_DEB_DISTRIBUTION +# The 'Suite' ('Suite: ' field) distribution series for grouping .deb pakages +# by major release. The value is used for generating changelog and for +# the .deb package repository processes. More info: +# https://www.debian.org/doc/debian-policy/ch-controlfields.html#id25 +# https://www.debian.org/doc/debian-policy/ch-source.html#debian-changelog-debian-changelog +# https://wiki.debian.org/DebianRepository/Format +# +# By default, the repository is operating in the conventional pool repository +# mode (with 'dist' and 'pool' sub-directories). To enable the flat repository +# mode (e.g. GitHub Release / GitLab Release), simply ends with a slash to +# indicate it is a directory. For example: +# (1) GitHub Release: +# value: 'download/' +# actual URL: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download/[FILE]' +# +# Otherwise, the default pool repository mode is implemented. In this case, when +# in doubt, the following values are recommended for the highest compatibilities +# with all Debian-based OSes: +# (1) 'stable' = for stable branch (e.g. 'main') +# (2) 'unstable' OR 'testing' = for next release branch (e.g 'staging', or +# 'next'). +# (3) 'experimental' = for latest branch (e.g 'experimental' or +# 'edge'). +PROJECT_DEB_DISTRIBUTION = 'download/' + + +# PROJECT_DEB_COMPONENT +# The value used by deb package repository for grouping packages by +# categorization. In any case, the value **MUST** match any one of the +# 'Component:' field understood by the apt package manager. +# +# This is mainly used to group the packages by categories (e.g. 'firmware', +# 'gui', 'models', etc). Some recommended values would be your repository +# functioning name (e.g. 'main', 'next', 'dev', etc.). +# +# When in doubt or usually unused, set the value to 'main'. +PROJECT_DEB_COMPONENT = 'main' + + +# PROJECT_DEB_CODENAME +# The value used by deb package repository for tagging a release series. In any +# case, the value **MUST** match any one of the 'Codename:' field understood by +# the apt package manager. Generally, Codename is used to symlink against +# Suite for unique identification or specific release version freezes. +# +# Example values from Debian are: 'experimental', 'sid', 'bookworm', 'wheeze', +# etc (toy story characters). +# +# When in doubt or unused, It is advisble to set the following values: +# (1) In flat repository: 'stable'. +# (2) In pool repository: 'stable' or same as PROJECT_DEB_DISTRIBUTION. +PROJECT_DEB_CODENAME = 'stable' -# PROJECT_DEBIAN_IS_NATIVE +# PROJECT_DEB_ARCH +# The list of overriding system architectures values for the deb package +# repository. It accepts a list of values separated by space (' ') based on +# dpkg supported architectures. The command: +# "$ dpkg-architecture --list-known" +# will print out a list of supported architectures' value based on the host +# system. +# +# Please keep in mind that the values are not used for gatekeeping purposes. +# When left empty, AutomataCI shall generate a full list from the existing +# published packages autonomously. +# +# By default and recommended, the value is empty '' for automation purposes. +PROJECT_DEB_ARCH = '' + + +# PROJECT_DEB_IS_NATIVE # Flag to determine the project is Debian natively sponsored package. Usually # is false. +# # Only accept: "true/false" -PROJECT_DEBIAN_IS_NATIVE = "false" +# +# Default is 'false'. +PROJECT_DEB_IS_NATIVE = 'false' -# PROJECT_DEBIAN_PRIORITY +# PROJECT_DEB_PRIORITY # Indicate the current package's distribution priority. Strictly the following -# values +# values arranged from highest priority to the lowest: # (1) required # (2) important # (3) standard @@ -771,245 +1084,404 @@ PROJECT_DEBIAN_IS_NATIVE = "false" # (5) extra # see https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities for # more info. -PROJECT_DEBIAN_PRIORITY = "optional" - - -# PROJECT_DEBIAN_DISTRIBUTION -# The distribution series for compiling the .deb pakage changelog. See this page -# for more info: -# https://www.debian.org/doc/debian-policy/ch-controlfields.html#id25 -# https://www.debian.org/doc/debian-policy/ch-source.html#debian-changelog-debian-changelog # -# Strictly of the following values: -# (1) stable = for stable branches (e.g. 'main') -# (2) unstable OR testing = for next release branches (e.g 'staging', or 'next'). -# (3) experimental = for latest branches (e.g 'experimental' or 'edge'). -PROJECT_DEBIAN_DISTRIBUTION = "stable" +# Default is 'optional'. +PROJECT_DEB_PRIORITY = 'optional' -# PROJECT_DEBIAN_URGENCY -# The urgency value for compiling the .deb pakage changelog. See this page +# PROJECT_DEB_URGENCY +# The urgency value used for compiling the .deb pakage changelog. See this page # for more info: # https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-urgency # https://www.debian.org/doc/debian-policy/ch-source.html#debian-changelog-debian-changelog # -# Strictly of the following values: -# (1) low -# (2) medium +# Strictly of the following values from highest attention to the lowest: +# (1) critical +# (2) emergency # (3) high = for user diversions -# (4) emergency -# (5) critical -PROJECT_DEBIAN_URGENCY = "low" +# (4) medium +# (5) low +# +# Default is 'low'. +PROJECT_DEB_URGENCY = 'low' -# PROJECT_DEBIAN_SECTION +# PROJECT_DEB_SECTION # The categories the project belongs to in the Debian .deb package ecosystem. # Contains restricted values. Refer: # https://www.debian.org/doc/debian-policy/ch-archive.html#sections # For maximum compliances -PROJECT_DEBIAN_SECTION = "devel" +PROJECT_DEB_SECTION = 'devel' -# PROJECT_FLATPAK_RUNTIME -# The runtime module where the Flatpak is operating on. -PROJECT_FLATPAK_RUNTIME = "org.freedesktop.Platform" +# PROJECT_DEB_REPO +# The git repository for publishing all .deb packages using a static file +# sharing service (e.g NGINX file hosting, GitHub/GitLab Pages, etc). When +# enabled, this repository URL shall be git clone into +# '$PROJECT_PATH_ROOT/$PROJECT_PATH_RELEASE' directory named as 'deb'. +# +# Note that if PROJECT_RELEASE_REPO is set, this field is ignored regardless of +# its value. +PROJECT_DEB_REPO = 'git@github.com:ChewKeanHo/AutomataCI.wiki.git' -# PROJECT_FLATPAK_RUNTIME_VERSION -# The runtime module where the Flatpak is operating on. -PROJECT_FLATPAK_RUNTIME_VERSION = "22.08" +# PROJECT_DEB_REPO_KEY +# The git upstream key. Value CANNOT be empty. +# +# Default is 'origin'. +PROJECT_DEB_REPO_KEY = 'origin' -# PROJECT_FLATPAK_SDK -# The runtime module where the Flatpak is operating on. -PROJECT_FLATPAK_SDK = "org.freedesktop.Sdk" +# PROJECT_DEB_REPO_BRANCH +# The git upstream branch. Value CANNOT be empty. +# +# Default is 'master' or 'main'. +PROJECT_DEB_REPO_BRANCH = 'master' -# PROJECT_REPREPRO_CODENAME -# The codename used by .deb's Reprepro for publishing any detected .deb package -# file. In any cases, the value **MUST** match any one of the 'Codename:' field -# understood by the reprepro. +# PROJECT_DEB_PATH +# The relative pathing for organizing within the debian repository directory. +# The path is always relative to +# '${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/deb' directory which is the +# PROJECT_DEB_REPO debian repository. This is useful for cases where specific +# directory is required (e.g. 'GitHub Pages using "docs/" directory for +# publications). +# +# If left empty, AutomataCI shall use 'deb' as its value. # -# When in doubt or unused, set the value to 'main'. -PROJECT_REPREPRO_CODENAME = "main" +# Default is 'deb'. +PROJECT_DEB_PATH = 'deb' -# PROJECT_REPREPRO_COMPONENT -# The component used by .deb's Reprepro for publishing any detected .deb package -# file. In any case, the value **MUST** match any one of the 'Component:' field -# understood by the reprepro. +# PROJECT_DEB_PATH_DATA +# The deb repository noDB database directory. This houses all the packages data +# for recursive compilations. When set, the pathing is strictly relative to +# '${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/data/deb' directory. # -# This is mainly used to group the packages by categories (e.g. 'firmware', -# 'gui', 'models', etc). +# Leaving it empty shall use a disposable database directory located in: +# '${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/releaser-deb-repoDB' pathing. # -# When in doubt or unused, set the value matching PROJECT_DEBIAN_DISTRIBUTION. -PROJECT_REPREPRO_COMPONENT = "stable" +# Default is 'repoDB' ('${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/data/deb/repoDB') +PROJECT_DEB_PATH_DATA = 'repoDB' -# PROJECT_REPREPRO_ARCH -# The list of accepted reprepro architecture used by .deb's Reprepro for -# gatekeeping a given .deb package. It accepts a list of values separated by -# space (' ') based on dpkg supported architectures. The command: -# "$ dpkg-architecture --list-known" -# will print out a list of supported architectures' value based on the host -# syste. + + +########################## +# DISTRIBUTION - DOCS # +########################## +# PROJECT_DOCS_URL +# The base URL for viewing the published documentation (e.g. website address). +# It is made available in-case of publication needs. # -# When left empty, AutomataCI shall generate a full list of arch-only hard-coded -# arch values. -PROJECT_REPREPRO_ARCH = "" +# This field also acts as the flag for enabling or disabling the documentation +# pipeline. +# +# To enable : fill in the end-user downloadable URL without ending slash. +# To disable: leave this field empty (''). +# +# !! IMPORTANT !! - Please avoid ending with the URL slash. +PROJECT_DOCS_URL = 'https://github.io/ChewKeanHo/AutomataCI' -# PROJECT_STATIC_REPO -# The git repository for publishing all the packages using static file sharing -# (e.g. .deb repo, .rpm repo, flatpak repo, etc). This URL shall be git cloned -# as the PROJECT_PATH_RELEASE directory. -PROJECT_STATIC_REPO = "git@github.com:ChewKeanHo/AutomataCI.wiki.git" +# PROJECT_DOCS_REPO +# The git repository for publishing all the docs web artifacts using a static +# file sharing service (e.g NGINX file hosting, GitHub/GitLab Pages, etc). +# This repository URL shall be git clone into +# '$PROJECT_PATH_ROOT/$PROJECT_PATH_RELEASE' directory internally named as +# 'x_docsrepo'. +# +# Note that regardless of PROJECT_RELEASE_REPO is set or otherwise, this repo +# shall be deleted automatically at the end of its operation, successful or +# otherwise to prevent output distortion. +PROJECT_DOCS_REPO = 'git@github.com:ChewKeanHo/AutomataCI.git' -# PROJECT_STATIC_REPO_KEY -# The git upstream key. Default is 'origin'. -PROJECT_STATIC_REPO_KEY = "origin" +# PROJECT_DOCS_REPO_KEY +# The git upstream key. Value CANNOT be empty. +# +# Default is 'origin'. +PROJECT_DOCS_REPO_KEY = 'origin' -# PROJECT_STATIC_REPO_BRANCH -# The git upstream branch. Default is 'master' or 'main'. -PROJECT_STATIC_REPO_BRANCH = "master" +# PROJECT_DOCS_REPO_BRANCH +# The git upstream branch. Value CANNOT be empty. +# +# For Website service provider using git version control system such as but not +# limited to GitHub/GitLab Pages, it is always advisable to implement 'gh-pages' +# (default settings) instead of other means. Otherwise, if the repository is +# a standalone one (e.g. [USERNAME].github.io repository as root profile) +# website, then standard branch name is used. +# +# Default is 'gh-pages'. +PROJECT_DOCS_REPO_BRANCH = 'gh-pages' -# PROJECT_STATIC_REPO_DIRECTORY -# The directory name housing the static repo. Value CANNOT be empty. -# Default is 'static'. -PROJECT_STATIC_REPO_DIRECTORY = "static" -# PROJECT_SIMULATE_RELEASE_REPO -# A flag to disable PROJECT_STATIC_REPO supplied from an external automated -# ecosystem to construct a simulated blank repository instead of sourcing. This -# is made primarily created for situation where release repository has complex -# security access or the ecosystem is not using Release Job at all (e.g. GitHub -# Actions). +########################## +# DISTRIBUTION - FLATPAK # +########################## +# PROJECT_FLATPAK_URL +# The base URL for Flatpak to download its associated .flatpak package payload. +# This variable is also acting as a switch to enable/disable Flatpak +# distribution pipeline. +# +# AutomataCI will always compile "Single File Bundles" distribution channel by +# default. Should PROJECT_FLATPAK_REPO is set, then AutomataCI shall also +# compile and update the "Repository" distribution channel. More info: +# 1. https://docs.flatpak.org/en/latest/repositories.html +# +# In the event where "Repository" distribution channel is set +# (PROJECT_FLATPAK_REPO), then the URL shall be pointing to the repository URL +# instead of the "Single File Bundles" downlodable portal version. The value +# shall be used for creating .flakpakrepo and .flatpakref files respectively. +# +# Some examples are: +# (1) GitHub Release (Single Bundle channel only): +# value: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download' +# actual URL: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download/[FILE]' +# +# (2) GitHub Pages (Single Bundle channel + Repository): +# value: 'https://[USERNAME]github.io/flatpak/[PROJECT].flatpakrepo' +# actual URL: 'https://[USERNAME]github.io/flatpak/[PROJECT].flatpakrepo' +# +# (3) Other static file hosting services (Single Bundle channel + Repository): +# value: 'https://www.example.com/flatpak/[PROJECT].flatpakrepo' +# actual URL: 'https://www.example.com/flatpak/[PROJECT].flatpakrepo' +# +# This field also acts as the flag for enabling or disabling the flatpak +# pipeline. # -# PROJECT_SIMULATE_RELEASE_REPO = "" # Reserved - provided externally. +# To enable it: set the URL without the ending slash. +# To disable it: set it empty. +# +# !! IMPORTANT !! - Please avoid ending with the URL slash. +PROJECT_FLATPAK_URL = 'https://github.com/ChewKeanHo/AutomataCI/releases/latest/download' -# PROJECT_ROBOT_RUN -# A flag to indicate the run is operating inside a CI service by its -# autonomous robot. +# PROJECT_FLATPAK_REPO +# The Flatpak publication git repository for updating and publishing +# Flatpak packages repository. AutomataCI will always use the temporary +# directory for all flatpak packaging operations at: +# $PROJECT_PATH_ROOT/$PROJECT_PATH_TEMP/flatpak-repo +# until it is being moved to the release job when set. # -# PROJECT_ROBOT_RUN = "" # Reserved - provided externally. +# This field also acts as a flag for enabling "Repository" distribution channel +# when PROJECT_FLATPAK_URL is set. +# +# To enable it: set the URL without the ending slash. +# To disable it: set it empty. +# +# In the event where PROJECT_RELEASE_REPO is set, this repo shall be ignored. +# However, to maintain enabling the "Repository" distribution channel packaging +# decision, this field shall have the same value as PROJECT_RELEASE_REPO. +PROJECT_FLATPAK_REPO = 'git@github.com:ChewKeanHo/AutomataCI.wiki.git' -# PROJECT_STATIC_URL -# The public facing base URL for accessing the published static repo. This URL -# shall be used to construct the final user instructions across various -# distribution ecosystems. -PROJECT_STATIC_URL = "https://github.com/ChewKeanHo/AutomataCI/wiki/" +# PROJECT_FLATPAK_PATH +# The relative pathing for organizing within the flatpak repository directory. +# when "Repository" distribution channel is set. +# The path is always relative to +# '${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/flatpak' directory which is the +# PROJECT_FLATPAK_REPO debian repository. This is useful for cases where +# specific directory is required (e.g. 'GitHub Pages using "docs/" directory +# for publications). +# +# If left empty, AutomataCI shall use 'flatpak' as its value. +# +# Default is 'flatpak'. +PROJECT_FLATPAK_PATH = 'flatpak' -# PROJECT_CONTAINER_REGISTRY -# The container registry URI value. DO NOT end with a slash. Example: -# 1. DockerHub : registry.hub.docker.com/[ NAMESPACE ] -# 2. GitHub Package: ghcr.io/[ NAMESPACE ] -# 2. Local : localhost:5000/[ NAMESPACE ] -PROJECT_CONTAINER_REGISTRY = "ghcr.io/chewkeanho" +# PROJECT_FLATPAK_REPO_KEY +# The git upstream key. Value CANNOT be empty. +# +# Default is 'origin'. +PROJECT_FLATPAK_REPO_KEY = 'origin' -# DOCKER_CLI_EXPERIMENTAL -# Enable the Docker's experimental CLI features for using buildx. If disabled, -# is shall break many of the CI job. -DOCKER_CLI_EXPERIMENTAL = "enabled" +# PROJECT_FLATPAK_REPO_BRANCH +# The git upstream branch. Value CANNOT be empty. +# +# Default is 'main' or 'master'. +PROJECT_FLATPAK_REPO_BRANCH = 'master' -# PROJECT_HOMEBREW_REPO -# The Homebrew formula publication git repository for updating and publishing -# Homebrew's formula. This is used in release job. -PROJECT_HOMEBREW_REPO = "git@github.com:ChewKeanHo/Testbed.git" +# PROJECT_FLATPAK_RUNTIME +# The runtime module where the Flatpak is operating on. +PROJECT_FLATPAK_RUNTIME = 'org.freedesktop.Platform' -# PROJECT_HOMEBREW_REPO_KEY -# The git upstream key. Default is 'origin'. -PROJECT_HOMEBREW_REPO_KEY = "origin" +# PROJECT_FLATPAK_RUNTIME_VERSION +# The runtime module where the Flatpak is operating on. +PROJECT_FLATPAK_RUNTIME_VERSION = '22.08' -# PROJECT_HOMEBREW_REPO_BRANCH -# The git upstream branch. Default is 'main' or 'master'. -PROJECT_HOMEBREW_REPO_BRANCH = "main" +# PROJECT_FLATPAK_SDK +# The runtime module where the Flatpak is operating on. +PROJECT_FLATPAK_SDK = 'org.freedesktop.Sdk' -# PROJECT_HOMEBREW_DIRECTORY -# The directory name housing the Homebrew repo. Value CANNOT be empty. -# Default is 'homebrew'. -PROJECT_HOMEBREW_DIRECTORY = "homebrew" -# PROJECT_HOMEBREW_SOURCE_URL -# The base URL for Homebrew to source its tar.*z archive file. It is made -# available for maintaining consistency purposes and is only meant for Homebrew -# use for constructing the 'url' value. +########################### +# DISTRIBUTION - HOMEBREW # +########################### +# PROJECT_HOMEBREW_URL +# The base URL for Homebrew formula to download its associated tar.*z archive +# payload. This variable is also acting as a switch to enable/disable Homebrew +# distribution pipeline. +# +# Some examples are: +# (1) GitHub Release: +# value: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download' +# actual URL: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download/[FILE]' # -# NOTE: Please avoid ending with the URL slash. -PROJECT_HOMEBREW_SOURCE_URL = "https://github.com/ChewKeanHo/AutomataCI/releases/download" +# This field also acts as the flag for enabling or disabling the homebrew +# pipeline. +# +# To enable it: set the URL without the ending slash. +# To disable it: set it empty. +# +# !! IMPORTANT !! - Please avoid ending with the URL slash. +PROJECT_HOMEBREW_URL = 'https://github.com/ChewKeanHo/AutomataCI/releases/latest/download' -# PROJECT_CHOCOLATEY_REPO -# The Chocolatey package publication git repository for updating and publishing -# Chocolatey's usable nupkg packages. This is used in release job. -PROJECT_CHOCOLATEY_REPO = "git@github.com:ChewKeanHo/Testbed.git" +# PROJECT_HOMEBREW_REPO +# The Homebrew formula publication git repository for updating and publishing +# Homebrew's formula. This repository is ENTIRELY DIFFERENT from your project +# version (as in a tap repo: '$ brew tap [username]/[collections] [URL]'). +# More info: +# 1. https://docs.brew.sh/Taps +# +# Value CANNOT BE EMPTY. When in doubt, you can create a publishing +# 'Collections' git repository which is great for branding. For example: +# 1. (Holloway) Chew, Kean Ho: 'git@github.com:ChewKeanHo/Collections.git' +# +# Note that regardless of PROJECT_RELEASE_REPO is set or otherwise, this repo +# shall be deleted automatically at the end of its operation, successful or +# otherwise to prevent output distortion. +PROJECT_HOMEBREW_REPO = 'git@github.com:ChewKeanHo/Collections.git' -# PROJECT_CHOCOLATEY_REPO_KEY -# The git upstream key. Default is 'origin'. -PROJECT_CHOCOLATEY_REPO_KEY = "origin" +# PROJECT_HOMEBREW_REPO_KEY +# The git upstream key. Value CANNOT be empty. +# +# Default is 'origin'. +PROJECT_HOMEBREW_REPO_KEY = 'origin' -# PROJECT_CHOCOLATEY_REPO_BRANCH -# The git upstream branch. Default is 'main' or 'master'. -PROJECT_CHOCOLATEY_REPO_BRANCH = "main" +# PROJECT_HOMEBREW_REPO_BRANCH +# The git upstream branch. Value CANNOT be empty. +# +# Default is 'main' or 'master'. +PROJECT_HOMEBREW_REPO_BRANCH = 'main' -# PROJECT_CHOCOLATEY_DIRECTORY -# The directory name housing the Chocolatey repo. Value CANNOT be empty. -# Default is 'chocolatey'. -PROJECT_CHOCOLATEY_DIRECTORY = "chocolatey" -# PROJECT_CHOCOLATEY_SOURCE_URL -# The base URL for Chocolatey to source its .nupkg packages. It is made -# available for maintaining consistency purposes and is only meant for -# Chocolatey use for constructing the 'url' value. +########################## +# DISTRIBUTION - RPM # +########################## +# PROJECT_RPM_URL +# The .rpm' downloadable yum URL used for generating .repo source file inside +# /etc/yum.repos.d directory. More info: +# (1) https://developers.redhat.com/articles/2022/10/07/whats-inside-rpm-repo-file +# +# Some examples: +# (1) GitHub Release: +# value: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download' +# actual URL: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download/[FILE]' +# +# This field also acts as the flag for enabling or disabling the rpm pipeline. # -# NOTE: Please avoid ending with the URL slash. -PROJECT_CHOCOLATEY_SOURCE_URL = "https://github.com/ChewKeanHo/AutomataCI/releases/download" +# To enable : fill in the end-user downloadable URL without ending slash. +# To disable: leave this field empty (''). +# +# !! IMPORTANT !! - Please avoid ending with the URL slash. +PROJECT_RPM_URL = 'https://github.com/ChewKeanHo/AutomataCI/releases/latest/download' -# PROJECT_DOCS_REPO -# The git repository for publishing all the docs web artifacts. This URL shall -# be git cloned into the PROJECT_PATH_RELEASE directory. -PROJECT_DOCS_REPO = "git@github.com:ChewKeanHo/AutomataCI.git" +# PROJECT_RPM_FLAT_MODE +# The flag to create a flat .rpm repository directory rather than using the +# conventional mode with repodata/ sub-directory. This is especially useful +# for filesystem without sub-directories such as but not limited to +# GitHub/GitLab Release page. +# +# To enable : leave the non-empty (e.g. 'enabled') +# To disable: leave it empty ('') +PROJECT_RPM_FLAT_MODE = 'enabled' -# PROJECT_DOCS_REPO_KEY -# The git upstream key. Default is 'origin'. -PROJECT_DOCS_REPO_KEY = "origin" +# PROJECT_RPM_REPOXML_NAME +# The filename of the repomd.xml file after the directory is flattened. This +# field SHALL NOT be left empty or it will cause catastrophic, irreversible +# effect to the release repo. +# +# Default is: 'repomd.xml' +PROJECT_RPM_REPOXML_NAME = 'repomd.xml' -# PROJECT_DOCS_REPO_BRANCH -# The git upstream branch. Default is 'gh-pages'. -PROJECT_DOCS_REPO_BRANCH = "gh-pages" +# PROJECT_RPM_METALINK +# The filename of the METALINK file after the directory is flattened. This +# field SHALL NOT be left empty or it will cause catastrophic, irreversible +# effect to the release repo. +# +# Default is: 'METALINK_RPM' +PROJECT_RPM_METALINK = 'METALINK_RPM' -# PROJECT_DOCS_REPO_DIRECTORY -# The directory name housing the docs repo. Value CANNOT be empty. -# Default is 'docs'. -PROJECT_DOCS_REPO_DIRECTORY = "docs" +# PROJECT_RPM_IS_NATIVE +# Flag to determine the project is Red Hat natively sponsored package. Usually +# is false. +# +# Only accept: "true/false" +# +# Default is 'false'. +PROJECT_RPM_IS_NATIVE = 'false' -# PROJECT_DOCS_SOURCE_URL -# The base URL for viewing the published documentation (e.g. website address). -# It is made available in-case of publication needs. +# PROJECT_RPM_REPO +# The git repository for publishing all .rpm packages using a static file +# sharing service (e.g NGINX file hosting, GitHub/GitLab Pages, etc). When .rpm +# is operating in the conventional mode, this repository URL shall be git clone +# into '$PROJECT_PATH_ROOT/$PROJECT_PATH_RELEASE' directory named as 'rpm'. # -# NOTE: Please avoid ending with the URL slash. -PROJECT_DOCS_SOURCE_URL = "https://github.io/ChewKeanHo/AutomataCI" +# If PROJECT_RPM_REPO_TYPE is not set to git type, then this variable shall be +# ignored. +# +# Note that if PROJECT_RELEASE_REPO is set, this field is ignored regardless of +# its value. +PROJECT_RPM_REPO = 'git@github.com:ChewKeanHo/AutomataCI.wiki.git' + + +# PROJECT_RPM_REPO_KEY +# The git upstream key. Value CANNOT be empty. +# +# Default is 'origin'. +PROJECT_DEB_REPO_KEY = 'origin' + + +# PROJECT_RPM_REPO_BRANCH +# The git upstream branch. Value CANNOT be empty. +# +# Default is 'master' or 'main'. +PROJECT_RPM_REPO_BRANCH = 'master' + + +# PROJECT_RPM_PATH +# The relative pathing for organizing within the rpm repository directory. +# The path is always relative to +# '${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/rpm' directory which is the +# PROJECT_RPM_REPO rpm repository. This is useful for cases where specific +# directory is required (e.g. 'GitHub Pages using "docs/" directory for +# publications). +# +# If left empty, AutomataCI shall use 'rpm' as its value. +# +# Default is 'rpm'. +PROJECT_RPM_PATH = 'rpm' @@ -1029,79 +1501,79 @@ PROJECT_DOCS_SOURCE_URL = "https://github.io/ChewKeanHo/AutomataCI" # # WARNING: DO NOT attempt to change/override this naming convention. It will # break AutomataCI. -# PROJECT_PATH_AUTOMATA = "automataCI" # Reserved - determined by ci.cmd automatically. +# PROJECT_PATH_AUTOMATA = 'automataCI' # Reserved - determined by ci.cmd automatically. # LIBS_AUTOMATACI # This is the reserved pathing containing: # ${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA} # for easy service libraries import. -# WARNING: DO NOT attempt to change/override this naming convention. It will -# break AutomataCI. +# !! WARNING !! DO NOT attempt to change/override this naming convention. It +# will break AutomataCI. # PROJECT_PATH_SOURCE # This is the relative pathing to PROJECT_PATH_ROOT where it locates the # baseline source directory independent of technological section and acts as an # overall controls. -PROJECT_PATH_SOURCE = "src" +PROJECT_PATH_SOURCE = 'src' # PROJECT_PATH_TOOLS # This is the relative pathing to PROJECT_PATH_ROOT where it locates the # project's tooling directory like programming languages' engine or executables. -PROJECT_PATH_TOOLS = "tools" +PROJECT_PATH_TOOLS = 'tools' # PROJECT_PATH_BUILD # This is the relative pathing to PROJECT_PATH_ROOT where it locates the # project's build output directory. -PROJECT_PATH_BUILD = "build" +PROJECT_PATH_BUILD = 'build' # PROJECT_PATH_BIN # This is the relative pathing to PROJECT_PATH_ROOT where it locates the # project's shippable executable binraries. -PROJECT_PATH_BIN = "bin" +PROJECT_PATH_BIN = 'bin' # PROJECT_PATH_LIB # This is the relative pathing to PROJECT_PATH_ROOT where it locates the # project's shippable importable libraries. -PROJECT_PATH_LIB = "lib" +PROJECT_PATH_LIB = 'lib' # PROJECT_PATH_TEMP # This is the relative pathing to PROJECT_PATH_ROOT where it locates the # project's temporary workspace directory. -PROJECT_PATH_TEMP = "tmp" +PROJECT_PATH_TEMP = 'tmp' # PROJECT_PATH_LOG # This is the relative pathing to PROJECT_PATH_ROOT where it locates the # project's log output directory. -PROJECT_PATH_LOG = "log" +PROJECT_PATH_LOG = 'log' # PROJECT_PATH_CI # This is the relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_SOURCE where # it locates the project's tech-specific CI job directory. -PROJECT_PATH_CI = ".ci" +PROJECT_PATH_CI = '.ci' # PROJECT_PATH_PKG # This is the relative pathing to PROJECT_PATH_ROOT where it locates the # project's releasable packages output directory. -PROJECT_PATH_PKG = "pkg" +PROJECT_PATH_PKG = 'pkg' # PROJECT_PATH_RELEASE # This is the relative pathing to PROJECT_PATH_ROOT where it locates the # project's publication output directory. -PROJECT_PATH_RELEASE = "releases" +PROJECT_PATH_RELEASE = 'releases' # PROJECT_PATH_DOCS # This is the relative pathing to PROJECT_PATH_ROOT where it locates the # project's documentation directory. -PROJECT_PATH_DOCS = "public" +PROJECT_PATH_DOCS = 'public' diff --git a/LICENSE.pdf b/LICENSE.pdf new file mode 100644 index 00000000..4be6683f Binary files /dev/null and b/LICENSE.pdf differ diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 261eeb9e..00000000 --- a/LICENSE.txt +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/automataCI/_package-archive_unix-any.sh b/automataCI/_package-archive_unix-any.sh index 2f823409..24a54b61 100644 --- a/automataCI/_package-archive_unix-any.sh +++ b/automataCI/_package-archive_unix-any.sh @@ -71,7 +71,7 @@ PACKAGE_Run_ARCHIVE() { I18N_Create_Package "ARCHIVE" _src="${_target_filename}_${PROJECT_VERSION}_${_target_os}-${_target_arch}" _target_path="${_dest}/${_src}" - _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/archive_${_src}" + _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-archive-${_src}" I18N_Remake "$_src" FS_Remake_Directory "$_src" if [ $? -ne 0 ]; then @@ -115,13 +115,13 @@ PACKAGE_Run_ARCHIVE() { windows) _target_path="${_target_path}.zip" I18N_Package "$_target_path" - ZIP_Create "$_target_path" "*" + ZIP_Create "$_target_path" "." ___process=$? ;; *) _target_path="${_target_path}.tar.xz" I18N_Package "$_target_path" - TAR_Create_XZ "$_target_path" "*" + TAR_Create_XZ "$_target_path" "." ___process=$? ;; esac diff --git a/automataCI/_package-archive_windows-any.ps1 b/automataCI/_package-archive_windows-any.ps1 index 47b397d0..49da491a 100644 --- a/automataCI/_package-archive_windows-any.ps1 +++ b/automataCI/_package-archive_windows-any.ps1 @@ -20,7 +20,7 @@ # initialize if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataIC/ci.sh.ps1 instead!`n" + Write-Error "[ ERROR ] - Please run from automataIC\ci.sh.ps1 instead!`n" return } @@ -62,7 +62,7 @@ function PACKAGE-Run-ARCHIVE { $null = I18N-Create-Package "ARCHIVE" $_src = "${_target_filename}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}" $_target_path = "${_dest}\${_src}" - $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\archive_${_src}" + $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-archive-${_src}" $null = I18N-Remake "${_src}" $___process = FS-Remake-Directory "${_src}" if ($___process -ne 0) { @@ -110,11 +110,11 @@ function PACKAGE-Run-ARCHIVE { windows { $_target_path = "${_target_path}.zip" $null = I18N-Package "${_target_path}" - $___process = ZIP-Create "${_target_path}" "*" + $___process = ZIP-Create "${_target_path}" "." } Default { $_target_path = "${_target_path}.tar.xz" $null = I18N-Package "${_target_path}" - $___process = TAR-Create-XZ "${_target_path}" "*" + $___process = TAR-Create-XZ "${_target_path}" "." }} diff --git a/automataCI/_package-cargo_unix-any.sh b/automataCI/_package-cargo_unix-any.sh index c7c0e0b2..de9fd79e 100644 --- a/automataCI/_package-cargo_unix-any.sh +++ b/automataCI/_package-cargo_unix-any.sh @@ -68,7 +68,7 @@ PACKAGE_Run_CARGO() { I18N_Create_Package "RUST" _src="${_target_filename}_${PROJECT_VERSION}_${_target_os}-${_target_arch}" _target_path="${_dest}/cargo_${_src}" - _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/cargo_${_src}" + _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-cargo-${_src}" I18N_Remake "$_src" FS_Remake_Directory "$_src" if [ $? -ne 0 ]; then diff --git a/automataCI/_package-cargo_windows-any.ps1 b/automataCI/_package-cargo_windows-any.ps1 index 0c6831bc..f1c74e59 100644 --- a/automataCI/_package-cargo_windows-any.ps1 +++ b/automataCI/_package-cargo_windows-any.ps1 @@ -19,7 +19,7 @@ # initialize if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!`n" + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" return } @@ -59,7 +59,7 @@ function PACKAGE-Run-CARGO { $null = I18N-Create-Package "RUST" $_src = "${_target_filename}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}" $_target_path = "${_dest}\cargo_${_src}" - $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\cargo_${_src}" + $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-cargo-${_src}" $null = I18N-Remake "${_src}" $___process = FS-Remake-Directory "${_src}" if ($___process -ne 0) { diff --git a/automataCI/_package-chocolatey_unix-any.sh b/automataCI/_package-chocolatey_unix-any.sh index 59a6be97..87d06391 100644 --- a/automataCI/_package-chocolatey_unix-any.sh +++ b/automataCI/_package-chocolatey_unix-any.sh @@ -64,7 +64,7 @@ PACKAGE_Run_CHOCOLATEY() { I18N_Create_Package "CHOCOLATEY" _src="${_target_filename}_${PROJECT_VERSION}_${_target_os}-${_target_arch}" _target_path="${_dest}/${_src}" - _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/choco_${_src}" + _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-choco-${_src}" I18N_Remake "$_src" FS_Remake_Directory "$_src" if [ $? -ne 0 ]; then @@ -100,7 +100,7 @@ PACKAGE_Run_CHOCOLATEY() { # check nuspec file is available - I18N_Check ".nuspec metadata" + I18N_Check ".nuspec" __name="" for __file in "${_src}/"*.nuspec; do FS_Is_File "${__file}" diff --git a/automataCI/_package-chocolatey_windows-any.ps1 b/automataCI/_package-chocolatey_windows-any.ps1 index 1f1a32cd..7b158d9e 100644 --- a/automataCI/_package-chocolatey_windows-any.ps1 +++ b/automataCI/_package-chocolatey_windows-any.ps1 @@ -55,7 +55,7 @@ function PACKAGE-Run-CHOCOLATEY { $null = I18N-Create-Package "CHOCOLATEY" $_src = "${_target_filename}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}" $_target_path = "${_dest}\${_src}" - $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\choco_${_src}" + $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-choco-${_src}" $null = I18N-Remake "${_src}" $___process = FS-Remake-Directory "${_src}" if ($___process -ne 0) { diff --git a/automataCI/_package-citation_unix-any.sh b/automataCI/_package-citation_unix-any.sh index 3811a39b..54bb8c43 100644 --- a/automataCI/_package-citation_unix-any.sh +++ b/automataCI/_package-citation_unix-any.sh @@ -39,7 +39,7 @@ PACKAGE_Run_CITATION() { "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/CITATIONS.yml" \ "$PROJECT_CITATION" \ "$PROJECT_CITATION_TYPE" \ - "$(TIME_Format_ISO8601_Date "$(TIME_Now)")" \ + "$(TIME_Format_Date_ISO8601 "$(TIME_Now)")" \ "$PROJECT_NAME" \ "$PROJECT_VERSION" \ "$PROJECT_LICENSE" \ diff --git a/automataCI/_package-citation_windows-any.ps1 b/automataCI/_package-citation_windows-any.ps1 index 42892682..232d02c9 100644 --- a/automataCI/_package-citation_windows-any.ps1 +++ b/automataCI/_package-citation_windows-any.ps1 @@ -19,7 +19,7 @@ # initialize if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!`n" + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" return } @@ -39,7 +39,7 @@ function PACKAGE-Run-CITATION { "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\CITATIONS.yml" ` "${env:PROJECT_CITATION}" ` "${env:PROJECT_CITATION_TYPE}" ` - "$(TIME-Format-ISO8601-Date "$(TIME-Now)")" ` + "$(TIME-Format-Date-ISO8601 "$(TIME-Now)")" ` "${env:PROJECT_NAME}" ` "${env:PROJECT_VERSION}" ` "${env:PROJECT_LICENSE}" ` diff --git a/automataCI/_package-deb_unix-any.sh b/automataCI/_package-deb_unix-any.sh index 5b3d5762..f2662576 100644 --- a/automataCI/_package-deb_unix-any.sh +++ b/automataCI/_package-deb_unix-any.sh @@ -74,7 +74,7 @@ PACKAGE_Run_DEB() { I18N_Create_Package "DEB" _src="${_target_filename}_${PROJECT_VERSION}_${_target_os}-${_target_arch}" _target_path="${_dest}/${_src}.deb" - _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/deb_${_src}" + _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-deb-${_src}" I18N_Remake "$_src" FS_Remake_Directory "${_src}" if [ $? -ne 0 ]; then diff --git a/automataCI/_package-deb_windows-any.ps1 b/automataCI/_package-deb_windows-any.ps1 index a3a2be8e..8691bd92 100644 --- a/automataCI/_package-deb_windows-any.ps1 +++ b/automataCI/_package-deb_windows-any.ps1 @@ -19,7 +19,7 @@ # initialize if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!`n" + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" return } @@ -61,7 +61,7 @@ function PACKAGE-Run-DEB { $null = I18N-Create-Package "DEB" $_src = "${_target_filename}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}" $_target_path = "${_dest}\${_src}.deb" - $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\deb_${_src}" + $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-deb-${_src}" $null = I18N-Remake "${_src}" $___process = FS-Remake-Directory "${_src}" if ($___process -ne 0) { diff --git a/automataCI/_package-docker_unix-any.sh b/automataCI/_package-docker_unix-any.sh index bab3609d..3d755150 100644 --- a/automataCI/_package-docker_unix-any.sh +++ b/automataCI/_package-docker_unix-any.sh @@ -79,7 +79,7 @@ PACKAGE_Run_DOCKER() { I18N_Create_Package "DOCKER" _src="${_target_filename}_${PROJECT_VERSION}_${_target_os}-${_target_arch}" _target_path="${_dest}/docker.txt" - _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/docker_${_src}" + _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-docker-${_src}" I18N_Remake "$_src" FS_Remake_Directory "$_src" if [ $? -ne 0 ]; then diff --git a/automataCI/_package-docker_windows-any.ps1 b/automataCI/_package-docker_windows-any.ps1 index 8c49b9bb..fb4d2381 100644 --- a/automataCI/_package-docker_windows-any.ps1 +++ b/automataCI/_package-docker_windows-any.ps1 @@ -19,7 +19,7 @@ # initialize if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!`n" + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" return 1 } @@ -60,7 +60,7 @@ function PACKAGE-Run-DOCKER { $null = I18N-Create-Package "DOCKER" $_src = "${__target_filename}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}" $_target_path = "${_dest}\docker.txt" - $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\docker_${_src}" + $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-docker-${_src}" $null = I18N-Remake "${_src}" $___process = FS-Remake-Directory "${_src}" if ($___process -ne 0) { diff --git a/automataCI/_package-flatpak_unix-any.sh b/automataCI/_package-flatpak_unix-any.sh index d65367da..a2d0740f 100644 --- a/automataCI/_package-flatpak_unix-any.sh +++ b/automataCI/_package-flatpak_unix-any.sh @@ -73,7 +73,7 @@ PACKAGE_Run_FLATPAK() { I18N_Create_Package "FLATPAK" _src="${_target_filename}_${PROJECT_VERSION}_${_target_os}-${_target_arch}" _target_path="${_dest}/${_src}.flatpak" - _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/flatpak_${_src}" + _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-flatpak-${_src}" I18N_Remake "$_src" FS_Remake_Directory "${_src}" if [ $? -ne 0 ]; then diff --git a/automataCI/_package-flatpak_windows-any.ps1 b/automataCI/_package-flatpak_windows-any.ps1 index 766e8d5e..c8b15484 100644 --- a/automataCI/_package-flatpak_windows-any.ps1 +++ b/automataCI/_package-flatpak_windows-any.ps1 @@ -61,7 +61,7 @@ function PACKAGE-Run-FLATPAK { $null = I18N-Create-Package "FLATPAK" $_src = "${_target_filename}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}" $_target_path = "${_dest}\${_src}.flatpak" - $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\flatpak_${_src}" + $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-flatpak-${_src}" $null = I18N-Remake "${_src}" $___process = FS-Remake-Directory "${_src}" if ($___process -ne 0) { diff --git a/automataCI/_package-homebrew_unix-any.sh b/automataCI/_package-homebrew_unix-any.sh index 7644521d..d93674fe 100644 --- a/automataCI/_package-homebrew_unix-any.sh +++ b/automataCI/_package-homebrew_unix-any.sh @@ -12,10 +12,8 @@ # the License. . "${LIBS_AUTOMATACI}/services/io/os.sh" . "${LIBS_AUTOMATACI}/services/io/fs.sh" -. "${LIBS_AUTOMATACI}/services/io/strings.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" -. "${LIBS_AUTOMATACI}/services/archive/tar.sh" -. "${LIBS_AUTOMATACI}/services/checksum/shasum.sh" +. "${LIBS_AUTOMATACI}/services/publishers/homebrew.sh" @@ -51,36 +49,14 @@ PACKAGE_Run_HOMEBREW() { _target_arch="${__line%%|*}" __line="${__line#*|}" + _src="${__line%%|*}" + # validate input - I18N_Check_Availability "TAR" - TAR_Is_Available - if [ $? -ne 0 ]; then - I18N_Check_Failed - return 1 - fi # prepare workspace and required values I18N_Create_Package "HOMEBREW" - _src="${_target_filename}_${PROJECT_VERSION}_${_target_os}-${_target_arch}" - _target_path="${_dest}/${_src}" - _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/homebrew_${_src}" - I18N_Remake "$_src" - FS_Remake_Directory "$_src" - if [ $? -ne 0 ]; then - I18N_Remake_Failed - return 1 - fi - - - # check formula.rb is available - I18N_Check "formula.rb" - FS_Is_File "${_src}/formula.rb" - if [ $? -eq 0 ]; then - I18N_Check_Failed - return 1 - fi # copy all complimentary files to the workspace @@ -97,7 +73,6 @@ PACKAGE_Run_HOMEBREW() { case $? in 10) I18N_Assemble_Skipped - FS_Remove_Silently "$_src" return 0 ;; 0) @@ -110,54 +85,6 @@ PACKAGE_Run_HOMEBREW() { esac - # archive the assembled payload - __current_path="$PWD" && cd "$_src" - I18N_Archive "${_target_path}.tar.xz" - TAR_Create_XZ "${_target_path}.tar.xz" "*" - ___process=$? - cd "$__current_path" && unset __current_path - if [ $___process -ne 0 ]; then - I18N_Archive_Failed - return 1 - fi - - - # sha256 the package - I18N_Shasum "SHA256" - __shasum="$(SHASUM_Create_From_File "${_target_path}.tar.xz" "256")" - if [ $(STRINGS_Is_Empty "$__shasum") -eq 0 ]; then - I18N_Shasum_Failed - return 1 - fi - - - # update the formula.rb script - I18N_Subject_Update "formula.rb" - FS_Remove_Silently "${_target_path}.rb" - __old_IFS="$IFS" - while IFS= read -r __line || [ -n "$__line" ]; do - __line="$(STRINGS_Replace_All \ - "$__line" \ - "{{ TARGET_PACKAGE }}" \ - "${_target_path##*/}.tar.xz" \ - )" - - __line="$(STRINGS_Replace_All \ - "$__line" \ - "{{ TARGET_SHASUM }}" \ - "${__shasum}" \ - )" - - FS_Append_File "${_target_path}.rb" "${__line}\n" - if [ $? -ne 0 ]; then - IFS="$__old_IFS" && unset __line __old_IFS - I18N_Update_Failed - return 1 - fi - done < "${_src}/formula.rb" - IFS="$__old_IFS" && unset __line __old_IFS - - # report status return 0 } diff --git a/automataCI/_package-homebrew_windows-any.ps1 b/automataCI/_package-homebrew_windows-any.ps1 index 40d28098..0a1c0cd4 100644 --- a/automataCI/_package-homebrew_windows-any.ps1 +++ b/automataCI/_package-homebrew_windows-any.ps1 @@ -11,10 +11,8 @@ # under the License. . "${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\i18n\translations.ps1" -. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" -. "${env:LIBS_AUTOMATACI}\services\checksum\shasum.ps1" +. "${env:LIBS_AUTOMATACI}\services\publishers\homebrew.ps1" @@ -22,7 +20,7 @@ # initialize if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!`n" + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" return } @@ -42,37 +40,14 @@ function PACKAGE-Run-HOMEBREW { $_target_filename = $__list[2] $_target_os = $__list[3] $_target_arch = $__list[4] + $_src = $__list[5] # validate input - $null = I18N-Check-Availability "TAR" - $___process = TAR-Is-Available - if ($___process -ne 0) { - $null = I18N-Check-Failed - return 1 - } # prepare workspace and required values $null = I18N-Create-Package "HOMEBREW" - $_src = "${_target_filename}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}" - $_target_path = "${_dest}\${_src}" - $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\homebrew_${_src}" - $null = I18N-Remake "${_src}" - $___process = FS-Remake-Directory "${_src}" - if ($___process -ne 0) { - $null = I18N-Remake-Failed - return 1 - } - - - # check formula.rb is available - $null = I18N-Check "formula.rb" - $___process = FS-Is-File "${_src}/formula.rb" - if ($___process -eq 0) { - $null = I18N-Check-Failed - return 1 - } # copy all complimentary files to the workspace @@ -94,7 +69,6 @@ function PACKAGE-Run-HOMEBREW { switch ($___process) { 10 { $null = I18N-Assemble-Skipped - $null = FS-Remove-Silently "${_src}" return 0 } 0 { # accepted @@ -104,50 +78,6 @@ function PACKAGE-Run-HOMEBREW { }} - # archive the assembled payload - $__current_path = Get-Location - $null = Set-Location -Path "${_src}" - $null = I18N-Archive "${_target_path}.tar.xz" - $___process = TAR-Create-XZ "${_target_path}.tar.xz" "*" - $null = Set-Location -Path "${__current_path}" - $null = Remove-Variable -Name __current_path - if ($___process -ne 0) { - $null = I18N-Archive-Failed - return 1 - } - - - # sha256 the package - $null = I18N-Shasum "SHA256" - $__shasum = SHASUM-Checksum-From-File "${_target_path}.tar.xz" "256" - if ($(STRINGS-Is-Empty "${__shasum}") -eq 0) { - $null = I18N-Shasum-Failed - return 1 - } - - - # update the formula.rb script - $null = I18N-Update "formula.rb" - $null = FS-Remove-Silently "${_target_path}.rb" - foreach ($__line in (Get-Content "${_src}\formula.rb")) { - $__line = STRINGS-Replace-All ` - "${__line}" ` - "{{ TARGET_PACKAGE }}" ` - "$(Split-Path -Leaf -Path "${_target_path}.tar.xz")" - - $__line = STRINGS-Replace-All ` - "${__line}" ` - "{{ TARGET_SHASUM }}" ` - "${__shasum}" - - $___process = FS-Append-File "${_target_path}.rb" "${__line}`n" - if ($___process -ne 0) { - $null = I18N-Update-Failed - return 1 - } - } - - # report status return 0 } diff --git a/automataCI/_package-ipk_unix-any.sh b/automataCI/_package-ipk_unix-any.sh index 6386a30e..8813d8e2 100644 --- a/automataCI/_package-ipk_unix-any.sh +++ b/automataCI/_package-ipk_unix-any.sh @@ -72,7 +72,7 @@ PACKAGE_Run_IPK() { I18N_Create_Package "IPK" _src="${_target_filename}_${PROJECT_VERSION}_${_target_os}-${_target_arch}" _target_path="${_dest}/${_src}.ipk" - _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/ipk_${_src}" + _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-ipk-${_src}" I18N_Remake "$_src" FS_Remake_Directory "${_src}" if [ $? -ne 0 ]; then diff --git a/automataCI/_package-ipk_windows-any.ps1 b/automataCI/_package-ipk_windows-any.ps1 index 90c71a4a..fdf0c151 100644 --- a/automataCI/_package-ipk_windows-any.ps1 +++ b/automataCI/_package-ipk_windows-any.ps1 @@ -60,7 +60,7 @@ function PACKAGE-Run-IPK { $null = I18N-Create-Package "IPK" $_src = "${_target_filename}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}" $_target_path = "${_dest}\${_src}.ipk" - $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\ipk_${_src}" + $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-ipk-${_src}" $null = I18N-Remake "${_src}" $___process = FS-Remake-Directory "${_src}" if ($___process -ne 0) { diff --git a/automataCI/_package-msi_unix-any.sh b/automataCI/_package-msi_unix-any.sh index 15c5e6e9..f6b4363b 100644 --- a/automataCI/_package-msi_unix-any.sh +++ b/automataCI/_package-msi_unix-any.sh @@ -112,7 +112,7 @@ PACKAGE_Run_MSI() { # prepare workspace and required values I18N_Create_Package "MSI" _src="${_target_filename}_${PROJECT_VERSION}_${_target_os}-${_target_arch}" - _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/msi_${_src}" + _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-msi-${_src}" I18N_Remake "$_src" FS_Remake_Directory "$_src" if [ $? -ne 0 ]; then diff --git a/automataCI/_package-msi_windows-any.ps1 b/automataCI/_package-msi_windows-any.ps1 index a951fd24..42c80ee3 100644 --- a/automataCI/_package-msi_windows-any.ps1 +++ b/automataCI/_package-msi_windows-any.ps1 @@ -20,7 +20,7 @@ # initialize if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!`n" + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" return } @@ -114,7 +114,7 @@ function PACKAGE-Run-MSI { # prepare workspace and required values $null = I18N-Create-Package "MSI" $_src = "${_target_filename}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}" - $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\msi_${_src}" + $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-msi-${_src}" $null = I18N-Remake "${_src}" $___process = FS-Remake-Directory "${_src}" if ($___process -ne 0) { diff --git a/automataCI/_package-npm_unix-any.sh b/automataCI/_package-npm_unix-any.sh deleted file mode 100644 index ef5c70e0..00000000 --- a/automataCI/_package-npm_unix-any.sh +++ /dev/null @@ -1,80 +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/os.sh" -. "${LIBS_AUTOMATACI}/services/io/fs.sh" -. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" - - - - -# initialize -if [ "$PROJECT_PATH_ROOT" = "" ]; then - >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" - return 1 -fi - - - - -PACKAGE_Run_NPM() { - #__line="$1" - - - # parse input - __line="$1" - - _dest="${__line%%|*}" - __line="${__line#*|}" - - _target="${__line%%|*}" - __line="${__line#*|}" - - _target_filename="${__line%%|*}" - __line="${__line#*|}" - - _target_os="${__line%%|*}" - __line="${__line#*|}" - - _target_arch="${__line%%|*}" - __line="${__line#*|}" - - - # copy all complimentary files to the workspace - cmd="PACKAGE_Assemble_NPM_Content" - I18N_Check_Function "$cmd" - OS_Is_Command_Available "$cmd" - if [ $? -ne 0 ]; then - I18N_Check_Failed - return 1 - fi - - I18N_Assemble_Package - "$cmd" "$_target" "$_dest" "$_target_filename" "$_target_os" "$_target_arch" - case $? in - 10) - I18N_Assemble_Skipped - return 0 - ;; - 0) - # accepted - ;; - *) - I18N_Assemble_Failed - return 1 - ;; - esac - - - # report status - return 0 -} diff --git a/automataCI/_package-npm_windows-any.ps1 b/automataCI/_package-npm_windows-any.ps1 deleted file mode 100644 index 8a84999c..00000000 --- a/automataCI/_package-npm_windows-any.ps1 +++ /dev/null @@ -1,73 +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\os.ps1" -. "${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" - return -} - - - - -function PACKAGE-Run-NPM { - param ( - [string]$__line - ) - - - # parse input - $__list = $__line -split "\|" - $_dest = $__list[0] - $_target = $__list[1] - $_target_filename = $__list[2] - $_target_os = $__list[3] - $_target_arch = $__list[4] - - - # copy all complimentary files to the workspace - $cmd = "PACKAGE-Assemble-NPM-Content" - $null = I18N-Check-Function "$cmd" - $___process = OS-Is-Command-Available "$cmd" - if ($___process -ne 0) { - $null = I18N-Check-Failed - return 1 - } - - $null = I18N-Assemble-Package - $___process = PACKAGE-Assemble-NPM-Content ` - "${_target}" ` - "${_dest}" ` - "${_target_filename}" ` - "${_target_os}" ` - "${_target_arch}" - switch ($___process) { - 10 { - $null = I18N-Assemble-Skipped - return 0 - } 0 { - # accepted - } Default { - $null = I18N-Assemble-Failed - return 1 - }} - - - # report status - return 0 -} diff --git a/automataCI/_package-pdf_windows-any.ps1 b/automataCI/_package-pdf_windows-any.ps1 index bd94f190..fd78da09 100644 --- a/automataCI/_package-pdf_windows-any.ps1 +++ b/automataCI/_package-pdf_windows-any.ps1 @@ -18,7 +18,7 @@ # initialize if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!`n" + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" return } diff --git a/automataCI/_package-pypi_unix-any.sh b/automataCI/_package-pypi_unix-any.sh index 6f89f8ff..7399772a 100644 --- a/automataCI/_package-pypi_unix-any.sh +++ b/automataCI/_package-pypi_unix-any.sh @@ -80,7 +80,7 @@ PACKAGE_Run_PYPI() { I18N_Create "PYPI" _src="${_target_filename}_${PROJECT_VERSION}_${_target_os}-${_target_arch}" _target_path="${_dest}/pypi_${_src}" - _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/pypi_${_src}" + _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-pypi-${_src}" I18N_Remake "$_src" FS_Remake_Directory "$_src" if [ $? -ne 0 ]; then diff --git a/automataCI/_package-pypi_windows-any.ps1 b/automataCI/_package-pypi_windows-any.ps1 index 200e835a..62ee7b59 100644 --- a/automataCI/_package-pypi_windows-any.ps1 +++ b/automataCI/_package-pypi_windows-any.ps1 @@ -70,7 +70,7 @@ function PACKAGE-Run-PYPI { $null = I18N-Create "PYPI" $_src = "${_target_filename}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}" $_target_path = "${_dest}\pypi_${_src}" - $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\pypi_${_src}" + $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-pypi-${_src}" $null = I18N-Remake "${_src}" $___process = FS-Remake-Directory "${_src}" if ($___process -ne 0) { diff --git a/automataCI/_package-rpm_unix-any.sh b/automataCI/_package-rpm_unix-any.sh index cdf8b6f3..c5b4a596 100644 --- a/automataCI/_package-rpm_unix-any.sh +++ b/automataCI/_package-rpm_unix-any.sh @@ -69,7 +69,7 @@ PACKAGE_Run_RPM() { ;; esac - I18N_Check_Availability "MANUAL DOCS" + I18N_Check_Availability "MANUAL" MANUAL_Is_Available if [ $? -ne 0 ]; then I18N_Check_Failed @@ -80,7 +80,7 @@ PACKAGE_Run_RPM() { # prepare workspace and required values I18N_Create_Package "RPM" _src="${_target_filename}_${_target_os}-${_target_arch}" - _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/rpm_${_src}" + _src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-rpm-${_src}" I18N_Remake "$_src" FS_Remake_Directory "$_src" if [ $? -ne 0 ]; then diff --git a/automataCI/_package-rpm_windows-any.ps1 b/automataCI/_package-rpm_windows-any.ps1 index fd39f62e..f531a296 100644 --- a/automataCI/_package-rpm_windows-any.ps1 +++ b/automataCI/_package-rpm_windows-any.ps1 @@ -57,10 +57,10 @@ function PACKAGE-Run-RPM { return 0 }} - $null = I18N-Check-Availability "MANUAL DOCS" + $null = I18N-Check-Availability "MANUAL" $___process = MANUAL-Is-Available if ($___process -ne 0) { - $null = I18N-Check-Failed "MANUAL DOCS" + $null = I18N-Check-Failed "MANUAL" return 1 } @@ -68,7 +68,7 @@ function PACKAGE-Run-RPM { # prepare workspace and required values $null = I18N-Create-Package "RPM" $_src = "${_target_filename}_${_target_os}-${_target_arch}" - $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\rpm_${_src}" + $_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-rpm-${_src}" $null = I18N-Remake "${_src}" $___process = FS-Remake-Directory "${_src}" if ($___process -ne 0) { diff --git a/automataCI/_release-changelog_unix-any.sh b/automataCI/_release-changelog_unix-any.sh index fa282890..dfe08796 100644 --- a/automataCI/_release-changelog_unix-any.sh +++ b/automataCI/_release-changelog_unix-any.sh @@ -10,6 +10,7 @@ # 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/os.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" . "${LIBS_AUTOMATACI}/services/compilers/changelog.sh" @@ -27,13 +28,18 @@ fi RELEASE_Conclude_CHANGELOG() { # execute - I18N_Export "${PROJECT_VERSION} CHANGELOG" - CHANGELOG_Seal \ - "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/changelog" \ - "$PROJECT_VERSION" - if [ $? -ne 0 ]; then - I18N_Export_Failed - return 1 + I18N_Conclude "${PROJECT_VERSION} CHANGELOG" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + CHANGELOG_Seal \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/changelog" \ + "$PROJECT_VERSION" + if [ $? -ne 0 ]; then + I18N_Conclude_Failed + return 1 + fi + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Conclude "${PROJECT_VERSION} CHANGELOG" fi diff --git a/automataCI/_release-changelog_windows-any.ps1 b/automataCI/_release-changelog_windows-any.ps1 index 7aa330ef..5d6d76eb 100644 --- a/automataCI/_release-changelog_windows-any.ps1 +++ b/automataCI/_release-changelog_windows-any.ps1 @@ -9,6 +9,7 @@ # 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\os.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" . "${env:LIBS_AUTOMATACI}\services\compilers\changelog.ps1" @@ -26,16 +27,21 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { function RELEASE-Conclude-CHANGELOG { # execute - $null = I18N-Export "${env:PROJECT_VERSION} CHANGELOG" - $___process = CHANGELOG-Seal ` - "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\changelog" ` - "${env:PROJECT_VERSION}" - if ($___process -ne 0) { - $null = I18N-Export-Failed - return 1 + $null = I18N-Conclude "${env:PROJECT_VERSION} CHANGELOG" + if ($(OS-Is-Run-Simulated) -ne 0) { + $___process = CHANGELOG-Seal ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\changelog" ` + "${env:PROJECT_VERSION}" + if ($___process -ne 0) { + $null = I18N-Conclude-Failed + return 1 + } + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Conclude "${env:PROJECT_VERSION} CHANGELOG" } - # report status + # return status return 0 } diff --git a/automataCI/_release-checksum_unix-any.sh b/automataCI/_release-checksum_unix-any.sh index 799db642..22291274 100644 --- a/automataCI/_release-checksum_unix-any.sh +++ b/automataCI/_release-checksum_unix-any.sh @@ -10,8 +10,9 @@ # 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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" . "${LIBS_AUTOMATACI}/services/crypto/gpg.sh" . "${LIBS_AUTOMATACI}/services/checksum/shasum.sh" @@ -28,23 +29,23 @@ fi -RELEASE_Run_CHECKSUM() { - #__static_repo="$1" +RELEASE_Conclude_CHECKSUM() { + #__repo_directory="$1" # execute - __sha256_file="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/sha256.txt" + __sha256_file="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/releaser-sha256.txt" FS_Remove_Silently "$__sha256_file" + __sha512_file="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/releaser-sha512.txt" + FS_Remove_Silently "$__sha512_file" + __sha256_target="${PROJECT_SKU}-sha256_${PROJECT_VERSION}.txt" - __sha256_target="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}/${__sha256_target}" + __sha256_target="${1}/${__sha256_target}" FS_Remove_Silently "$__sha256_target" - __sha512_file="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/sha512.txt" - FS_Remove_Silently "$__sha512_file" - __sha512_target="${PROJECT_SKU}-sha512_${PROJECT_VERSION}.txt" - __sha512_target="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}/${__sha512_target}" + __sha512_target="${1}/${__sha512_target}" FS_Remove_Silently "$__sha512_target" @@ -52,31 +53,38 @@ RELEASE_Run_CHECKSUM() { GPG_Is_Available "$PROJECT_GPG_ID" if [ $? -eq 0 ]; then __keyfile="${PROJECT_SKU}-gpg_${PROJECT_VERSION}.keyfile" - I18N_Export "$__keyfile" - __keyfile="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}/${__keyfile}" - FS_Remove_Silently "${__keyfile}" - - GPG_Export_Public_Key "$__keyfile" "$PROJECT_GPG_ID" - if [ $? -ne 0 ]; then - I18N_Export_Failed - return 1 - fi + __keyfile="${1}/${__keyfile}" - FS_Copy_File "$__keyfile" "${1}/${__keyfile##*/}" - if [ $? -ne 0 ]; then - I18N_Export_Failed - return 1 + I18N_Publish "$__keyfile" + FS_Remove_Silently "$__keyfile" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + GPG_Export_Public_Key "$__keyfile" "$PROJECT_GPG_ID" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + else + I18N_Simulate_Publish "$__keyfile" fi # gpg sign all packages - for TARGET in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}"/*; do - if [ ! "${TARGET%%.asc*}" = "${TARGET}" ]; then + for TARGET in "$1"/*; do + if [ ! "${TARGET%%.asc*}" = "$TARGET" ]; then continue # it's a gpg cert fi + if [ ! "${TARGET%%.gpg*}" = "$TARGET" ]; then + continue # it's a gpg keyfile or cert + fi + I18N_Sign "$TARGET" "GPG" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Notarize "$TARGET" + continue + fi + FS_Remove_Silently "${TARGET}.asc" - GPG_Detach_Sign_File "$TARGET" "$PROJECT_GPG_ID" + GPG_Detach_Sign_File "${TARGET}.asc" "$TARGET" "$PROJECT_GPG_ID" if [ $? -ne 0 ]; then I18N_Sign_Failed return 1 @@ -86,7 +94,7 @@ RELEASE_Run_CHECKSUM() { # shasum all files - for TARGET in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}"/*; do + for TARGET in "$1"/*; do FS_Is_Directory "$TARGET" if [ $? -eq 0 ]; then I18N_Is_Directory_Skipped "$TARGET" @@ -101,9 +109,9 @@ RELEASE_Run_CHECKSUM() { return 1 fi - FS_Append_File "${__sha256_file}" "\ -${__value} ${TARGET##*/} -" + FS_Append_File \ + "$__sha256_file" \ + "${__value} $(FS_Get_File "$TARGET")\n" if [ $? -ne 0 ]; then I18N_Checksum_Failed return 1 @@ -114,14 +122,14 @@ ${__value} ${TARGET##*/} if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_SHA512") -ne 0 ]; then I18N_Checksum "$TARGET" "SHA512" __value="$(SHASUM_Create_From_File "$TARGET" "512")" - if [ $(STRINGS_Is_Empty "${__value}") -eq 0 ]; then + if [ $(STRINGS_Is_Empty "$__value") -eq 0 ]; then I18N_Checksum_Failed return 1 fi - FS_Append_File "${__sha512_file}" "\ -${__value} ${TARGET##*/} -" + FS_Append_File \ + "$__sha512_file" \ + "${__value} $(FS_Get_File "$TARGET")\n" if [ $? -ne 0 ]; then I18N_Checksum_Failed return 1 @@ -132,10 +140,10 @@ ${__value} ${TARGET##*/} FS_Is_File "$__sha256_file" if [ $? -eq 0 ]; then - I18N_Export "$__sha256_target" - FS_Move "${__sha256_file}" "$__sha256_target" + I18N_Conclude "$__sha256_target" + FS_Move "$__sha256_file" "$__sha256_target" if [ $? -ne 0 ]; then - I18N_Export_Failed + I18N_Conclude_Failed return 1 fi fi @@ -143,10 +151,10 @@ ${__value} ${TARGET##*/} FS_Is_File "$__sha512_file" if [ $? -eq 0 ]; then - I18N_Export "$__sha512_target" - FS_Move "${__sha512_file}" "$__sha512_target" + I18N_Conclude "$__sha512_target" + FS_Move "$__sha512_file" "$__sha512_target" if [ $? -ne 0 ]; then - I18N_Export_Failed + I18N_Conclude_Failed return 1 fi fi diff --git a/automataCI/_release-checksum_windows-any.ps1 b/automataCI/_release-checksum_windows-any.ps1 index dc7c8a0d..74c2feec 100644 --- a/automataCI/_release-checksum_windows-any.ps1 +++ b/automataCI/_release-checksum_windows-any.ps1 @@ -11,6 +11,7 @@ # under the License. . "${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\i18n\translations.ps1" . "${env:LIBS_AUTOMATACI}\services\crypto\gpg.ps1" . "${env:LIBS_AUTOMATACI}\services\checksum\shasum.ps1" @@ -27,25 +28,25 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { -function RELEASE-Run-CHECKSUM { +function RELEASE-Conclude-CHECKSUM { param ( - [string]$__static_repo + [string]$__repo_directory ) # execute - $__sha256_file = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\sha256.txt" + $__sha256_file = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\releaser-sha256.txt" $null = FS-Remove-Silently "${__sha256_file}" + $__sha512_file = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\releaser-sha512.txt" + $null = FS-Remove-Silently "${__sha512_file}" + $__sha256_target = "${env:PROJECT_SKU}-sha256_${env:PROJECT_VERSION}.txt" - $__sha256_target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\${__sha256_target}" + $__sha256_target = "${__repo_directory}\${__sha256_target}" $null = FS-Remove-Silently "${__sha256_target}" - $__sha512_file = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\sha512.txt" - $null = FS-Remove-Silently "${__sha512_file}" - $__sha512_target = "${env:PROJECT_SKU}-sha512_${env:PROJECT_VERSION}.txt" - $__sha512_target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\${__sha512_target}" + $__sha512_target = "${__repo_directory}\${__sha512_target}" $null = FS-Remove-Silently "${__sha512_target}" @@ -53,33 +54,44 @@ function RELEASE-Run-CHECKSUM { $___process = GPG-Is-Available "${env:PROJECT_GPG_ID}" if ($___process -eq 0) { $__keyfile = "${env:PROJECT_SKU}-gpg_${env:PROJECT_VERSION}.keyfile" - $null = I18N-Export "${__keyfile}" - $__keyfile = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\${__keyfile}" - $null = FS-Remove-Silently "${__keyfile}" + $__keyfile = "${__repo_directory}\${__keyfile}" - $___process = GPG-Export-Public-Key "${__keyfile}" "${env:PROJECT_GPG_ID}" - if ($___process -ne 0) { - $null = I18N-Export-Failed - return 1 + $null = I18N-Publish "${__keyfile}" + $null = FS-Remove-Silently "${__keyfile}" + if ($(OS-Is-Run-Simulated) -ne 0) { + $___process = GPG-Export-Public-Key ` + "${__keyfile}" ` + "${env:PROJECT_GPG_ID}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + } else { + $null = I18N-Simulate-Publish "${__keyfile}" } - $___process = FS-Copy-File ` - "${__keyfile}" ` - "${__static_repo}\$(Split-Path -Leaf -Path "${__keyfile}")" - if ($___process -ne 0) { - $null = I18N-Export-Failed - return 1 - } + foreach ($TARGET in (Get-ChildItem -Path "${__repo_directory}")) { + $TARGET = $TARGET.FullName - foreach ($TARGET in (Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}")) { - $TARGET = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\${TARGET}" if ($("${TARGET}" -replace '^.*.asc') -ne "${TARGET}") { continue # it's a gpg cert } + if ($("${TARGET}" -replace '^.*.gpg') -ne "${TARGET}") { + continue # it's a gpg keyfile or cert + } + $null = I18N-Sign "${TARGET}" "GPG" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Notarize "${TARGET}" + continue + } + FS-Remove-Silently "${TARGET}.asc" - $___process = GPG-Detach-Sign-File "${TARGET}" "${env:PROJECT_GPG_ID}" + $___process = GPG-Detach-Sign-File ` + "${TARGET}.asc" ` + "${TARGET}" ` + "${env:PROJECT_GPG_ID}" if ($___process -ne 0) { $null = I18N-Sign-Failed return 1 @@ -89,7 +101,9 @@ function RELEASE-Run-CHECKSUM { # shasum all files - foreach ($TARGET in (Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}")) { + foreach ($TARGET in (Get-ChildItem -Path "${__repo_directory}")) { + $TARGET = $TARGET.FullName + $___process = FS-Is-Directory "${TARGET}" if ($___process -eq 0) { $null = I18N-Is-Directory-Skipped "${TARGET}" @@ -97,14 +111,16 @@ function RELEASE-Run-CHECKSUM { } if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_SHA256}") -ne 0) { - $null = I18N-Checksum "$TARGET" "SHA256" - $__value = SHASUM-Checksum-From-File $TARGET.FullName "256" + $null = I18N-Checksum $TARGET "SHA256" + $__value = SHASUM-Create-From-File $TARGET "256" if ($(STRINGS-Is-Empty "${__value}") -eq 0) { $null = I18N-Checksum-Failed return 1 } - $___process = FS-Append-File "${__sha256_file}" "${__value} $TARGET`n" + $___process = FS-Append-File ` + "${__sha256_file}" ` + "${__value} $(FS-Get-File "$TARGET")`n" if ($___process -ne 0) { $null = I18N-Checksum-Failed return 1 @@ -112,14 +128,16 @@ function RELEASE-Run-CHECKSUM { } if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_SHA512}") -ne 0) { - $null = I18N-Checksum "$TARGET" "SHA512" - $__value = SHASUM-Checksum-From-File $TARGET.FullName "512" + $null = I18N-Checksum $TARGET "SHA512" + $__value = SHASUM-Create-From-File $TARGET "512" if ($(STRINGS-Is-Empty "${__value}") -eq 0) { $null = I18N-Checksum-Failed return 1 } - $___process = FS-Append-File "${__sha512_file}" "${__value} $TARGET`n" + $___process = FS-Append-File ` + "${__sha512_file}" ` + "${__value} $(FS-Get-File "$TARGET")`n" if ($___process -ne 0) { $null = I18N-Checksum-Failed return 1 @@ -130,10 +148,10 @@ function RELEASE-Run-CHECKSUM { $___process = FS-Is-File "${__sha256_file}" if ($___process -eq 0) { - $null = I18N-Export "${__sha256_target}" + $null = I18N-Conclude "${__sha256_target}" $___process = FS-Move "${__sha256_file}" "${__sha256_target}" if ($___process -ne 0) { - $null = I18N-Export-Failed + $null = I18N-Conclude-Failed return 1 } } @@ -141,10 +159,10 @@ function RELEASE-Run-CHECKSUM { $___process = FS-Is-File "${__sha512_file}" if ($___process -eq 0) { - $null = I18N-Export "${__sha512_target}" + $null = I18N-Conclude "${__sha512_target}" $___process = FS-Move "${__sha512_file}" "${__sha512_target}" if ($___process -ne 0) { - $null = I18N-Export-Failed + $null = I18N-Conclude-Failed return 1 } } @@ -170,7 +188,7 @@ function RELEASE-Initiate-CHECKSUM { if ($(OS-Is-Run-Simulated) -eq 0) { $null = I18N-Simulate-Available "GPG" } else { - $___process = GPG-Is-Available + $___process = GPG-Is-Available "${env:PROJECT_GPG_ID}" if ($___process -ne 0) { $null = I18N-Check-Failed return 1 diff --git a/automataCI/_release-chocolatey_unix-any.sh b/automataCI/_release-chocolatey_unix-any.sh deleted file mode 100644 index b42534ae..00000000 --- a/automataCI/_release-chocolatey_unix-any.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/sh -# 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 -# 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/i18n/translations.sh" -. "${LIBS_AUTOMATACI}/services/versioners/git.sh" -. "${LIBS_AUTOMATACI}/services/publishers/chocolatey.sh" - - - - -# initialize -if [ "$PROJECT_PATH_ROOT" = "" ]; then - >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" - return 1 -fi - - - - -RELEASE_Run_CHOCOLATEY() { - #___target="$1" - #___repo="$2" - - - # validate input - CHOCOLATEY_Is_Valid_Nupkg "$1" - if [ $? -ne 0 ]; then - return 0 - fi - - I18N_Export "$1" - if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then - I18N_Export_Failed - return 1 - fi - - - # execute - CHOCOLATEY_Publish "$1" "${2}/${PROJECT_CHOCOLATEY_DIRECTORY}/" - if [ $? -ne 0 ]; then - I18N_Export_Failed - return 1 - fi - - - # report status - return 0 -} - - - - -RELEASE_Conclude_CHOCOLATEY() { - #___directory="$1" - - - # validate input - I18N_Commit "CHOCOLATEY" - if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then - I18N_Commit_Failed - return 1 - fi - - FS_Is_Directory "$1" - if [ $? -ne 0 ]; then - I18N_Commit_Failed - return 1 - fi - - - # execute - __current_path="$PWD" - cd "$1" - GIT_Autonomous_Commit "${PROJECT_SKU} ${PROJECT_VERSION}" - if [ $? -ne 0 ]; then - cd "$__current_path" && unset __current_path - I18N_Commit_Failed - return 1 - fi - - GIT_Pull_To_Latest - if [ $? -ne 0 ]; then - cd "$__current_path" && unset __current_path - I18N_Commit_Failed - return 1 - fi - - GIT_Push "$PROJECT_CHOCOLATEY_REPO_KEY" "$PROJECT_CHOCOLATEY_REPO_BRANCH" - ___process=$? - cd "$__current_path" && unset __current_path - if [ $___process -ne 0 ]; then - I18N_Commit_Failed - return 1 - fi - - - # report status - return 0 -} - - - - -RELEASE_Setup_CHOCOLATEY() { - # clean up base directory - I18N_Check "CHOCOLATEY" - FS_Is_File "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" - if [ $? -eq 0 ]; then - I18N_Check_Failed - return 1 - fi - FS_Make_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" - - - # execute - I18N_Setup "CHOCOLATEY" - GIT_Clone_Repo \ - "$PROJECT_PATH_ROOT" \ - "$PROJECT_PATH_RELEASE" \ - "$PWD" \ - "$PROJECT_CHOCOLATEY_REPO" \ - "$PROJECT_SIMULATE_RELEASE_REPO" \ - "$PROJECT_CHOCOLATEY_DIRECTORY" - if [ $? -ne 0 ]; then - I18N_Setup_Failed - return 1 - fi - - - # report status - return 0 -} diff --git a/automataCI/_release-chocolatey_windows-any.ps1 b/automataCI/_release-chocolatey_windows-any.ps1 deleted file mode 100644 index c35f6c74..00000000 --- a/automataCI/_release-chocolatey_windows-any.ps1 +++ /dev/null @@ -1,155 +0,0 @@ -# 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 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\i18n\translations.ps1" -. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" -. "${env:LIBS_AUTOMATACI}\services\publishers\chocolatey.ps1" - - - - -# initialize -if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" - return -} - - - - -function RELEASE-Run-CHOCOLATEY { - param( - [string]$___target, - [string]$___repo - ) - - - # validate input - $___process = CHOCOLATEY-Is-Valid-Nupkg "${___target}" - if ($___process -ne 0) { - return 0 - } - - $null = I18N-Export "${___target}" - if (($(STRINGS-Is-Empty "${___target}") -eq 0) -or - ($(STRINGS-Is-Empty "${___repo}") -eq 0)) { - $null = I18N-Export-Failed - return 1 - } - - - # execute - $___process = CHOCOLATEY-Publish ` - "${___target}" ` - "${___repo}\${env:PROJECT_CHOCOLATEY_DIRECTORY}" - if ($___process -ne 0) { - $null = I18N-Export-Failed - return 1 - } - - - # report status - return 0 -} - - - - -function RELEASE-Conclude-CHOCOLATEY { - param( - [string]$___directory - ) - - - # validate input - $null = I18N-Commit "CHOCOLATEY" - if ($(STRINGS-Is-Empty "${___directory}") -eq 0) { - $null = I18N-Commit-Failed - return 1 - } - - $___process = FS-Is-Directory "${___directory}" - if ($___process -ne 0) { - $null = I18N-Commit-Failed - return 1 - } - - - # execute - $__current_path = Get-Location - $null = Set-Location "${___directory}" - $___process = GIT-Autonomous-Commit "${env:PROJECT_SKU} ${env:PROJECT_VERSION}" - if ($___process -ne 0) { - $null = Set-Location "${__curent_path}" - $null = Remove-Variable __current_path - $null = I18N-Commit-Failed - return 1 - } - - - $___process = GIT-Pull-To-Latest - if ($___process -ne 0) { - $null = Set-Location "${__curent_path}" - $null = Remove-Variable __current_path - $null = I18N-Commit-Failed - return 1 - } - - - $___process = GIT-Push ` - "${env:PROJECT_CHOCOLATEY_REPO_KEY}" ` - "${env:PROJECT_CHOCOLATEY_REPO_BRANCH}" - $null = Set-Location "${__curent_path}" - $null = Remove-Variable __current_path - if ($___process -ne 0) { - $null = I18N-Commit-Failed - return 1 - } - - - # return status - return 0 -} - - - - -function RELEASE-Setup-CHOCOLATEY { - # clean up base directory - $null = I18N-Check "CHOCOLATEY" - $___process = FS-Is-File "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" - if ($___process -eq 0) { - $null = I18N-Check-Failed - return 1 - } - $null = FS-Make-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" - - - # execute - $null = I18N-Setup "CHOCOLATEY" - $___process = GIT-Clone-Repo ` - "${env:PROJECT_PATH_ROOT}" ` - "${env:PROJECT_PATH_RELEASE}" ` - "$(Get-Location)" ` - "${env:PROJECT_CHOCOLATEY_REPO}" ` - "${env:PROJECT_SIMULATE_RELEASE_REPO}" ` - "${env:PROJECT_CHOCOLATEY_DIRECTORY}" - if ($___process -ne 0) { - $null = I18N-Setup-Failed - return 1 - } - - - # report status - return 0 -} diff --git a/automataCI/_release-citation_unix-any.sh b/automataCI/_release-citation_unix-any.sh index 8a758bb8..2b950d23 100644 --- a/automataCI/_release-citation_unix-any.sh +++ b/automataCI/_release-citation_unix-any.sh @@ -11,6 +11,7 @@ # 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/i18n/translations.sh" @@ -26,21 +27,30 @@ fi RELEASE_Run_CITATION_CFF() { - _target="$1" + #__target="$1" # validate - if [ $(FS_Is_Target_A_Citation_CFF "$_target") -ne 0 ]; then + if [ $(FS_Is_Target_A_Citation_CFF "$1") -ne 0 ]; then return 0 fi + if [ $(STRINGS_Is_Empty "$PROJECT_CITATION") -eq 0 ]; then + return 0 # disabled explicitly + fi + # execute - I18N_Export "CITATION.cff" - FS_Copy_File "$_target" "${PROJECT_PATH_ROOT}/CITATION.cff" - if [ $? -ne 0 ]; then - I18N_Export_Failed - return 1 + I18N_Publish "CITATION.cff" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + FS_Copy_File "$1" "${PROJECT_PATH_ROOT}/CITATION.cff" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Publish "CITATION.cff" fi diff --git a/automataCI/_release-citation_windows-any.ps1 b/automataCI/_release-citation_windows-any.ps1 index 4b0fc0ea..261a7f43 100644 --- a/automataCI/_release-citation_windows-any.ps1 +++ b/automataCI/_release-citation_windows-any.ps1 @@ -10,6 +10,7 @@ # 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\i18n\translations.ps1" @@ -26,23 +27,32 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { function RELEASE-Run-CITATION-CFF { param( - [string]$_target + [string]$__target ) # validate input - $___process = FS-Is-Target-A-Citation-CFF "${_target}" + $___process = FS-Is-Target-A-Citation-CFF "${__target}" if ($___process -ne 0) { return 0 } + if ($(STRINGS-Is-Empty "${env:PROJECT_CITATION}") -eq 0) { + return 0 # disabled explicitly + } + # execute - $null = I18N-Export "CITATION.cff" - $___process = FS-Copy-File "${_target}" "${env:PROJECT_PATH_ROOT}\CITATION.cff" - if ($___process -ne 0) { - $null = I18N-Export-Failed - return 1 + $null = I18N-Publish "CITATION.cff" + if ($(OS-Is-Run-Simulated) -ne 0) { + $___process = FS-Copy-File "${__target}" "${env:PROJECT_PATH_ROOT}\CITATION.cff" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Publish "CITATION.cff" } diff --git a/automataCI/_release-deb_unix-any.sh b/automataCI/_release-deb_unix-any.sh index 751c7522..05cc8307 100644 --- a/automataCI/_release-deb_unix-any.sh +++ b/automataCI/_release-deb_unix-any.sh @@ -12,9 +12,10 @@ # the License. . "${LIBS_AUTOMATACI}/services/io/fs.sh" . "${LIBS_AUTOMATACI}/services/io/os.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" . "${LIBS_AUTOMATACI}/services/compilers/deb.sh" -. "${LIBS_AUTOMATACI}/services/publishers/reprepro.sh" +. "${LIBS_AUTOMATACI}/services/versioners/git.sh" @@ -28,9 +29,95 @@ fi +# define operating variables +DEB_REPO_DATA="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/releaser-deb-repoDB" +if [ $(STRINGS_Is_Empty "$PROJECT_DEB_PATH_DATA") -ne 0 ]; then + DEB_REPO_DATA="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/data/deb/${PROJECT_DEB_PATH_DATA}" +fi + +DEB_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}" # default: flat mode +if [ "${PROJECT_DEB_DISTRIBUTION%%/*}" = "$PROJECT_DEB_DISTRIBUTION" ]; then + ## conventional mode + DEB_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/deb" + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + ;; + *) + # fallback to git mode + if [ $(STRINGS_Is_Empty "$PROJECT_DEB_PATH") -ne 0 ]; then + DEB_REPO="${DEB_REPO}/${PROJECT_DEB_PATH}" + fi + ;; + esac + + ## overrides if PROJECT_RELEASE_REPO is set + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + DEB_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/deb" + fi +fi + + + + +RELEASE_Conclude_DEB() { + #__repo_directory="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_DEB_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + + # execute + I18N_Conclude "DEB" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Conclude "DEB" + return 0 + elif [ ! "${PROJECT_DEB_DISTRIBUTION%%/*}" = "$PROJECT_DEB_DISTRIBUTION" ]; then + # nothing to do in flat mode - report status + return 0 + elif [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + # do nothing - single unified repository will take over later + return 0 + fi + + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + # nothing to do for local directory type - report status + return 0 + ;; + *) + # repository is an independent git repository so proceed as follows. + ;; + esac + + + # commit release + __current_path="$PWD" && cd "$1" + GIT_Autonomous_Force_Commit \ + "$PROJECT_VERSION" \ + "$PROJECT_DEB_REPO_KEY" \ + "$PROJECT_DEB_REPO_BRANCH" + ___process=$? + cd "$__current_path" && unset __current_path + if [ $___process -ne 0 ]; then + I18N_Conclude_Failed + return 1 + fi + + + # report status + return 0 +} + + + + RELEASE_Run_DEB() { __target="$1" - __directory="$2" + __repo_directory="$2" + __data_directory="$3" # validate input @@ -39,55 +126,145 @@ RELEASE_Run_DEB() { return 0 fi - I18N_Check_Availability "REPREPRO" - REPREPRO_Is_Available - if [ $? -ne 0 ]; then - I18N_Check_Failed_Skipped - return 0 + if [ $(STRINGS_Is_Empty "$PROJECT_DEB_URL") -eq 0 ]; then + return 0 # disabled explicitly fi # execute - __conf="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/deb" - __file="${__conf}/conf/distributions" - FS_Is_File "$__file" - if [ $? -ne 0 ]; then - I18N_Create "$__file" - REPREPRO_Create_Conf \ - "$__conf" \ - "$PROJECT_REPREPRO_CODENAME" \ - "$PROJECT_DEBIAN_DISTRIBUTION" \ - "$PROJECT_REPREPRO_COMPONENT" \ - "$PROJECT_REPREPRO_ARCH" \ - "$PROJECT_GPG_ID" + I18N_Publish "DEB" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + DEB_Publish \ + "$__repo_directory" \ + "$__data_directory" \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/releaser-deb" \ + "$__target" \ + "$PROJECT_DEB_DISTRIBUTION" \ + "$PROJECT_DEB_COMPONENT" if [ $? -ne 0 ]; then - I18N_Create_Failed + I18N_Publish_Failed return 1 fi + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Publish "DEB" fi - __dest="${2}/deb" - I18N_Create "$__dest" - FS_Make_Directory "${__dest}" - if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 + + # report status + return 0 +} + + + + +RELEASE_Setup_DEB() { + #__repo_directory="$1" + + + # validate input + I18N_Check "DEB" + if [ $(STRINGS_Is_Empty "$PROJECT_DEB_URL") -eq 0 ]; then + I18N_Check_Disabled_Skipped + return 0 # disabled explicitly fi - I18N_Publish "REPREPRO" - if [ $(OS_Is_Run_Simulated) -eq 0 ]; then - I18N_Simulate_Publish "REPREPRO" - else - REPREPRO_Publish \ - "$__target" \ - "$__dest" \ - "$__conf" \ - "${__conf}/db" \ - "$PROJECT_REPREPRO_CODENAME" + + # execute + I18N_Setup "DEB" + if [ "${PROJECT_DEB_DISTRIBUTION%%/*}" = "$PROJECT_DEB_DISTRIBUTION" ]; then + # conventional mode + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + ## overridden by single unified repository + FS_Remake_Directory "$1" + return 0 + fi + + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + ## local file directory type + FS_Remake_Directory "$1" + return 0 + ;; + *) + ## fallback to git repository source + ;; + esac + + FS_Make_Housing_Directory "$1" + GIT_Clone_Repo \ + "$PROJECT_PATH_ROOT" \ + "$PROJECT_PATH_RELEASE" \ + "$PWD" \ + "$PROJECT_DEB_REPO" \ + "$PROJECT_SIMULATE_RUN" \ + "deb" if [ $? -ne 0 ]; then - I18N_Publish_Failed + I18N_Setup_Failed return 1 fi + + FS_Make_Directory "$1" + fi + + + # report status + return 0 +} + + + + +RELEASE_Update_DEB() { + #__repo_directory="$1" + #__data_directory="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_DEB_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + + # execute + I18N_Publish "DEB" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Publish "DEB" + return 0 + fi + + DEB_Publish_Conclude \ + "$1" \ + "$2" \ + "$PROJECT_DEB_DISTRIBUTION" \ + "$PROJECT_DEB_ARCH" \ + "$PROJECT_DEB_COMPONENT" \ + "$PROJECT_DEB_CODENAME" \ + "$PROJECT_GPG_ID" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + + + # create the README.md + if [ ! "${PROJECT_DEB_DISTRIBUTION%%/*}" = "$PROJECT_DEB_DISTRIBUTION" ]; then + # it's flat repo so stop here - no README.md is required + return 0 + fi + + __dest="${1}/DEB_Repository.md" + I18N_Create "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Remove_Silently "$__dest" + FS_Write_File "$__dest" "\ +# DEB Distribution Repository + +This directory is now re-purposed to host DEB packages repository. +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 fi diff --git a/automataCI/_release-deb_windows-any.ps1 b/automataCI/_release-deb_windows-any.ps1 index f7ad6b84..134c38fc 100644 --- a/automataCI/_release-deb_windows-any.ps1 +++ b/automataCI/_release-deb_windows-any.ps1 @@ -3,7 +3,7 @@ # 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 +# 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 @@ -11,9 +11,10 @@ # under the License. . "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" . "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" . "${env:LIBS_AUTOMATACI}\services\compilers\deb.ps1" -. "${env:LIBS_AUTOMATACI}\services\publishers\reprepro.ps1" +. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" @@ -27,10 +28,96 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { +# define operating variables +$DEB_REPO_DATA = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\releaser-deb-repoDB" +if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_PATH_DATA}") -ne 0) { + $DEB_REPO_DATA = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\data\deb\${env:PROJECT_DEB_PATH_DATA}" +} + +$DEB_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}" # default: flat mode +if ("$(${env:PROJECT_DEB_DISTRIBUTION} -replace "\/.*$", '')" -eq "${env:PROJECT_DEB_DISTRIBUTION}") { + ## conventional mode + $DEB_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\deb" + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + # retain existing path + } default { + # fallback to git mode + if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_PATH}") -ne 0) { + $DEB_REPO = "${DEB_REPO}\${PROJECT_DEB_PATH}" + } + }} + + ## overrides if PROJECT_RELEASE_REPO is set + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0) { + $DEB_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\deb" + } +} + + + + +function RELEASE-Conclude-DEB { + param( + [string]$__repo_directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_URL}") -eq 0) { + return 0 # disabled explictly + } + + + # execute + $null = I18N-Conclude "DEB" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Conclude "DEB" + return 0 + } elseif ("$($___distribution -replace "\/.*$", '')" -ne $___distribution) { + # nothing to do in flat mode - report status + return 0 + } elseif ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0) { + # do nothing - single unified repository will take over later + return 0 + } + + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + # nothing to do for local directory type - report status + return 0 + } default { + # repository is an independent git repository so proceed as follows. + }} + + + # commit release + $__current_path = Get-Location + $null = Set-Location "${__repo_directory}" + $___process = Git-Autonomous-Force-Commit ` + "${env:PROJECT_VERSION}" ` + "${env:PROJECT_DEB_REPO_KEY}" ` + "${env:PROJECT_DEB_REPO_BRANCH}" + $null = Set-Location "${__curent_path}" + $null = Remove-Variable __current_path + if ($___process -ne 0) { + $null = I18N-Conclude-Failed + return 1 + } + + + # return status + return 0 +} + + + + function RELEASE-Run-DEB { param( [string]$__target, - [string]$__directory + [string]$__repo_directory, + [string]$__data_directory ) @@ -40,55 +127,148 @@ function RELEASE-Run-DEB { return 0 } - $null = I18N-Check-Availability "REPREPRO" - $___process = REPREPRO-Is-Available - if ($___process -ne 0) { - $null = I18N-Check-Failed-Skipped - return 0 + if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_URL}") -eq 0) { + return 0 # disabled explictly } # execute - $__conf = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\deb" - $__file = "${__conf}\conf\distributions" - $___process = FS-Is-File "${__file}" - if ($___process -ne 0) { - $null = I18N-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}" + $null = I18N-Publish "DEB" + if ($(OS-Is-Run-Simulated) -ne 0) { + $___process = DEB-Publish ` + "${__repo_directory}" ` + "${__data_directory}" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\releaser-deb" ` + "${__target}" ` + "${env:PROJECT_DEB_DISTRIBUTION}" ` + "${env:PROJECT_DEB_COMPONENT}" if ($___process -ne 0) { - $null = I18N-Create-Failed + $null = I18N-Publish-Failed return 1 } + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Publish "DEB" } - $__dest = "${__directory}/deb" - $null = I18N-Create "${__dest}" - $___process = FS-Make-Directory "${__dest}" + + # report status + return 0 +} + + + + +function RELEASE-Setup-DEB { + param( + [string]$__repo_directory + ) + + + # validate input + $null = I18N-Check "DEB" + if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_URL}") -eq 0) { + $null = I18N-Check-Disabled-Skipped + return 0 # disabled explictly + } + + + # execute + $null = I18N-Setup "DEB" + if ("$($___distribution -replace "\/.*$", '')" -eq $___distribution) { + # conventional mode + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -eq 0) { + ## overridden by single unified repository + $null = FS-Remake-Directory "${__repo_directory}" + return 0 + } + + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + ## local file directory type + $null = FS-Remake-Directory "${__repo_directory}" + return 0 + } default { + ## fallback to git repository source + }} + + $null = FS-Make-Housing-Directory "${__repo_directory}" + $___process = GIT-Clone-Repo ` + "${env:PROJECT_PATH_ROOT}" ` + "${env:PROJECT_PATH_RELEASE}" ` + "$(Get-Location)" ` + "${env:PROJECT_DEB_REPO}" ` + "${env:PROJECT_SIMULATE_RUN}" ` + "deb" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + + $null = FS-Make-Directory "${__repo_directory}" + } + + + # report status + return 0 +} + + + + +function RELEASE-Update-DEB { + param( + [string]$__repo_directory, + [string]$__data_directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_URL}") -eq 0) { + return 0 # disabled explictly + } + + + # execute + $null = I18N-Publish "DEB" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Publish "DEB" + return 0 + } + + $___process = DEB-Publish-Conclude ` + "${__repo_directory}" ` + "${__data_directory}" ` + "${env:PROJECT_DEB_DISTRIBUTION}" ` + "${env:PROJECT_DEB_ARCH}" ` + "${env:PROJECT_DEB_COMPONENT}" ` + "${env:PROJECT_DEB_CODENAME}" ` + "${env:PROJECT_GPG_ID}" if ($___process -ne 0) { - $null = I18N-Create-Failed + $null = I18N-Publish-Failed return 1 } - $null = I18N-Publish "REPREPRO" - if ($(OS-Is-Run-Simulated) -eq 0) { - $null = I18N-Simulate-Publish "REPREPRO" - } else { - $___process = REPREPRO-Publish ` - "${__target}" ` - "${__dest}" ` - "${__conf}" ` - "${__conf}\db" ` - "${env:PROJECT_REPREPRO_CODENAME}" - if ($___process -ne 0) { - $null = I18N-Publish-Failed - return 1 - } + + # create the README.md + if ("$($___distribution -replace "\/.*$", '')" -ne $___distribution) { + # it's flat repo so stop here - no README.md is required + return 0 + } + + $___dest = "${__repo_directory}\DEB_Repository.md" + $null = I18N-Create "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $null = FS-Remove-Silently "${__dest}" + $___process = FS-Write-File "${__dest}" @" +# DEB Distribution Repository + +This directory is now re-purposed to host DEB packages repository. + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 } diff --git a/automataCI/_release-docker_unix-any.sh b/automataCI/_release-docker_unix-any.sh index 55e1c1c6..218b11ed 100644 --- a/automataCI/_release-docker_unix-any.sh +++ b/automataCI/_release-docker_unix-any.sh @@ -10,8 +10,9 @@ # 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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" . "${LIBS_AUTOMATACI}/services/compilers/docker.sh" @@ -28,16 +29,19 @@ fi RELEASE_Run_DOCKER() { - _target="$1" - _directory="$2" + __target="$1" # validate input - DOCKER_Is_Valid "$_target" + DOCKER_Is_Valid "$__target" if [ $? -ne 0 ]; then return 0 fi + if [ $(STRINGS_Is_Empty "$PROJECT_CONTAINER_REGISTRY") -eq 0 ]; then + return 0 # disabled explicitly + fi + I18N_Check_Availability "DOCKER" DOCKER_Is_Available if [ $? -ne 0 ]; then @@ -48,17 +52,18 @@ RELEASE_Run_DOCKER() { # execute I18N_Publish "DOCKER" - if [ $(OS_Is_Run_Simulated) -eq 0 ]; then - I18N_Simulate_Publish "DOCKER" - else - DOCKER_Release "$_target" "$PROJECT_VERSION" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + DOCKER_Release "$__target" "$PROJECT_VERSION" if [ $? -ne 0 ]; then I18N_Publish_Failed return 1 fi - I18N_Clean "$_target" - FS_Remove_Silently "$_target" + I18N_Clean "$__target" + FS_Remove_Silently "$__target" + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Publish "DOCKER" fi diff --git a/automataCI/_release-docker_windows-any.ps1 b/automataCI/_release-docker_windows-any.ps1 index 1ecb8a15..4435555c 100644 --- a/automataCI/_release-docker_windows-any.ps1 +++ b/automataCI/_release-docker_windows-any.ps1 @@ -9,8 +9,9 @@ # 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\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" . "${env:LIBS_AUTOMATACI}\services\compilers\docker.ps1" @@ -28,17 +29,20 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { function RELEASE-Run-DOCKER { param( - [string]$_target, - [string]$_directory + [string]$__target ) # validate input - $___process = DOCKER-Is-Valid "${_target}" + $___process = DOCKER-Is-Valid "${__target}" if ($___process -ne 0) { return 0 } + if ($(STRINGS-Is-Empty "${env:PROJECT_CONTAINER_REGISTRY}") -eq 0) { + return 0 # disabled explicitly + } + $null = I18N-Check-Availability "DOCKER" $___process = DOCKER-Is-Available if ($___process -ne 0) { @@ -49,17 +53,18 @@ function RELEASE-Run-DOCKER { # execute $null = I18N-Publish "DOCKER" - if ($(OS-Is-Run-Simulated) -eq 0) { - $null = I18N-Simulate-Publish "DOCKER" - } else { - $___process = DOCKER-Release "${_target}" "${env:PROJECT_VERSION}" + if ($(OS-Is-Run-Simulated) -ne 0) { + $___process = DOCKER-Release "${__target}" "${env:PROJECT_VERSION}" if ($___process -ne 0) { $null = I18N-Publish-Failed return 1 } - $null = I18N-Clean "${_target}" - $null = FS-Remove-Silently "${_target}" + $null = I18N-Clean "${__target}" + $null = FS-Remove-Silently "${__target}" + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Publish "DOCKER" } diff --git a/automataCI/_release-docsrepo_unix-any.sh b/automataCI/_release-docsrepo_unix-any.sh index 4cbee009..770c3f37 100644 --- a/automataCI/_release-docsrepo_unix-any.sh +++ b/automataCI/_release-docsrepo_unix-any.sh @@ -10,6 +10,7 @@ # 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/os.sh" . "${LIBS_AUTOMATACI}/services/io/fs.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" . "${LIBS_AUTOMATACI}/services/versioners/git.sh" @@ -28,7 +29,18 @@ fi RELEASE_Conclude_DOCS() { # validate input - I18N_Check "DOCS" + if [ $(STRINGS_Is_Empty "$PROJECT_DOCS_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + + # execute + I18N_Publish "DOCS" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Conclude "DOCS" + return 0 + fi + FS_Is_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_DOCS}" if [ $? -ne 0 ]; then return 0 @@ -36,21 +48,21 @@ RELEASE_Conclude_DOCS() { FS_Is_File "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" if [ $? -eq 0 ]; then - I18N_Check_Failed + I18N_Publish_Failed return 1 fi - FS_Make_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" + FS_Make_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" - # execute I18N_Setup "DOCS" + __directory_name="x_docsrepo" GIT_Clone_Repo \ "$PROJECT_PATH_ROOT" \ "$PROJECT_PATH_RELEASE" \ "$PWD" \ "$PROJECT_DOCS_REPO" \ - "$PROJECT_SIMULATE_RELEASE_REPO" \ - "$PROJECT_DOCS_REPO_DIRECTORY" \ + "$PROJECT_SIMULATE_RUN" \ + "$__directory_name" \ "$PROJECT_DOCS_REPO_BRANCH" if [ $? -ne 0 ]; then I18N_Setup_Failed @@ -60,35 +72,40 @@ RELEASE_Conclude_DOCS() { # export contents __staging="${PROJECT_PATH_ROOT}/${PROJECT_PATH_DOCS}" - __dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/${PROJECT_DOCS_REPO_DIRECTORY}" + __dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/${__directory_name}" I18N_Export "$__staging" FS_Copy_All "${__staging}/" "$__dest" if [ $? -ne 0 ]; then I18N_Export_Failed + FS_Remove_Silently "$__dest" return 1 fi - I18N_Commit "DOCS" __tag="$(GIT_Get_Latest_Commit_ID)" + I18N_Commit "$__tag" if [ $(STRINGS_Is_Empty "$__tag") -eq 0 ]; then I18N_Commit_Failed + FS_Remove_Silently "$__dest" return 1 fi - ___current_path="$PWD" && cd "${__dest}" + __current_path="$PWD" && cd "$__dest" GIT_Autonomous_Force_Commit \ "$__tag" \ "$PROJECT_DOCS_REPO_KEY" \ "$PROJECT_DOCS_REPO_BRANCH" ___process=$? - cd "$___current_path" && unset ___current_path + cd "$__current_path" && unset __current_path if [ $___process -ne 0 ]; then I18N_Commit_Failed + FS_Remove_Silently "$__dest" return 1 fi + FS_Remove_Silently "$__dest" + # report status return 0 diff --git a/automataCI/_release-docsrepo_windows-any.ps1 b/automataCI/_release-docsrepo_windows-any.ps1 index 2730fdff..caccec59 100644 --- a/automataCI/_release-docsrepo_windows-any.ps1 +++ b/automataCI/_release-docsrepo_windows-any.ps1 @@ -9,6 +9,7 @@ # 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\os.ps1" . "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" . "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" @@ -27,7 +28,18 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { function RELEASE-Conclude-DOCS { # validate input - $null = I18N-Check "DOCS" + if ($(STRINGS-Is-Empty "${env:PROJECT_DOCS_URL}") -eq 0) { + return 0 # disabled explicitly + } + + + # execute + $null = I18N-Publish "DOCS" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Conclude "DOCS" + return 0 + } + $___process = FS-Is-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_DOCS}" if ($___process -ne 0) { return 0 @@ -35,21 +47,21 @@ function RELEASE-Conclude-DOCS { $___process = FS-Is-File "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" if ($___process -eq 0) { - $null = I18N-Check-Failed + $null = I18N-Publish-Failed return 1 } - $null = FS-Make-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + $null = FS-Make-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" - # execute $null = I18N-Setup "DOCS" + $__directory_name = "x_docsrepo" $___process = GIT-Clone-Repo ` "${env:PROJECT_PATH_ROOT}" ` "${env:PROJECT_PATH_RELEASE}" ` "$(Get-Location)" ` "${env:PROJECT_DOCS_REPO}" ` - "${env:PROJECT_SIMULATE_RELEASE_REPO}" ` - "${env:PROJECT_DOCS_REPO_DIRECTORY}" ` + "${env:PROJECT_SIMULATE_RUN}" ` + "${__directory_name}" ` "${env:PROJECT_DOCS_REPO_BRANCH}" if ($___process -ne 0) { $null = I18N-Setup-Failed @@ -59,19 +71,21 @@ function RELEASE-Conclude-DOCS { # export contents $__staging = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_DOCS}" - $__dest = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\${env:PROJECT_DOCS_REPO_DIRECTORY}" + $__dest = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\${__directory_name}" $null = I18N-Export "${__staging}" $___process = FS-Copy-All "${__staging}\" "${__dest}" if ($___process -ne 0) { $null = I18N-Export-Failed + $null = FS-Remove-Silently "${__dest}" return 1 } - $null = I18N-Commit "DOCS" $__tag = GIT-Get-Latest-Commit-ID + $null = I18N-Commit "${__tag}" if ($(STRINGS-Is-Empty "${__tag}") -eq 0) { $null = I18N-Commit-Failed + $null = FS-Remove-Silently "${__dest}" return 1 } @@ -88,10 +102,13 @@ function RELEASE-Conclude-DOCS { if ($___process -ne 0) { $null = I18N-Commit-Failed + $null = FS-Remove-Silently "${__dest}" return 1 } + $null = FS-Remove-Silently "${__dest}" + - # report status + # return status return 0 } diff --git a/automataCI/_release-flatpak_unix-any.sh b/automataCI/_release-flatpak_unix-any.sh new file mode 100644 index 00000000..9a03dabf --- /dev/null +++ b/automataCI/_release-flatpak_unix-any.sh @@ -0,0 +1,145 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/versioners/git.sh" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +# define operating variables +FLATPAK_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/flatpak" + + + + +RELEASE_Conclude_FLATPAK() { + #__repo_directory="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_FLATPAK_URL") -eq 0 ]; then + return 0 # disabled explicitly + elif [ $(STRINGS_Is_Empty "$PROJECT_FLATPAK_REPO") -eq 0 ] && + [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -eq 0 ]; then + return 0 # single file bundles only + elif [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + return 0 # do nothing - single unified repository will take over later + fi + + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + return 0 # do nothing + ;; + *) + # it's a git repository + ;; + esac + + + # execute + I18N_Conclude "FLATPAK" + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 0 # no repository setup during package job + fi + + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Conclude "FLATPAK" + return 0 + fi + + + # commit the git repository + __current_path="$PWD" && cd "$1" + GIT_Pull_To_Latest + if [ $? -ne 0 ]; then + cd "$__current_path" && unset __current_path + I18N_Conclude_Failed + return 1 + fi + + GIT_Autonomous_Commit "${PROJECT_SKU} ${PROJECT_VERSION}" + if [ $? -ne 0 ]; then + cd "$__current_path" && unset __current_path + I18N_Conclude_Failed + return 1 + fi + + GIT_Push "$PROJECT_FLATPAK_REPO_KEY" "$PROJECT_FLATPAK_REPO_BRANCH" + ___process=$? + cd "$__current_path" && unset __current_path + if [ $___process -ne 0 ]; then + I18N_Conclude_Failed + return 1 + fi + + + # report status + return 0 +} + + + + +RELEASE_Setup_FLATPAK() { + #__repo_directory="$1" + + + # validate input + I18N_Check "FLATPAK" + if [ $(STRINGS_Is_Empty "$PROJECT_FLATPAK_URL") -eq 0 ]; then + I18N_Check_Disabled_Skipped + return 0 # disabled explicitly + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_FLATPAK_REPO") -eq 0 ] && + [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -eq 0 ]; then + return 0 # single file bundles only + fi + + + # execute + __source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/flatpak-repo" + FS_Is_Directory "$__source" + if [ $? -ne 0 ]; then + return 0 # no repository setup during package job + fi + + I18N_Setup "FLATPAK" + FS_Remove_Silently "$1" + FS_Move "$__source" "$1" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + FS_Remove_Silently "${1}/.git" + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-flatpak_windows-any.ps1 b/automataCI/_release-flatpak_windows-any.ps1 new file mode 100644 index 00000000..010dadd5 --- /dev/null +++ b/automataCI/_release-flatpak_windows-any.ps1 @@ -0,0 +1,149 @@ +# 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\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + return +} + + + + +# define operating variables +$FLATPAK_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\flatpak" + + + + +function RELEASE-Conclude-FLATPAK { + param( + [string]$__repo_directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_URL}") -eq 0) { + return 0 # disabled explictly + } elseif (($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_REPO}") -eq 0) -and + ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -eq 0)) { + return 0 # single file bundles only + } + + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + return 0 # do nothing + } default { + # it's a git repository + }} + + + # execute + $null = I18N-Conclude "FLATPAK" + $___process = FS-Is-Directory "${__repo_directory}" + if ($___process -ne 0) { + return 0 # no repository setup during package job + } + + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Conclude "FLATPAK" + return 0 + } + + + # commit the git repository + $__current_path = Get-Location + $null = Set-Location "${__repo_directory}" + $___process = GIT-Pull-To-Latest + if ($___process -ne 0) { + $null = Set-Location "${__curent_path}" + $null = Remove-Variable __current_path + $null = I18N-Conclude-Failed + return 1 + } + + $___process = GIT-Autonomous-Commit "${env:PROJECT_SKU} ${env:PROJECT_VERSION}" + if ($___process -ne 0) { + $null = Set-Location "${__curent_path}" + $null = Remove-Variable __current_path + $null = I18N-Conclude-Failed + return 1 + } + + $___process = GIT-Push ` + "${env:PROJECT_FLATPAK_REPO_KEY}" ` + "${env:PROJECT_FLATPAK_REPO_BRANCH}" + $null = Set-Location "${__curent_path}" + $null = Remove-Variable __current_path + if ($___process -ne 0) { + $null = I18N-Conclude-Failed + return 1 + } + + + # return status + return 0 +} + + + + +function RELEASE-Setup-FLATPAK { + param( + [string]$__repo_directory + ) + + + # validate input + $null = I18N-Check "FLATPAK" + if ($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_URL}") -eq 0) { + $null = I18N-Check-Disabled-Skipped + return 0 # disabled explictly + } + + if (($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_REPO}") -eq 0) -and + ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -eq 0)) { + return 0 # single file bundles only + } + + + # execute + $__source = "${PROJECT_PATH_ROOT}\${PROJECT_PATH_TEMP}\flatpak-repo" + $___process = FS-Is-Directory "${__source}" + if ($___process -ne 0) { + return 0 # no repository setup during package job + } + + $null = I18N-Setup "FLATPAK" + $null = FS-Remove-Silently "${__repo_directory}" + $___process = FS-Move "${__source}" "${__repo_directory}" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0) { + $null = FS-Remove-Silently "${__repo_directory}\.git" + } + + + # report status + return 0 +} diff --git a/automataCI/_release-homebrew_unix-any.sh b/automataCI/_release-homebrew_unix-any.sh index 627210ac..1ab5d17d 100644 --- a/automataCI/_release-homebrew_unix-any.sh +++ b/automataCI/_release-homebrew_unix-any.sh @@ -4,17 +4,18 @@ # 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 +# 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/os.sh" . "${LIBS_AUTOMATACI}/services/io/fs.sh" . "${LIBS_AUTOMATACI}/services/io/strings.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" -. "${LIBS_AUTOMATACI}/services/versioners/git.sh" . "${LIBS_AUTOMATACI}/services/publishers/homebrew.sh" +. "${LIBS_AUTOMATACI}/services/versioners/git.sh" @@ -28,28 +29,79 @@ fi -RELEASE_Run_HOMEBREW() { - #___target="$1" - #___repo="$2" +# define operating variables +HOMEBREW_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/homebrew" + + + + +RELEASE_Conclude_HOMEBREW() { + #__repo_directory="$1" # validate input - HOMEBREW_Is_Valid_Formula "$1" - if [ $? -ne 0 ]; then + if [ $(STRINGS_Is_Empty "$PROJECT_HOMEBREW_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + + # execute + I18N_Conclude "HOMEBREW" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Conclude "HOMEBREW" return 0 fi - I18N_Export "$1" - if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then - I18N_Export_Failed + + # commit the formula first + __current_path="$PWD" && cd "$1" + GIT_Pull_To_Latest + if [ $? -ne 0 ]; then + cd "$__current_path" && unset __current_path + I18N_Conclude_Failed + return 1 + fi + + GIT_Autonomous_Commit "${PROJECT_SKU} ${PROJECT_VERSION}" + if [ $? -ne 0 ]; then + cd "$__current_path" && unset __current_path + I18N_Conclude_Failed + return 1 + fi + + GIT_Push "$PROJECT_HOMEBREW_REPO_KEY" "$PROJECT_HOMEBREW_REPO_BRANCH" + ___process=$? + cd "$__current_path" && unset __current_path + if [ $___process -ne 0 ]; then + I18N_Conclude_Failed return 1 fi - # execute - HOMEBREW_Publish "$1" "${2}/Formula/${PROJECT_SKU}.rb" + # clean up in case of other release configurations + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + # remove traces - single unified repository will take over later + FS_Remove "$1" + if [ $? -ne 0 ]; then + I18N_Conclude_Failed + return 1 + fi + + return 0 + fi + + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + # remove traces - formula is never stray from its tap repository. + ;; + *) + return 0 + ;; + esac + + FS_Remove "$1" if [ $? -ne 0 ]; then - I18N_Export_Failed + I18N_Conclude_Failed return 1 fi @@ -61,47 +113,37 @@ RELEASE_Run_HOMEBREW() { -RELEASE_Conclude_HOMEBREW() { - #___directory="$1" +RELEASE_Run_HOMEBREW() { + #___target="$1" + #___repo_directory="$2" - # validate input - I18N_Commit "HOMEBREW" - if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then - I18N_Commit_Failed - return 1 - fi - FS_Is_Directory "$1" + # validate input + HOMEBREW_Is_Valid_Formula "$1" if [ $? -ne 0 ]; then - I18N_Commit_Failed - return 1 + return 0 fi - - # execute - ___current_path="$PWD" - cd "$1" - GIT_Autonomous_Commit "${PROJECT_SKU} ${PROJECT_VERSION}" - if [ $? -ne 0 ]; then - cd "$___current_path" && unset ___current_path - I18N_Commit_Failed - return 1 + if [ $(STRINGS_Is_Empty "$PROJECT_HOMEBREW_URL") -eq 0 ]; then + return 0 # disabled explicitly fi - GIT_Pull_To_Latest - if [ $? -ne 0 ]; then - cd "$___current_path" && unset ___current_path - I18N_Commit_Failed - return 1 - fi - GIT_Push "$PROJECT_CHOCOLATEY_REPO_KEY" "$PROJECT_CHOCOLATEY_REPO_BRANCH" - ___process=$? - cd "$___current_path" && unset ___current_path - if [ $___process -ne 0 ]; then - I18N_Commit_Failed - return 1 + # execute + I18N_Publish "HOMEBREW" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + __dest="$(printf -- "%.1s" "$(FS_Get_File "$1")")" + __dest="${2}/Formula/${__dest}/$(FS_Get_File "$1")" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$1" "$__dest" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Publish "HOMEBREW" fi @@ -113,30 +155,34 @@ RELEASE_Conclude_HOMEBREW() { RELEASE_Setup_HOMEBREW() { - # clean up base directory + #__repo_directory="$1" + + + # validate input I18N_Check "HOMEBREW" - FS_Is_File "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" - if [ $? -eq 0 ]; then - I18N_Check_Failed - return 1 + if [ $(STRINGS_Is_Empty "$PROJECT_HOMEBREW_URL") -eq 0 ]; then + I18N_Check_Disabled_Skipped + return 0 # disabled explicitly fi - FS_Make_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" # execute I18N_Setup "HOMEBREW" + FS_Make_Housing_Directory "$1" GIT_Clone_Repo \ "$PROJECT_PATH_ROOT" \ "$PROJECT_PATH_RELEASE" \ "$PWD" \ "$PROJECT_HOMEBREW_REPO" \ - "$PROJECT_SIMULATE_RELEASE_REPO" \ - "$PROJECT_HOMEBREW_DIRECTORY" + "$PROJECT_SIMULATE_RUN" \ + "homebrew" if [ $? -ne 0 ]; then I18N_Setup_Failed return 1 fi + FS_Make_Directory "$1" + # report status return 0 diff --git a/automataCI/_release-homebrew_windows-any.ps1 b/automataCI/_release-homebrew_windows-any.ps1 index 30c48713..a7402c54 100644 --- a/automataCI/_release-homebrew_windows-any.ps1 +++ b/automataCI/_release-homebrew_windows-any.ps1 @@ -9,11 +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:LIBS_AUTOMATACI}\services\io\os.ps1" . "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" . "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" -. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" . "${env:LIBS_AUTOMATACI}\services\publishers\homebrew.ps1" +. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" @@ -27,90 +28,82 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { -function RELEASE-Run-HOMEBREW { - param( - [string]$___target, - [string]$___repo - ) - - - # validate input - $___process = HOMEBREW-Is-Valid-Formula "${___target}" - if ($___process -ne 0) { - return 0 - } - - $null = I18N-Export "${___target}" - if (($(STRINGS-Is-Empty "${___target}") -eq 0) -or - ($(STRINGS-Is-Empty "${___repo}") -eq 0)) { - $null = I18N-Export-Failed - return 1 - } - - - # execute - $___process = HOMEBREW-Publish "${___target}" "${___repo}/Formula/${env:PROJECT_SKU}.rb" - if ($___process -ne 0) { - $null = I18N-Export-Failed - return 1 - } - - - # report status - return 0 -} +# define operating variables +$HOMEBREW_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\homebrew" function RELEASE-Conclude-HOMEBREW { param( - [string]$___directory + [string]$__repo_directory ) # validate input - $null = I18N-Commit "HOMEBREW" - if ($(STRINGS-Is-Empty "${___directory}") -eq 0) { - $null = I18N-Commit-Failed - return 1 + if ($(STRINGS-Is-Empty "${env:PROJECT_HOMEBREW_URL}") -eq 0) { + return 0 # disabled explictly } - $___process = FS-Is-Directory "${___directory}" - if ($___process -ne 0) { - $null = I18N-Commit-Failed - return 1 + + # execute + $null = I18N-Conclude "HOMEBREW" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Conclude "HOMEBREW" + return 0 } - # execute + # commit the formula first $__current_path = Get-Location - $null = Set-Location "${___directory}" - $___process = GIT-Autonomous-Commit "${env:PROJECT_SKU} ${env:PROJECT_VERSION}" + $null = Set-Location "${__repo_directory}" + $___process = GIT-Pull-To-Latest if ($___process -ne 0) { $null = Set-Location "${__curent_path}" $null = Remove-Variable __current_path - $null = I18N-Commit-Failed + $null = I18N-Conclude-Failed return 1 } - - $___process = GIT-Pull-To-Latest + $___process = GIT-Autonomous-Commit "${env:PROJECT_SKU} ${env:PROJECT_VERSION}" if ($___process -ne 0) { $null = Set-Location "${__curent_path}" $null = Remove-Variable __current_path - $null = I18N-Commit-Failed + $null = I18N-Conclude-Failed return 1 } - $___process = GIT-Push ` "${env:PROJECT_HOMEBREW_REPO_KEY}" ` "${env:PROJECT_HOMEBREW_REPO_BRANCH}" $null = Set-Location "${__curent_path}" $null = Remove-Variable __current_path if ($___process -ne 0) { - $null = I18N-Commit-Failed + $null = I18N-Conclude-Failed + return 1 + } + + + # clean up in case of other release configurations + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0) { + # remove traces - single unified repository will take over later + $___process = FS-Remove "${__repo_directory}" + if ($___process -ne 0) { + $null = I18N-Conclude-Failed + return 1 + } + } + + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + # remove traces - formula is never stray from its tap repository. + } default { + return 0 + }} + + $___process = FS-Remove "${__repo_directory}" + if ($___process -ne 0) { + $null = I18N-Conclude-Failed return 1 } @@ -122,30 +115,78 @@ function RELEASE-Conclude-HOMEBREW { +function RELEASE-Run-HOMEBREW { + param( + [string]$__target, + [string]$__repo_directory + ) + + + # validate input + $___process = HOMEBREW-Is-Valid-Formula "${__target}" + if ($___process -ne 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_HOMEBREW_URL}") -eq 0) { + return 0 # disabled explictly + } + + + # execute + $null = I18N-Publish "HOMEBREW" + if ($(OS-Is-Run-Simulated) -ne 0) { + $__dest = $(FS-Get-File "${__target}").Substring(0,1) + $__dest = "${___repo_directory}\Formula\${__dest}\$(FS_Get_File "${__target}")" + $null = FS-Make-Housing-Directory "${__dest}" + $___process = FS-Copy-File "${__target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Publish "HOMEBREW" + } + + + # report status + return 0 +} + + + + function RELEASE-Setup-HOMEBREW { - # clean up base directory + param( + [string]$__repo_directory + ) + + + # validate input $null = I18N-Check "HOMEBREW" - $___process = FS-Is-File "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" - if ($___process -eq 0) { - $null = I18N-Check-Failed - return 1 + if ($(STRINGS-Is-Empty "${env:PROJECT_HOMEBREW_URL}") -eq 0) { + $null = I18N-Check-Disabled-Skipped + return 0 # disabled explictly } - $null = FS-Make-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" # execute $null = I18N-Setup "HOMEBREW" + $null = FS-Make-Housing-Directory "${__repo_directory}" $___process = GIT-Clone-Repo ` "${env:PROJECT_PATH_ROOT}" ` "${env:PROJECT_PATH_RELEASE}" ` "$(Get-Location)" ` "${env:PROJECT_HOMEBREW_REPO}" ` - "${env:PROJECT_SIMULATE_RELEASE_REPO}" ` - "${env:PROJECT_HOMEBREW_DIRECTORY}" - if ($___process -ne 0) { - $null = I18N-Setup-Failed - return 1 - } + "${env:PROJECT_SIMULATE_RUN}" ` + "homebrew" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + + $null = FS-Make-Directory "${__repo_directory}" # report status diff --git a/automataCI/_release-lib_unix-any.sh b/automataCI/_release-lib_unix-any.sh index 2b6b4621..cd7f60e9 100644 --- a/automataCI/_release-lib_unix-any.sh +++ b/automataCI/_release-lib_unix-any.sh @@ -10,8 +10,8 @@ # 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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" . "${LIBS_AUTOMATACI}/services/io/strings.sh" . "${LIBS_AUTOMATACI}/services/archive/tar.sh" . "${LIBS_AUTOMATACI}/services/archive/zip.sh" @@ -31,15 +31,15 @@ fi RELEASE_Run_LIBS() { - #_target="$1" + #__target="$1" # validate input - if [ $(STRINGS_Is_Empty "$PROJECT_SOURCE_RELEASE_TAG_LATEST") -eq 0 ]; then + if [ $(FS_Is_Target_A_Library "$1") -ne 0 ]; then return 0 fi - if [ $(FS_Is_Target_A_Library "$1") -ne 0 ]; then + if [ $(STRINGS_Is_Empty "$PROJECT_SOURCE_RELEASE_TAG_LATEST") -eq 0 ]; then return 0 fi @@ -54,7 +54,6 @@ RELEASE_Run_LIBS() { # execute - ## identify tag __branch="v${PROJECT_VERSION}" if [ $(FS_Is_Target_A_NPM "$1") -eq 0 ]; then if [ $(STRINGS_Is_Empty "$PROJECT_NODE_BRANCH_TAG") -eq 0 ]; then @@ -62,17 +61,26 @@ RELEASE_Run_LIBS() { fi __branch="${__branch}_${PROJECT_NODE_BRANCH_TAG}" + elif [ $(FS_Is_Target_A_C "$1") -eq 0 ]; then + if [ $(STRINGS_Is_Empty "$PROJECT_C_BRANCH_TAG") -eq 0 ]; then + return 0 + fi + + __branch="${__branch}_${PROJECT_C_BRANCH_TAG}" else return 0 fi + + # begin publication I18N_Publish "git@$__branch" if [ $(OS_Is_Run_Simulated) -eq 0 ]; then I18N_Simulate_Publish "$__branch" return 0 fi - ## create workspace directory + + # create workspace directory __workspace="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/release-branch_${__branch}" GIT_Setup_Workspace_Bare "$PROJECT_SOURCE_GIT_REMOTE" "$__branch" "$__workspace" if [ $? -ne 0 ]; then @@ -80,7 +88,8 @@ RELEASE_Run_LIBS() { return 1 fi - ## unpack package into directory + + # unpack package into directory if [ $(FS_Is_Target_A_TARGZ "$1") -eq 0 ]; then TAR_Extract_GZ "$__workspace" "$1" elif [ $(FS_Is_Target_A_TARXZ "$1") -eq 0 ]; then @@ -96,7 +105,8 @@ RELEASE_Run_LIBS() { return 1 fi - ## commit release + + # commit release __current_path="$PWD" && cd "$__workspace" GIT_Autonomous_Commit "$__branch" ___process=$? @@ -106,7 +116,8 @@ RELEASE_Run_LIBS() { return 1 fi - ## push to upstream + + # push to upstream GIT_Push_Specific "$__workspace" \ "$PROJECT_SOURCE_GIT_REMOTE" \ "$__branch" \ diff --git a/automataCI/_release-lib_windows-any.ps1 b/automataCI/_release-lib_windows-any.ps1 index 56fe45f1..08017365 100644 --- a/automataCI/_release-lib_windows-any.ps1 +++ b/automataCI/_release-lib_windows-any.ps1 @@ -9,8 +9,8 @@ # 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\os.ps1" +. "${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" @@ -31,17 +31,17 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { function RELEASE-Run-LIBS { param( - [string]$_target + [string]$__target ) # validate input - if ($(STRINGS-Is-Empty "${env:PROJECT_SOURCE_RELEASE_TAG_LATEST}") -eq 0) { + $___process = FS-Is-Target-A-Library "${__target}" + if ($___process -ne 0) { return 0 } - $___process = FS-Is-Target-A-Library "${_target}" - if ($___process -ne 0) { + if ($(STRINGS-Is-Empty "${env:PROJECT_SOURCE_RELEASE_TAG_LATEST}") -eq 0) { return 0 } @@ -56,26 +56,34 @@ function RELEASE-Run-LIBS { # execute - ## identify tag $__branch = "v${env:PROJECT_VERSION}" - if ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { + if ($(FS-Is-Target-A-NPM "${__target}") -eq 0) { if ($(STRINGS-Is-Empty "${env:PROJECT_NODE_BRANCH_TAG}") -eq 0) { return 0 } $__branch = "${__branch}_${env:PROJECT_NODE_BRANCH_TAG}" + } elseif ($(FS-Is-Target-A-C "${__target}") -eq 0) { + if ($(STRINGS-Is-Empty "${env:PROJECT_C_BRANCH_TAG}") -eq 0) { + return 0 + } + + $__branch = "${__branch}_${env:PROJECT_C_BRANCH_TAG}" } else { return 0 } + + # begin publication $null = I18N-Publish "git@${__branch}" if ($(OS-Is-Run-Simulated) -eq 0) { $null = I18N-Simulate-Publish "${__branch}" return 0 } - ## create workspace directory - $__workspace = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\release-branch_${_branch}" + + # create workspace directory + $__workspace = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\release-branch_${__branch}" $___process = GIT-Setup-Workspace-Bare ` "${env:PROJECT_SOURCE_GIT_REMOTE}" ` "${__branch}" ` @@ -85,15 +93,16 @@ function RELEASE-Run-LIBS { return 1 } - ## unpack package into directory - if ($(FS-Is-Target-A-TARGZ "$1") -eq 0) { - $___process = TAR-Extract-GZ "${__workspace}" "${_target}" - } elseif ($(FS-Is-Target-A-TARXZ "$1") -eq 0) { - $___process = TAR-Extract-XZ "${__workspace}" "${_target}" - } elseif ($(FS-Is-Target-A-ZIP "$1") -eq 0) { - $___process = ZIP-Extract "${__workspace}" "${_target}" + + # unpack package into directory + if ($(FS-Is-Target-A-TARGZ "${__target}") -eq 0) { + $___process = TAR-Extract-GZ "${__workspace}" "${__target}" + } elseif ($(FS-Is-Target-A-TARXZ "${__target}") -eq 0) { + $___process = TAR-Extract-XZ "${__workspace}" "${__target}" + } elseif ($(FS-Is-Target-A-ZIP "${__target}") -eq 0) { + $___process = ZIP-Extract "${__workspace}" "${__target}" } else { - $___process = FS-Copy-File "${_target}" "${__workspace}" + $___process = FS-Copy-File "${__target}" "${__workspace}" } if ($___process -ne 0) { @@ -101,7 +110,8 @@ function RELEASE-Run-LIBS { return 1 } - ## commit release + + # commit release $__current_path = Get-Location $null = Set-Location -Path "${__workspace}" $___process = GIT-Autonomous-Commit "${__branch}" @@ -112,7 +122,8 @@ function RELEASE-Run-LIBS { return 1 } - ## push to upstream + + # push to upstream $___process = GIT-Push-Specific "${__workspace}" ` "${env:PROJECT_SOURCE_GIT_REMOTE}" ` "${__branch}" diff --git a/automataCI/_release-npm_unix-any.sh b/automataCI/_release-npm_unix-any.sh index d3090853..566815dc 100644 --- a/automataCI/_release-npm_unix-any.sh +++ b/automataCI/_release-npm_unix-any.sh @@ -10,8 +10,8 @@ # 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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" . "${LIBS_AUTOMATACI}/services/compilers/node.sh" @@ -28,7 +28,7 @@ fi RELEASE_Run_NPM() { - #_target="$1" + #__target="$1" # validate input @@ -37,6 +37,10 @@ RELEASE_Run_NPM() { return 0 fi + if [ $(STRINGS_Is_Empty "$PROJECT_NODE") -eq 0 ]; then + return 0 # disabled explicitly + fi + I18N_Activate_Environment NODE_Activate_Local_Environment if [ $? -ne 0 ]; then @@ -46,19 +50,23 @@ RELEASE_Run_NPM() { # execute - I18N_Check_Login "NPM" - NODE_NPM_Check_Login - if [ $? -eq 0 ]; then - I18N_Publish "NPM" - if [ $(OS_Is_Run_Simulated) -eq 0 ]; then - I18N_Simulate_Publish "$1" - else - NODE_NPM_Publish "$1" - if [ $? -ne 0 ]; then - I18N_Publish_Failed - return 1 - fi + I18N_Publish "NPM" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + I18N_Check_Login "NPM" + NODE_NPM_Check_Login + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + + NODE_NPM_Publish "$1" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 fi + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Publish "NPM" fi diff --git a/automataCI/_release-npm_windows-any.ps1 b/automataCI/_release-npm_windows-any.ps1 index 0d620d8b..23e186f3 100644 --- a/automataCI/_release-npm_windows-any.ps1 +++ b/automataCI/_release-npm_windows-any.ps1 @@ -9,8 +9,8 @@ # 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\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" . "${env:LIBS_AUTOMATACI}\services\compilers\node.ps1" @@ -28,16 +28,20 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { function RELEASE-Run-NPM { param( - [string]$_target + [string]$__target ) # validate input - $___process = NODE-NPM-Is-Valid "${_target}" + $___process = NODE-NPM-Is-Valid "${__target}" if ($___process -ne 0) { return 0 } + if ($(STRINGS-Is-Empty "${env:PROJECT_NODE}") -eq 0) { + return 0 # disabled explicitly + } + $null = I18N-Activate-Environment $___process = NODE-Activate-Local-Environment if ($___process -ne 0) { @@ -47,19 +51,23 @@ function RELEASE-Run-NPM { # execute - $null = I18N-Check-Login "NPM" - $___process = NODE-NPM-Check-Login - if ($___process -eq 0) { - $null = I18N-Publish "NPM" - if ($(OS-Is-Run-Simulated) -ne 0) { - $null = I18N-Simulate-Publish "${_target}" - } else { - $___process = NODE-NPM-Publish "${_target}" - if ($___process -ne 0) { - $null = I18N-Publish-Failed - return 1 - } + $null = I18N-Publish "NPM" + if ($(OS-Is-Run-Simulated) -ne 0) { + $null = I18N-Check-Login "NPM" + $___process = NODE-NPM-Check-Login + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + + $___process = NODE-NPM-Publish "${__target}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 } + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Publish "NPM" } diff --git a/automataCI/_release-project_unix-any.sh b/automataCI/_release-project_unix-any.sh new file mode 100644 index 00000000..939fb18b --- /dev/null +++ b/automataCI/_release-project_unix-any.sh @@ -0,0 +1,95 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/versioners/git.sh" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +RELEASE_Conclude_PROJECT() { + # execute + I18N_Conclude "$PROJECT_VERSION" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Conclude "$PROJECT_VERSION" + return 0 + fi + + + FS_Is_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" + if [ $? -eq 0 ] && [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + # commit single unified repository + I18N_Commit "$PROJECT_RELEASE_REPO" + __current_path="$PWD" && cd "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" + GIT_Autonomous_Force_Commit \ + "$PROJECT_VERSION" \ + "$PROJECT_RELEASE_REPO_KEY" \ + "$PROJECT_RELEASE_REPO_BRANCH" + ___process=$? + cd "$__current_path" && unset __current_path + if [ $___process -ne 0 ]; then + I18N_Commit_Failed + return 1 + fi + fi + + + # report status + return 0 +} + + + + +RELEASE_Setup_PROJECT() { + # execute + I18N_Setup "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + I18N_Setup "$PROJECT_RELEASE_REPO" + GIT_Is_Available + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + + FS_Remove_Silently "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" + __current_path="$PWD" && cd "$PROJECT_PATH_ROOT" + git clone "$PROJECT_RELEASE_REPO" "$PROJECT_PATH_RELEASE" + ___process=$? + cd "$__current_path" && unset __current_path + if [ $___process -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + else + FS_Remake_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-project_windows-any.ps1 b/automataCI/_release-project_windows-any.ps1 new file mode 100644 index 00000000..c53744e0 --- /dev/null +++ b/automataCI/_release-project_windows-any.ps1 @@ -0,0 +1,97 @@ +# 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 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\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\changelog.ps1" +. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + return +} + + + + +function RELEASE-Conclude-PROJECT { + # execute + $null = I18N-Conclude "${env:PROJECT_VERSION}" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Conclude "${env:PROJECT_VERSION}" + return 0 + } + + $___process = FS-Is-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + if (($___process -eq 0) -and ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0)) { + # commit single unified repository + $null = I18N-Commit "${env:PROJECT_RELEASE_REPO}" + $__current_path = Get-Location + $null = Set-Location "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + $___process = GIT-Autonomous-Force-Commit ` + "${env:PROJECT_VERSION}" ` + "${env:PROJECT_RELEASE_REPO_KEY}" ` + "${env:PROJECT_RELEASE_REPO_BRANCH}" + $null = Set-Location "${__current_path}" + $null = Remove-Variable __current_path + if ($___process -ne 0) { + $null = I18N-Commit-Failed + return 1 + } + } + + + # return status + return 0 +} + + + + +function RELEASE-Setup-PROJECT { + # execute + $null = I18N-Setup "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0) { + $null = I18N-Setup "${env:PROJECT_RELEASE_REPO}" + $___process = GIT-Is-Available + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + + $null = FS-Remove-Silently "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + $__current_path = Get-Location + $null = Set-Location "${env:PROJECT_PATH_ROOT}" + $___process = OS-Exec "git" ` + "clone `"${env:PROJECT_RELEASE_REPO}`" `"${env:PROJECT_PATH_RELEASE}`"" + $null = Set-Location "${__current_path}" + $null = Remove-Variable __current_path + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + } else { + $___process = FS-Remake-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + } + + + # report status + return 0 +} diff --git a/automataCI/_release-pdf_unix-any.sh b/automataCI/_release-research_unix-any.sh similarity index 66% rename from automataCI/_release-pdf_unix-any.sh rename to automataCI/_release-research_unix-any.sh index 8482988a..77bc2c0c 100644 --- a/automataCI/_release-pdf_unix-any.sh +++ b/automataCI/_release-research_unix-any.sh @@ -10,6 +10,7 @@ # 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/os.sh" . "${LIBS_AUTOMATACI}/services/io/fs.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" @@ -25,8 +26,8 @@ fi -RELEASE_Run_PDF() { - #_target="$1" +RELEASE_Run_RESEARCH() { + #__target="$1" # validate input @@ -34,18 +35,25 @@ RELEASE_Run_PDF() { return 0 fi + if [ "${1##*${PROJECT_RESEARCH_IDENTIFIER}}" = "$1" ]; then + return 0 # not a research paper + fi + # execute - ___dest="PAPER.pdf" - I18N_Publish "$___dest" - ___dest="${PROJECT_PATH_ROOT}/${___dest}" - if [ "${1##*${PROJECT_RESEARCH_IDENTIFIER}}" != "$1" ]; then - ## it's a research paper - FS_Copy_File "$1" "$___dest" + I18N_Publish "RESEARCH" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + __dest="PAPER.pdf" + __dest="${PROJECT_PATH_ROOT}/${__dest}" + I18N_Publish "$__dest" + FS_Copy_File "$1" "$__dest" if [ $? -ne 0 ]; then I18N_Publish_Failed return 1 fi + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Publish "RESEARCH" fi diff --git a/automataCI/_release-pdf_windows-any.ps1 b/automataCI/_release-research_windows-any.ps1 similarity index 62% rename from automataCI/_release-pdf_windows-any.ps1 rename to automataCI/_release-research_windows-any.ps1 index 2c4ec0bc..405d0741 100644 --- a/automataCI/_release-pdf_windows-any.ps1 +++ b/automataCI/_release-research_windows-any.ps1 @@ -9,6 +9,7 @@ # 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\os.ps1" . "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" @@ -24,30 +25,37 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { -function RELEASE-Run-PDF { +function RELEASE-Run-RESEARCH { param( - [string]$_target + [string]$__target ) # validate input - $___process = FS-Is-Target-A-PDF "${_target}" + $___process = FS-Is-Target-A-PDF "${__target}" if ($___process -ne 0) { return 0 } + if ($($__target -replace "^.*${env:PROJECT_RESEARCH_IDENTIFIER}") -eq "${__target}") { + return 0 # not a research paper + } + # execute - $___dest = "PAPER.pdf" - $null = I18N-Publish "${___dest}" - $___dest = "${env:PROJECT_PATH_ROOT}\${___dest}" - if ($($_target -replace "^.*${env:PROJECT_RESEARCH_IDENTIFIER}") -ne "${_target}") { - ## it's a research paper - $___process = FS-Copy-File "${_target}" "${___dest}" + $null = I18N-Publish "RESEARCH" + if ($(OS-Is-Run-Simulated) -ne 0) { + $__dest = "PAPER.pdf" + $null = I18N-Publish "${__dest}" + $__dest = "${env:PROJECT_PATH_ROOT}\${__dest}" + $___process = FS-Copy-File "${__target}" "${__dest}" if ($___process -ne 0) { $null = I18N-Publish-Failed return 1 } + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Publish "RESEARCH" } diff --git a/automataCI/_release-rpm_unix-any.sh b/automataCI/_release-rpm_unix-any.sh index e422fd3d..054b79e7 100644 --- a/automataCI/_release-rpm_unix-any.sh +++ b/automataCI/_release-rpm_unix-any.sh @@ -11,9 +11,12 @@ # License for the specific language governing permissions and limitations under # the License. . "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/os.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" . "${LIBS_AUTOMATACI}/services/compilers/rpm.sh" . "${LIBS_AUTOMATACI}/services/publishers/createrepo.sh" +. "${LIBS_AUTOMATACI}/services/versioners/git.sh" @@ -27,41 +30,261 @@ fi +# define operating variables +RPM_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}" # default: flat mode +if [ $(STRINGS_Is_Empty "$PROJECT_RPM_FLAT_MODE") -eq 0 ]; then + ## conventional mode + RPM_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/rpm" + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + # retain existing path + ;; + *) + # fallback to git mode + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_PATH") -ne 0 ]; then + RPM_REPO="${RPM_REPO}/${PROJECT_RPM_PATH}" + fi + ;; + esac + + ## overrides if PROJECT_RELEASE_REPO is set + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + RPM_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/rpm" + fi +fi + + + + +RELEASE_Conclude_RPM() { + #__repo_directory="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + CREATEREPO_Is_Available + if [ $? -ne 0 ]; then + return 0 # nothing to execute without createrepo or createrepo_c. + fi + + + # execute + I18N_Conclude "RPM" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Conclude "RPM" + return 0 + elif [ $(STRINGS_Is_Empty "$PROJECT_RPM_FLAT_MODE") -ne 0 ]; then + # nothing to do in flat mode - report status + return 0 + elif [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + # do nothing - single unified repository will take over later + return 0 + fi + + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + # nothing to do for local directory type - report status + return 0 + ;; + *) + # repository is an independent git repository so proceed as follows. + ;; + esac + + + # commit release + __current_path="$PWD" && cd "$1" + GIT_Autonomous_Force_Commit \ + "$PROJECT_VERSION" \ + "$PROJECT_RPM_REPO_KEY" \ + "$PROJECT_RPM_REPO_BRANCH" + ___process=$? + cd "$__current_path" && unset __current_path + if [ $___process -ne 0 ]; then + I18N_Conclude_Failed + return 1 + fi + + + # report status + return 0 +} + + + + RELEASE_Run_RPM() { - __target="$1" - __directory="$2" + #__target="$1" + #__repo_directory="$2" # validate input - RPM_Is_Valid "$__target" + RPM_Is_Valid "$1" if [ $? -ne 0 ]; then return 0 fi + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + CREATEREPO_Is_Available + if [ $? -ne 0 ]; then + return 0 # can't execute without createrepo or createrepo_c. + fi + + + # execute + I18N_Publish "RPM" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_FLAT_MODE") -eq 0 ]; then + FS_Copy_File "$1" "${2}/$(FS_Get_File "$1")" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + fi + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Publish "RPM" + fi + + + # report status + return 0 +} + + + + +RELEASE_Setup_RPM() { + #__repo_directory="$1" + + + # validate input + I18N_Check "RPM" + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_URL") -eq 0 ]; then + I18N_Check_Disabled_Skipped + return 0 # disabled explicitly + fi + I18N_Check_Availability "CREATEREPO" CREATEREPO_Is_Available if [ $? -ne 0 ]; then I18N_Check_Failed_Skipped - return 0 + return 0 # pipeline cannot run without createrepo or createrepo_c fi # execute - __dest="${__directory}/rpm" - I18N_Create "$__dest" - FS_Make_Directory "${__dest}" + I18N_Setup "RPM" + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_FLAT_MODE") -eq 0 ]; then + # conventional mode + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + ## overridden by single unified repository + FS_Remake_Directory "$1" + return 0 + fi + + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + ## local file directory type + FS_Remake_Directory "$1" + return 0 + ;; + *) + ## fallback to git repository source + ;; + esac + + FS_Make_Housing_Directory "$1" + GIT_Clone_Repo \ + "$PROJECT_PATH_ROOT" \ + "$PROJECT_PATH_RELEASE" \ + "$PWD" \ + "$PROJECT_RPM_REPO" \ + "$PROJECT_SIMULATE_RUN" \ + "rpm" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + + FS_Make_Directory "$1" + fi + + + # report status + return 0 +} + + + + +RELEASE_Update_RPM() { + #__repo_directory="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + CREATEREPO_Is_Available if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 + return 0 # can't execute without createrepo or createrepo_c. fi - I18N_Publish "CREATEREPO" - CREATEREPO_Publish "$__target" "${__dest}" + + # execute + I18N_Publish "RPM" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Publish "RPM" + return 0 + fi + + CREATEREPO_Publish "$1" if [ $? -ne 0 ]; then I18N_Publish_Failed return 1 fi + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_FLAT_MODE") -ne 0 ]; then + # flattening requested + RPM_Flatten_Repo "$1" \ + "$PROJECT_RPM_REPOXML_NAME" \ + "$PROJECT_RPM_METALINK" \ + "$PROJECT_RPM_URL" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + fi + + + # create the README.md + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_FLAT_MODE") -ne 0 ]; then + # stop here - report status + return 0 + fi + + __dest="${1}/RPM_Repository.md" + I18N_Create "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Remove_Silently "$__dest" + FS_Write_File "$__dest" "\ +# RPM Distribution Repository + +This directory is now re-purposed to host RPM packages repository. +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + # report status return 0 diff --git a/automataCI/_release-rpm_windows-any.ps1 b/automataCI/_release-rpm_windows-any.ps1 index 5780304b..4131c133 100644 --- a/automataCI/_release-rpm_windows-any.ps1 +++ b/automataCI/_release-rpm_windows-any.ps1 @@ -10,9 +10,12 @@ # License for the specific language governing permissions and limitations # under the License. . "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" . "${env:LIBS_AUTOMATACI}\services\compilers\rpm.ps1" . "${env:LIBS_AUTOMATACI}\services\publishers\createrepo.ps1" +. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" @@ -26,10 +29,98 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { +# define operating variables +$RPM_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}" # default: flat mode +if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_FLAT_MODE}") -eq 0) { + ## conventional mode + $RPM_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\rpm" + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + # retain existing path + } default { + # fallback to git mode + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_PATH}") -ne 0) { + $RPM_REPO = "${RPM_REPO}\${PROJECT_RPM_PATH}" + } + }} + + ## overrides if PROJECT_RELEASE_REPO is set + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0) { + $RPM_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\rpm" + } +} + + + + +function RELEASE-Conclude-RPM { + param( + [string]$__repo_directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_URL}") -eq 0) { + return 0 # disabled explictly + } + + $___process = CREATEREPO-Is-Available + if ($___process -ne 0) { + return 0 # nothing to execute without createrepo or createrepo_c. + } + + + # execute + $null = I18N-Conclude "RPM" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Conclude "RPM" + return 0 + } + + + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_FLAT_MODE}") -ne 0) { + # nothing to do in flat mode - report status + return 0 + } elseif ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0) { + # do nothing - single unified repository will take over later + return 0 + } + + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + # nothing to do for local directory type - report status + return 0 + } default { + # repository is an independent git repository so proceed as follows. + }} + + + # commit release + $__current_path = Get-Location + $null = Set-Location "${__repo_directory}" + $___process = Git-Autonomous-Force-Commit ` + "${env:PROJECT_VERSION}" ` + "${env:PROJECT_RPM_REPO_KEY}" ` + "${env:PROJECT_RPM_REPO_BRANCH}" + $null = Set-Location "${__curent_path}" + $null = Remove-Variable __current_path + if ($___process -ne 0) { + $null = I18N-Conclude-Failed + return 1 + } + + + # return status + return 0 +} + + + + function RELEASE-Run-RPM { param( [string]$__target, - [string]$__directory + [string]$__repo_directory ) @@ -39,30 +130,168 @@ function RELEASE-Run-RPM { return 0 } + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_URL}") -eq 0) { + return 0 # disabled explictly + } + + $___process = CREATEREPO-Is-Available + if ($___process -ne 0) { + return 0 # can't execute without createrepo or createrepo_c. + } + + + # execute + $null = I18N-Publish "RPM" + if ($(OS-Is-Run-Simulated) -ne 0) { + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_FLAT_MODE}") -eq 0) { + $___process = FS-Copy-File ` + "${__target}" ` + "${__repo_directory}/$(FS-Get-File "${__target}")" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + } + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Publish "RPM" + } + + + # report status + return 0 +} + + + + +function RELEASE-Setup-RPM { + param( + [string]$__repo_directory + ) + + + # validate input + $null = I18N-Check "RPM" + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_URL}") -eq 0) { + $null = I18N-Check-Disabled-Skipped + return 0 # disabled explictly + } + $null = I18N-Check-Availability "CREATEREPO" $___process = CREATEREPO-Is-Available if ($___process -ne 0) { $null = I18N-Check-Failed-Skipped - return 0 + return 0 # pipeline cannot run without createrepo or createrepo_c } # execute - $__dest = "${__directory}/rpm" - $null = I18N-Create "${__dest}" - $___process = FS-Make-Directory "${__dest}" + $null = I18N-Setup "RPM" + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_FLAT_MODE}") -eq 0) { + # conventional mode + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -eq 0) { + ## overridden by single unified repository + $null = FS-Remake-Directory "${__repo_directory}" + return 0 + } + + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + ## local file directory type + $null = FS-Remake-Directory "${__repo_directory}" + return 0 + } default { + ## fallback to git repository source + }} + + $null = FS-Make-Housing-Directory "${__repo_directory}" + $___process = GIT-Clone-Repo ` + "${env:PROJECT_PATH_ROOT}" ` + "${env:PROJECT_PATH_RELEASE}" ` + "$(Get-Location)" ` + "${env:PROJECT_RPM_REPO}" ` + "${env:PROJECT_SIMULATE_RUN}" ` + "rpm" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + + $null = FS-Make-Directory "${__repo_directory}" + } + + + # report status + return 0 +} + + + + +function RELEASE-Update-RPM { + param( + [string]$__repo_directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_URL}") -eq 0) { + return 0 # disabled explictly + } + + $___process = CREATEREPO-Is-Available if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 + return 0 # can't execute without createrepo or createrepo_c. } - $null = I18N-Publish "CREATEREPO" - $___process = CREATEREPO-Publish "${__target}" "${__dest}" + + # execute + $null = I18N-Publish "RPM" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Publish "RPM" + return 0 + } + + $___process = CREATEREPO-Publish "${__repo_directory}" if ($___process -ne 0) { $null = I18N-Publish-Failed return 1 } + if ($(STRINGS-Is-Empty "$PROJECT_RPM_FLAT_MODE") -ne 0) { + $___process = RPM-Flatten-Repo "${__repo_directory}" ` + "${env:PROJECT_RPM_REPOXML_NAME}" ` + "${env:PROJECT_RPM_METALINK}" ` + "${env:PROJECT_RPM_URL}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + } + + + # create the README.md + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_FLAT_MODE}") -eq 0) { + # stop here - report status + return 0 + } + + $___dest = "${__repo_directory}\RPM_Repository.md" + $null = I18N-Create "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $null = FS-Remove-Silently "${__dest}" + $___process = FS-Write-File "${__dest}" @" +# RPM Distribution Repository + +This directory is now re-purposed to host RPM packages repository. + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + # report status return 0 diff --git a/automataCI/_release-staticrepo_unix-any.sh b/automataCI/_release-staticrepo_unix-any.sh deleted file mode 100644 index fc7605b7..00000000 --- a/automataCI/_release-staticrepo_unix-any.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/sh -# 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 -# 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/i18n/translations.sh" -. "${LIBS_AUTOMATACI}/services/versioners/git.sh" - - - - -# initialize -if [ "$PROJECT_PATH_ROOT" = "" ]; then - >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" - return 1 -fi - - - - -RELEASE_Conclude_STATIC_REPO() { - # validate input - I18N_Source "GIT COMMIT ID" - __tag="$(GIT_Get_Latest_Commit_ID)" - if [ $(STRINGS_Is_Empty "$__tag") -eq 0 ]; then - I18N_Source_Failed - return 1 - fi - - - # execute - __current_path="$PWD" - cd "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/${PROJECT_STATIC_REPO_DIRECTORY}" - - ___file="Home.md" - I18N_Create "$___file" - FS_Write_File "$___file" "\ -# ${PROJECT_NAME} Static Distribution Repository - -This is a re-purposed repository for housing various distribution ecosystem -such as but not limited to \`.deb\`, \`.rpm\`, \`.flatpak\`, and etc for folks -to \`apt-get install\`, \`yum install\`, or \`flatpak install\`. -" - - - I18N_Commit "STATIC REPO" - GIT_Autonomous_Force_Commit \ - "$__tag" \ - "$PROJECT_STATIC_REPO_KEY" \ - "$PROJECT_STATIC_REPO_BRANCH" - ___process=$? - - cd "$__current_path" && unset __current_path - - - # report status - if [ $___process -ne 0 ]; then - I18N_Commit_Failed - return 1 - fi - - return 0 -} - - - - -RELEASE_Setup_STATIC_REPO() { - # clean up base directory - I18N_Check "STATIC REPO" - FS_Is_File "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" - if [ $? -eq 0 ]; then - I18N_Check_Failed - return 1 - fi - FS_Make_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" - - - # execute - I18N_Setup "STATIC REPO" - GIT_Clone_Repo \ - "$PROJECT_PATH_ROOT" \ - "$PROJECT_PATH_RELEASE" \ - "$PWD" \ - "$PROJECT_STATIC_REPO" \ - "$PROJECT_SIMULATE_RELEASE_REPO" \ - "$PROJECT_STATIC_REPO_DIRECTORY" - if [ $? -ne 0 ]; then - I18N_Setup_Failed - return 1 - fi - - - # move existing items to static repo - __staging="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/${PROJECT_PATH_RELEASE}" - __dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/${PROJECT_STATIC_REPO_DIRECTORY}" - FS_Is_Directory "$__staging" - if [ $? -eq 0 ]; then - I18N_Export "STATIC REPO" - FS_Copy_All "${__staging}/" "$__dest" - if [ $? -ne 0 ]; then - I18N_Export_Failed - return 1 - fi - fi - - - # report status - return 0 -} diff --git a/automataCI/_release-staticrepo_windows-any.ps1 b/automataCI/_release-staticrepo_windows-any.ps1 deleted file mode 100644 index 2f60b82e..00000000 --- a/automataCI/_release-staticrepo_windows-any.ps1 +++ /dev/null @@ -1,115 +0,0 @@ -# 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 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\i18n\translations.ps1" -. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" - - - - -# initialize -if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" - return -} - - - - - -function RELEASE-Conclude-STATIC-REPO { - # validate input - $null = I18N-Source "GIT COMMIT ID" - $__tag = GIT-Get-Latest-Commit-ID - if ($(STRINGS-Is-Empty "${__tag}") -eq 0) { - $null = I18N-Source-Failed - return 1 - } - - - # execute - $__current_path = Get-Location - $null = Set-Location "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\${env:PROJECT_STATIC_REPO_DIRECTORY}" - - $__file = "Home.md" - $null = I18N-Create "${__file}" - $null = FS-Write-File "${__file}" @" -# ${env:PROJECT_NAME} Static Distribution Repository - -This is a re-purposed repository for housing various distribution ecosystem -such as but not limited to ``.deb``, ``.rpm``, ``.flatpak``, and etc for folks -to ``apt-get install``, ``yum install``, or ``flatpak install``. - -"@ - - $null = I18N-Commit "STATIC REPO" - $___process = Git-Autonomous-Force-Commit ` - "${__tag}" ` - "${env:PROJECT_STATIC_REPO_KEY}" ` - "${env:PROJECT_STATIC_REPO_BRANCH}" - - $null = Set-Location "${__curent_path}" - $null = Remove-Variable __current_path - - - # return status - if ($___process -ne 0) { - $null = I18N-Commit-Failed - return 1 - } - - return 0 -} - - - - -function RELEASE-Setup-STATIC-REPO { - # clean up base directory - $null = I18N-Check "STATIC REPO" - if ($(FS-Is-File "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}") -eq 0) { - $null = I18N-Check-Failed - return 1 - } - $null = FS-Make-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" - - - # execute - $null = I18N-Setup "STATIC REPO" - $___process = GIT-Clone-Repo ` - "${env:PROJECT_PATH_ROOT}" ` - "${env:PROJECT_PATH_RELEASE}" ` - "$(Get-Location)" ` - "${env:PROJECT_STATIC_REPO}" ` - "${env:PROJECT_SIMULATE_RELEASE_REPO}" ` - "${env:PROJECT_STATIC_REPO_DIRECTORY}" - if ($___process -ne 0) { - $null = I18N-Setup-Failed - return 1 - } - - $__staging = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\${env:PROJECT_PATH_RELEASE}" - $__dest = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\${env:PROJECT_STATIC_REPO_DIRECTORY}" - if ($(FS-Is-Directory "${__staging}") -eq 0) { - $null = I18N-Export "STATIC REPO" - $___process = FS-Copy-All "${__staging}/" "${__dest}" - if ($___process -ne 0) { - $null = I18N-Export-Failed - return 1 - } - } - - - # report status - return 0 -} diff --git a/automataCI/common_unix-any.sh b/automataCI/common_unix-any.sh index ace249ef..c4fc41c8 100644 --- a/automataCI/common_unix-any.sh +++ b/automataCI/common_unix-any.sh @@ -92,12 +92,6 @@ if [ $? -ne 0 ]; then fi -Run_Subroutine_Exec "$PROJECT_C" "C" -if [ $? -ne 0 ]; then - return 1 -fi - - Run_Subroutine_Exec "$PROJECT_GO" "GO" if [ $? -ne 0 ]; then return 1 @@ -146,6 +140,15 @@ if [ $? -ne 0 ]; then fi +# IMPORTANT: C can set the terminal into a very strict mode after build causing +# other technological integrations to fail after run (e.g. flatpak). +# Therefore, it shall be placed as the last one to execute. +Run_Subroutine_Exec "$PROJECT_C" "C" +if [ $? -ne 0 ]; then + return 1 +fi + + # report status diff --git a/automataCI/common_windows-any.ps1 b/automataCI/common_windows-any.ps1 index d5bdb082..fb71873b 100644 --- a/automataCI/common_windows-any.ps1 +++ b/automataCI/common_windows-any.ps1 @@ -88,11 +88,6 @@ if ($___process -ne 0) { return 1 } -$___process = RUN-Subroutine-Exec "${env:PROJECT_C}" "C" -if ($___process -ne 0) { - return 1 -} - $___process = RUN-Subroutine-Exec "${env:PROJECT_GO}" "GO" if ($___process -ne 0) { return 1 @@ -133,6 +128,15 @@ if ($___process -ne 0) { return 1 } +# IMPORTANT: C on unix has some issue with setting the terminal into ultra +# strict mode after build causing other technological integrations +# to fail after run (e.g. flatpak). Therefore, it will be placed as +# the last one to execute. +$___process = RUN-Subroutine-Exec "${env:PROJECT_C}" "C" +if ($___process -ne 0) { + return 1 +} + diff --git a/automataCI/env_unix-any.sh b/automataCI/env_unix-any.sh index ddb64a28..42172966 100644 --- a/automataCI/env_unix-any.sh +++ b/automataCI/env_unix-any.sh @@ -37,7 +37,6 @@ fi . "${LIBS_AUTOMATACI}/services/publishers/dotnet.sh" . "${LIBS_AUTOMATACI}/services/publishers/github.sh" . "${LIBS_AUTOMATACI}/services/publishers/homebrew.sh" -. "${LIBS_AUTOMATACI}/services/publishers/reprepro.sh" @@ -91,14 +90,6 @@ if [ $? -ne 0 ]; then fi -I18N_Install "REPREPRO" -REPREPRO_Setup -if [ $? -ne 0 ]; then - I18N_Install_Failed - return 1 -fi - - I18N_Install "OSSLSIGNCODE" NOTARY_Setup_Microsoft if [ $? -ne 0 ]; then diff --git a/automataCI/env_windows-any.ps1 b/automataCI/env_windows-any.ps1 index e859436e..715f058b 100644 --- a/automataCI/env_windows-any.ps1 +++ b/automataCI/env_windows-any.ps1 @@ -35,7 +35,6 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { . "${env:LIBS_AUTOMATACI}\services\publishers\chocolatey.ps1" . "${env:LIBS_AUTOMATACI}\services\publishers\dotnet.ps1" . "${env:LIBS_AUTOMATACI}\services\publishers\github.ps1" -. "${env:LIBS_AUTOMATACI}\services\publishers\reprepro.ps1" @@ -90,13 +89,6 @@ if ($(MSI-Setup) -ne 0) { } -$null = I18N-Install "REPREPRO" -if ($(REPREPRO-Setup) -ne 0) { - $null = I18N-Install-Failed - return 1 -} - - if ($(STRINGS-Is-Empty "${env:PROJECT_PYTHON}") -ne 0) { $null = I18N-Install "PYTHON" if ($(PYTHON-Setup) -ne 0) { diff --git a/automataCI/package_unix-any.sh b/automataCI/package_unix-any.sh index 175d0e14..7e7a7c6e 100644 --- a/automataCI/package_unix-any.sh +++ b/automataCI/package_unix-any.sh @@ -24,6 +24,9 @@ fi . "${LIBS_AUTOMATACI}/services/io/strings.sh" . "${LIBS_AUTOMATACI}/services/io/sync.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/flatpak.sh" +. "${LIBS_AUTOMATACI}/services/publishers/homebrew.sh" +. "${LIBS_AUTOMATACI}/services/versioners/git.sh" . "${LIBS_AUTOMATACI}/_package-archive_unix-any.sh" . "${LIBS_AUTOMATACI}/_package-cargo_unix-any.sh" @@ -60,14 +63,64 @@ if [ $? -ne 0 ]; then fi +if [ "$(STRINGS_Is_Empty "$PROJECT_HOMEBREW_URL")" -ne 0 ]; then + HOMEBREW_WORKSPACE="packagers-homebrew-${PROJECT_SKU}" + I18N_Setup "$HOMEBREW_WORKSPACE" + HOMEBREW_WORKSPACE="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/${HOMEBREW_WORKSPACE}" + FS_Remake_Directory "${HOMEBREW_WORKSPACE}" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi +fi + + +if [ "$(STRINGS_Is_Empty "$PROJECT_FLATPAK_URL")" -ne 0 ]; then + FLATPAK_REPO="flatpak-repo" + I18N_Setup "$FLATPAK_REPO" + FLATPAK_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/${FLATPAK_REPO}" + FS_Remove_Silently "$FLATPAK_REPO" + + if [ $(STRINGS_Is_Empty "$PROJECT_FLATPAK_REPO") -ne 0 ] && + [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -eq 0 ]; then + # version controlled repository supplied; AND + # single unified repository is not enabled + FS_Make_Housing_Directory "$FLATPAK_REPO" + GIT_Clone_Repo \ + "$PROJECT_PATH_ROOT" \ + "$PROJECT_PATH_TEMP" \ + "$PWD" \ + "$PROJECT_FLATPAK_REPO" \ + "$PROJECT_SIMULATE_RUN" \ + "$(FS_Get_File "$FLATPAK_REPO")" \ + "$PROJECT_FLATPAK_REPO_BRANCH" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_FLATPAK_PATH") -ne 0 ]; then + FLATPAK_REPO="${FLATPAK_REPO}/${PROJECT_FLATPAK_PATH}" + fi + fi + + FS_Make_Directory "$FLATPAK_REPO" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi +fi + + FILE_CHANGELOG_MD="${PROJECT_SKU}-CHANGELOG_${PROJECT_VERSION}.md" FILE_CHANGELOG_MD="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}/${FILE_CHANGELOG_MD}" -FILE_CHANGELOG_DEB="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/deb/changelog.gz" +FILE_CHANGELOG_DEB="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-changelog/deb.gz" PACKAGE_Run_CHANGELOG "$FILE_CHANGELOG_MD" "$FILE_CHANGELOG_DEB" if [ $? -ne 0 ]; then return 1 fi + FILE_CITATION_CFF="${PROJECT_SKU}-CITATION_${PROJECT_VERSION}.cff" FILE_CITATION_CFF="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}/${FILE_CITATION_CFF}" PACKAGE_Run_CITATION "$FILE_CITATION_CFF" @@ -177,112 +230,205 @@ for i in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}"/*; do fi fi - I18N_Sync_Register "$i" __common="${DEST}|${i}|${TARGET_FILENAME}|${TARGET_OS}|${TARGET_ARCH}" - __log="${__log_directory}/archive_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - FS_Append_File "$__parallel_control" "\ + + # begin registrations + I18N_Sync_Register "$i" + + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_ARCHIVE") -ne 0 ]; then + __log="archive_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ ${__common}|${__log}|PACKAGE_Run_ARCHIVE " - if [ $? -ne 0 ]; then - return 1 + if [ $? -ne 0 ]; then + return 1 + fi fi - __log="${__log_directory}/cargo_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - FS_Append_File "$__parallel_control" "\ + if [ $(STRINGS_Is_Empty "$PROJECT_RUST") -ne 0 ]; then + __log="cargo_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ ${__common}|${__log}|PACKAGE_Run_CARGO " - if [ $? -ne 0 ]; then - return 1 + if [ $? -ne 0 ]; then + return 1 + fi fi - __log="${__log_directory}/chocolatey_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - FS_Append_File "$__parallel_control" "\ + # NOTE: chocolatey only serve windows + if [ $(STRINGS_Is_Empty "$PROJECT_CHOCOLATEY_URL") -ne 0 ]; then + case "$TARGET_OS" in + any|windows) + __log="chocolatey_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ ${__common}|${__log}|PACKAGE_Run_CHOCOLATEY " - if [ $? -ne 0 ]; then - return 1 + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + ;; + esac fi - __log="${__log_directory}/deb_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - FS_Append_File "$__parallel_control" "\ + # NOTE: deb does not work in windows or mac + if [ $(STRINGS_Is_Empty "$PROJECT_DEB_URL") -ne 0 ]; then + case "$TARGET_OS" in + windows|darwin) + ;; + *) + __log="deb_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ ${__common}|${FILE_CHANGELOG_DEB}|${__log}|PACKAGE_Run_DEB " - if [ $? -ne 0 ]; then - return 1 + if [ $? -ne 0 ]; then + return 1 + fi + ;; + esac fi - __log="${__log_directory}/docker_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - FS_Append_File "$__serial_control" "\ + # NOTE: container only serve windows and linux + if [ $(STRINGS_Is_Empty "$PROJECT_CONTAINER_REGISTRY") -ne 0 ]; then + case "$TARGET_OS" in + any|linux|windows) + __log="docker_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__serial_control" "\ ${__common}|${__log}|PACKAGE_Run_DOCKER " - if [ $? -ne 0 ]; then - return 1 + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + ;; + esac fi - __flatpak_path="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/${PROJECT_PATH_RELEASE}/flatpak" - __log="${__log_directory}/flatpak_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - FS_Append_File "$__serial_control" "\ -${__common}|${__flatpak_path}|${__log}|PACKAGE_Run_FLATPAK + # NOTE: flatpak only serve linux + FLATPAK_Is_Available + if [ $? -eq 0 ] && [ $(STRINGS_Is_Empty "$PROJECT_FLATPAK_URL") -ne 0 ]; then + case "$TARGET_OS" in + any|linux) + __log="flatpak_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__serial_control" "\ +${__common}|${FLATPAK_REPO}|${__log}|PACKAGE_Run_FLATPAK " - if [ $? -ne 0 ]; then - return 1 + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + ;; + esac fi - __log="${__log_directory}/homebrew_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - FS_Append_File "$__parallel_control" "\ -${__common}|${__log}|PACKAGE_Run_HOMEBREW + # NOTE: homebrew only serve linux and mac + if [ $(STRINGS_Is_Empty "$PROJECT_HOMEBREW_URL") -ne 0 ]; then + case "$TARGET_OS" in + any|darwin|linux) + __log="homebrew_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ +${__common}|${HOMEBREW_WORKSPACE}|${__log}|PACKAGE_Run_HOMEBREW " - if [ $? -ne 0 ]; then - return 1 + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + ;; + esac fi - __log="${__log_directory}/ipk_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - FS_Append_File "$__parallel_control" "\ + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_IPK") -ne 0 ]; then + __log="ipk_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ ${__common}|${__log}|PACKAGE_Run_IPK " - if [ $? -ne 0 ]; then - return 1 + if [ $? -ne 0 ]; then + return 1 + fi fi - __log="${__log_directory}/lib_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - FS_Append_File "$__parallel_control" "\ + if [ $(FS_Is_Target_A_Library "$i") -eq 0 ] && + [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_ARCHIVE") -ne 0 ]; then + __log="lib_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ ${__common}|${__log}|PACKAGE_Run_LIB " - if [ $? -ne 0 ]; then - return 1 + if [ $? -ne 0 ]; then + return 1 + fi fi - __log="${__log_directory}/msi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - FS_Append_File "$__serial_control" "\ + # NOTE: MSI only works in windows + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_MSI") -ne 0 ]; then + case "$TARGET_OS" in + any|windows) + __log="msi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__serial_control" "\ ${__common}|${__log}|PACKAGE_Run_MSI " - if [ $? -ne 0 ]; then - return 1 + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + ;; + esac + fi - __log="${__log_directory}/pdf_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - FS_Append_File "$__parallel_control" "\ + if [ $(FS_Is_Target_A_PDF "$i") -eq 0 ]; then + __log="pdf_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ ${__common}|${__log}|PACKAGE_Run_PDF " - if [ $? -ne 0 ]; then - return 1 + if [ $? -ne 0 ]; then + return 1 + fi fi - __log="${__log_directory}/pypi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - FS_Append_File "$__parallel_control" "\ + if [ $(STRINGS_Is_Empty "$PROJECT_PYTHON") -ne 0 ]; then + __log="pypi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ ${__common}|${__log}|PACKAGE_Run_PYPI " - if [ $? -ne 0 ]; then - return 1 + if [ $? -ne 0 ]; then + return 1 + fi fi - __log="${__log_directory}/rpm_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - FS_Append_File "$__parallel_control" "\ + # NOTE: RPM only serve linux + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_URL") -ne 0 ]; then + case "$TARGET_OS" in + any|linux) + __log="rpm_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ ${__common}|${__log}|PACKAGE_Run_RPM " - if [ $? -ne 0 ]; then - return 1 + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + ;; + esac fi done fi @@ -299,6 +445,28 @@ if [ $? -eq 0 ]; then fi +if [ $(STRINGS_Is_Empty "$PROJECT_HOMEBREW_URL") -ne 0 ]; then + I18N_Newline + I18N_Newline + + __dest="${PROJECT_SKU}.rb" + I18N_Export "$__dest" + __dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}/${__dest}" + HOMEBREW_Seal "$__dest" \ + "${PROJECT_SKU}-homebrew_${PROJECT_VERSION}_any-any.tar.xz" \ + "$HOMEBREW_WORKSPACE" \ + "$PROJECT_SKU" \ + "$PROJECT_PITCH" \ + "$PROJECT_CONTACT_WEBSITE" \ + "$PROJECT_LICENSE" \ + "$PROJECT_HOMEBREW_URL" + if [ $? -ne 0 ];then + I18N_Export_Failed + return 1 + fi +fi + + I18N_Sync_Run_Series FS_Is_File "$__serial_control" if [ $? -eq 0 ]; then diff --git a/automataCI/package_windows-any.ps1 b/automataCI/package_windows-any.ps1 index 2c5f18ce..05abb633 100644 --- a/automataCI/package_windows-any.ps1 +++ b/automataCI/package_windows-any.ps1 @@ -23,6 +23,9 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { . "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" . "${env:LIBS_AUTOMATACI}\services\io\sync.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\flatpak.ps1" +. "${env:LIBS_AUTOMATACI}\services\publishers\homebrew.ps1" +. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" . "${env:LIBS_AUTOMATACI}\_package-changelog_windows-any.ps1" . "${env:LIBS_AUTOMATACI}\_package-citation_windows-any.ps1" @@ -40,9 +43,58 @@ if ($___process -ne 0) { } +if ($(STRINGS-Is-Empty "${env:PROJECT_HOMEBREW_URL}") -ne 0) { + $HOMEBREW_WORKSPACE = "packagers-homebrew-${env:PROJECT_SKU}" + $null = I18N-Setup "${HOMEBREW_WORKSPACE}" + $HOMEBREW_WORKSPACE = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\${HOMEBREW_WORKSPACE}" + $___process = FS-Remake-Directory "${HOMEBREW_WORKSPACE}" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } +} + + +if ($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_URL}") -ne 0) { + $FLATPAK_REPO = "flatpak-repo" + $null = I18N-Setup "${FLATPAK_REPO}" + $FLATPAK_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\${FLATPAK_REPO}" + $null = FS-Remove-Silently "$FLATPAK_REPO" + + if (($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_REPO}") -ne 0) -and + ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0)) { + # version controlled repository supplied; AND + # single unified repository is not enabled + $null = FS-Make-Housing-Directory "$FLATPAK_REPO" + $___process = GIT-Clone-Repo ` + "${env:PROJECT_PATH_ROOT}" ` + "${env:PROJECT_PATH_TEMP}" ` + "$(Get-Location)" ` + "${env:PROJECT_FLATPAK_REPO}" ` + "${env:PROJECT_SIMULATE_RUN}" ` + "$(FS-Get-File "${env:FLATPAK_REPO}")" ` + "${env:PROJECT_FLATPAK_REPO_BRANCH}" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_PATH}") -ne 0) { + $FLATPAK_REPO = "${FLATPAK_REPO}/${env:PROJECT_FLATPAK_PATH}" + } + } + + $___process = FS-Make-Directory "$FLATPAK_REPO" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } +} + + $FILE_CHANGELOG_MD = "${env:PROJECT_SKU}-CHANGELOG_${env:PROJECT_VERSION}.md" $FILE_CHANGELOG_MD = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\${FILE_CHANGELOG_MD}" -$FILE_CHANGELOG_DEB = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\deb\changelog.gz" +$FILE_CHANGELOG_DEB = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-changelog\deb.gz" $___process = Package-Run-CHANGELOG "$FILE_CHANGELOG_MD" "$FILE_CHANGELOG_DEB" if ($___process -ne 0) { return 1 @@ -157,17 +209,18 @@ function SUBROUTINE-Package { # begin registering packagers if ($(FS-Is-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}") -eq 0) { -foreach ($file in (Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}" ` - | Select-Object -ExpandProperty FullName)) { - $___process = FS-Is-File "$file" +foreach ($i in (Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}")) { + $i = $i.FullName + + $___process = FS-Is-File "$i" if ($___process -ne 0) { continue } # parse build candidate - $null = I18N-Detected "${file}" - $TARGET_FILENAME = Split-Path -Leaf $file + $null = I18N-Detected "${i}" + $TARGET_FILENAME = Split-Path -Leaf $i $TARGET_FILENAME = $TARGET_FILENAME -replace "\..*$" $TARGET_OS = $TARGET_FILENAME -replace ".*_" $TARGET_FILENAME = $TARGET_FILENAME -replace "_.*" @@ -192,125 +245,204 @@ foreach ($file in (Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_P } } - $null = I18N-Sync-Register "$file" - $__common = "${DEST}|${file}|${TARGET_FILENAME}|${TARGET_OS}|${TARGET_ARCH}" + $__common = "${DEST}|${i}|${TARGET_FILENAME}|${TARGET_OS}|${TARGET_ARCH}" + + + # begin registrations + $null = I18N-Sync-Register "$i" - $__log = "${__log_directory}\archive_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - $___process = FS-Append-File "${__parallel_control}" @" + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_ARCHIVE}") -ne 0) { + $__log = "archive_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" ${__common}|${__log}|PACKAGE-Run-ARCHIVE "@ - if ($___process -ne 0) { - return 1 + if ($___process -ne 0) { + return 1 + } } - $__log = "${__log_directory}\cargo_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - $___process = FS-Append-File "${__parallel_control}" @" + if ($(STRINGS-Is-Empty "${env:PROJECT_RUST}") -ne 0) { + $__log = "cargo_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" ${__common}|${__log}|PACKAGE-Run-CARGO "@ - if ($___process -ne 0) { - return 1 + if ($___process -ne 0) { + return 1 + } } - $__log = "${__log_directory}\chocolatey_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - $___process = FS-Append-File "${__parallel_control}" @" + # NOTE: chocolatey only serve windows + if ($(STRINGS-Is-Empty "${env:PROJECT_CHOCOLATEY_URL}") -ne 0) { + switch ("${TARGET_OS}") { + { $_ -in "any", "windows" } { + $__log = "chocolatey_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" ${__common}|${__log}|PACKAGE-Run-CHOCOLATEY "@ - if ($___process -ne 0) { - return 1 + if ($___process -ne 0) { + return 1 + } + } default { + }} } - $__log = "${__log_directory}\deb_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - $___process = FS-Append-File "${__parallel_control}" @" + # NOTE: deb does not work in windows or mac + if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_URL}") -ne 0) { + switch ("${TARGET_OS}") { + { $_ -in "windows", "darwin" } { + $__log = "deb_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" ${__common}|${FILE_CHANGELOG_DEB}|${__log}|PACKAGE-Run-DEB "@ - if ($___process -ne 0) { - return 1 + if ($___process -ne 0) { + return 1 + } + } default { + }} } - $__log = "${__log_directory}\docker_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - $___process = FS-Append-File "${__serial_control}" @" + # NOTE: container only server windows and linux + if ($(STRINGS-Is-Empty "${env:PROJECT_CONTAINER_REGISTRY}") -ne 0) { + switch ("${TARGET_OS}") { + { $_ -in "any", "linux", "windows" } { + $__log = "docker_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__serial_control}" @" ${__common}|${__log}|PACKAGE-Run-DOCKER "@ - if ($___process -ne 0) { - return 1 + if ($___process -ne 0) { + return 1 + } + } default { + }} } - $__flatpak_path = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\${env:PROJECT_PATH_RELEASE}\flatpak" - $__log = "${__log_directory}\flatpak_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - $___process = FS-Append-File "${__serial_control}" @" -${__common}|${__flatpak_path}|${__log}|PACKAGE-Run-FLATPAK + # NOTE: flatpak only serve linux + $___process = FLATPAK-Is-Available + if (($___process -eq 0) -and + ($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_URL}") -ne 0)) { + switch ("${TARGET_OS}") { + { $_ -in "any", "linux" } { + $__log = "flatpak_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__serial_control}" @" +${__common}|${FLATPAK_REPO}|${__log}|PACKAGE-Run-FLATPAK "@ - if ($___process -ne 0) { - return 1 + if ($___process -ne 0) { + return 1 + } + } default { + }} } - $__log = "${__log_directory}\homebrew_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - $___process = FS-Append-File "${__parallel_control}" @" -${__common}|${__log}|PACKAGE-Run-HOMEBREW + # NOTE: homebrew only serve linux and mac + if ($(STRINGS-Is-Empty "${env:PROJECT_HOMEBREW_URL}") -ne 0) { + switch ("${TARGET_OS}") { + { $_ -in "any", "darwin", "linux" } { + $__log = "homebrew_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${HOMEBREW_WORKSPACE}|${__log}|PACKAGE-Run-HOMEBREW "@ - if ($___process -ne 0) { - return 1 + if ($___process -ne 0) { + return 1 + } + } default { + }} } - $__log = "${__log_directory}\ipk_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - $___process = FS-Append-File "${__parallel_control}" @" + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_IPK}") -ne 0) { + $__log = "ipk_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" ${__common}|${__log}|PACKAGE-Run-IPK "@ - if ($___process -ne 0) { - return 1 + if ($___process -ne 0) { + return 1 + } } - $__log = "${__log_directory}\lib_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - $___process = FS-Append-File "${__parallel_control}" @" + if (($(FS-Is-Target-A-Library "${i}") -eq 0) -and + ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_ARCHIVE}") -ne 0)) { + $__log = "lib_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" ${__common}|${__log}|PACKAGE-Run-LIB "@ - if ($___process -ne 0) { - return 1 + if ($___process -ne 0) { + return 1 + } } - $__log = "${__log_directory}\msi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - $___process = FS-Append-File "${__serial_control}" @" + # NOTE: MSI only works in windows + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_MSI}") -ne 0) { + switch ("${TARGET_OS}") { + { $_ -in "any", "windows" } { + $__log = "msi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__serial_control}" @" ${__common}|${__log}|PACKAGE-Run-MSI "@ - if ($___process -ne 0) { - return 1 + if ($___process -ne 0) { + return 1 + } + } default { + }} } - $__log = "${__log_directory}\PDF_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - $___process = FS-Append-File "${__parallel_control}" @" + if ($(FS-Is-Target-A-PDF "${i}") -eq 0) { + $__log = "PDF_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" ${__common}|${__log}|PACKAGE-Run-PDF "@ - if ($___process -ne 0) { - return 1 + if ($___process -ne 0) { + return 1 + } } - $__log = "${__log_directory}\pypi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - $___process = FS-Append-File "${__parallel_control}" @" + if ($(STRINGS-Is-Empty "${env:PROJECT_PYTHON}") -ne 0) { + $__log = "pypi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" ${__common}|${__log}|PACKAGE-Run-PYPI "@ - if ($___process -ne 0) { - return 1 + if ($___process -ne 0) { + return 1 + } } - $__log = "${__log_directory}\rpm_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" - $___process = FS-Append-File "${__parallel_control}" @" + # NOTE: RPM only serve linux + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_URL}") -ne 0) { + switch ("${TARGET_OS}") { + { $_ -in "any", "linux" } { + $__log = "rpm_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" ${__common}|${__log}|PACKAGE-Run-RPM "@ - if ($___process -ne 0) { - return 1 + if ($___process -ne 0) { + return 1 + } + } default { + }} } } } @@ -330,6 +462,28 @@ if ($___process -eq 0) { } +if ($(STRINGS-Is-Empty "${env:PROJECT_HOMEBREW_URL}") -ne 0) { + $null = I18N-Newline + $null = I18N-Newline + + $__dest = "${env:PROJECT_SKU}.rb" + $null = I18N-Export "${__dest}" + $__dest = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\${__dest}" + $___process = HOMEBREW-Seal "${__dest}" ` + "${env:PROJECT_SKU}-homebrew_${env:PROJECT_VERSION}_any-any.tar.xz" ` + "${HOMEBREW_WORKSPACE}" ` + "${env:PROJECT_SKU}" ` + "${env:PROJECT_PITCH}" ` + "${env:PROJECT_CONTACT_WEBSITE}" ` + "${env:PROJECT_LICENSE}" ` + "${env:PROJECT_HOMEBREW_URL}" + if ($___process -ne 0) { + $null = I18N-Export-Failed + return 1 + } +} + + $null = I18N-Sync-Run-Series $___process = FS-Is-File "${__serial_control}" if ($___process -eq 0) { diff --git a/automataCI/release_unix-any.sh b/automataCI/release_unix-any.sh index b1b196cf..3562d3ef 100644 --- a/automataCI/release_unix-any.sh +++ b/automataCI/release_unix-any.sh @@ -27,17 +27,17 @@ fi . "${LIBS_AUTOMATACI}/_release-cargo_unix-any.sh" . "${LIBS_AUTOMATACI}/_release-changelog_unix-any.sh" . "${LIBS_AUTOMATACI}/_release-checksum_unix-any.sh" -. "${LIBS_AUTOMATACI}/_release-chocolatey_unix-any.sh" . "${LIBS_AUTOMATACI}/_release-citation_unix-any.sh" . "${LIBS_AUTOMATACI}/_release-deb_unix-any.sh" . "${LIBS_AUTOMATACI}/_release-docker_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-flatpak_unix-any.sh" . "${LIBS_AUTOMATACI}/_release-homebrew_unix-any.sh" . "${LIBS_AUTOMATACI}/_release-lib_unix-any.sh" . "${LIBS_AUTOMATACI}/_release-npm_unix-any.sh" -. "${LIBS_AUTOMATACI}/_release-pdf_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-project_unix-any.sh" . "${LIBS_AUTOMATACI}/_release-pypi_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-research_unix-any.sh" . "${LIBS_AUTOMATACI}/_release-rpm_unix-any.sh" -. "${LIBS_AUTOMATACI}/_release-staticrepo_unix-any.sh" . "${LIBS_AUTOMATACI}/_release-docsrepo_unix-any.sh" @@ -54,8 +54,8 @@ __recipe="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}" __recipe="${__recipe}/release_unix-any.sh" FS_Is_File "$__recipe" if [ $? -eq 0 ]; then - I18N_Detected "${__recipe}" - I18N_Parse "${__recipe}" + I18N_Detected "$__recipe" + I18N_Parse "$__recipe" . "$__recipe" if [ $? -ne 0 ]; then I18N_Parse_Failed @@ -64,6 +64,15 @@ if [ $? -eq 0 ]; then fi + + +# determine pathing variables +PACKAGE_DIRECTORY="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}" + + + + +# initialize workspace and release job functions OS_Is_Command_Available "RELEASE_Run_Pre_Processor" if [ $? -eq 0 ]; then RELEASE_Run_Pre_Processor @@ -73,88 +82,111 @@ if [ $? -eq 0 ]; then fi -RELEASE_Setup_STATIC_REPO +RELEASE_Setup_PROJECT # !! IMPORTANT !! - always the first if [ $? -ne 0 ]; then return 1 fi -RELEASE_Setup_HOMEBREW +RELEASE_Setup_DEB "$DEB_REPO" if [ $? -ne 0 ]; then return 1 fi -RELEASE_Setup_CHOCOLATEY +RELEASE_Setup_FLATPAK "$FLATPAK_REPO" if [ $? -ne 0 ]; then return 1 fi -STATIC_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/${PROJECT_STATIC_REPO_DIRECTORY}" -HOMEBREW_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/${PROJECT_HOMEBREW_DIRECTORY}" -CHOCOLATEY_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/${PROJECT_CHOCOLATEY_DIRECTORY}" -for TARGET in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}"/*; do +RELEASE_Setup_HOMEBREW "$HOMEBREW_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Setup_RPM "$RPM_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + + + +# scan through each product and run the release processing respectively +for TARGET in "$PACKAGE_DIRECTORY"/*; do if [ "${TARGET%.asc*}" != "$TARGET" ]; then - continue + continue # it's a gpg cert + fi + + if [ "${TARGET%.gpg*}" != "$TARGET" ]; then + continue # it's a gpg keyfile or cert fi + I18N_Processing "$TARGET" + RELEASE_Run_CARGO "$TARGET" if [ $? -ne 0 ]; then return 1 fi - RELEASE_Run_CHOCOLATEY "$TARGET" "$CHOCOLATEY_REPO" - if [ $? -ne 0 ]; then - return 1 - fi RELEASE_Run_CITATION_CFF "$TARGET" if [ $? -ne 0 ]; then return 1 fi - RELEASE_Run_DEB "$TARGET" "$STATIC_REPO" + + RELEASE_Run_DEB "$TARGET" "$DEB_REPO" "$DEB_REPO_DATA" if [ $? -ne 0 ]; then return 1 fi + RELEASE_Run_DOCKER "$TARGET" if [ $? -ne 0 ]; then return 1 fi - RELEASE_Run_LIBS "$TARGET" + + RELEASE_Run_HOMEBREW "$TARGET" "$HOMEBREW_REPO" if [ $? -ne 0 ]; then return 1 fi - RELEASE_Run_HOMEBREW "$TARGET" "$HOMEBREW_REPO" + + RELEASE_Run_LIBS "$TARGET" if [ $? -ne 0 ]; then return 1 fi + RELEASE_Run_NPM "$TARGET" if [ $? -ne 0 ]; then return 1 fi - RELEASE_Run_PDF "$TARGET" + + RELEASE_Run_PYPI "$TARGET" if [ $? -ne 0 ]; then return 1 fi - RELEASE_Run_PYPI "$TARGET" + + RELEASE_Run_RESEARCH "$TARGET" if [ $? -ne 0 ]; then return 1 fi - RELEASE_Run_RPM "$TARGET" "$STATIC_REPO" + + RELEASE_Run_RPM "$TARGET" "$RPM_REPO" if [ $? -ne 0 ]; then return 1 fi + OS_Is_Command_Available "RELEASE_Run_Package_Processor" if [ $? -eq 0 ]; then RELEASE_Run_Package_Processor "$TARGET" @@ -165,7 +197,16 @@ for TARGET in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}"/*; do done -RELEASE_Run_CHECKSUM "$STATIC_REPO" + + +# run one-time directory-wide release processing functions +RELEASE_Update_DEB "$DEB_REPO" "$DEB_REPO_DATA" +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Update_RPM "$RPM_REPO" if [ $? -ne 0 ]; then return 1 fi @@ -180,34 +221,54 @@ if [ $? -eq 0 ]; then fi -if [ $(OS_Is_Run_Simulated) -eq 0 ]; then - I18N_Simulate_Conclude "STATIC REPO" - I18N_Simulate_Conclude "CHANGELOG" -else - RELEASE_Conclude_STATIC_REPO - if [ $? -ne 0 ]; then - return 1 - fi - RELEASE_Conclude_HOMEBREW "$HOMEBREW_REPO" - if [ $? -ne 0 ]; then - return 1 - fi - RELEASE_Conclude_CHOCOLATEY "$CHOCOLATEY_REPO" - if [ $? -ne 0 ]; then - return 1 - fi +# conclude the release +RELEASE_Conclude_CHECKSUM "$PACKAGE_DIRECTORY" ## !! IMPORTANT !! - always the first +if [ $? -ne 0 ]; then + return 1 +fi - RELEASE_Conclude_CHANGELOG - if [ $? -ne 0 ]; then - return 1 - fi - RELEASE_Conclude_DOCS - if [ $? -ne 0 ]; then - return 1 - fi +RELEASE_Conclude_DEB "$DEB_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Conclude_FLATPAK "$FLATPAK_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Conclude_HOMEBREW "$HOMEBREW_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Conclude_RPM "$RPM_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Conclude_DOCS +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Conclude_CHANGELOG +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Conclude_PROJECT # !! IMPORTANT !! - always the last +if [ $? -ne 0 ]; then + return 1 fi diff --git a/automataCI/release_windows-any.ps1 b/automataCI/release_windows-any.ps1 index 884883b6..69dd6980 100644 --- a/automataCI/release_windows-any.ps1 +++ b/automataCI/release_windows-any.ps1 @@ -26,17 +26,17 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { . "${env:LIBS_AUTOMATACI}\_release-cargo_windows-any.ps1" . "${env:LIBS_AUTOMATACI}\_release-changelog_windows-any.ps1" . "${env:LIBS_AUTOMATACI}\_release-checksum_windows-any.ps1" -. "${env:LIBS_AUTOMATACI}\_release-chocolatey_windows-any.ps1" . "${env:LIBS_AUTOMATACI}\_release-citation_windows-any.ps1" . "${env:LIBS_AUTOMATACI}\_release-deb_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-flatpak_windows-any.ps1" . "${env:LIBS_AUTOMATACI}\_release-docker_windows-any.ps1" . "${env:LIBS_AUTOMATACI}\_release-homebrew_windows-any.ps1" . "${env:LIBS_AUTOMATACI}\_release-lib_windows-any.ps1" . "${env:LIBS_AUTOMATACI}\_release-npm_windows-any.ps1" -. "${env:LIBS_AUTOMATACI}\_release-pdf_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-project_windows-any.ps1" . "${env:LIBS_AUTOMATACI}\_release-pypi_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-research_windows-any.ps1" . "${env:LIBS_AUTOMATACI}\_release-rpm_windows-any.ps1" -. "${env:LIBS_AUTOMATACI}\_release-staticrepo_windows-any.ps1" . "${env:LIBS_AUTOMATACI}\_release-docsrepo_windows-any.ps1" @@ -63,6 +63,15 @@ if ($___process -eq 0) { } + + +# determine pathing variables +$PACKAGE_DIRECTORY = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}" + + + + +# initialize workspace and release job functions $___process = OS-Is-Command-Available "RELEASE-Run-Pre-Processor" if ($___process -eq 0) { $___process = RELEASE-Run-Pre-Processor @@ -72,143 +81,128 @@ if ($___process -eq 0) { } -$___process = RELEASE-Setup-STATIC-REPO +$___process = RELEASE-Setup-PROJECT # !! IMPORTANT !! - always the first if ($___process -ne 0) { return 1 } -$___process = RELEASE-Setup-HOMEBREW +$___process = RELEASE-Setup-DEB "${DEB_REPO}" if ($___process -ne 0) { return 1 } -$___process = RELEASE-Setup-CHOCOLATEY +$___process = RELEASE-Setup-FLATPAK "$FLATPAK_REPO" if ($___process -ne 0) { return 1 } -$STATIC_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\${env:PROJECT_STATIC_REPO_DIRECTORY}" -$HOMEBREW_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\${env:PROJECT_HOMEBREW_DIRECTORY}" -$CHOCOLATEY_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\${env:PROJECT_CHOCOLATEY_DIRECTORY}" -$PACKAGE_DIRECTORY = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}" -if (Test-Path -PathType Container -Path "${PACKAGE_DIRECTORY}") { - foreach ($TARGET in (Get-ChildItem -Path "${PACKAGE_DIRECTORY}")) { - $TARGET = $TARGET.FullName - if ($TARGET -like "*.asc") { - continue - } - - $null = I18N-Processing "${TARGET}" - - $___process = RELEASE-Run-CARGO "$TARGET" - if ($___process -ne 0) { - return 1 - } +$___process = RELEASE-Setup-HOMEBREW "${HOMEBREW_REPO}" +if ($___process -ne 0) { + return 1 +} - $___process = RELEASE-Run-CITATION-CFF "$TARGET" - if ($___process -ne 0) { - return 1 - } - $___process = RELEASE-Run-CHOCOLATEY "$TARGET" "$CHOCOLATEY_REPO" - if ($___process -ne 0) { - return 1 - } +$___process = RELEASE-Setup-RPM "${RPM_REPO}" +if ($___process -ne 0) { + return 1 +} - $___process = RELEASE-Run-DEB "$TARGET" "$STATIC_REPO" - if ($___process -ne 0) { - return 1 - } - $___process = RELEASE-Run-DOCKER "$TARGET" - if ($___process -ne 0) { - return 1 - } - $___process = RELEASE-Run-HOMEBREW "$TARGET" "$HOMEBREW_REPO" - if ($___process -ne 0) { - return 1 - } - $___process = RELEASE-Run-LIBS "$TARGET" - if ($___process -ne 0) { - return 1 - } - - $___process = RELEASE-Run-NPM "$TARGET" - if ($___process -ne 0) { - return 1 - } - - $___process = RELEASE-Run-PDF "$TARGET" - if ($___process -ne 0) { - return 1 - } +# scan through each product and run the release processing respectively +foreach ($TARGET in (Get-ChildItem -Path "${PACKAGE_DIRECTORY}")) { $TARGET = $TARGET.FullName + if ($TARGET -like "*.asc") { + continue # it's a gpg cert + } - $___process = RELEASE-Run-PYPI "$TARGET" - if ($___process -ne 0) { - return 1 - } + if ($TARGET -like "*.gpg") { + continue # it's a gpg keyfile or cert + } - $___process = RELEASE-Run-RPM "$TARGET" "$STATIC_REPO" ` - if ($___process -ne 0) { - return 1 - } + $null = I18N-Processing "${TARGET}" - $___process = OS-Is-Command-Available "RELEASE-Run-Package-Processor" - if ($___process -eq 0) { - $___process = RELEASE-Run-Package-Processor "$TARGET" - if ($___process -ne 0) { - return 1 - } - } + $___process = RELEASE-Run-CARGO "$TARGET" + if ($___process -ne 0) { + return 1 } -} + $___process = RELEASE-Run-CITATION-CFF "$TARGET" + if ($___process -ne 0) { + return 1 + } -$___process = RELEASE-Run-CHECKSUM "$STATIC_REPO" -if ($___process -ne 0) { - return 1 -} + $___process = RELEASE-Run-DEB "$TARGET" "$DEB_REPO" "$DEB_REPO_DATA" + if ($___process -ne 0) { + return 1 + } + $___process = RELEASE-Run-DOCKER "$TARGET" + if ($___process -ne 0) { + return 1 + } -$___process = OS-Is-Command-Available "RELEASE-Run-Post-Processor" -if ($___process -eq 0) { - $___process = RELEASE-Run-Post-Processor + $___process = RELEASE-Run-HOMEBREW "$TARGET" "$HOMEBREW_REPO" if ($___process -ne 0) { return 1 } -} + $___process = RELEASE-Run-LIBS "$TARGET" + if ($___process -ne 0) { + return 1 + } -if ($(OS-Is-Run-Simulated) -eq 0) { - $null = I18N-Simulate-Conclusion "STATIC REPO" - $null = I18N-Simulate-Conclusion "CHANGELOG" -} else { - $___process = RELEASE-Conclude-STATIC-REPO + $___process = RELEASE-Run-NPM "$TARGET" if ($___process -ne 0) { return 1 } - $___process = RELEASE-Conclude-HOMEBREW "$HOMEBREW_REPO" + $___process = RELEASE-Run-PYPI "$TARGET" if ($___process -ne 0) { return 1 } - $___process = RELEASE-Conclude-CHOCOLATEY "$CHOCOLATEY_REPO" + $___process = RELEASE-Run-RESEARCH "$TARGET" if ($___process -ne 0) { return 1 } - $___process = RELEASE-Conclude-CHANGELOG + $___process = RELEASE-Run-RPM "$TARGET" "$RPM_REPO" if ($___process -ne 0) { return 1 } - $___process = RELEASE-Conclude-DOCS + $___process = OS-Is-Command-Available "RELEASE-Run-Package-Processor" + if ($___process -eq 0) { + $___process = RELEASE-Run-Package-Processor "$TARGET" + if ($___process -ne 0) { + return 1 + } + } +} + + + + +# run one-time directory-wide release processing functions +$___process = RELEASE-Update-DEB "$DEB_REPO" "$DEB_REPO_DATA" +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Update-RPM "$RPM_REPO" +if ($___process -ne 0) { + return 1 +} + + +$___process = OS-Is-Command-Available "RELEASE-Run-Post-Processor" +if ($___process -eq 0) { + $___process = RELEASE-Run-Post-Processor if ($___process -ne 0) { return 1 } @@ -217,6 +211,57 @@ if ($(OS-Is-Run-Simulated) -eq 0) { +# conclude the release +$___process = RELEASE-Conclude-CHECKSUM "$PACKAGE_DIRECTORY" ## !! IMPORTANT !! - always the first +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Conclude-DEB "$DEB_REPO" +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Conclude-FLATPAK "$FLATPAK_REPO" +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Conclude-HOMEBREW "$HOMEBREW_REPO" +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Conclude-RPM "$RPM_REPO" +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Conclude-DOCS +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Conclude-CHANGELOG +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Conclude-PROJECT # !! IMPORTANT !! - must always be the last +if ($___process -ne 0) { + return 1 +} + + + + # report status $null = I18N-Run-Successful return 0 diff --git a/automataCI/services/archive/ar.ps1 b/automataCI/services/archive/ar.ps1 index e68f238b..059ab777 100644 --- a/automataCI/services/archive/ar.ps1 +++ b/automataCI/services/archive/ar.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 @@ -11,6 +11,7 @@ # under the License. . "${env:LIBS_AUTOMATACI}\services\io\os.ps1" . "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" @@ -59,3 +60,34 @@ function AR-Create { # report status return 0 } + + + + +function AR-Extract { + param ( + [string]$___file + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___file}") -eq 0) { + return 1 + } + + $___process = AR-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "ar" "-x `"${___file}`"" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/archive/ar.sh b/automataCI/services/archive/ar.sh index 70a1bf72..dac8898a 100644 --- a/automataCI/services/archive/ar.sh +++ b/automataCI/services/archive/ar.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 @@ -11,6 +11,7 @@ # License for the specific language governing permissions and limitations under # the License. . "${LIBS_AUTOMATACI}/services/io/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" . "${LIBS_AUTOMATACI}/services/io/strings.sh" @@ -58,3 +59,32 @@ AR_Create() { # report status return 0 } + + + + +AR_Extract() { + #___file="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + AR_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ar -x "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/archive/tar.ps1 b/automataCI/services/archive/tar.ps1 index 7a277b5b..316569e4 100644 --- a/automataCI/services/archive/tar.ps1 +++ b/automataCI/services/archive/tar.ps1 @@ -129,23 +129,25 @@ function TAR-Create-GZ { # create tar archive - $___process = TAR-Create "${___dest}" "${___source}" "${___owner}" "${___group}" + $___process = TAR-Create "${___dest}.tar" "${___source}" "${___owner}" "${___group}" if ($___process -ne 0) { return 1 } # compress archive - $___process = GZ-Create "${___dest}" + $___process = GZ-Create "${___dest}.tar" if ($___process -ne 0) { return 1 } # rename to target - $___process = FS-Move "${___dest}.gz" "${___destination}" - if ($___process -ne 0) { - return 1 + if ("${___destination}" -ne "${___dest}.tar.gz") { + $___process = FS-Move "${___dest}.tar.gz" "${___destination}" + if ($___process -ne 0) { + return 1 + } } @@ -194,23 +196,25 @@ function TAR-Create-XZ { # create tar archive - $___process = TAR-Create "${___dest}" "${___source}" "${___owner}" "${___group}" + $___process = TAR-Create "${___dest}.tar" "${___source}" "${___owner}" "${___group}" if ($___process -ne 0) { return 1 } # compress archive - $___process = XZ-Create "${___dest}" + $___process = XZ-Create "${___dest}.tar" if ($___process -ne 0) { return 1 } # rename to target - $___process = FS-Move "${___dest}.xz" "${___destination}" - if ($___process -ne 0) { - return 1 + if ("${___destination}" -ne "${___dest}.tar.xz") { + $___process = FS-Move "${___dest}.xz" "${___destination}" + if ($___process -ne 0) { + return 1 + } } @@ -251,7 +255,7 @@ function TAR-Extract-GZ { # unpack tar.gz - $___process = OS-Exec "tar" "-xzf `"${___destination}`" -C `"${___source}`"" + $___process = OS-Exec "tar" "-C `"${___destination}`" -xzf `"${___source}`"" if ($___process -ne 0) { return 1 } @@ -277,8 +281,8 @@ function TAR-Extract-XZ { return 1 } - $___process = FS-Is-File "${___destination}" - if ($___process -eq 0) { + $___process = FS-Is-Directory "${___destination}" + if ($___process -ne 0) { return 1 } @@ -294,7 +298,7 @@ function TAR-Extract-XZ { # unpack tar.xz - $___process = OS-Exec "tar" "-xf `"${___destination}`" -C `"${___source}`"" + $___process = OS-Exec "tar" "-C `"${___destination}`" -xf `"${___source}`"" if ($___process -ne 0) { return 1 } diff --git a/automataCI/services/archive/tar.sh b/automataCI/services/archive/tar.sh index fae30458..61638815 100644 --- a/automataCI/services/archive/tar.sh +++ b/automataCI/services/archive/tar.sh @@ -118,23 +118,25 @@ TAR_Create_GZ() { # create tar archive - TAR_Create "$___dest" "$2" "$3" "$4" + TAR_Create "${___dest}.tar" "$2" "$3" "$4" if [ $? -ne 0 ]; then return 1 fi # compress archive - GZ_Create "$___dest" + GZ_Create "${___dest}.tar" if [ $? -ne 0 ]; then return 1 fi # rename to destination target - FS_Move "${___dest}.gz" "$1" - if [ $? -ne 0 ]; then - return 1 + if [ ! "$1" = "${___dest}.tar.gz" ]; then + FS_Move "${___dest}.tar.gz" "$1" + if [ $? -ne 0 ]; then + return 1 + fi fi @@ -180,23 +182,25 @@ TAR_Create_XZ() { # create tar archive - TAR_Create "$___dest" "$2" "$3" "$4" + TAR_Create "${___dest}.tar" "$2" "$3" "$4" if [ $? -ne 0 ]; then return 1 fi # compress archive - XZ_Create "$___dest" + XZ_Create "${___dest}.tar" if [ $? -ne 0 ]; then return 1 fi # rename to target - FS_Move "${___dest}.xz" "$1" - if [ $? -ne 0 ]; then - return 1 + if [ ! "$1" = "${___dest}.tar.xz" ]; then + FS_Move "${___dest}.tar.xz" "$1" + if [ $? -ne 0 ]; then + return 1 + fi fi @@ -234,7 +238,7 @@ TAR_Extract_GZ() { # unpack tar.gz - tar -xzf "$2" -C "$1" + tar -C "$1" -xzf "$2" if [ $? -ne 0 ]; then return 1 fi @@ -257,8 +261,8 @@ TAR_Extract_XZ() { return 1 fi - FS_Is_File "$1" - if [ $? -eq 0 ]; then + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then return 1 fi @@ -274,7 +278,7 @@ TAR_Extract_XZ() { # unpack tar.xz - tar -xf "$2" -C "$1" + tar -C "$1" -xf "$2" if [ $? -ne 0 ]; then return 1 fi diff --git a/automataCI/services/checksum/md5.ps1 b/automataCI/services/checksum/md5.ps1 index af80db24..c6254501 100644 --- a/automataCI/services/checksum/md5.ps1 +++ b/automataCI/services/checksum/md5.ps1 @@ -15,7 +15,7 @@ -function MD5-Checksum-From-File { +function MD5-Create-From-File { param ( [string]$___target ) diff --git a/automataCI/services/checksum/md5.sh b/automataCI/services/checksum/md5.sh index 1f742630..923a7a2c 100644 --- a/automataCI/services/checksum/md5.sh +++ b/automataCI/services/checksum/md5.sh @@ -17,7 +17,7 @@ -MD5_Checksum_From_File() { +MD5_Create_From_File() { #___target="$1" @@ -35,27 +35,28 @@ MD5_Checksum_From_File() { # execute OS_Is_Command_Available "md5sum" if [ $? -eq 0 ]; then - md5sum "$1" + ___value="$(md5sum "$1")" if [ $? -ne 0 ]; then return 1 fi - - return 0 fi OS_Is_Command_Available "md5" if [ $? -eq 0 ]; then - md5 "$1" + ___value="$(md5 "$1")" if [ $? -ne 0 ]; then return 1 fi + fi - return 0 + if [ $(STRINGS_Is_Empty "$___value") -eq 0 ]; then + return 1 fi # report status - return 1 + printf -- "%s" "${___value%% *}" + return 0 } diff --git a/automataCI/services/checksum/shasum.ps1 b/automataCI/services/checksum/shasum.ps1 index 2b7f795e..e0b6c9f7 100644 --- a/automataCI/services/checksum/shasum.ps1 +++ b/automataCI/services/checksum/shasum.ps1 @@ -15,7 +15,7 @@ -function SHASUM-Checksum-From-File { +function SHASUM-Create-From-File { param ( [string]$___target, [string]$___algo diff --git a/automataCI/services/compilers/changelog.ps1 b/automataCI/services/compilers/changelog.ps1 index e8b3211f..d4969e15 100644 --- a/automataCI/services/compilers/changelog.ps1 +++ b/automataCI/services/compilers/changelog.ps1 @@ -298,13 +298,7 @@ function CHANGELOG-Build-DEB-Entry { return 1 } - - switch ($___dist) { - { $_ -in "stable", "unstable", "testing", "experimental" } { - break - } default { - return 1 - }} + $___dest = $___dest -replace "\/.*$", "" # all good. Generate the log fragment @@ -312,6 +306,7 @@ function CHANGELOG-Build-DEB-Entry { # create the entry header + $null = FS-Remove-Silently "${___directory}\deb\.latest" $null = FS-Write-File "${___directory}\deb\.latest" @" ${___sku} (${___version}) ${___dist}; urgency=${___urgency} diff --git a/automataCI/services/compilers/changelog.sh b/automataCI/services/compilers/changelog.sh index f3e50e1f..efddc0d8 100644 --- a/automataCI/services/compilers/changelog.sh +++ b/automataCI/services/compilers/changelog.sh @@ -299,13 +299,7 @@ CHANGELOG_Build_DEB_Entry() { return 1 fi - case "$___dist" in - stable|unstable|testing|experimental) - ;; - *) - return 1 - ;; - esac + ___dist="${___dist%%/*}" # all good. Generate the log fragment @@ -313,6 +307,7 @@ CHANGELOG_Build_DEB_Entry() { # create the entry header + FS_Remove_Silently "${___directory}/deb/.latest" FS_Append_File "${___directory}/deb/.latest" "\ ${___sku} (${___version}) ${___dist}; urgency=${___urgency} diff --git a/automataCI/services/compilers/deb.ps1 b/automataCI/services/compilers/deb.ps1 index 50861dd9..faf5cecc 100644 --- a/automataCI/services/compilers/deb.ps1 +++ b/automataCI/services/compilers/deb.ps1 @@ -9,14 +9,16 @@ # 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\disk.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\io\time.ps1" . "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" . "${env:LIBS_AUTOMATACI}\services\archive\ar.ps1" . "${env:LIBS_AUTOMATACI}\services\crypto\gpg.ps1" . "${env:LIBS_AUTOMATACI}\services\checksum\md5.ps1" +. "${env:LIBS_AUTOMATACI}\services\publishers\unix.ps1" @@ -54,13 +56,13 @@ function DEB-Create-Archive { } - # change directory into workspace + # to workspace directory $___current_path = Get-Location # package control $null = Set-Location "${___directory}\control" - $___process = TAR-Create-XZ "..\control.tar.xz" "*" + $___process = TAR-Create-XZ "${___directory}\control.tar.xz" "*" if ($___process -ne 0) { $null = Set-Location $___current_path $null = Remove-Variable -Name ___current_path @@ -70,7 +72,7 @@ function DEB-Create-Archive { # package data $null = Set-Location "${___directory}\data" - $___process = TAR-Create-XZ "..\data.tar.xz" "*" + $___process = TAR-Create-XZ "${___directory}\data.tar.xz" "*" if ($___process -ne 0) { $null = Set-Location $___current_path $null = Remove-Variable -Name ___current_path @@ -184,10 +186,10 @@ function DEB-Create-Checksum { # checksum every items foreach ($___line in (Get-ChildItem -Path "${___directory}\data" -File -Recurse)) { - $___checksum = MD5-Checksum-From-File "${___line}" - $___path = "${___line}" -replace [regex]::Escape("${___directory}\data\"), "" + $___checksum = MD5-Create-From-File "${___line}" + $___path = "${___line}" -replace [regex]::Escape("${___directory}\data\"), '' $___path = $___path -replace "\\", "/" - $___checksum = $___checksum -replace "\ .*$", "" + $___checksum = $___checksum -replace "\ .*$", '' $___process = FS-Append-File "${___location}" "${___checksum} ${___path}`n" if ($___process -ne 0) { return 1 @@ -262,7 +264,7 @@ function DEB-Create-Control { # generate control file - $___size = DISK-Calculate-Size "${___directory}\data" + $___size = DISK-Calculate-Size-Directory-KB "${___directory}\data" if ($(STRINGS-Is-Empty "${___size}") -eq 0) { return 1 } @@ -289,11 +291,11 @@ Description: ${___pitch} foreach ($___line in (Get-Content -Path "${___description_filepath}")) { if (($(STRINGS-Is-Empty "${___line}") -ne 0) -and - ($(STRINGS-Is-Empty "$($___line -replace "#.*$")") -eq 0)) { + ($(STRINGS-Is-Empty "$($___line -replace "#.*$", '')") -eq 0)) { continue } - $___line = $___line -replace '#.*' + $___line = $___line -replace '#.*', '' if ($(STRINGS-Is-Empty "${___line}") -eq 0) { $___line = " ." } else { @@ -316,7 +318,7 @@ function DEB-Create-Source-List { [string]$___directory, [string]$___gpg_id, [string]$___url, - [string]$___codename, + [string]$___component, [string]$___distribution, [string]$___keyring ) @@ -325,7 +327,7 @@ function DEB-Create-Source-List { # validate input if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or ($(STRINGS-Is-Empty "${___url}") -eq 0) -or - ($(STRINGS-Is-Empty "${___codename}") -eq 0) -or + ($(STRINGS-Is-Empty "${___component}") -eq 0) -or ($(STRINGS-Is-Empty "${___distribution}") -eq 0) -or ($(STRINGS-Is-Empty "${___keyring}") -eq 0)) { return 1 @@ -342,8 +344,6 @@ function DEB-Create-Source-List { # execute - $___url = "${___url}/deb" - $___url = $___url -replace "//deb", "/deb" $___key = "usr\local\share\keyrings\${___keyring}-keyring.gpg" $___filename = "${___directory}\data\etc\apt\sources.list.d\${___keyring}.list" @@ -358,11 +358,21 @@ function DEB-Create-Source-List { } $null = FS-Make-Housing-Directory "${___filename}" - $___process = FS-Write-File "${___filename}" @" + if ("$($___distribution -replace "\/.*$", '')" -eq $___distribution) { + # it's a pool repository + $___process = FS-Write-File "${___filename}" @" +# WARNING: AUTO-GENERATED - DO NOT EDIT! +deb [signed-by=/${___key}] ${___url} ${___distribution} ${__component} + +"@ + } else { + # it's a flat repository + $___process = FS-Write-File "${___filename}" @" # WARNING: AUTO-GENERATED - DO NOT EDIT! -deb [signed-by=/${___key}] ${___url} ${___codename} ${___distribution} +deb [signed-by=/${___key}] ${___url} ${___distribution} "@ + } if ($___process -ne 0) { return 1 } @@ -401,40 +411,21 @@ function DEB-Get-Architecture { } - # process os + # execute switch ($___os) { - linux { + any { + $___output = "all-" + } linux { $___output = "" } dragonfly { $___output = "dragonflybsd-" } default { $___output = "${___os}-" }} - - - # process arch - switch ($___arch) { - { $_ -in "386", "i386", "486", "i486", "586", "i586", "686", "i686" } { - $___output = "${___output}i386" - } "mipsle" { - $___output = "${___output}mipsel" - } "mipsr6le" { - $___output = "${___output}mipsr6el" - } "mips32le" { - $___output = "${___output}mips32el" - } "mips32r6le" { - $___output = "${___output}mips32r6el" - } "mips64le" { - $___output = "${___output}mips64el" - } "mips64r6le" { - $___output = "${___output}mips64r6el" - } "powerpcle" { - $___output = "${___output}powerpcel" - } "ppc64le" { - $___output = "${___output}ppc64el" - } default { - $___output = "${___output}${___arch}" - }} + $___output = "${___output}$(UNIX-Get-Arch "${___arch}")" + if ($___output -eq "all-all") { + $___output = "all" + } # report status @@ -462,6 +453,11 @@ function DEB-Is-Available { return 1 } + $___process = SHASUM-Is-Available + if ($___process -ne 0) { + return 1 + } + $___process = TAR-Is-Available if ($___process -ne 0) { return 1 @@ -477,6 +473,11 @@ function DEB-Is-Available { return 1 } + $___process = GPG-Is-Available + if ($___process -ne 0) { + return 1 + } + # check compatible target os switch ($___os) { @@ -529,3 +530,667 @@ function DEB-Is-Valid { # report status return 1 } + + + + +function DEB-Publish { + param ( + [string]$___repo_directory, + [string]$___data_directory, + [string]$___workspace_directory, + [string]$___target, + [string]$___distribution, + [string]$___component + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___repo_directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___data_directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___workspace_directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___distribution}") -eq 0) -or + ($(STRINGS-Is-Empty "${___component}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___repo_directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___directory_unpack = "${___workspace_directory}\deb" + $___repo_is_pool = $false + if ("$($___distribution -replace "\/.*$", '')" -eq $___distribution) { + # it's a pool repository + $___repo_is_pool = $true + } else { + # it's a flat repository + $___distribution = $___distribution -replace "\/.*$", '' + } + + + # unpack package control section + $null = FS-Remake-Directory "${___directory_unpack}" + $___process = DEB-Unpack "${___directory_unpack}" "${___target}" "control" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___directory_unpack}\control\control" + if ($___process -ne 0) { + return 1 + } + + + # parse package control data + $___value_type = "binary" # currently support this for now + $___value_package = "" + $___value_version = "" + $___value_arch = "" + $___value_maintainer = "" + $___value_buffer = "" + $___value_size = "$(DISK-Calculate-Size-File-Byte "${___target}")" + $___value_sha256 = "$(SHASUM-Create-From-File "${___target}" "256")" + $___value_sha1 = "$(SHASUM-Create-From-File "${___target}" "1")" + $___value_md5 = "$(MD5-Create-From-File "${___target}")" + $___value_description = "" + + foreach ($___line in (Get-Content "${___directory_unpack}/control/control")) { + $___regex = "^.*Package:\ " + if ("$($___line -replace $___regex, '')" -ne $___line) { + if ($(STRINGS-Is-Empty "${___value_package}") -ne 0) { + ## invalid control file - multiple same fileds detected + return 1 + } + + $___value_package = $___line -replace $___regex, '' + continue + } + + $___regex = "^.*Version:\ " + if ("$($___line -replace $___regex, '')" -ne $___line) { + if ($(STRINGS-Is-Empty "${___value_version}") -ne 0) { + ## invalid control file - multiple same fileds detected + return 1 + } + + $___value_version = $___line -replace $___regex, '' + continue + } + + $___regex = "^.*Architecture:\ " + if ("$($___line -replace $___regex, '')" -ne $___line) { + if ($(STRINGS-Is-Empty "${___value_arch}") -ne 0) { + ## invalid control file - multiple same fileds detected + return 1 + } + + $___value_arch = $___line -replace $___regex, '' + continue + } + + $___regex = "^.*Maintainer:\ " + if ("$($___line -replace $___regex, '')" -ne $___line) { + if ($(STRINGS-Is-Empty "${___value_maintainer}") -ne 0) { + ## invalid control file - multiple same fileds detected + return 1 + } + + $___value_maintainer = $___line -replace $___regex, '' + continue + } + + $___regex = "^.*Description:\ " + if ("$($___line -replace $___regex, '')" -ne $___line) { + if ($(STRINGS-Is-Empty "${___value_description}") -ne 0) { + ## invalid control file - multiple same fileds detected + return 1 + } + + $___value_description = $___line + continue + } + + if ($(STRINGS-Is-Empty "${___value_description}") -eq 0) { + if ($(STRINGS-Is-Empty "${___value_buffer}") -ne 0) { + $___value_buffer = "${___value_buffer}`n" + } + + $___value_buffer = "${___value_buffer}${___line}" + } else { + if ($(STRINGS-Is-Empty "${___value_description}") -ne 0) { + $___value_description = "${___value_description}`n" + } + + $___value_description = "${___value_description}${___line}" + } + } + + + # sanitize package metadata + if (($(STRINGS-Is-Empty "${___value_type}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_package}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_version}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_arch}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_maintainer}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_size}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_sha256}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_sha1}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_md5}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_description}") -eq 0)) { + return 1 + } + + + # process filename + $___value_filename = "${___value_package}_${___value_version}_${___value_arch}.deb" + if ($___repo_is_pool) { + $___value_filename = "${___value_package}\${___value_filename}" + $___value_filename = "$($(FS-Get-File "${___value_package}").Substring(0, 1))\${___value_filename}" + $___value_filename = "pool\${___distribution}\${___value_filename}" + } + + + # write to package database + $___dest = "${___value_package}_${___value_version}_${___value_arch}" + if ($___repo_is_pool) { + $___dest = "${___value_type}-${___value_arch}/${___dest}" + $___dest = "${___component}\${___dest}" + $___dest = "${___distribution}\${___dest}" + } + $___dest = "${___data_directory}\packages\${___dest}" + $___process = FS-Is-File "${___dest}" + if ($___process -eq 0) { + return 1 # duplicated package - already registered + } + + $null = FS-Make-Housing-Directory "${___dest}" + $___process = FS-Write-File "${___dest}" @" +Package: ${___value_package} +Version: ${___value_version} +Architecture: ${___value_arch} +Maintainer: ${___value_maintainer} +${___value_buffer} +Filename: $($___value_filename -replace "\\", "/") +Size: ${___value_size} +SHA256: ${___value_sha256} +SHA1: ${___value_sha1} +MD5sum: ${___value_md5} +${___value_description} + +"@ + if ($___process -ne 0) { + return 1 + } + + + # write to arch database + $___dest = "${___data_directory}\arch\${___value_arch}" + $null = FS-Make-Housing-Directory "${___dest}" + $___process = FS-Append-File "${___dest}" "${___value_filename}`n" + if ($___process -ne 0) { + return 1 + } + + + # export deb payload to destination + $___dest = "${___repo_directory}\${___value_filename}" + $___process = FS-Is-File "${___dest}" + if ($___process -ne 0) { + $null = FS-Make-Housing-Directory "${___dest}" + $___process = FS-Move "${___target}" "${___dest}" + if ($___process -ne 0) { + return 1 + } + } else { + return 1 # duplicated package existence or corrupted run + } + + + # report status + return 0 +} + + + + +function DEB-Publish-Conclude { + param ( + [string]$___repo_directory, + [string]$___data_directory, + [string]$___distribution, + [string]$___arch_list, + [string]$___component, + [string]$___codename, + [string]$___gpg_id + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___repo_directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___data_directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch_list}") -eq 0) -or + ($(STRINGS-Is-Empty "${___component}") -eq 0) -or + ($(STRINGS-Is-Empty "${___codename}") -eq 0) -or + ($(STRINGS-Is-Empty "${___gpg_id}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___repo_directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Directory "${___data_directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = GPG-Is-Available "${___gpg_id}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___directory_package = "${___data_directory}\packages" + $___repo_is_pool = $false + if ("$($___distribution -replace "\/.*$", '')" -eq $___distribution) { + # it's a pool repository + $___repo_is_pool = $true + $___repo_directory = "${___repo_directory}\dists" + } else { + # it's a flat repository + $___distribution = $___distribution -replace "\/.*$", '' + } + + + # formulate arch list if empty + if ($(STRINGS-Is-Empty "${___arch_list}") -eq 0) { + Get-ChildItem -Path "${___data_directory}\arch" -File ` + | ForEach-Object { $___line = $_.FullName + if ($(STRINGS-Is-Empty "${___arch_list}") -ne 0) { + $___arch_list = "${___arch_list} " + } + + $___arch_list = "${___arch_list}$(FS-Get-File "${___line}")" + } + } + + if ($(STRINGS-Is-Empty "${___arch_list}") -eq 0) { + return 1 + } + + + # purge all Package and Release files from repository + if ($___repo_is_pool) { + $null = FS-Remove-Silently "${___repo_directory}" + } else { + Get-ChildItem -Path "${___repo_directory}" ` + | Where-Object { + ($_.Name -eq "Packages") -or + ($_.Name -eq "Packages.gz") -or + ($_.Name -eq "Releases") -or + ($_.Name -eq "Releases.gpg") -or + ($_.Name -eq "InRelease") + } | ForEach-Object { + $null = FS-Remove-Silently $_.FullName + } + } + + + # recreate Package files + Get-ChildItem -Path "${___directory_package}" -File ` + | ForEach-Object { $___line = $_.FullName + ## get relative path + $___dest = $___line -replace [regex]::Escape("${___directory_package}\"), '' + + ## determine destination path + $___dest = "$(FS-Get-Directory "${___line}")" + if ($___repo_is_pool) { + $___dest = "${___repo_directory}\${___dest}" + } else { + if ("${___dest}" -ne "${___line}") { + # skip - it is a pool mode package in flat mode operation + continue + } + + $___dest = "${___repo_directory}" + } + $null = FS-Make-Directory "${___dest}" + + ## append package entry + $___process = FS-Is-File "${___dest}\Packages" + if ($___process -eq 0) { + $___process = FS-Append-File "${___dest}\Packages" "`n" + if ($___process -ne 0) { + return 1 + } + } + + foreach ($___content in (Get-Content -Path "${___directory_package}\${___line}")) { + $___process = FS-Append-File "${___dest}\Packages" "${___content}`n" + if ($___process -ne 0) { + return 1 + } + } + + $null = FS-Append-File $___location "${___line}`n" + } + + Get-ChildItem -Path "${___repo_directory}" ` + | Where-Object { ($_.Name -eq "Packages") } ` + | ForEach-Object { $___line = $_.FullName + ## gunzip all Package files + $null = FS-Copy-File "${___line}" "${___line}.backup" + $null = FS-Remove-Silently "${___line}.gz" + $___process = GZ-Create "${___line}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Move "${___line}.backup" "${___line}" + if ($___process -ne 0) { + return 1 + } + + ## create corresponding legacy Release file for pool mode + if ($___repo_is_pool) { + $___arch = $___line -replace [regex]::Escape("${___repo_directory}\"), '' + $___arch = "$(FS-Get-Directory "${___arch}")" + + $___arch = $___arch -split "\" + $___suite = $___arch[0] + + $___component = $___arch[1] + $___arch = $___arch[2] -split "-" + + $___package_type = $___arch[0] + $___arch = $___arch[1] + + $___process = FS-Write-File ` + "$(FS-Get-Directory "${___line}")\Release" ` @" +Archive: ${___suite} +Component: ${___component} +Architecture: ${___arch} + +"@ + if ($___process -ne 0) { + return 1 + } + } + } + + + # generate repository metadata + if ($___repo_is_pool) { + $___repo_directory = "${___repo_directory}\${___distribution}" + } + $___dest_release = "${___repo_directory}\Release" + $null = FS-Remove-Silently "${___dest_release}" + $___dest_inrelease = "${___repo_directory}\InRelease" + $null = FS-Remove-Silently "${___dest_inrelease}" + $___dest_md5 = "${___repo_directory}\ReleaseMD5" + $null = FS-Remove-Silently "${___dest_md5}" + $___dest_sha1 = "${___repo_directory}\ReleaseSHA1" + $null = FS-Remove-Silently "${___dest_sha1}" + $___dest_sha256 = "${___repo_directory}\ReleaseSHA256" + $null = FS-Remove-Silently "${___dest_sha256}" + + Get-ChildItem -Path "${___repo_directory}" ` + | Where-Object { + ($_.Name -eq "Packages") -or + ($_.Name -eq "Packages.gz") -or + ($_.Name -eq "Release") + } | ForEach-Object { $___line = $_.FullName + $___size = "$(DISK-Calculate-Size-File-Byte "${___line}")" + $___path = $___line -replace [regex]::Escape("${___repo_directory}\"), '' + + $___checksum = "$(MD5-Create-From-File "${___line}")" + $___process = FS-Append-File "${___dest_md5}" ` + " ${___checksum} ${___size} ${___path}`n" + if ($___process -ne 0) { + return 1 + } + + $___checksum = "$(SHASUM-Create-From-File "${___line}" "1")" + $___process = FS-Append-File "${___dest_sha1}" ` + " ${___checksum} ${___size} ${___path}`n" + if ($___process -ne 0) { + return 1 + } + + $___checksum = "$(SHASUM-Create-From-File "${___line}" "256")" + $___process = FS-Append-File "${___dest_sha256}" ` + " ${___checksum} ${___size} ${___path}`n" + if ($___process -ne 0) { + return 1 + } + } + + + # create root Release file + $___process = FS-Write-File "${___dest_release}" @" +Suite: ${___distribution} +Codename: ${___codename} +Date: $(TIME-Format-Datetime-RFC5322-UTC "$(TIME-Now)") +Architectures: ${___arch_list} +Components: ${___component} + +"@ + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Append-File "${___dest_release}" "MD5Sum:`n" + if ($___process -ne 0) { + return 1 + } + foreach ($___line in (Get-Content -Path "${___dest_md5}")) { + $___process = FS-Append-File "${___dest_release}" "${___line}`n" + if ($___process -ne 0) { + return 1 + } + } + $___process = FS-Remove "${___dest_md5}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Append-File "${___dest_release}" "SHA1:`n" + if ($___process -ne 0) { + return 1 + } + foreach ($___line in (Get-Content -Path "${___dest_sha1}")) { + $___process = FS-Append-File "${___dest_release}" "${___line}`n" + if ($___process -ne 0) { + return 1 + } + } + $___process = FS-Remove "${___dest_sha1}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Append-File "${___dest_release}" "SHA256:`n" + if ($___process -ne 0) { + return 1 + } + foreach ($___line in (Get-Content -Path "${___dest_sha256}")) { + $___process = FS-Append-File "${___dest_release}" "${___line}`n" + if ($___process -ne 0) { + return 1 + } + } + $___process = FS-Remove "${___dest_sha256}" + if ($___process -ne 0) { + return 1 + } + + + # create InRelease file + $___process = GPG-Clear-Sign-File ` + "${___dest_inrelease}" ` + "${___dest_release}" ` + "${___gpg_id}" + if ($___process -ne 0) { + return 1 + } + + + # create Release.gpg file + $___process = GPG-Detach-Sign-File ` + "${___dest_release}.gpg" ` + "${___dest_release}" ` + "${___gpg_id}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function DEB-Unpack { + param( + [string]$___directory, + [string]$___target, + [string]$___unpack_type + ) + + # validate input + if ($(STRINGS-Is-Empty "${___directory}") -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Target-Exist "${___directory}\control" + if ($___process -eq 0) { + return 1 + } + + $___process = FS-Is-Target-Exist "${___directory}\data" + if ($___process -eq 0) { + return 1 + } + + $___process = FS-Is-Target-Exist "${___directory}\debian-binary" + if ($___process -eq 0) { + return 1 + } + + + # execute + # copy target into directory + $___process = FS-Copy-File "${___target}" "${___directory}" + if ($___process -ne 0) { + return 1 + } + + + # to workspace directory + $___current_path = Get-Location + $null = Set-Location "${___directory}" + + + # ar extract outer layer + $___source = ".\$(FS-Get-File "${___target}")" + $___process = AR-Extract "${___source}" + if ($___process -ne 0) { + $null = Set-Location -Path $___current_path + $null = Remove-Variable -Name ___current_path + return 1 + } + $null = FS-Remove-Silently "${___source}" + + + # unpack control.tar.*z by request + if ($(STRINGS-To-Lowercase "${___unpack_type}") -ne "data") { + $___source=".\control.tar.xz" + $___dest=".\control" + $null = FS-Make-Directory "${___dest}" + $___process = FS-Is-File "${___source}" + if ($___process -eq 0) { + $___process = TAR-Extract-XZ "${___dest}" "${___source}" + } else { + $___source=".\control.tar.gz" + $___process = FS-Is-File "${___source}" + if ($___process -ne 0) { + $null = Set-Location -Path $___current_path + $null = Remove-Variable -Name ___current_path + return 1 + } + + $___process = TAR-Extract-GZ "${___dest}" "${___source}" + } + $null = FS-Remove-Silently "${___source}" + } + + if ($(STRINGS-To-Lowercase "${___unpack_type}") -eq "control") { + # stop as requested. + $null = Set-Location -Path $___current_path + $null = Remove-Variable -Name ___current_path + + + # report status + if ($___process -ne 0) { + return 1 + } + return 0 + } + + + # unpack data.tar.*z by request + $___source=".\data.tar.xz" + $___dest=".\data" + $null = FS-Make-Directory "${___dest}" + $___process = FS-Is-File "${___source}" + if ($___process -eq 0) { + $___process = TAR-Extract-XZ "${___dest}" "${___source}" + } else { + $___source=".\data.tar.gz" + $___process = FS-Is-File "${___source}" + if ($___process -ne 0) { + $null = Set-Location -Path $___current_path + $null = Remove-Variable -Name ___current_path + return 1 + } + + $___process = TAR-Extract-GZ "${___dest}" "${___source}" + } + $null = FS-Remove-Silently "${___source}" + + + # back to current directory + $null = Set-Location -Path $___current_path + $null = Remove-Variable -Name ___current_path + + + # report status + if ($___process -ne 0) { + return 1 + } + return 0 +} diff --git a/automataCI/services/compilers/deb.sh b/automataCI/services/compilers/deb.sh index 928e03d6..4642f017 100644 --- a/automataCI/services/compilers/deb.sh +++ b/automataCI/services/compilers/deb.sh @@ -10,14 +10,16 @@ # 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/disk.sh" . "${LIBS_AUTOMATACI}/services/io/os.sh" . "${LIBS_AUTOMATACI}/services/io/fs.sh" . "${LIBS_AUTOMATACI}/services/io/strings.sh" -. "${LIBS_AUTOMATACI}/services/io/disk.sh" +. "${LIBS_AUTOMATACI}/services/io/time.sh" . "${LIBS_AUTOMATACI}/services/archive/tar.sh" . "${LIBS_AUTOMATACI}/services/archive/ar.sh" . "${LIBS_AUTOMATACI}/services/crypto/gpg.sh" . "${LIBS_AUTOMATACI}/services/checksum/md5.sh" +. "${LIBS_AUTOMATACI}/services/publishers/unix.sh" @@ -53,13 +55,13 @@ DEB_Create_Archive() { fi - # capture current directory + # to workspace directory ___current_path="$PWD" # package control cd "${___directory}/control" - TAR_Create_XZ "../control.tar.xz" "*" + TAR_Create_XZ "${___directory}/control.tar.xz" "." if [ $? -ne 0 ]; then cd "$___current_path" && unset ___current_path return 1 @@ -68,7 +70,7 @@ DEB_Create_Archive() { # package data cd "${___directory}/data" - TAR_Create_XZ "../data.tar.xz" "*" + TAR_Create_XZ "${___directory}/data.tar.xz" "*" if [ $? -ne 0 ]; then cd "$___current_path" && unset ___current_path return 1 @@ -175,7 +177,11 @@ DEB_Create_Checksum() { # checksum every items for ___line in $(find "${1}/data" -type f); do - ___checksum="$(MD5_Checksum_From_File "$___line")" + ___checksum="$(MD5_Create_From_File "$___line") ${___line}" + if [ $? -ne 0 ]; then + return 1 + fi + ___line="${___line##*${1}/data/}" ___checksum="${___checksum%% *}" FS_Append_File "$___location" "${___checksum} ${___line}\n" @@ -251,7 +257,7 @@ DEB_Create_Control() { # generate control file - ___size="$(DISK_Calculate_Size "${___directory}/data")" + ___size="$(DISK_Calculate_Size_Directory_KB "${___directory}/data")" if [ $(STRINGS_Is_Empty "$___size") -eq 0 ]; then return 1 fi @@ -270,7 +276,8 @@ Description: $___pitch # append description data file - if [ ! "$(FS_Is_File "$___description_filepath")" = "0" ]; then + FS_Is_File "$___description_filepath" + if [ $? -ne 0 ]; then return 0 # report status early fi @@ -303,7 +310,7 @@ DEB_Create_Source_List() { ___directory="$1" ___gpg_id="$2" ___url="$3" - ___codename="$4" + ___component="$4" ___distribution="$5" ___keyring="$6" @@ -311,7 +318,7 @@ DEB_Create_Source_List() { # validate input if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || [ $(STRINGS_Is_Empty "$___url") -eq 0 ] || - [ $(STRINGS_Is_Empty "$___codename") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___component") -eq 0 ] || [ $(STRINGS_Is_Empty "$___distribution") -eq 0 ] || [ $(STRINGS_Is_Empty "$___keyring") -eq 0 ]; then return 1 @@ -328,8 +335,6 @@ DEB_Create_Source_List() { # execute - ___url="${___url}/deb" - ___url="${___url%//deb*}/deb" ___key="usr/local/share/keyrings/${___keyring}-keyring.gpg" ___filename="${___directory}/data/etc/apt/sources.list.d/${___keyring}.list" @@ -343,12 +348,20 @@ DEB_Create_Source_List() { return 1 fi - FS_Make_Housing_Directory "$___filename" - FS_Write_File "$___filename" "\ + if [ "${___distribution%%/*}" = "$___distribution" ]; then + # it's a pool repository + FS_Write_File "$___filename" "\ # WARNING: AUTO-GENERATED - DO NOT EDIT! -deb [signed-by=/${___key}] ${___url} ${___codename} ${___distribution} +deb [signed-by=/${___key}] ${___url} ${___distribution} ${__component} " + else + # it's a flat repository + FS_Write_File "$___filename" "\ +# WARNING: AUTO-GENERATED - DO NOT EDIT! +deb [signed-by=/${___key}] ${___url} ${___distribution} +" + fi if [ $? -ne 0 ]; then return 1 fi @@ -383,8 +396,11 @@ DEB_Get_Architecture() { fi - # process os + # execute case "$1" in + any) + ___output="all-" + ;; linux) ___output="" ;; @@ -395,41 +411,10 @@ DEB_Get_Architecture() { ___output="${1}-" ;; esac - - - # process arch - case "$2" in - 386|i386|486|i486|586|i586|686|i686) - ___output="${___output}i386" - ;; - mipsle) - ___output="${___output}mipsel" - ;; - mipsr6le) - ___output="${___output}mipsr6el" - ;; - mips32le) - ___output="${___output}mips32el" - ;; - mips32r6le) - ___output="${___output}mips32r6el" - ;; - mips64le) - ___output="${___output}mips64el" - ;; - mips64r6le) - ___output="${___output}mips64r6el" - ;; - powerpcle) - ___output="${___output}powerpcel" - ;; - ppc64le) - ___output="${___output}ppc64el" - ;; - *) - ___output="${___output}${2}" - ;; - esac + ___output="${___output}$(UNIX_Get_Arch "$2")" + if [ "$___output" = "all-all" ]; then + ___output="all" + fi # report status @@ -456,6 +441,11 @@ DEB_Is_Available() { return 1 fi + SHASUM_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + TAR_Is_Available if [ $? -ne 0 ]; then return 1 @@ -471,6 +461,11 @@ DEB_Is_Available() { return 1 fi + GPG_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + OS_Is_Command_Available "find" if [ $? -ne 0 ]; then return 1 @@ -488,7 +483,6 @@ DEB_Is_Available() { esac - # check compatible target cpu architecture case "$2" in any) @@ -531,3 +525,659 @@ DEB_Is_Valid() { # return status return 1 } + + + + +DEB_Publish() { + ___repo_directory="$1" + ___data_directory="$2" + ___workspace_directory="$3" + ___target="$4" + ___distribution="$5" + ___component="$6" + + + # validate input + if [ $(STRINGS_Is_Empty "$___repo_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___data_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___workspace_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___target") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___distribution") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___component") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___repo_directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "$___target" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___directory_unpack="${___workspace_directory}/deb" + ___repo_is_pool=1 + if [ "${___distribution%%/*}" = "$___distribution" ]; then + ## it's a pool repository + ___repo_is_pool=0 + else + ## it's a flat repository + ___distribution="${___distribution%%/*}" + fi + + + # unpack package control section + FS_Remake_Directory "$___directory_unpack" + DEB_Unpack "$___directory_unpack" "$___target" "control" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "${___directory_unpack}/control/control" + if [ $? -ne 0 ]; then + return 1 + fi + + + # parse package control data + ___value_type="binary" # currently support this for now + ___value_package="" + ___value_version="" + ___value_arch="" + ___value_maintainer="" + ___value_buffer="" + ___value_size="$(DISK_Calculate_Size_File_Byte "$___target")" + ___value_sha256="$(SHASUM_Create_From_File "$___target" "256")" + ___value_sha1="$(SHASUM_Create_From_File "$___target" "1")" + ___value_md5="$(MD5_Create_From_File "$___target")" + ___value_description="" + + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + if [ "${___line#*Package: }" != "${___line}" ]; then + if [ $(STRINGS_Is_Empty "$___value_package") -ne 0 ]; then + ## invalid control file - multiple same fields detected + return 1 + fi + + ___value_package="${___line#*Package: }" + continue + fi + + if [ "${___line#*Version: }" != "${___line}" ]; then + if [ $(STRINGS_Is_Empty "$___value_version") -ne 0 ]; then + ## invalid control file - multiple same fields detected + return 1 + fi + + ___value_version="${___line#*Version: }" + continue + fi + + if [ "${___line#*Architecture: }" != "${___line}" ]; then + if [ $(STRINGS_Is_Empty "$___value_arch") -ne 0 ]; then + ## invalid control file - multiple same fields detected + return 1 + fi + + ___value_arch="${___line#*Architecture: }" + continue + fi + + if [ "${___line#*Maintainer: }" != "${___line}" ]; then + if [ $(STRINGS_Is_Empty "$___value_maintainer") -ne 0 ]; then + ## invalid control file - multiple same fields detected + return 1 + fi + + ___value_maintainer="${___line#*Maintainer: }" + continue + fi + + if [ "${___line#*Description: }" != "${___line}" ]; then + if [ $(STRINGS_Is_Empty "$___value_description") -ne 0 ]; then + ## invalid control file - multiple same fields detected + return 1 + fi + + ___value_description="$___line" + continue + fi + + if [ $(STRINGS_Is_Empty "$___value_description") -eq 0 ]; then + if [ $(STRINGS_Is_Empty "$___value_buffer") -ne 0 ]; then + ___value_buffer="${___value_buffer}\n" + fi + + ___value_buffer="${___value_buffer}${___line}" + else + if [ $(STRINGS_Is_Empty "$___value_description") -ne 0 ]; then + ___value_description="${___value_description}\n" + fi + + ___value_description="${___value_description}${___line}" + fi + done < "${___directory_unpack}/control/control" + IFS="$___old_IFS" && unset ___old_IFS + + + # sanitize package metadata + if [ $(STRINGS_Is_Empty "$___value_type") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_package") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_version") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_arch") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_maintainer") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_size") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_sha256") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_sha1") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_md5") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_description") -eq 0 ]; then + return 1 + fi + + + # process filename + ___value_filename="${___value_package}_${___value_version}_${___value_arch}.deb" + if [ $___repo_is_pool -eq 0 ]; then + ___value_filename="${___value_package}/${___value_filename}" + ___value_filename="$(printf -- "%.1s" "$(FS_Get_File "$___value_package")")/${___value_filename}" + ___value_filename="pool/${___distribution}/${___value_filename}" + fi + + + # write to package database + ___dest="${___value_package}_${___value_version}_${___value_arch}" + if [ $___repo_is_pool -eq 0 ]; then + ___dest="${___value_type}-${___value_arch}/${___dest}" + ___dest="${___component}/${___dest}" + ___dest="${___distribution}/${___dest}" + fi + ___dest="${___data_directory}/packages/${___dest}" + FS_Is_File "$___dest" + if [ $? -eq 0 ]; then + return 1 # duplicated package - already registered + fi + + FS_Make_Housing_Directory "$___dest" + FS_Write_File "$___dest" "\ +Package: ${___value_package} +Version: ${___value_version} +Architecture: ${___value_arch} +Maintainer: ${___value_maintainer} +${___value_buffer} +Filename: ${___value_filename} +Size: ${___value_size} +SHA256: ${___value_sha256} +SHA1: ${___value_sha1} +MD5sum: ${___value_md5} +${___value_description} +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # write to arch database + ___dest="${___data_directory}/arch/${___value_arch}" + FS_Make_Housing_Directory "$___dest" + FS_Append_File "$___dest" "${___value_filename}\n" + if [ $? -ne 0 ]; then + return 1 + fi + + + # export deb payload to destination + ___dest="${___repo_directory}/${___value_filename}" + FS_Is_File "$___dest" + if [ $? -ne 0 ]; then + FS_Make_Housing_Directory "$___dest" + if [ $___repo_is_pool -eq 0 ]; then + FS_Copy_File "$___target" "$___dest" + else + FS_Move "$___target" "$___dest" + fi + if [ $? -ne 0 ]; then + return 1 + fi + elif [ "$___target" != "$___dest" ]; then + return 1 # duplicated package existence or corrupted run + fi + + + # report status + return 0 +} + + + + +DEB_Publish_Conclude() { + ___repo_directory="$1" + ___data_directory="$2" + ___distribution="$3" + ___arch_list="$4" + ___component="$5" + ___codename="$6" + ___gpg_id="$7" + + + # validate input + if [ $(STRINGS_Is_Empty "$___repo_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___data_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___distribution") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___component") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___codename") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___gpg_id") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___repo_directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "$___data_directory" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "find" + if [ $? -ne 0 ]; then + return 1 + fi + + GPG_Is_Available "$___gpg_id" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___directory_package="${___data_directory}/packages" + ___repo_is_pool=1 + if [ "${___distribution%%/*}" = "$___distribution" ]; then + # it's a pool repository + ___repo_is_pool=0 + ___repo_directory="${___repo_directory}/dists" + else + ## it's a flat repository + ___distribution="${___distribution%%/*}" + fi + + + # formulate arch list if empty + if [ $(STRINGS_Is_Empty "$___arch_list") -eq 0 ]; then + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + if [ $(STRINGS_Is_Empty "$___arch_list") -ne 0 ]; then + ___arch_list="${___arch_list} " + fi + + ___arch_list="${___arch_list}$(FS_Get_File "$___line")" + done < +# 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 @@ -58,7 +58,7 @@ function IPK-Create-Archive { # package control $null = Set-Location "${___directory}\control" - $___process = TAR-Create-GZ "..\control.tar.gz" "*" + $___process = TAR-Create-GZ "${___directory}\control.tar.gz" "." if ($___process -ne 0) { $null = Set-Location $___current_path $null = Remove-Variable -Name ___current_path @@ -68,7 +68,7 @@ function IPK-Create-Archive { # package data $null = Set-Location "${___directory}\data" - $___process = TAR-Create-GZ "..\data.tar.gz" "*" + $___process = TAR-Create-GZ "${___directory}\data.tar.gz" "." if ($___process -ne 0) { $null = Set-Location $___current_path $null = Remove-Variable -Name ___current_path @@ -98,7 +98,7 @@ function IPK-Create-Archive { # move to destination $null = FS-Remove-Silently "${___destination}" - $___process = FS-Move "${___file}.gz" "${___destination}" + $___process = FS-Move "${___file}" "${___destination}" # return to current directory diff --git a/automataCI/services/compilers/ipk.sh b/automataCI/services/compilers/ipk.sh index 8e7c2763..86dffe99 100644 --- a/automataCI/services/compilers/ipk.sh +++ b/automataCI/services/compilers/ipk.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 @@ -57,7 +57,7 @@ IPK_Create_Archive() { # package control cd "${___directory}/control" - TAR_Create_GZ "../control.tar.gz" "*" + TAR_Create_GZ "${___directory}/control.tar.gz" "." if [ $? -ne 0 ]; then cd "$___current_path" && unset ___current_path return 1 @@ -66,7 +66,7 @@ IPK_Create_Archive() { # package data cd "${___directory}/data" - TAR_Create_GZ "../data.tar.gz" "*" + TAR_Create_GZ "${___directory}/data.tar.gz" "." if [ $? -ne 0 ]; then cd "$___current_path" && unset ___current_path return 1 @@ -93,7 +93,7 @@ IPK_Create_Archive() { # move to destination FS_Remove_Silently "$___destination" - FS_Move "${___file}.gz" "$___destination" + FS_Move "$___file" "$___destination" ___process=$? diff --git a/automataCI/services/compilers/node.ps1 b/automataCI/services/compilers/node.ps1 index fa926a7d..5c088a95 100644 --- a/automataCI/services/compilers/node.ps1 +++ b/automataCI/services/compilers/node.ps1 @@ -370,9 +370,11 @@ function NODE-Setup { } $___location = "$(NODE-Get-Activator-Path)" - $null = FS-Remove-Silently "$(FS-Get-Directory "${___location}")" + $___directory = "$(FS-Get-Directory "${___location}")" + $null = FS-Remove-Silently "${___directory}" $___target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}\" + $null = FS-Make-Directory "${___target}" switch ("${env:PROJECT_OS}") { "windows" { $___process = ZIP-Extract "${___target}" "${___filepath}" @@ -387,15 +389,14 @@ function NODE-Setup { return 1 } - $___process = FS-Move "${___target}" "$(FS-Get-Directory "${___location}")" + $___process = FS-Move "${___target}" "${___directory}" if ($___process -ne 0) { return 1 } - ## create activator script $___label = "(${env:PROJECT_PATH_NODE_ENGINE})" - $___target = "$(FS-Get-Directory "${___location}")" + $___target = "${___directory}" $null = FS-Write-File "${___location}" @" `$___target = `"${___target}`" diff --git a/automataCI/services/compilers/node.sh b/automataCI/services/compilers/node.sh index 29cbaece..b645f1ef 100644 --- a/automataCI/services/compilers/node.sh +++ b/automataCI/services/compilers/node.sh @@ -377,6 +377,7 @@ NODE_Setup() { FS_Remove_Silently "$(FS_Get_Directory "$___location")" ___target="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/" + FS_Make_Directory "$___target" case "$PROJECT_OS" in windows) ZIP_Extract "$___target" "$___filepath" @@ -395,7 +396,8 @@ NODE_Setup() { return 1 fi - FS_Move "$___target" "$(FS_Get_Directory "$___location")" + ___directory="$(FS_Get_Directory "$___location")" + FS_Move "$___target" "$___directory" if [ $? -ne 0 ]; then return 1 fi @@ -403,7 +405,7 @@ NODE_Setup() { ## create activator script ___label="($PROJECT_PATH_NODE_ENGINE)" - ___target="$(FS_Get_Directory "$___location")/bin" + ___target="${___directory}/bin" FS_Write_File "$___location" "\ #!/bin/sh ___target=\"${___target}\" diff --git a/automataCI/services/compilers/rpm.ps1 b/automataCI/services/compilers/rpm.ps1 index ef150674..0df151ce 100644 --- a/automataCI/services/compilers/rpm.ps1 +++ b/automataCI/services/compilers/rpm.ps1 @@ -11,8 +11,12 @@ # under the License. . "${env:LIBS_AUTOMATACI}\services\io\os.ps1" . "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\disk.ps1" . "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\time.ps1" . "${env:LIBS_AUTOMATACI}\services\compilers\changelog.ps1" +. "${env:LIBS_AUTOMATACI}\services\checksum\md5.ps1" +. "${env:LIBS_AUTOMATACI}\services\checksum\shasum.ps1" @@ -100,7 +104,9 @@ function RPM-Create-Source-Repo { [string]$___directory, [string]$___gpg_id, [string]$___url, + [string]$___metalink, [string]$___name, + [string]$___scope, [string]$___sku ) @@ -114,6 +120,7 @@ function RPM-Create-Source-Repo { ($(STRINGS-Is-Empty "${___gpg_id}") -eq 0) -or ($(STRINGS-Is-Empty "${___url}") -eq 0) -or ($(STRINGS-Is-Empty "${___name}") -eq 0) -or + ($(STRINGS-Is-Empty "${___scope}") -eq 0) -or ($(STRINGS-Is-Empty "${___sku}") -eq 0)) { return 1 } @@ -135,11 +142,23 @@ function RPM-Create-Source-Repo { # execute - $___url = "${___url}/rpm" - $___url = $___url -replace "//rpm", "/rpm" $___key = "usr\local\share\keyrings\${___sku}-keyring.gpg" $___filename = "etc\yum.repos.d\${___sku}.repo" + if ($(STRINGS-Is-Empty "${___metalink}") -ne 0) { + $___url = @" +#baseurl=${___url} # note: flat repository - base url is only for reference +metalink=${___metalink} + +"@ + } else { + $___url = @" +baseurl=${___url} + +"@ + +} + $___process = FS-Is-File "${___directory}\BUILD\$(FS-Get-File "${___filename}")" if ($___process -eq 0) { return 10 @@ -151,12 +170,11 @@ function RPM-Create-Source-Repo { } $null = FS-Make-Directory "${___directory}\BUILD" - $___process = FS-Write-File ` - "${___directory}\BUILD\$(FS-Get-File "${___filename}")" @" + $___process = FS-Write-File "${___directory}\BUILD\$(FS-Get-File "${___filename}")" @" # WARNING: AUTO-GENERATED - DO NOT EDIT! -[${___sku}] +[${___scope}-${___sku}] name=${___name} -baseurl=${___url} +${___url} gpgcheck=1 gpgkey=file:///${___key} @@ -445,6 +463,149 @@ URL: ${___website} +function RPM-Flatten-Repo { + param( + [string]$___repo_directory, + [string]$___filename_repomdxml, + [string]$___filename_metalink, + [string]$___base_url + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___repo_directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___filename_repomdxml}") -eq 0) -or + ($(STRINGS-Is-Empty "${___filename_metalink}") -eq 0) -or + ($(STRINGS-Is-Empty "${___base_url}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___repo_directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Directory "${___repo_directory}\repodata" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___repo_directory}\repodata\repomd.xml" + if ($___process -ne 0) { + return 1 + } + + $___repomd = "${___repo_directory}\repomd.xml" + if ($(STRINGS-Is-Empty "${___filename_repomdxml}") -ne 0) { + $___repomd = "${___repo_directory}\${___filename_repomdxml}" + } + + $___metalink = "${___repo_directory}\METALINK_RPM" + if ($(STRINGS-Is-Empty "${___filename_metalink}") -ne 0) { + $___repomd = "${___repo_directory}\${___filename_metalink}" + } + + + # patch repomd.xml location fields and write to main directory + $null = FS-Remove-Silently "${___repomd}" + + foreach ($___line in (Get-Content -Path "${___repo_directory}/repodata/repomd.xml")) { + ## patch location fields + if ($($___line -replace "^\s* + + + + ${___time} + $(DISK-Calculate-Size-File-Byte "${___repomd}") + + $(MD5-Create-From-File "${___repomd}") + $(SHASUM-Create-From-File "${___repomd}" "1") + $(SHASUM-Create-From-File "${___repomd}" "256") + $(SHASUM-Create-From-File "${___repomd}" "512") + + + ${___url} + + + + + +"@ + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + function RPM-Is-Available { param( [string]$___os, @@ -550,22 +711,30 @@ function RPM-Register { # 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" + if ($(STRINGS-Is-Empty "${___is_directory}") -ne 0) { + $___content = @" +mkdir -p %{buildroot}/${___target} +cp -r $(FS_Get_Directory "${___source}") %{buildroot}/${___target}/. + +"@ + } else { + $___content = @" +mkdir -p %{buildroot}/$(FS-Get-Directory "${___target}") +cp -r ${___source} %{buildroot}/${___target}/. + +"@ } - $___content = "${___content}`ncp -r ${___source} %{buildroot}/${___target}`n" - $___process = FS-Append-File "${___spec}" "${___content}`n" + + $___process = FS-Append-File "${___spec}" "${___content}" if ($___process -ne 0) { return 1 } - ## write into SPEC_FILES + # write into SPEC_FILES $___spec = "${___workspace}/SPEC_FILES" $___content = "/${___content}" if ($(STRINGS-Is-Empty "${___is_directory}") -ne 0) { - $___content = "${___content}/*" + $___content = "${___content}/$(FS-Get-Directory "${___target}")" } $___content = "${___content}`n" $___process = FS-Append-File "${___spec}" "${___content}" diff --git a/automataCI/services/compilers/rpm.sh b/automataCI/services/compilers/rpm.sh index 3870e222..28afbf96 100644 --- a/automataCI/services/compilers/rpm.sh +++ b/automataCI/services/compilers/rpm.sh @@ -12,8 +12,12 @@ # the License. . "${LIBS_AUTOMATACI}/services/io/os.sh" . "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/disk.sh" . "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/io/time.sh" . "${LIBS_AUTOMATACI}/services/compilers/changelog.sh" +. "${LIBS_AUTOMATACI}/services/checksum/md5.sh" +. "${LIBS_AUTOMATACI}/services/checksum/shasum.sh" @@ -106,8 +110,10 @@ RPM_Create_Source_Repo() { ___directory="$2" ___gpg_id="$3" ___url="$4" - ___name="$5" - ___sku="$6" + ___metalink="$5" + ___name="$6" + ___scope="$7" + ___sku="$8" # validate input @@ -119,6 +125,7 @@ RPM_Create_Source_Repo() { [ $(STRINGS_Is_Empty "$___gpg_id") -eq 0 ] || [ $(STRINGS_Is_Empty "$___url") -eq 0 ] || [ $(STRINGS_Is_Empty "$___name") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___scope") -eq 0 ] || [ $(STRINGS_Is_Empty "$___sku") -eq 0 ]; then return 1 fi @@ -140,11 +147,20 @@ RPM_Create_Source_Repo() { # execute - ___url="${___url}/rpm" - ___url="${___url%//rpm*}/rpm" ___key="usr/local/share/keyrings/${___sku}-keyring.gpg" ___filename="etc/yum.repos.d/${___sku}.repo" + if [ $(STRINGS_Is_Empty "$___metalink") -ne 0 ]; then + ___url="\ +#baseurl=${___url} # note: flat repository - only for reference +metalink=${___metalink} +" + else + ___url="\ +baseurl=${___url} +" + fi + FS_Is_File "${___directory}/BUILD/$(FS_Get_File "$___filename")" if [ $? -eq 0 ]; then return 10 @@ -158,9 +174,9 @@ RPM_Create_Source_Repo() { FS_Make_Directory "${___directory}/BUILD" FS_Write_File "${___directory}/BUILD/$(FS_Get_File "$___filename")" "\ # WARNING: AUTO-GENERATED - DO NOT EDIT! -[${___sku}] +[${___scope}-${___sku}] name=${___name} -baseurl=${___url} +${___url} gpgcheck=1 gpgkey=file:///${___key} " @@ -456,6 +472,150 @@ URL: ${___website} +RPM_Flatten_Repo() { + ___repo_directory="$1" + ___filename_repomdxml="$2" + ___filename_metalink="$3" + ___base_url="$4" + + + # validate input + if [ $(STRINGS_Is_Empty "$___repo_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___filename_repomdxml") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___filename_metalink") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___base_url") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___repo_directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "${___repo_directory}/repodata" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "${___repo_directory}/repodata/repomd.xml" + if [ $? -ne 0 ]; then + return 1 + fi + + ___repomd="${___repo_directory}/repomd.xml" + if [ $(STRINGS_Is_Empty "$___filename_repomdxml") -ne 0 ]; then + ___repomd="${___repo_directory}/${___filename_repomdxml}" + fi + + ___metalink="${___repo_directory}/METALINK_RPM" + if [ $(STRINGS_Is_Empty "$___filename_metalink") -ne 0 ]; then + ___metalink="${___repo_directory}/${___filename_metalink}" + fi + + + # patch repomd.xml location fields and write to main directory + FS_Remove_Silently "$___repomd" + + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + ## patch location fields + if [ ! "${___line##* + + + + ${___time} + $(DISK_Calculate_Size_File_Byte "$___repomd") + + $(MD5_Create_From_File "$___repomd") + $(SHASUM_Create_From_File "$___repomd" "1") + $(SHASUM_Create_From_File "$___repomd" "256") + $(SHASUM_Create_From_File "$___repomd" "512") + + + ${___url} + + + + +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + RPM_Is_Available() { ___os="$1" ___arch="$2" @@ -473,7 +633,7 @@ RPM_Is_Available() { fi - # check compatible target cpu architecture + # check compatible target os case "$___os" in linux|any) ;; @@ -555,24 +715,30 @@ RPM_Register() { # execute - ## write into SPEC_INSTALL + # 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" + if [ $(STRINGS_Is_Empty "$4") -ne 0 ]; then + ___content="\ +mkdir -p %{buildroot}/${3} +cp -r $(FS_Get_Directory "$2") %{buildroot}/${3}/. +" + else + ___content="\ +mkdir -p %{buildroot}/$(FS_Get_Directory "$3") +cp -r ${2} %{buildroot}/${3} +" 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" + # write into SPEC_FILES + ___spec="${1}/SPEC_FILES" ___content="/${3}" if [ $(STRINGS_Is_Empty "$4") -ne 0 ]; then - ___content="${___content}/*" + ___content="${___content}/$(FS_Get_Directory "$2")" fi ___content="${___content}\n" FS_Append_File "$___spec" "$___content" diff --git a/automataCI/services/crypto/gpg.ps1 b/automataCI/services/crypto/gpg.ps1 index 40543e8e..6739dd7d 100644 --- a/automataCI/services/crypto/gpg.ps1 +++ b/automataCI/services/crypto/gpg.ps1 @@ -16,24 +16,78 @@ -function GPG-Detach-Sign-File { +function GPG-Clear-Sign-File { param ( + [string]$___output, [string]$___target, [string]$___id ) # validate input - if (($(STRINGS-Is-Empty "${___target}") -eq 0) -or + if (($(STRINGS-Is-Empty "${___output}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target}") -eq 0) -or ($(STRINGS-Is-Empty "${___id}") -eq 0)) { return 1 } + $___process = FS-Is-Target-Exist "${___output}" + if ($___process -eq 0) { + return 1 + } + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + $___process = GPG-Is-Available "${___id}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "gpg" @" +--armor --clear-sign --local-user `"${___id}`" --output `"${___output}`" `"${___target}`" +"@ + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function GPG-Detach-Sign-File { + param ( + [string]$___output, + [string]$___target, + [string]$___id + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___output}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___id}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Target-Exists "${___output}" if ($___process -eq 0) { return 1 } + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + $___process = GPG-Is-Available "${___id}" if ($___process -ne 0) { return 1 @@ -41,8 +95,9 @@ function GPG-Detach-Sign-File { # execute - $___process = OS-Exec ` - "gpg" "--armor --detach-sign --local-user `"${__id}`" `"${__target}`"" + $___process = OS-Exec "gpg" @" +--armor --detach-sign --local-user `"${___id}`" --output `"${___output}`" `"${___target}`" +"@ if ($___process -ne 0) { return 1 } @@ -135,6 +190,10 @@ function GPG-Is-Available { return 1 } + if ($(STRINGS-Is-Empty "${___id}") -eq 0) { + return 0 + } + $___process = OS-Exec "gpg" "--list-key `"${___id}`"" if ($___process -ne 0) { return 1 diff --git a/automataCI/services/crypto/gpg.sh b/automataCI/services/crypto/gpg.sh index c8d96e98..934ecd84 100644 --- a/automataCI/services/crypto/gpg.sh +++ b/automataCI/services/crypto/gpg.sh @@ -17,29 +17,80 @@ +GPG_Clear_Sign_File() { + #___output="$1" + #___target="$2" + #___id="$3" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || + [ $(STRINGS_Is_Empty "$2") -eq 0 ] || + [ $(STRINGS_Is_Empty "$3") -eq 0 ]; then + return 1 + fi + + FS_Is_Target_Exist "$1" + if [ $? -eq 0 ]; then + return 1 + fi + + FS_Is_File "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + GPG_Is_Available "$3" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + gpg --armor --clear-sign --local-user "$3" --output "$1" "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + GPG_Detach_Sign_File() { - #___target="$1" - #___id="$2" + #___output="$1" + #___target="$2" + #___id="$3" # validate input - if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || + [ $(STRINGS_Is_Empty "$2") -eq 0 ] || + [ $(STRINGS_Is_Empty "$3") -eq 0 ]; then return 1 fi - FS_Is_File "$1" + FS_Is_Target_Exist "$1" + if [ $? -eq 0 ]; then + return 1 + fi + + FS_Is_File "$2" if [ $? -ne 0 ]; then return 1 fi - GPG_Is_Available "$2" + GPG_Is_Available "$3" if [ $? -ne 0 ]; then return 1 fi # execute - gpg --armor --detach-sign --local-user "$2" "$1" + gpg --armor --detach-sign --local-user "$3" --output "$1" "$2" if [ $? -ne 0 ]; then return 1 fi @@ -124,6 +175,10 @@ GPG_Is_Available() { return 1 fi + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 0 + fi + gpg --list-key "$1" &> /dev/null if [ $? -ne 0 ]; then return 1 diff --git a/automataCI/services/i18n/_check-disabled-skipped.ps1 b/automataCI/services/i18n/_check-disabled-skipped.ps1 new file mode 100644 index 00000000..0b43c550 --- /dev/null +++ b/automataCI/services/i18n/_check-disabled-skipped.ps1 @@ -0,0 +1,29 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Check-Disabled-Skipped { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning ` + "explicit disabled action detected. Skipping...`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-disabled-skipped.sh b/automataCI/services/i18n/_check-disabled-skipped.sh new file mode 100644 index 00000000..7cfd4417 --- /dev/null +++ b/automataCI/services/i18n/_check-disabled-skipped.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Check_Disabled_Skipped() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "explicit disabled action detected. Skipping...\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_conclude.ps1 b/automataCI/services/i18n/_conclude.ps1 new file mode 100644 index 00000000..157f5dd9 --- /dev/null +++ b/automataCI/services/i18n/_conclude.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Conclude { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "concluding '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_conclude.sh b/automataCI/services/i18n/_conclude.sh new file mode 100644 index 00000000..f3f84164 --- /dev/null +++ b/automataCI/services/i18n/_conclude.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Conclude() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "concluding '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_simulate-conclusion.ps1 b/automataCI/services/i18n/_simulate-conclusion.ps1 index 916705e2..2f65ba44 100644 --- a/automataCI/services/i18n/_simulate-conclusion.ps1 +++ b/automataCI/services/i18n/_simulate-conclusion.ps1 @@ -15,7 +15,7 @@ -function I18N-Simulate-Conclusion { +function I18N-Simulate-Conclude { param( [string]$___subject ) diff --git a/automataCI/services/i18n/translations.ps1 b/automataCI/services/i18n/translations.ps1 index 230275b2..69584ce4 100644 --- a/automataCI/services/i18n/translations.ps1 +++ b/automataCI/services/i18n/translations.ps1 @@ -25,6 +25,7 @@ . "${env:LIBS_AUTOMATACI}\services\i18n\_build-failed-parallel.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\_check.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\_check-availability.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_check-disabled-skipped.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\_check-failed.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\_check-failed-skipped.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\_check-function.ps1" @@ -33,9 +34,9 @@ . "${env:LIBS_AUTOMATACI}\services\i18n\_checksum.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\_checksum-failed.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\_clean.ps1" -. "${env:LIBS_AUTOMATACI}\services\i18n\_clean-failed.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\_commit.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\_commit-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_conclude.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\_configure-build-settings.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\_configure-failed.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\_copy.ps1" diff --git a/automataCI/services/i18n/translations.sh b/automataCI/services/i18n/translations.sh index ce29c3b1..075a698c 100644 --- a/automataCI/services/i18n/translations.sh +++ b/automataCI/services/i18n/translations.sh @@ -25,6 +25,7 @@ . "${LIBS_AUTOMATACI}/services/i18n/_build-failed-parallel.sh" . "${LIBS_AUTOMATACI}/services/i18n/_check.sh" . "${LIBS_AUTOMATACI}/services/i18n/_check-availability.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_check-disabled-skipped.sh" . "${LIBS_AUTOMATACI}/services/i18n/_check-failed.sh" . "${LIBS_AUTOMATACI}/services/i18n/_check-failed-skipped.sh" . "${LIBS_AUTOMATACI}/services/i18n/_check-function.sh" @@ -36,6 +37,7 @@ . "${LIBS_AUTOMATACI}/services/i18n/_clean-failed.sh" . "${LIBS_AUTOMATACI}/services/i18n/_commit.sh" . "${LIBS_AUTOMATACI}/services/i18n/_commit-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_conclude.sh" . "${LIBS_AUTOMATACI}/services/i18n/_configure-build-settings.sh" . "${LIBS_AUTOMATACI}/services/i18n/_configure-failed.sh" . "${LIBS_AUTOMATACI}/services/i18n/_copy.sh" diff --git a/automataCI/services/io/disk.ps1 b/automataCI/services/io/disk.ps1 index 8a5f5f9a..9aa2a391 100644 --- a/automataCI/services/io/disk.ps1 +++ b/automataCI/services/io/disk.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 @@ -9,15 +9,15 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -function DISK-Calculate-Size { +function DISK-Calculate-Size-Directory-KB { param ( - [string]$___location + [string]$___directory ) # validate input - if ([string]::IsNullOrEmpty($___location) -or - (-not (Test-Path -Path "${___location}"))) { + if ([string]::IsNullOrEmpty($___directory) -or + (-not (Test-Path -Path "${___directory}"))) { return 1 } @@ -28,7 +28,7 @@ function DISK-Calculate-Size { # execute - $___value = Get-ChildItem "${___location}" -Recurse -Force ` + $___value = Get-ChildItem "${___directory}" -Recurse -Force ` -ErrorAction SilentlyContinue -Include * ` | Where-Object {$_.psiscontainer -eq $false} ` | Measure-Object -Property length -sum ` @@ -39,6 +39,33 @@ function DISK-Calculate-Size { +function DISK-Calculate-Size-File-Byte { + param ( + [string]$___file + ) + + + # validate input + if ([string]::IsNullOrEmpty($___file) -or (-not (Test-Path -Path "${___file}"))) { + return 1 + } + + $___process = DISK-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___value = Get-ChildItem $___file ` + | Measure-Object -Property length -Sum ` + | Select-Object sum + return [math]::Round($___value.sum / 1, 0) +} + + + + function DISK-Is-Available { return 0 } diff --git a/automataCI/services/io/disk.sh b/automataCI/services/io/disk.sh index 7bbe2a09..bc2cc559 100644 --- a/automataCI/services/io/disk.sh +++ b/automataCI/services/io/disk.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 @@ -10,8 +10,8 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. -DISK_Calculate_Size() { - #___location="$1" +DISK_Calculate_Size_Directory_KB() { + #___directory="$1" # validate input @@ -41,6 +41,36 @@ DISK_Calculate_Size() { +DISK_Calculate_Size_File_Byte() { + #___file="$1" + + + # validate input + if [ -z "$1" ] || [ -d "$1" ]; then + return 1 + fi + + DISK_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___size="$(du -b "$1")" + if [ $? -ne 0 ]; then + return 1 + fi + printf -- "%b" "${___size%%[!0-9]*}" + + + # report status + return 0 +} + + + + DISK_Is_Available() { # execute if [ ! -z "$(type -t du)" ]; then diff --git a/automataCI/services/io/fs.ps1 b/automataCI/services/io/fs.ps1 index b12736d0..af92f28a 100644 --- a/automataCI/services/io/fs.ps1 +++ b/automataCI/services/io/fs.ps1 @@ -48,6 +48,16 @@ function FS-Copy-All { return 1 } + $___process = FS-Is-Directory "${___source}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Directory "${___destination}" + if ($___process -ne 0) { + return 1 + } + # execute $null = Copy-Item -Path "${___source}\*" -Destination "${___destination}" -Recurse @@ -75,6 +85,16 @@ function FS-Copy-File { return 1 } + $___process = FS-Is-File "${___source}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Target-Exist "${___destination}" + if ($___process -eq 0) { + return 1 + } + # execute $null = Copy-Item -Path "${___source}" -Destination "${___destination}" @@ -309,6 +329,34 @@ function FS-Is-Directory { +function FS-Is-Directory-Empty { + param ( + [string]$___target + ) + + + # validate input + $___process = FS-Is-Directory "${___target}" + if ($___process -ne 0) { + return 0 + } + + + # execute + if((Get-ChildItem "${___target}" -force ` + | Select-Object -First 1 ` + | Measure-Object).Count -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + function FS-Is-File { param ( [string]$___target @@ -339,6 +387,40 @@ function FS-Is-File { +function FS-Is-Target-A-C { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + if ($(FS-Is-Target-A-Cargo "${___target}") -eq 0) { + return 1 + } + + if ($(FS-Is-Target-A-Chocolatey "${___target}") -eq 0) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*-C.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-c.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*\.c$', '') -ne "${___file_subject}")) { + return 0 + } + + + # report status + return 1 +} + + + + function FS-Is-Target-A-Cargo { param ( [string]$___target @@ -346,7 +428,12 @@ function FS-Is-Target-A-Cargo { # execute - if (($("${___target}" -replace '^.*-cargo') -ne "${___target}")) { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*-cargo.*', '') -ne "${___file_subject}") { return 0 } @@ -365,8 +452,13 @@ function FS-Is-Target-A-Chocolatey { # execute - if (($("${___target}" -replace '^.*-chocolatey') -ne "${___target}") -or - ($("${___target}" -replace '^.*-choco') -ne "${___target}")) { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*-chocolatey.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-choco.*', '') -ne "${___file_subject}")) { return 0 } @@ -385,7 +477,12 @@ function FS-Is-Target-A-Citation-CFF { # execute - if ($("${___target}" -replace '^.*.cff') -ne "${___target}") { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*\.cff$', '') -ne "${___file_subject}") { return 0 } @@ -404,8 +501,13 @@ function FS-Is-Target-A-Docs { # execute - if (($("${___target}" -replace '^.*-doc') -ne "${___target}") -or - ($("${___target}" -replace '^.*-docs') -ne "${___target}")) { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*-doc.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-docs.*', '') -ne "${___file_subject}")) { return 0 } @@ -424,8 +526,13 @@ function FS-Is-Target-A-Homebrew { # execute - if (($("${___target}" -replace '^.*-homebrew') -ne "${___target}") -or - ($("${___target}" -replace '^.*-brew') -ne "${___target}")) { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*-homebrew.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-brew.*', '') -ne "${___file_subject}")) { return 0 } @@ -439,18 +546,23 @@ function FS-Is-Target-A-Homebrew { function FS-Is-Target-A-Library { param ( - [string]$___subject + [string]$___target ) # execute - if (($("${___subject}" -replace '^lib.*') -ne "${___subject}") -or - ($("${___subject}" -replace '.*\.a$') -ne "${___subject}") -or - ($("${___subject}" -replace '.*\.dll$') -ne "${___subject}") -or - ($("${___subject}" -replace '^.*-lib') -ne "${___subject}") -or - ($("${___subject}" -replace '^.*-libs') -ne "${___subject}") -or - ($("${___subject}" -replace '^.*-library') -ne "${___subject}") -or - ($("${___subject}" -replace '^.*-libraries') -ne "${___subject}")) { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '^lib.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*\.a$', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*\.dll$', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-lib.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-libs.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-library.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-libraries.*', '') -ne "${___file_subject}")) { return 0 } @@ -469,8 +581,13 @@ function FS-Is-Target-A-MSI { # execute - if (($("${___target}" -replace '^.*-msi') -ne "${___target}") -or - ($("${___target}" -replace '^.*.msi') -ne "${___target}")) { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*\.msi$', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-msi.*', '') -ne "${___file_subject}")) { return 0 } @@ -489,7 +606,12 @@ function FS-Is-Target-A-NPM { # execute - if ($("${___target}" -replace '^.*_js-js.tgz') -ne "${___target}") { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*_js-js\.tgz$', '') -ne "${___file_subject}") { return 0 } @@ -508,7 +630,12 @@ function FS-Is-Target-A-Nupkg { # execute - if ($("${___target}" -replace '^.*.nupkg') -ne "${___target}") { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*\.nupkg$', '') -ne "${___file_subject}") { return 0 } @@ -527,7 +654,12 @@ function FS-Is-Target-A-PDF { # execute - if ($("${___target}" -replace '^.*.pdf') -ne "${___target}") { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*\.pdf$', '') -ne "${___file_subject}") { return 0 } @@ -546,7 +678,12 @@ function FS-Is-Target-A-PYPI { # execute - if ($("${___target}" -replace '^.*-pypi') -ne "${___target}") { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*-pypi.*', '') -ne "${___file_subject}") { return 0 } @@ -565,8 +702,13 @@ function FS-Is-Target-A-Source { # execute - if (($("${___target}" -replace '^.*-src') -ne "${___target}") -or - ($("${___target}" -replace '^.*-source') -ne "${___target}")) { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*-src.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-source.*', '') -ne "${___file_subject}")) { return 0 } @@ -585,8 +727,13 @@ function FS-Is-Target-A-TARGZ { # execute - if (($("${___target}" -replace '^.*.tar.gz') -ne "${___target}") -or - ($("${___target}" -replace '^.*.tgz') -ne "${___target}")) { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*\.tar\.gz$', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*\.tgz$', '') -ne "${___file_subject}")) { return 0 } @@ -605,8 +752,13 @@ function FS-Is-Target-A-TARXZ { # execute - if (($("${___target}" -replace '^.*.tar.xz') -ne "${___target}") -or - ($("${___target}" -replace '^.*.txz') -ne "${___target}")) { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*\.tar\.xz$', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*\.txz$', '') -ne "${___file_subject}")) { return 0 } @@ -625,7 +777,12 @@ function FS-Is-Target-A-WASM { # execute - if ($("${___target}" -replace '^.*-wasm') -ne "${___target}") { + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*-wasm.*', '') -ne "${___file_subject}") { return 0 } @@ -644,11 +801,16 @@ function FS-Is-Target-A-WASM-JS { # execute - if ($("${___target}" -replace '^.*-wasm') -eq "${___target}") { + if ([string]::IsNullOrEmpty("${___target}")) { return 1 } - if ($("${___target}" -replace '^.*.js') -eq "${___target}") { + if ($(FS-Is-Target-A-WASM "${___target}") -ne 0) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*\.js$', '') -eq "${___file_subject}") { return 1 } @@ -660,21 +822,19 @@ function FS-Is-Target-A-WASM-JS { -function FS-Is-Target-Exist { +function FS-Is-Target-A-ZIP { param ( [string]$___target ) - # validate input + # execute if ([string]::IsNullOrEmpty("${___target}")) { return 1 } - - # perform checking - $___process = Test-Path -Path "${___target}" -PathType Any -ErrorAction SilentlyContinue - if ($___process) { + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '^.*\.zip$', '') -ne "${___file_subject}") { return 0 } @@ -686,14 +846,21 @@ function FS-Is-Target-Exist { -function FS-Is-Target-A-ZIP { +function FS-Is-Target-Exist { param ( [string]$___target ) - # execute - if ($("${___target}" -replace '^.*.zip') -ne "${___target}") { + # validate input + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + + # perform checking + $___process = Test-Path -Path "${___target}" -PathType Any -ErrorAction SilentlyContinue + if ($___process) { return 0 } @@ -812,6 +979,11 @@ function FS-Move { return 1 } + $___process = FS-Is-Target-Exist $___source + if ($___process -ne 0) { + return 1 + } + # execute try { diff --git a/automataCI/services/io/fs.sh b/automataCI/services/io/fs.sh index d043cc3c..aaaf22fe 100644 --- a/automataCI/services/io/fs.sh +++ b/automataCI/services/io/fs.sh @@ -45,6 +45,16 @@ FS_Copy_All() { return 1 fi + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "$2" + if [ $? -ne 0 ]; then + return 1 + fi + # execute cp -r "${1}"* "${2}/." @@ -70,6 +80,16 @@ FS_Copy_File() { return 1 fi + FS_Is_File "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Target_Exist "$2" + if [ $? -eq 0 ]; then + return 1 + fi + # execute cp "$1" "$2" @@ -272,6 +292,32 @@ FS_Is_Directory() { +FS_Is_Directory_Empty() { + #___target="$1" + + + # validate input + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 0 + fi + + + # execute + for ___item in "$1"/*; do + if [ -e "$___item" ]; then + return 1 + fi + done + + + # report status + return 0 +} + + + + FS_Is_File() { #___target="$1" @@ -300,12 +346,53 @@ FS_Is_File() { +FS_Is_Target_A_C() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + if [ $(FS_Is_Target_A_Cargo "$1") -eq 0 ]; then + return 1 + fi + + if [ $(FS_Is_Target_A_Chocolatey "$1") -eq 0 ]; then + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-C}" != "$___file_subject" ] || + [ "${___file_subject#*-c}" != "$___file_subject" ] || + [ "${___file_subject#*.c}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + FS_Is_Target_A_Cargo() { #___target="$1" # execute - if [ "${1#*-cargo}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-cargo}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -324,7 +411,14 @@ FS_Is_Target_A_Chocolatey() { # execute - if [ "${1#*-chocolatey}" != "$1" ] || [ "${1#*-choco}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-chocolatey}" != "$___file_subject" ] || + [ "${___file_subject#*-choco}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -343,7 +437,13 @@ FS_Is_Target_A_Citation_CFF() { # execute - if [ "${1#*.cff}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*.cff}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -362,7 +462,14 @@ FS_Is_Target_A_Docs() { # execute - if [ "${1#*-doc}" != "$1" ] || [ "${1#*-docs}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-doc}" != "$___file_subject" ] || + [ "${___file_subject#*-docs}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -381,7 +488,14 @@ FS_Is_Target_A_Homebrew() { # execute - if [ "${1#*-homebrew}" != "$1" ] || [ "${1#*-brew}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-homebrew}" != "$___file_subject" ] || + [ "${___file_subject#*-brew}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -400,13 +514,19 @@ FS_Is_Target_A_Library() { # execute - if [ "${1%%lib*}" != "$1" ] || - [ "${1##*.a}" != "$1" ] || - [ "${1##*.dll}" != "$1" ] || - [ "${1#*-lib}" != "$1" ] || - [ "${1#*-libs}" != "$1" ] || - [ "${1#*-library}" != "$1" ] || - [ "${1#*-libraries}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#lib*}" != "$___file_subject" ] || + [ "${___file_subject#*.a}" != "$___file_subject" ] || + [ "${___file_subject#*.dll}" != "$___file_subject" ] || + [ "${___file_subject#*-lib}" != "$___file_subject" ] || + [ "${___file_subject#*-libs}" != "$___file_subject" ] || + [ "${___file_subject#*-library}" != "$___file_subject" ] || + [ "${___file_subject#*-libraries}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -425,7 +545,14 @@ FS_Is_Target_A_MSI() { # execute - if [ "${1#*-msi}" != "$1" ] || [ "${1#*.msi}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-msi}" != "$___file_subject" ] || + [ "${___file_subject#*.msi}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -444,7 +571,13 @@ FS_Is_Target_A_NPM() { # execute - if [ "${1#*_js-js.tgz}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*_js-js.tgz}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -463,7 +596,13 @@ FS_Is_Target_A_Nupkg() { # execute - if [ "${1#*.nupkg}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*.nupkg}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -482,7 +621,13 @@ FS_Is_Target_A_PDF() { # execute - if [ "${1#*.pdf}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*.pdf}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -501,7 +646,13 @@ FS_Is_Target_A_PYPI() { # execute - if [ "${1#*-pypi}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-pypi}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -520,7 +671,14 @@ FS_Is_Target_A_Source() { # execute - if [ "${1#*-src}" != "$1" ] || [ "${1#*-source}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-src}" != "$___file_subject" ] || + [ "${___file_subject#*-source}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -539,7 +697,14 @@ FS_Is_Target_A_TARGZ() { # execute - if [ "${1#*.tar.gz}" != "$1" ] || [ "${1#*.tgz}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*.tar.gz}" != "$___file_subject" ] || + [ "${___file_subject#*.tgz}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -558,7 +723,14 @@ FS_Is_Target_A_TARXZ() { # execute - if [ "${1#*.tar.xz}" != "$1" ] || [ "${1#*.txz}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*.tar.xz}" != "$___file_subject" ] || + [ "${___file_subject#*.txz}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -577,7 +749,13 @@ FS_Is_Target_A_WASM() { # execute - if [ "${1#*-wasm}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-wasm}" != "$___file_subject" ]; then printf -- "0" return 0 fi @@ -596,12 +774,18 @@ FS_Is_Target_A_WASM_JS() { # execute - if [ "${1#*-wasm}" == "$1" ]; then + if [ "$1" = "" ]; then printf -- "1" return 1 fi - if [ "${1#*.js}" == "$1" ]; then + if [ $(FS_Is_Target_A_WASM "$1") -ne 0 ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*.js}" == "$___file_subject" ]; then printf -- "1" return 1 fi @@ -620,7 +804,13 @@ FS_Is_Target_A_ZIP() { # execute - if [ "${1#*.zip}" != "$1" ]; then + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*.zip}" != "${___file_subject}" ]; then printf -- "0" return 0 fi @@ -753,6 +943,11 @@ FS_Move() { return 1 fi + FS_Is_Target_Exist "$1" + if [ $? -ne 0 ]; then + return 1 + fi + # execute mv "$1" "$2" @@ -837,6 +1032,22 @@ FS_Rename() { #___target="$2" + # validate input + if [ -z "$1" ] || [ -z "$2" ]; then + return 1 + fi + + FS_Is_Target_Exist "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Target_Exist "$2" + if [ $? -eq 0 ]; then + return 1 + fi + + # execute FS_Move "$1" "$2" return $? diff --git a/automataCI/services/io/os.ps1 b/automataCI/services/io/os.ps1 index e9df5602..45ea61e8 100644 --- a/automataCI/services/io/os.ps1 +++ b/automataCI/services/io/os.ps1 @@ -200,7 +200,7 @@ function OS-Exec { function OS-Is-Run-Simulated { # execute - if (-not ([string]::IsNullOrEmpty("${env:PROJECT_SIMULATE_RELEASE_REPO}"))) { + if (-not ([string]::IsNullOrEmpty("${env:PROJECT_SIMULATE_RUN}"))) { return 0 } diff --git a/automataCI/services/io/os.sh b/automataCI/services/io/os.sh index e5f4ba14..cd9572ff 100644 --- a/automataCI/services/io/os.sh +++ b/automataCI/services/io/os.sh @@ -133,7 +133,7 @@ OS_Is_Command_Available() { OS_Is_Run_Simulated() { # execute - if [ ! -z "$PROJECT_SIMULATE_RELEASE_REPO" ]; then + if [ ! -z "$PROJECT_SIMULATE_RUN" ]; then printf -- "0" return 0 fi diff --git a/automataCI/services/io/time.ps1 b/automataCI/services/io/time.ps1 index 22d58c47..5eedd9b1 100644 --- a/automataCI/services/io/time.ps1 +++ b/automataCI/services/io/time.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 @@ -9,7 +9,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -function TIME-Format-ISO8601-Date { +function TIME-Format-Date-ISO8601 { param( [string]$___epoch ) @@ -29,6 +29,46 @@ function TIME-Format-ISO8601-Date { +function TIME-Format-Datetime-RFC5322 { + param( + [string]$___epoch + ) + + + # validate input + if ([string]::IsNullOrEmpty($___epoch)) { + return 1 + } + + + # execute + $___t = (Get-Date "1970-01-01 00:00:00.000Z") + ([TimeSpan]::FromSeconds($___epoch)) + return $___t.ToString("ddd, dd MMM YYYY HH:mm:ss zzz") +} + + + + +function TIME-Format-Datetime-RFC5322-UTC { + param( + [string]$___epoch + ) + + + # validate input + if ([string]::IsNullOrEmpty($___epoch)) { + return 1 + } + + + # execute + $___t = (Get-Date "1970-01-01 00:00:00.000Z") + ([TimeSpan]::FromSeconds($___epoch)) + return $___t.ToUniversalTime().ToString("ddd, dd MMM YYYY HH:mm:ss zzz") +} + + + + function TIME-Is-Available { return 0 } diff --git a/automataCI/services/io/time.sh b/automataCI/services/io/time.sh index 57be53f6..dc2cbbd9 100644 --- a/automataCI/services/io/time.sh +++ b/automataCI/services/io/time.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 @@ -10,7 +10,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. -TIME_Format_ISO8601_Date() { +TIME_Format_Date_ISO8601() { #___epoch="$1" @@ -41,6 +41,68 @@ TIME_Format_ISO8601_Date() { +TIME_Format_Datetime_RFC5322() { + #___epoch="$1" + + + # validate input + if [ -z "$1" ]; then + printf -- "" + return 1 + fi + + TIME_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + if [ "$(echo "$(uname)" | tr '[:upper:]' '[:lower:]')" = "darwin" ]; then + printf -- "%b" "$(date -j -f "%s" "${1}" +"%a, %d %b %Y %H:%M:%S %z")" + else + printf -- "%b" "$(date --date="@${1}" +"%a, %d %b %Y %H:%M:%S %z")" + fi + + + # report status + return 0 +} + + + + +TIME_Format_Datetime_RFC5322_UTC() { + #___epoch="$1" + + + # validate input + if [ -z "$1" ]; then + printf -- "" + return 1 + fi + + TIME_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + if [ "$(echo "$(uname)" | tr '[:upper:]' '[:lower:]')" = "darwin" ]; then + printf -- "%b" "$(date -u -j -f "%s" "${1}" +"%a, %d %b %Y %H:%M:%S %z")" + else + printf -- "%b" "$(date -u --date="@${1}" +"%a, %d %b %Y %H:%M:%S %z")" + fi + + + # report status + return 0 +} + + + + TIME_Is_Available() { # execute if [ -z "$(type -t date)" ]; then diff --git a/automataCI/services/publishers/chocolatey.sh b/automataCI/services/publishers/chocolatey.sh index 3b6bcc94..1e1fe7af 100644 --- a/automataCI/services/publishers/chocolatey.sh +++ b/automataCI/services/publishers/chocolatey.sh @@ -83,7 +83,7 @@ CHOCOLATEY_Archive() { # execute ___current_path="$PWD" && cd "$2" - ZIP_Create "$1" "*" + ZIP_Create "$1" "." ___process=$? cd "$___current_path" && unset ___current_path if [ $___process -ne 0 ]; then diff --git a/automataCI/services/publishers/createrepo.ps1 b/automataCI/services/publishers/createrepo.ps1 index 95ca6d4e..f21a2f44 100644 --- a/automataCI/services/publishers/createrepo.ps1 +++ b/automataCI/services/publishers/createrepo.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 @@ -38,14 +38,12 @@ function CREATEREPO-Is-Available { function CREATEREPO-Publish { param ( - [string]$___target, [string]$___directory ) # validate input - if (($(STRINGS-Is-Empty "${___target}") -eq 0) -or - ($(STRINGS-Is-Empty "${___directory}") -eq 0)) { + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { return 1 } @@ -54,18 +52,8 @@ function CREATEREPO-Publish { return 1 } - $___process = FS-Is-Directory "${___directory}" - if ($___process -ne 0) { - return 1 - } - # execute - $___process = FS-Copy-File "${___target}" "${___directory}" - if ($___process -ne 0) { - return 1 - } - $___process = OS-Is-Command-Available "createrepo" if ($___process -eq 0) { $___process = OS-Exec "createrepo" "--update ${___directory}" diff --git a/automataCI/services/publishers/createrepo.sh b/automataCI/services/publishers/createrepo.sh index bd8e3896..b7cdb844 100644 --- a/automataCI/services/publishers/createrepo.sh +++ b/automataCI/services/publishers/createrepo.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 @@ -38,50 +38,40 @@ CREATEREPO_Is_Available() { CREATEREPO_Publish() { - ___target="$1" - ___directory="$2" + #___repo_directory="$1" # validate input - if [ $(STRINGS_Is_Empty "$___target") -eq 0 ] || - [ $(STRINGS_Is_Empty "$__directory") -eq 0 ]; then + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then return 1 fi - FS_Is_Directory "$___target" - if [ $? -eq 0 ]; then - return 1 - fi - - FS_Is_Directory "$___directory" + FS_Is_Directory "$1" if [ $? -ne 0 ]; then return 1 fi # execute - FS_Copy_File "$__target" "$__directory" - if [ $? -ne 0 ]; then - return 1 - fi - OS_Is_Command_Available "createrepo" if [ $? -eq 0 ]; then - createrepo --update "$__directory" - if [ $? -eq 0 ]; then - return 0 + createrepo --update "$1" + if [ $? -ne 0 ]; then + return 1 fi + + return 0 fi OS_Is_Command_Available "createrepo_c" if [ $? -eq 0 ]; then - createrepo_c --update "$__directory" - if [ $? -eq 0 ]; then - return 0 + createrepo_c --update "$1" + if [ $? -ne 0 ]; then + return 1 fi fi # report status - return 1 + return 0 } diff --git a/automataCI/services/publishers/homebrew.ps1 b/automataCI/services/publishers/homebrew.ps1 index 8a44dab2..0ef1f0f0 100644 --- a/automataCI/services/publishers/homebrew.ps1 +++ b/automataCI/services/publishers/homebrew.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 @@ -11,6 +11,8 @@ # 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\checksum\shasum.ps1" @@ -26,11 +28,6 @@ function HOMEBREW-Is-Valid-Formula { return 1 } - $___process = FS-Is-Target-A-Homebrew "${___target}" - if ($___process -ne 0) { - return 1 - } - if ($___target -like "*.asc") { return 1 } @@ -49,25 +46,215 @@ function HOMEBREW-Is-Valid-Formula { -function HOMEBREW-Publish { +function HOMEBREW-Seal { param ( - [string]$___target, - [string]$___destination + [string]$___formula, + [string]$___archive_name, + [string]$___workspace, + [string]$___sku, + [string]$___description, + [string]$___website, + [string]$___license, + [string]$___base_url ) # validate input - if (($(STRINGS-Is-Empty "${___target}") -eq 0) -or - ($(STRINGS-Is-Empty "${___destination}") -eq 0)) { + if (($(STRINGS-Is-Empty "${___formula}") -eq 0) -or + ($(STRINGS-Is-Empty "${___archive_name}") -eq 0) -or + ($(STRINGS-Is-Empty "${___workspace}") -eq 0) -or + ($(STRINGS-Is-Empty "${___sku}") -eq 0) -or + ($(STRINGS-Is-Empty "${___description}") -eq 0) -or + ($(STRINGS-Is-Empty "${___website}") -eq 0) -or + ($(STRINGS-Is-Empty "${___license}") -eq 0) -or + ($(STRINGS-Is-Empty "${___base_url}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___workspace}" + if ($___process -ne 0) { + return 1 + } + + $___export_directory = "$(FS-Get-Directory "${___formula}")" + if ($___export_directory -eq $___formula) { return 1 } + $null = FS-Make-Directory "${___export_directory}" # execute - $null = FS-Make-Directory "${___destination}" - $___process = FS-Copy-File ` - "${___target}" ` - "${___destination}\$(Split-Path -Leaf -Path "${___target}")" + ## generate the init script + $___dest = "${___workspace}/init.sh" + $___process = FS-Write-File "${___dest}" @" +#!/bin/sh +OS_Get_Arch() { + ___output="`$(uname -m)" + ___output="`$(printf -- "%b" "`$___output" | tr '[:upper:]' '[:lower:]')" + case "`$___output" in + i686-64) + export ___output='ia64' # Intel Itanium. + ;; + i386|i486|i586|i686) + export ___output='i386' + ;; + x86_64) + export ___output='amd64' + ;; + sun4u) + export ___output='sparc' + ;; + 'power macintosh') + export ___output='powerpc' + ;; + ip*) + export ___output='mips' + ;; + *) + ;; + esac + + + # report status + printf -- "%b" "`$___output" + return 0 +} + + +OS_Get() { + # execute + ___output="`$(uname)" + ___output="`$(printf -- "%b" "`${___output}" | tr '[:upper:]' '[:lower:]')" + case "`$___output" in + windows*|ms-dos*) + ___output='windows' + ;; + cygwin*|mingw*|mingw32*|msys*) + ___output='windows' + ;; + *freebsd) + ___output='freebsd' + ;; + dragonfly*) + ___output='dragonfly' + ;; + *) + ;; + esac + + + # report status + printf -- "%b" "`$___output" + return 0 +} + + +main() { + host_os="`$(OS_Get)" + host_arch="`$(OS_Get_Arch)" + for ___file in './bin/'*; do + if [ ! -e "`$___file" ]; then + continue + fi + + ___system="`${___file##*/}" + ___system="`${___system%%.*}" + ___system="`${___system##*_}" + ___os="`${___system%%-*}" + ___arch="`${___system##*-}" + + case "`$___os" in + any|"`$host_os") + ;; + *) + rm -f "`$___file" &> /dev/null + continue + ;; + esac + + case "`$___arch" in + any|"`$host_arch") + mv "`$___file" "`${___file%%_*}" + ;; + *) + rm -f "`$___file" &> /dev/null + ;; + esac + done + + return 0 +} +main `$* +return `$? + +"@ + if ($___process -ne 0) { + return 1 + } + + ## seal the workspace + $___current_path = Get-Location + $null = Set-Location -Path "${___workspace}" + $___process = TAR-Create-XZ "${___export_directory}\${___archive_name}" "." + $null = Set-Location -Path "${___current_path}" + $null = Remove-Variable -Name ___current_path + if ($___process -ne 0) { + return 1 + } + + ## create the formula + $___shasum = SHASUM-Create-From-File "${___export_directory}/${___archive_name}" "256" + if ($(STRINGS-Is-Empty "${___shasum}") -eq 0) { + return 1 + } + + $null = FS-Make-Housing-Directory "${___formula}" + $___process = FS-Write-File "${___formula}" @" +class $(STRINGS-To-Titlecase "${___sku}") < Formula + desc '${___description}' + homepage '${___website}' + license '${___license}' + url '${___base_url}/${___archive_name}' + sha256 '${___shasum}' + + def install + if File.file?('init.sh.ps1') + chmod 755, './init.sh.ps1' + system './init.sh.ps1' + else + chmod 755, './init.sh' + system './init.sh' + end + + if File.directory?('bin') + Dir.foreach('bin') do |filename| + next if filename == '.' or filename == '..' + chmod 0755, filename + libexec.install 'bin/' + filename + bin.install_symlink 'libexec/bin/' + filename => filename + end + end + + if File.directory?('lib') + Dir.foreach('lib') do |filename| + next if filename == '.' or filename == '..' + chmod 0544, filename + libexec.install 'lib/' + filename + lib.install_symlink 'libexec/lib/' + filename => filename + end + end + end + + test do + if File.file?('init.sh.ps1') + assert_predicate 'init.sh.ps1', :exist? + else + assert_predicate 'init.sh', :exist? + end + end +end + +"@ if ($___process -ne 0) { return 1 } diff --git a/automataCI/services/publishers/homebrew.sh b/automataCI/services/publishers/homebrew.sh index ba34251e..f2c9bba8 100644 --- a/automataCI/services/publishers/homebrew.sh +++ b/automataCI/services/publishers/homebrew.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 @@ -13,6 +13,8 @@ . "${LIBS_AUTOMATACI}/services/io/os.sh" . "${LIBS_AUTOMATACI}/services/io/fs.sh" . "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/checksum/shasum.sh" @@ -26,10 +28,6 @@ HOMEBREW_Is_Valid_Formula() { return 1 fi - if [ $(FS_Is_Target_A_Homebrew "$1") -ne 0 ]; then - return 1 - fi - if [ ! "${1%.asc*}" = "$1" ]; then return 1 fi @@ -48,20 +46,210 @@ HOMEBREW_Is_Valid_Formula() { -HOMEBREW_Publish() { - #___target="$1" - #___destination="$2" +HOMEBREW_Seal() { + ___formula="$1" + ___archive_name="$2" + ___workspace="$3" + ___sku="$4" + ___description="$5" + ___website="$6" + ___license="$7" + ___base_url="$8" # validate input - if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + if [ $(STRINGS_Is_Empty "$___formula") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___archive_name") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___workspace") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___sku") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___description") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___website") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___license") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___base_url") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___workspace" + if [ $? -ne 0 ]; then return 1 fi + ___export_directory="$(FS_Get_Directory "$___formula")" + if [ "$___export_directory" = "$___formula" ]; then + return 1 + fi + FS_Make_Directory "$___export_directory" + + + # execute + ## generate the init script + ___dest="${___workspace}/init.sh" + FS_Write_File "$___dest" "\ +#!/bin/sh +OS_Get_Arch() { + ___output=\"\$(uname -m)\" + ___output=\"\$(printf -- \"%b\" \"\$___output\" | tr '[:upper:]' '[:lower:]')\" + case \"\$___output\" in + i686-64) + export ___output='ia64' # Intel Itanium. + ;; + i386|i486|i586|i686) + export ___output='i386' + ;; + x86_64) + export ___output='amd64' + ;; + sun4u) + export ___output='sparc' + ;; + 'power macintosh') + export ___output='powerpc' + ;; + ip*) + export ___output='mips' + ;; + *) + ;; + esac + + + # report status + printf -- \"%b\" \"\$___output\" + return 0 +} + +OS_Get() { # execute - FS_Make_Housing_Directory "$2" - FS_Copy_File "$1" "$2" + ___output=\"\$(uname)\" + ___output=\"\$(printf -- \"%b\" \"\${___output}\" | tr '[:upper:]' '[:lower:]')\" + case \"\$___output\" in + windows*|ms-dos*) + ___output='windows' + ;; + cygwin*|mingw*|mingw32*|msys*) + ___output='windows' + ;; + *freebsd) + ___output='freebsd' + ;; + dragonfly*) + ___output='dragonfly' + ;; + *) + ;; + esac + + + # report status + printf -- \"%b\" \"\$___output\" + return 0 +} + + +main() { + host_os=\"\$(OS_Get)\" + host_arch=\"\$(OS_Get_Arch)\" + for ___file in './bin/'*; do + if [ ! -e \"\$___file\" ]; then + continue + fi + + ___system=\"\${___file##*/}\" + ___system=\"\${___system%%.*}\" + ___system=\"\${___system##*_}\" + ___os=\"\${___system%%-*}\" + ___arch=\"\${___system##*-}\" + + case \"\$___os\" in + any|\"\$host_os\") + ;; + *) + rm -f \"\$___file\" &> /dev/null + continue + ;; + esac + + case \"\$___arch\" in + any|\"\$host_arch\") + mv \"\$___file\" \"\${___file%%_*}\" + ;; + *) + rm -f \"\$___file\" &> /dev/null + ;; + esac + done + + return 0 +} +main \$* +return \$? +" + if [ $? -ne 0 ]; then + return 1 + fi + + ## seal the workspace + ___current_path="$PWD" && cd "$___workspace" + TAR_Create_XZ "${___export_directory}/${___archive_name}" "." + ___process=$? + cd "$___current_path" && unset ___current_path + if [ $___process -ne 0 ]; then + return 1 + fi + + ## create the formula + ___shasum="$(SHASUM_Create_From_File "${___export_directory}/${___archive_name}" "256")" + if [ $(STRINGS_Is_Empty "$___shasum") -eq 0 ]; then + return 1 + fi + + FS_Make_Housing_Directory "$___formula" + FS_Write_File "$___formula" "\ +class $(STRINGS_To_Titlecase "$___sku") < Formula + desc '${___description}' + homepage '${___website}' + license '${___license}' + url '${___base_url}/${___archive_name}' + sha256 '${___shasum}' + + def install + if File.file?('init.sh.ps1') + chmod 755, './init.sh.ps1' + system './init.sh.ps1' + else + chmod 755, './init.sh' + system './init.sh' + end + + if File.directory?('bin') + Dir.foreach('bin') do |filename| + next if filename == '.' or filename == '..' + chmod 0755, filename + libexec.install 'bin/' + filename + bin.install_symlink 'libexec/bin/' + filename => filename + end + end + + if File.directory?('lib') + Dir.foreach('lib') do |filename| + next if filename == '.' or filename == '..' + chmod 0544, filename + libexec.install 'lib/' + filename + lib.install_symlink 'libexec/lib/' + filename => filename + end + end + end + + test do + if File.file?('init.sh.ps1') + assert_predicate 'init.sh.ps1', :exist? + else + assert_predicate 'init.sh', :exist? + end + end +end +" if [ $? -ne 0 ]; then return 1 fi diff --git a/automataCI/services/publishers/unix.ps1 b/automataCI/services/publishers/unix.ps1 new file mode 100644 index 00000000..961c5906 --- /dev/null +++ b/automataCI/services/publishers/unix.ps1 @@ -0,0 +1,51 @@ +# 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\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" + + + + +function UNIX-Get-Arch { + param( + [string]$___arch + ) + + + # execute + switch ($___arch) { + "any" { + return "all" + } { $_ -in "386", "i386", "486", "i486", "586", "i586", "686", "i686" } { + return "i386" + } "armle" { + return "armel" + } "mipsle" { + return "mipsel" + } "mipsr6le" { + return "mips64r6el" + } "mipsn32le" { + return "mipsn32el" + } "mipsn32r6le" { + return "mipsn32r6el" + } "mips64le" { + return "mips64el" + } "mipsn64r6le" { + return "mipsn64r6el" + } "powerpcle" { + return "powerpcel" + } "ppc64le" { + return "ppc64el" + } default { + return $___arch + }} +} diff --git a/automataCI/services/publishers/unix.sh b/automataCI/services/publishers/unix.sh new file mode 100644 index 00000000..a6b0e608 --- /dev/null +++ b/automataCI/services/publishers/unix.sh @@ -0,0 +1,58 @@ +#!/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. +UNIX_Get_Arch() { + # execute + case "$1" in + any) + ___value="all" + ;; + 386|i386|486|i486|586|i586|686|i686) + ___value="i386" + ;; + armle) + ___value="armel" + ;; + mipsle) + ___value="mipsel" + ;; + mipsr6le) + ___value="mipsr6el" + ;; + mipsn32le) + ___value="mipsn32el" + ;; + mipsn32r6le) + ___value="mipsn32r6el" + ;; + mips64le) + ___value="mips64el" + ;; + mips64r6le) + ___value="mips64r6el" + ;; + powerpcle) + ___value="powerpcel" + ;; + ppc64le) + ___value="ppc64el" + ;; + *) + ___value="$1" + ;; + esac + printf -- "%s" "$___value" + + + # report status + return 0 +} diff --git a/src/.ci/_package-archive_unix-any.sh b/src/.ci/_package-archive_unix-any.sh index 04b4fee1..066772ce 100644 --- a/src/.ci/_package-archive_unix-any.sh +++ b/src/.ci/_package-archive_unix-any.sh @@ -38,14 +38,17 @@ PACKAGE_Assemble_ARCHIVE_Content() { if [ $(FS_Is_Target_A_Source "$_target") -eq 0 ]; then return 10 # not applicable elif [ $(FS_Is_Target_A_Docs "$_target") -eq 0 ]; then - ___source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_DOCS}/" - FS_Is_Directory "$___source" + __source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_DOCS}" + __dest="${_directory}/docs" + + FS_Is_Directory "$__source" if [ $? -ne 0 ]; then return 10 # not applicable fi - I18N_Assemble "$___source" "$_directory" - FS_Copy_All "$___source" "$_directory" + I18N_Assemble "$__source" "$__dest" + FS_Make_Directory "$__dest" + FS_Copy_All "$__source" "$__dest" if [ $? -ne 0 ]; then I18N_Assemble_Failed return 1 @@ -55,18 +58,22 @@ PACKAGE_Assemble_ARCHIVE_Content() { 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 - I18N_Assemble "$_target" "$_directory" - FS_Copy_File "$_target" "$_directory" + __dest="${_directory}/assets/$(FS_Get_File "$_target")" + + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" if [ $? -ne 0 ]; then I18N_Assemble_Failed return 1 fi - ___source="$(FS_Extension_Remove "$_target" ".wasm").js" - FS_Is_File "$___source" + __source="$(FS_Extension_Remove "$_target" ".wasm").js" + FS_Is_File "$__source" if [ $? -eq 0 ]; then - I18N_Assemble "$___source" "$_directory" - FS_Copy_File "$___source" "$_directory" + __dest="${__dest}/$(FS_Get_File "$__source")" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" if [ $? -ne 0 ]; then I18N_Assemble_Failed return 1 @@ -83,8 +90,14 @@ PACKAGE_Assemble_ARCHIVE_Content() { elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then return 10 # not applicable else - I18N_Assemble "$_target" "$_directory" - FS_Copy_File "$_target" "$_directory" + __dest="${_directory}/bin/${PROJECT_SKU}" + if [ "$_target_os" = "windows" ]; then + __dest="${__dest}.exe" + fi + + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" if [ $? -ne 0 ]; then I18N_Assemble_Failed return 1 @@ -93,23 +106,37 @@ PACKAGE_Assemble_ARCHIVE_Content() { # copy user guide - ___source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/USER-GUIDES_en.pdf" - I18N_Assemble "$___source" "$_directory" - FS_Copy_File "$___source" "${_directory}/." - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi + for __source in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/USER-GUIDES"*.pdf; do + FS_Is_Target_Exist "$__source" + if [ $? -ne 0 ]; then + continue + fi + + __dest="${_directory}/$(FS_Get_File "$__source")" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + done # copy license file - ___source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/licenses/LICENSE_en.pdf" - I18N_Assemble "$___source" "$_directory" - FS_Copy_File "$___source" "${_directory}/." - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi + for __source in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/licenses/LICENSE"*.pdf; do + FS_Is_Target_Exist "$__source" + if [ $? -ne 0 ]; then + continue + fi + + __dest="${_directory}/$(FS_Get_File "$__source")" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + done # report status diff --git a/src/.ci/_package-archive_windows-any.ps1 b/src/.ci/_package-archive_windows-any.ps1 index 479ef837..0d28260f 100644 --- a/src/.ci/_package-archive_windows-any.ps1 +++ b/src/.ci/_package-archive_windows-any.ps1 @@ -39,14 +39,17 @@ function PACKAGE-Assemble-ARCHIVE-Content { if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { return 10 # not applicable } elseif ($(FS-Is-Target-A-Docs "${_target}") -eq 0) { - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_DOCS}\" - $___process = FS-Is-Directory "${___source}" + $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_DOCS}" + $__dest = "${_directory}\docs" + + $___process = FS-Is-Directory "${__source}" if ($___process -ne 0) { return 10 # not applicable } - $null = I18N-Assemble "${___source}" "${_directory}" - $___process = FS-Copy-All "${___source}" "${_directory}" + $null = I18N-Assemble "${__source}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = FS-Copy-All "${__source}" "${__dest}" if ($___process -ne 0) { $null = I18N-Assemble-Failed return 1 @@ -56,18 +59,22 @@ function PACKAGE-Assemble-ARCHIVE-Content { } 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) { - $null = I18N-Assemble "${_target}" "${_directory}" - $___process = FS-Copy-File "${_target}" "${_directory}" + $__dest = "${_directory}\assets\$(FS-Get-File "${_target}")" + + $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 } - $___source = "$(FS-Extension-Remove "${_target}" ".wasm").js" - $___process = FS-Is-File "${___source}" + $__source = "$(FS-Extension-Remove "${_target}" ".wasm").js" + $___process = FS-Is-File "${__source}" if ($___process -eq 0) { - $null = I18N-Assemble "${___source}" "${_directory}" - $___process = FS-Copy-File "${___source}" "${_directory}" + $__dest = "${__dest}\$(FS-Get-File "${__source}")" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" if ($___process -ne 0) { $null = I18N-Assemble-Failed return 1 @@ -84,8 +91,14 @@ function PACKAGE-Assemble-ARCHIVE-Content { } elseif ($(FS-Is-Target-A-PDF "${_target}") -eq 0) { return 10 # not applicable } else { - $null = I18N-Assemble "${_target}" "${_directory}" - $___process = FS-Copy-File "${_target}" "${_directory}" + $__dest = "${_directory}\bin\${env:PROJECT_SKU}" + if ($_target_os -eq "windows") { + $__dest = "${__dest}.exe" + } + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" if ($___process -ne 0) { $null = I18N-Assemble-Failed return 1 @@ -94,22 +107,30 @@ function PACKAGE-Assemble-ARCHIVE-Content { # copy user guide - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\USER-GUIDES_en.pdf" - $null = I18N-Assemble "${___source}" "${_directory}" - $___process = FS-Copy-File "${___source}" "${_directory}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 + Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs" ` + | Where-Object { ($_.Name -like "USER-GUIDES*.pdf") } ` + | ForEach-Object { $__source = $_.FullName + $__dest = "${_directory}\$(FS-Get-File "${__source}")" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } } # copy license file - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses\LICENSE_en.pdf" - $null = I18N-Assemble "${___source}" "${_directory}" - $___process = FS-Copy-File "${___source}" "${_directory}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 + Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses" ` + | Where-Object { ($_.Name -like "LICENSE*.pdf") } ` + | ForEach-Object { $__source = $_.FullName + $__dest = "${_directory}\$(FS-Get-File "${__source}")" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } } diff --git a/src/.ci/_package-chocolatey_unix-any.sh b/src/.ci/_package-chocolatey_unix-any.sh index 57b5cbce..5bafcd8c 100644 --- a/src/.ci/_package-chocolatey_unix-any.sh +++ b/src/.ci/_package-chocolatey_unix-any.sh @@ -20,6 +20,9 @@ if [ "$PROJECT_PATH_ROOT" == "" ]; then return 1 fi +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + @@ -31,6 +34,222 @@ PACKAGE_Assemble_CHOCOLATEY_Content() { _target_arch="$5" + # validate input + case "$_target_os" in + any|windows) + ;; + *) + return 10 # not supported + ;; + esac + + 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 + __dest="${_directory}/lib" + + 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 + + _package="lib${PROJECT_SKU}" + elif [ $(FS_Is_Target_A_WASM_JS "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_WASM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Chocolatey "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Homebrew "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Cargo "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_MSI "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then + return 10 # not applicable + else + # copy main program + __dest="${_directory}/bin/${PROJECT_SKU}.exe" + + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + _package="${PROJECT_SKU}" + fi + + __source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/icons/icon-128x128.png" + __dest="${_directory}/icon.png" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + __source="${PROJECT_PATH_ROOT}/${PROJECT_README}" + __dest="${_directory}/${PROJECT_README}" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + + # REQUIRED: chocolatey required tools\ directory + __dest="${_directory}/tools" + I18N_Create "$__dest" + FS_Make_Directory "$__dest" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # OPTIONAL: chocolatey tools\chocolateyBeforeModify.ps1 + __dest="${_directory}/tools/chocolateyBeforeModify.ps1" + I18N_Create "$__dest" + FS_Write_File "$__dest" "\ +# REQUIRED - BEGIN EXECUTION +Write-Host \"Performing pre-configurations...\" +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # REQUIRED: chocolatey tools\chocolateyinstall.ps1 + __dest="${_directory}/tools/chocolateyinstall.ps1" + I18N_Create "$__dest" + FS_Write_File "$__dest" "\ +# REQUIRED - PREPARING INSTALLATION +Write-Host \"Installing ${PROJECT_SKU} (${PROJECT_VERSION})...\" +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # REQUIRED: chocolatey tools\chocolateyuninstall.ps1 + __dest="${_directory}/tools/chocolateyuninstall.ps1" + I18N_Create "$__dest" + FS_Write_File "$__dest" "\ +# REQUIRED - PREPARING UNINSTALLATION +Write-Host \"Uninstalling ${PROJECT_SKU} (${PROJECT_VERSION})...\" +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # REQUIRED: chocolatey xml.nuspec file + __dest="${_directory}/${_package}.nuspec" + I18N_Create "$__dest" + FS_Write_File "$__dest" "\ + + + + ${PROJECT_SKU} + ${PROJECT_NAME} + ${PROJECT_VERSION} + ${PROJECT_CONTACT_NAME} + ${PROJECT_CONTACT_NAME} + ${PROJECT_CONTACT_WEBSITE} + ${PROJECT_LICENSE} + ${PROJECT_PITCH} + ${PROJECT_README} + icon.png + + + + + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + FS_Is_Directory_Empty "${_directory}/bin" + if [ $? -ne 0 ]; then + FS_Append_File "$__dest" "\ + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + fi + + FS_Is_Directory_Empty "${_directory}/lib" + if [ $? -ne 0 ]; then + FS_Append_File "$__dest" "\ + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + fi + + FS_Append_File "$__dest" "\ + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + # execute - return 10 # not applicable - should be tech-oriented. + return 0 } diff --git a/src/.ci/_package-chocolatey_windows-any.ps1 b/src/.ci/_package-chocolatey_windows-any.ps1 index 933639bb..2bb2a8bf 100644 --- a/src/.ci/_package-chocolatey_windows-any.ps1 +++ b/src/.ci/_package-chocolatey_windows-any.ps1 @@ -19,6 +19,9 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { exit 1 } +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + @@ -32,6 +35,228 @@ function PACKAGE-Assemble-CHOCOLATEY-Content { ) - # execute - return 10 # not applicable - should be tech-oriented. + # validate project + switch ("${_target_os}") { + { $_ -in "any", "windows" } { + # accepted + } default { + return 10 # not supported + }} + + 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) { + $__dest = "${_directory}\lib" + + 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 + } + } + + $_package = "lib${env:PROJECT_SKU}" + } elseif ($(FS-Is-Target-A-WASM-JS "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-WASM "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Chocolatey "${_target}") -eq 0) { + 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) { + return 10 # not applicable + } else { + # copy main program + $__dest = "${_directory}\bin\${env:PROJECT_SKU}.exe" + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $_package = "${env:PROJECT_SKU}" + } + + + $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\icons\icon-128x128.png" + $__dest = "${_directory}\icon.png" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_README}" + $__dest = "${_directory}\${env:PROJECT_README}" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + + # REQUIRED: chocolatey required tools\ directory + $__dest = "${_directory}\tools" + $null = I18N-Create "${__dest}" + $___process = FS-Make-Directory "${__dest}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # OPTIONAL: chocolatey tools\chocolateyBeforeModify.ps1 + $__dest = "${_directory}\tools\chocolateyBeforeModify.ps1" + $null = I18N-Create "${__dest}" + $___process = FS-Write-File "${__dest}" @" +# REQUIRED - BEGIN EXECUTION +Write-Host "Performing pre-configurations..." +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # REQUIRED: chocolatey tools\chocolateyinstall.ps1 + $__dest = "${_directory}\tools\chocolateyinstall.ps1" + $null = I18N-Create "${__dest}" + $___process = FS-Write-File "${__dest}" @" +# REQUIRED - PREPARING INSTALLATION +Write-Host "Installing ${env:PROJECT_SKU} (${env:PROJECT_VERSION})..." + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # REQUIRED: chocolatey tools\chocolateyuninstall.ps1 + $__dest = "${_directory}\tools\chocolateyuninstall.ps1" + $null = I18N-Create "${__dest}" + $___process = FS-Write-File "${__dest}" @" +# REQUIRED - PREPARING UNINSTALLATION +Write-Host "Uninstalling ${env:PROJECT_SKU} (${env:PROJECT_VERSION})..." + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # REQUIRED: chocolatey xml.nuspec file + $__dest = "${_directory}\${env:PROJECT_SKU}.nuspec" + $null = I18N-Create "${__dest}" + $___process = FS-Write-File "${__dest}" @" + + + + ${env:PROJECT_SKU} + ${env:PROJECT_NAME} + ${env:PROJECT_VERSION} + ${env:PROJECT_CONTACT_NAME} + ${env:PROJECT_CONTACT_NAME} + ${env:PROJECT_CONTACT_WEBSITE} + ${env:PROJECT_LICENSE} + ${env:PROJECT_PITCH} + ${env:PROJECT_README} + icon.png + + + + + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + $___process = FS-Is-Directory-Empty "${_directory}\bin" + if ($___process -ne 0) { + $___process = FS-Append-File "${__dest}" @" + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + $___process = FS-Is-Directory-Empty "${_directory}\lib" + if ($___process -ne 0) { + $___process = FS-Append-File "${__dest}" @" + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + $___process = FS-Append-File "${__dest}" @" + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # report status + return 0 } diff --git a/src/.ci/_package-deb_unix-any.sh b/src/.ci/_package-deb_unix-any.sh index 7cde15c7..da5a640a 100644 --- a/src/.ci/_package-deb_unix-any.sh +++ b/src/.ci/_package-deb_unix-any.sh @@ -67,8 +67,8 @@ PACKAGE_Assemble_DEB_Content() { ## (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="${_directory}/data/usr" + if [ ! "$(STRINGS_To_Lowercase "$PROJECT_DEB_IS_NATIVE")" = "true" ]; then _chroot="${_chroot}/local" fi @@ -79,42 +79,42 @@ 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 - ___dest="${_chroot}/lib/${PROJECT_SCOPE}/${PROJECT_SKU}" + __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" + 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" + 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" + 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" + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" if [ $? -ne 0 ]; then I18N_Assemble_Failed return 1 @@ -139,11 +139,11 @@ PACKAGE_Assemble_DEB_Content() { return 10 # not applicable else # copy main program - ___dest="${_chroot}/bin/" + __dest="${_chroot}/bin/${PROJECT_SKU}" - I18N_Assemble "$_target" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_File "$_target" "$___dest" + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" if [ $? -ne 0 ]; then I18N_Assemble_Failed return 1 @@ -152,9 +152,9 @@ PACKAGE_Assemble_DEB_Content() { # NOTE: REQUIRED file - ___dest="${_chroot}/share/doc/${PROJECT_SCOPE}/${PROJECT_SKU}/changelog.gz" - I18N_Create "$___dest" - DEB_Create_Changelog "$___dest" "$_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 @@ -162,10 +162,10 @@ PACKAGE_Assemble_DEB_Content() { # NOTE: REQUIRED file - ___dest="${_chroot}/share/doc/${PROJECT_SCOPE}/${PROJECT_SKU}/copyright" - I18N_Create "$___dest" + __dest="${_chroot}/share/doc/${PROJECT_SCOPE}/${PROJECT_SKU}/copyright" + I18N_Create "$__dest" COPYRIGHT_Create \ - "$___dest" \ + "$__dest" \ "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/licenses/deb-copyright" \ "$PROJECT_SKU" \ "$PROJECT_CONTACT_NAME" \ @@ -178,10 +178,10 @@ PACKAGE_Assemble_DEB_Content() { # NOTE: REQUIRED file - ___dest="${_chroot}/share/man/man1/${PROJECT_SCOPE}-${PROJECT_SKU}.1" - I18N_Create "$___dest" + __dest="${_chroot}/share/man/man1/${PROJECT_SCOPE}-${PROJECT_SKU}.1" + I18N_Create "$__dest" MANUAL_Create \ - "$___dest" \ + "$__dest" \ "$PROJECT_SKU" \ "$PROJECT_CONTACT_NAME" \ "$PROJECT_CONTACT_EMAIL" \ @@ -203,12 +203,17 @@ PACKAGE_Assemble_DEB_Content() { # NOTE: OPTIONAL (Comment to turn it off) I18N_Create "${_directory}/source.list" + __url="$PROJECT_STATIC_URL" + if [ $(STRINGS_Is_Empty "$PROJECT_DEB_URL") -ne 0 ]; then + __url="$PROJECT_DEB_URL" + fi + DEB_Create_Source_List \ "$_directory" \ "$PROJECT_GPG_ID" \ - "$PROJECT_STATIC_URL" \ - "$PROJECT_REPREPRO_CODENAME" \ - "$PROJECT_DEBIAN_DISTRIBUTION" \ + "$__url" \ + "$PROJECT_DEB_COMPONENT" \ + "$PROJECT_DEB_DISTRIBUTION" \ "$_gpg_keyring" if [ $? -ne 0 ]; then I18N_Create_Failed @@ -217,20 +222,30 @@ PACKAGE_Assemble_DEB_Content() { # WARNING: THIS REQUIRED FILE MUST BE THE LAST ONE + __arch="$_target_arch" + if [ "$__arch" = "any" ]; then + __arch="all" + fi + + __os="$_target_os" + if [ "$__os" = "any" ]; then + __os="all" + fi + I18N_Create "${_directory}/control/control" DEB_Create_Control \ "$_directory" \ "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}" \ "$_package" \ "$PROJECT_VERSION" \ - "$_target_arch" \ - "$_target_os" \ + "$__arch" \ + "$__os" \ "$PROJECT_CONTACT_NAME" \ "$PROJECT_CONTACT_EMAIL" \ "$PROJECT_CONTACT_WEBSITE" \ "$PROJECT_PITCH" \ - "$PROJECT_DEBIAN_PRIORITY" \ - "$PROJECT_DEBIAN_SECTION" \ + "$PROJECT_DEB_PRIORITY" \ + "$PROJECT_DEB_SECTION" \ "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/ABSTRACTS.txt" if [ $? -ne 0 ]; then I18N_Create_Failed diff --git a/src/.ci/_package-deb_windows-any.ps1 b/src/.ci/_package-deb_windows-any.ps1 index 68542ed4..c21b8255 100644 --- a/src/.ci/_package-deb_windows-any.ps1 +++ b/src/.ci/_package-deb_windows-any.ps1 @@ -65,9 +65,9 @@ function PACKAGE-Assemble-DEB-Content { ## (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/" + $_chroot = "${_directory}/data/usr" + if ($(STRINGS-To-Lowercase "${env:PROJECT_DEB_IS_NATIVE}") -ne "true") { + $_chroot = "${_chroot}/local" } $_gpg_keyring = "${env:PROJECT_SKU}" @@ -77,42 +77,42 @@ 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) { - $___dest = "${_chroot}\lib\${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + $__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}" + $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}" + $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}" + $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}" + $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 @@ -137,11 +137,11 @@ function PACKAGE-Assemble-DEB-Content { return 10 # not applicable } else { # copy main program - $___dest = "${_chroot}\bin\" + $__dest = "${_chroot}\bin\${env:PROJECT_SKU}" - $null = I18N-Assemble "${_target}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-File "${_target}" "${___dest}" + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" if ($___process -ne 0) { $null = I18N-Assemble-Failed return 1 @@ -150,9 +150,9 @@ function PACKAGE-Assemble-DEB-Content { # NOTE: REQUIRED file - $___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}" + $__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 @@ -160,10 +160,10 @@ function PACKAGE-Assemble-DEB-Content { # NOTE: REQUIRED file - $___dest = "${_chroot}\share\doc\${env:PROJECT_SCOPE}\${env:PROJECT_SKU}\copyright" - $null = I18N-Create "${___dest}" + $__dest = "${_chroot}\share\doc\${env:PROJECT_SCOPE}\${env:PROJECT_SKU}\copyright" + $null = I18N-Create "${__dest}" $___process = COPYRIGHT-Create ` - "${___dest}" ` + "${__dest}" ` "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses\deb-copyright" ` "${env:PROJECT_SKU}" ` "${env:PROJECT_CONTACT_NAME}" ` @@ -176,11 +176,11 @@ function PACKAGE-Assemble-DEB-Content { # NOTE: REQUIRED file - $___dest = "${_chroot}\share\man\man1\${env:PROJECT_SCOPE}-${env:PROJECT_SKU}.1" - $null = I18N-Create "${___dest}" + $__dest = "${_chroot}\share\man\man1\${env:PROJECT_SCOPE}-${env:PROJECT_SKU}.1" + $null = I18N-Create "${__dest}" $___process = MANUAL-Create ` - "${___dest}" ` - "${env:PROJECT_DEBIAN_IS_NATIVE}" ` + "${__dest}" ` + "${env:PROJECT_DEB_IS_NATIVE}" ` "${env:PROJECT_SKU}" ` "${env:PROJECT_CONTACT_NAME}" ` "${env:PROJECT_CONTACT_EMAIL}" ` @@ -202,12 +202,17 @@ function PACKAGE-Assemble-DEB-Content { # NOTE: OPTIONAL (Comment to turn it off) $null = I18N-Create "source.list" + $__url = "${env:PROJECT_STATIC_URL}" + if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_URL}") -ne 0) { + $__url = "${env:PROJECT_DEB_URL}" + } + $___process = DEB-Create-Source-List ` "${_directory}" ` "${env:PROJECT_GPG_ID}" ` - "${env:PROJECT_STATIC_URL}" ` - "${env:PROJECT_REPREPRO_CODENAME}" ` - "${env:PROJECT_DEBIAN_DISTRIBUTION}" ` + "${__url}" ` + "${env:PROJECT_DEB_COMPONENT}" ` + "${env:PROJECT_DEB_DISTRIBUTION}" ` "${_gpg_keyring}" if ($___process -ne 0) { $null = I18N-Create-Failed @@ -216,20 +221,31 @@ function PACKAGE-Assemble-DEB-Content { # WARNING: THIS REQUIRED FILE MUST BE THE LAST ONE + $__arch = "${_target_arch}" + if ($__arch -eq "any") { + $__arch = "all" + } + + $__os = "${_target_os}" + if ($__os -eq "any") { + $__os = "all" + } + + $null = I18N-Create "${_directory}\control\control" $___process = DEB-Create-Control ` "${_directory}" ` "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}" ` "${_package}" ` "${env:PROJECT_VERSION}" ` - "${_target_arch}" ` - "${_target_os}" ` + "${__arch}" ` + "${__os}" ` "${env:PROJECT_CONTACT_NAME}" ` "${env:PROJECT_CONTACT_EMAIL}" ` "${env:PROJECT_CONTACT_WEBSITE}" ` "${env:PROJECT_PITCH}" ` - "${env:PROJECT_DEBIAN_PRIORITY}" ` - "${env:PROJECT_DEBIAN_SECTION}" ` + "${env:PROJECT_DEB_PRIORITY}" ` + "${env:PROJECT_DEB_SECTION}" ` "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\ABSTRACTS.txt" if ($___process -ne 0) { $null = I18N-Create-Failed diff --git a/src/.ci/_package-docker_unix-any.sh b/src/.ci/_package-docker_unix-any.sh index cf3e477b..9a183d07 100644 --- a/src/.ci/_package-docker_unix-any.sh +++ b/src/.ci/_package-docker_unix-any.sh @@ -58,13 +58,47 @@ PACKAGE_Assemble_DOCKER_Content() { fi case "$_target_os" in - linux|windows) + any) + _target_image="scratch" + __arch_list="" + ;; + linux) + _target_image="$PROJECT_CONTAINER_BASE_LINUX" + __arch_list="$PROJECT_CONTAINER_BASE_LINUX_ARCH" + ;; + windows) + _target_image="$PROJECT_CONTAINER_BASE_WINDOWS" + __arch_list="$PROJECT_CONTAINER_BASE_WINDOWS_ARCH" ;; *) - return 10 + return 10 # not supported ;; esac + __supported_arch=1 + if [ $(STRINGS_Is_Empty "$__arch_list") -ne 0 ] && + [ ! "$_target_image" = "scratch" ]; then + while [ ! "$__arch_list" = '' ]; do + __arch="${__arch_list%%|*}" + __arch_list="${__arch_list#*|}" + + if [ "$__arch_list" = "$__arch" ]; then + __arch_list="" + fi + + if [ "$_target_arch" = "$__arch" ]; then + __supported_arch=0 + break + fi + done + else + __supported_arch=0 + fi + + if [ $__supported_arch -ne 0 ]; then + return 10 # not supported + fi + # assemble the package FS_Copy_File "$_target" "${_directory}/${PROJECT_SKU}" @@ -80,19 +114,8 @@ PACKAGE_Assemble_DOCKER_Content() { # generate the Dockerfile FS_Write_File "${_directory}/Dockerfile" "\ -# Defining baseline image -" - if [ "$_target_os" = "windows" ]; then - FS_Append_File "${_directory}/Dockerfile" "\ -FROM --platform=${_target_os}/${_target_arch} mcr.microsoft.com/windows/nanoserver:ltsc2022 -" - else - FS_Append_File "${_directory}/Dockerfile" "\ -FROM --platform=${_target_os}/${_target_arch} busybox:latest -" - fi +FROM --platform=${_target_os}/${_target_arch} ${_target_image} - FS_Append_File "${_directory}/Dockerfile" "\ LABEL org.opencontainers.image.title=\"${PROJECT_NAME}\" LABEL org.opencontainers.image.description=\"${PROJECT_PITCH}\" LABEL org.opencontainers.image.authors=\"${PROJECT_CONTACT_NAME} <${PROJECT_CONTACT_EMAIL}>\" @@ -113,21 +136,22 @@ LABEL org.opencontainers.image.source=\"${PROJECT_SOURCE_URL}\" " fi - FS_Append_File "${_directory}/Dockerfile" "\ + FS_Append_File "${_directory}/Dockerfile" " # Defining environment variables ENV ARCH ${_target_arch} ENV OS ${_target_os} ENV PORT 80 # Assemble the file structure -COPY .blank /tmp/.tmpfile -ADD ${PROJECT_SKU} /app/bin/${PROJECT_SKU} +COPY .blank /tmp/.placeholder +ADD --chmod=765 ${PROJECT_SKU} /usr/local/bin/${PROJECT_SKU} # Set network port exposures EXPOSE 80 # Set entry point -ENTRYPOINT [\"/app/bin/${PROJECT_SKU}\"] +ENTRYPOINT ['/usr/local/bin/${PROJECT_SKU}'] +CMD ['help'] " if [ $? -ne 0 ]; then return 1 diff --git a/src/.ci/_package-docker_windows-any.ps1 b/src/.ci/_package-docker_windows-any.ps1 index 9a0b2565..136a81ba 100644 --- a/src/.ci/_package-docker_windows-any.ps1 +++ b/src/.ci/_package-docker_windows-any.ps1 @@ -54,15 +54,40 @@ 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-PDF "${_target}") -eq 0) { + return 10 # not applicable } switch ($_target_os) { - { $_ -in 'linux', 'windows' } { - # accepted + 'any' { + $_target_image = "scratch" + $__arch_list = "" + } 'linux' { + $_target_image = "${env:PROJECT_CONTAINER_BASE_LINUX}" + $__arch_list = "${env:PROJECT_CONTAINER_BASE_LINUX_ARCH}" + } 'windows' { + $_target_image = "${env:PROJECT_CONTAINER_BASE_WINDOWS}" + $__arch_list = "${env:PROJECT_CONTAINER_BASE_WINDOWS_ARCH}" } default { - return 10 + return 10 # not supported }} + $__supported = 1 + if (($(STRINGS-Is-Empty "${__arch_list}") -ne 0) -and ($_target_image -ne "scratch")) { + $__arch_list.Split("|") | ForEach { + if ($_target_arch -eq $_) { + $__supported = 0 + break + } + } + } else { + $__supported = 0 + } + + if ($__supported -ne 0) { + return 10 # not supported + } + # assemble the package $___process = FS-Copy-File "${_target}" "${_directory}\${env:PROJECT_SKU}" @@ -77,23 +102,9 @@ function PACKAGE-Assemble-DOCKER-Content { # generate the Dockerfile - $___process = FS-Write-File "${_directory}\Dockerfile" @" -# Defining baseline image - -"@ - if (${_target_os} == "windows") { - $___process = FS-Append-File "${_directory}\Dockerfile" @" -FROM --platform=${_target_os}/${_target_arch} mcr.microsoft.com/windows/nanoserver:ltsc2022 + $null = FS-Write-File "${_directory}\Dockerfile" @" +FROM --platform=${_target_os}/${_target_arch} ${_target_image} -"@ - } else { - $___process = FS-Append-File "${_directory}\Dockerfile" @" -FROM --platform=${_target_os}/${_target_arch} busybox:latest - -"@ - } - - $___process = FS-Append-File "${_directory}\Dockerfile" @" LABEL org.opencontainers.image.title=`"${env:PROJECT_NAME}`" LABEL org.opencontainers.image.description=`"${env:PROJECT_PITCH}`" LABEL org.opencontainers.image.authors=`"${env:PROJECT_CONTACT_NAME} <${env:PROJECT_CONTACT_EMAIL}>`" @@ -104,34 +115,36 @@ LABEL org.opencontainers.image.licenses=`"${env:PROJECT_LICENSE}`" "@ if ($(STRINGS-Is-Empty "${env:PROJECT_CONTACT_WEBSITE}") -ne 0) { - $___process = FS-Append-File "${_directory}\Dockerfile" @" + $null = FS-Append-File "${_directory}\Dockerfile" @" LABEL org.opencontainers.image.url=`"${env:PROJECT_CONTACT_WEBSITE}`" "@ } if ($(STRINGS-Is-Empty "${env:PROJECT_SOURCE_URL}") -ne 0) { - $___process = FS-Append-File "${_directory}\Dockerfile" @" + $null = FS-Append-File "${_directory}\Dockerfile" @" LABEL org.opencontainers.image.source=`"${env:PROJECT_SOURCE_URL}`" "@ } $___process = FS-Append-File "${_directory}\Dockerfile" @" + # Defining environment variables ENV ARCH ${_target_arch} ENV OS ${_target_os} ENV PORT 80 # Assemble the file structure -COPY .blank /tmp/.tmpfile -ADD ${PROJECT_SKU} /app/bin/${PROJECT_SKU} +COPY .blank /tmp/.placeholder +ADD --chmod 765 ${PROJECT_SKU} /usr/local/bin/${PROJECT_SKU} # Set network port exposures EXPOSE 80 # Set entry point -ENTRYPOINT ["/app/bin/${PROJECT_SKU}"] +ENTRYPOINT ['/usr/local/bin/${PROJECT_SKU}'] +CMD ['help'] "@ if ($___process -ne 0) { diff --git a/src/.ci/_package-homebrew_unix-any.sh b/src/.ci/_package-homebrew_unix-any.sh index 44d55281..d38a0f35 100644 --- a/src/.ci/_package-homebrew_unix-any.sh +++ b/src/.ci/_package-homebrew_unix-any.sh @@ -20,6 +20,10 @@ if [ "$PROJECT_PATH_ROOT" = "" ]; then return 1 fi +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + @@ -31,6 +35,95 @@ PACKAGE_Assemble_HOMEBREW_Content() { _target_arch="$5" + # validate input + if [ "$(STRINGS_Is_Empty "$PROJECT_HOMEBREW_URL")" -eq 0 ]; then + return 10 # disabled explictly + fi + + case "$_target_os" in + any|darwin|linux) + ;; + *) + return 10 # not supported + ;; + esac + + # execute - return 10 # not applicable - should be tech-oriented. + 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 + __dest="${_directory}/lib" + + 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 + elif [ $(FS_Is_Target_A_WASM_JS "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_WASM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Chocolatey "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Homebrew "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Cargo "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_MSI "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then + return 10 # not applicable + else + # copy main program + __dest="${_directory}/bin/$(FS_Get_File "$_target")" + + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + fi + + + # report status + return 0 } diff --git a/src/.ci/_package-homebrew_windows-any.ps1 b/src/.ci/_package-homebrew_windows-any.ps1 index 1b845465..02957af6 100644 --- a/src/.ci/_package-homebrew_windows-any.ps1 +++ b/src/.ci/_package-homebrew_windows-any.ps1 @@ -19,6 +19,10 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { exit 1 } +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + @@ -32,6 +36,92 @@ function PACKAGE-Assemble-HOMEBREW-Content { ) - # execute - return 10 # not applicable - should be tech-oriented. + # validate project + if ($(STRINGS-Is-Empty "${env:PROJECT_HOMEBREW_URL}") -eq 0) { + return 10 # disabled explictly + } + + switch ("${_target_os}") { + { $_ -in "any", "darwin", "linux" } { + # accepted + } default { + return 10 # not supported + }} + + 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) { + $__dest = "${_directory}\lib" + + 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 + } + } + } elseif ($(FS-Is-Target-A-WASM-JS "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-WASM "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Chocolatey "${_target}") -eq 0) { + 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) { + return 10 # not applicable + } else { + # copy main program + $__dest = "${_directory}\bin\$(FS-Get-File "${_target}")" + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # report status + return 0 } diff --git a/src/.ci/_package-ipk_unix-any.sh b/src/.ci/_package-ipk_unix-any.sh index 42937c68..26189ae2 100644 --- a/src/.ci/_package-ipk_unix-any.sh +++ b/src/.ci/_package-ipk_unix-any.sh @@ -53,8 +53,8 @@ PACKAGE_Assemble_IPK_Content() { ## (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="${_directory}/data/usr" + if [ ! "$(STRINGS_To_Lowercase "$PROJECT_DEB_IS_NATIVE")" = "true" ]; then _chroot="${_chroot}/local" fi @@ -65,42 +65,42 @@ 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 - ___dest="${_chroot}/lib/${PROJECT_SCOPE}/${PROJECT_SKU}" + __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" + 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" + 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" + 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" + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" if [ $? -ne 0 ]; then I18N_Assemble_Failed return 1 @@ -125,11 +125,14 @@ PACKAGE_Assemble_IPK_Content() { return 10 # not applicable else # copy main program - ___dest="${_chroot}/bin/" + __dest="${_chroot}/bin/${PROJECT_SKU}" + if [ "$_target_os" = "windows" ]; then + __dest="${__dest}.exe" + fi - I18N_Assemble "$_target" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_File "$_target" "$___dest" + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" if [ $? -ne 0 ]; then I18N_Assemble_Failed return 1 @@ -150,8 +153,8 @@ PACKAGE_Assemble_IPK_Content() { "$PROJECT_CONTACT_EMAIL" \ "$PROJECT_CONTACT_WEBSITE" \ "$PROJECT_PITCH" \ - "$PROJECT_DEBIAN_PRIORITY" \ - "$PROJECT_DEBIAN_SECTION" \ + "$PROJECT_DEB_PRIORITY" \ + "$PROJECT_DEB_SECTION" \ "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/ABSTRACTS.txt" if [ $? -ne 0 ]; then I18N_Create_Failed diff --git a/src/.ci/_package-ipk_windows-any.ps1 b/src/.ci/_package-ipk_windows-any.ps1 index 31cbc5b9..88b83726 100644 --- a/src/.ci/_package-ipk_windows-any.ps1 +++ b/src/.ci/_package-ipk_windows-any.ps1 @@ -53,9 +53,9 @@ function PACKAGE-Assemble-IPK-Content { ## (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/" + $_chroot = "${_directory}/data/usr" + if ($(STRINGS-To-Lowercase "${env:PROJECT_DEB_IS_NATIVE}") -ne "true") { + $_chroot = "${_chroot}/local" } $_gpg_keyring = "${env:PROJECT_SKU}" @@ -65,42 +65,42 @@ 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) { - $___dest = "${_chroot}\lib\${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + $__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}" + $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}" + $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}" + $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}" + $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 @@ -127,11 +127,14 @@ function PACKAGE-Assemble-IPK-Content { return 10 # not applicable } else { # copy main program - $___dest = "${_chroot}\bin\" + $__dest = "${_chroot}\bin\${env:PROJECT_SKU}" + if ($_target_os -eq "windows") { + $__dest = "${__dest}.exe" + } - $null = I18N-Assemble "${_target}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-File "${_target}" "${___dest}" + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" if ($___process -ne 0) { $null = I18N-Assemble-Failed return 1 @@ -152,8 +155,8 @@ function PACKAGE-Assemble-IPK-Content { "${env:PROJECT_CONTACT_EMAIL}" ` "${env:PROJECT_CONTACT_WEBSITE}" ` "${env:PROJECT_PITCH}" ` - "${env:PROJECT_DEBIAN_PRIORITY}" ` - "${env:PROJECT_DEBIAN_SECTION}" ` + "${env:PROJECT_DEB_PRIORITY}" ` + "${env:PROJECT_DEB_SECTION}" ` "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\ABSTRACTS.txt" if ($___process -ne 0) { $null = I18N-Create-Failed diff --git a/src/.ci/_package-lib_unix-any.sh b/src/.ci/_package-lib_unix-any.sh index c083d017..3e2324be 100644 --- a/src/.ci/_package-lib_unix-any.sh +++ b/src/.ci/_package-lib_unix-any.sh @@ -43,8 +43,13 @@ PACKAGE_Assemble_LIB_Content() { # execute - ## copy over known archived files + _workspace="packagers-lib-$(FS_Get_File "$_target")" + _workspace="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/${_workspace}" + FS_Remove_Silently "$_workspace" + + __dest="${_workspace}/lib" if [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then + # copy over - do not further modify its content anymore __dest="lib${PROJECT_SKU}-NPM_${PROJECT_VERSION}_js-js.tgz" __dest="${_directory}/${__dest}" I18N_Copy "$_target" "$__dest" @@ -56,67 +61,111 @@ PACKAGE_Assemble_LIB_Content() { 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" + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_GZ "$__dest" "$_target" 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" + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_XZ "$__dest" "$_target" 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" + # 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 + # assumed it is a standalone library file + 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 - - 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 + + # sanity check before proceeding + FS_Is_Directory_Empty "$__dest" + if [ $? -eq 0 ]; then + I18N_Assemble_Failed return 1 fi + + # copy README.md __source="${PROJECT_PATH_ROOT}/${PROJECT_README}" - I18N_Copy "$__source" "$__workspace" - FS_Copy_File "$__source" "$__workspace" + __dest="${_workspace}/${PROJECT_README}" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" if [ $? -ne 0 ]; then - I18N_Copy_Failed + I18N_Assemble_Failed return 1 fi - __source="${PROJECT_PATH_ROOT}/${PROJECT_LICENSE_FILE}" - I18N_Copy "$__source" "$__workspace" - FS_Copy_File "$__source" "$__workspace" + + # copy user guide files + for __source in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/USER-GUIDES"*.pdf; do + FS_Is_Target_Exist "$__source" + if [ $? -ne 0 ]; then + continue + fi + + __dest="${_workspace}/$(FS_Get_File "$__source")" + I18N_Copy "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + done + + + # copy license files + for __source in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/licenses/LICENSE"*.pdf; do + FS_Is_Target_Exist "$__source" + if [ $? -ne 0 ]; then + continue + fi + + __dest="${_workspace}/$(FS_Get_File "$__source")" + I18N_Copy "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + done + + + # assemble icon.png + __source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/icons/icon-128x128.png" + __dest="${_workspace}/icon.png" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" if [ $? -ne 0 ]; then - I18N_Copy_Failed + I18N_Assemble_Failed return 1 fi - __current_path="$PWD" && cd "$__workspace" + + # begin packaging + __current_path="$PWD" && cd "$_workspace" + ## package tar.xz __dest="lib${PROJECT_SKU}_${PROJECT_VERSION}_${_target_os}-${_target_arch}.tar.xz" I18N_Create_Package "$__dest" @@ -140,14 +189,14 @@ PACKAGE_Assemble_LIB_Content() { fi ## package nupkg - __dest="./Package.nuspec" __acceptance="false" if [ $(STRINGS_To_Lowercase "$PROJECT_LICENSE_ACCEPTANCE_REQUIRED") = "true" ]; then __acceptance="true" fi + __dest="lib${PROJECT_SKU}.nuspec" I18N_Create "$__dest" - FS_Write_File "$__dest" "\ + FS_Write_File "./${__dest}" "\ @@ -161,7 +210,13 @@ PACKAGE_Assemble_LIB_Content() { ${PROJECT_LICENSE} ${__acceptance} ${PROJECT_README} + icon.png + + + + + " if [ $? -ne 0 ]; then diff --git a/src/.ci/_package-lib_windows-any.ps1 b/src/.ci/_package-lib_windows-any.ps1 index 7b65e78b..9cdd1172 100644 --- a/src/.ci/_package-lib_windows-any.ps1 +++ b/src/.ci/_package-lib_windows-any.ps1 @@ -44,8 +44,13 @@ function PACKAGE-Assemble-LIB-Content { # execute - ## copy over known archived files + $_workspace = "packagers-lib-lib${env:PROJECT_SKU}_${_target_os}-${_target_arch}" + $_workspace = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\${_workspace}" + $null = FS-Remove-Silently "${_workspace}" + + $__dest = "${_workspace}\lib" if ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { + # copy over - do not modify anymore $__dest = "lib${env:PROJECT_SKU}-NPM_${env:PROJECT_VERSION}_js-js.tgz" $__dest = "${_directory}\${__dest}" $null = I18N-Copy "${_target}" "${__dest}" @@ -57,69 +62,106 @@ function PACKAGE-Assemble-LIB-Content { 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}" + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-GZ "${__dest}" "${_target}" if ($___process -ne 0) { - $null = I18N-Copy-Failed + $null = I18N-Assemble-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}" + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-XZ "${__dest}" "${_target}" if ($___process -ne 0) { - $null = I18N-Copy-Failed + $null = I18N-Assemble-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}" + # 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 { + # assumed it is a standalone library file + $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 } - - 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 + # sanity check before proceeding + $___process = FS-Is-Directory-Empty "${__dest}" + if ($___process -eq 0) { + $null = I18N-Assemble-Failed return 1 } + + # copy README.md $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_README}" - $null = I18N-Copy "${__source}" "${__workspace}" - $___process = FS-Copy-File "${__source}" "${__workspace}" + $__dest = "${_workspace}\${env:PROJECT_README}" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" if ($___process -ne 0) { - $null = I18N-Copy-Failed + $null = I18N-Assemble-Failed return 1 } - $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_LICENSE_FILE}" - $null = I18N-Copy "${__source}" "${__workspace}" - $___process = FS-Copy-File "${__source}" "${__workspace}" + + # copy user guide + Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs" ` + | Where-Object { ($_.Name -like "USER-GUIDES*.pdf") } ` + | ForEach-Object { $__source = $_.FullName + $__dest = "${_workspace}\$(FS-Get-File "${__source}")" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # copy license file + Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses" ` + | Where-Object { ($_.Name -like "LICENSE*.pdf") } ` + | ForEach-Object { $__source = $_.FullName + $__dest = "${_workspace}\$(FS-Get-File "${__source}")" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # assemble icon.png + $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\icons\icon-128x128.png" + $__dest = "${_workspace}\icon.png" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" if ($___process -ne 0) { - $null = I18N-Copy-Failed + $null = I18N-Assemble-Failed return 1 } + + # begin packaging $__current_path = Get-Location - $null = Set-Location -Path "${__workspace}" + $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}" @@ -145,28 +187,34 @@ function PACKAGE-Assemble-LIB-Content { } ## package nupkg - $__dest = ".\Package.nuspec" $__acceptance = "false" if ($(STRINGS-To-Lowercase "${env:PROJECT_LICENSE_ACCEPTANCE_REQUIRED}") -eq "true") { $__acceptance = "true" } + $__dest = "lib${env:PROJECT_SKU}.nuspec" $null = I18N-Create "${__dest}" + $__dest = ".\${__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} + ${env:PROJECT_SKU} + ${env:PROJECT_VERSION} + ${env:PROJECT_CONTACT_NAME} + ${env:PROJECT_CONTACT_NAME} + ${env:PROJECT_SOURCE_URL} + ${env:PROJECT_NAME} + ${env:PROJECT_PITCH} + ${env:PROJECT_LICENSE} ${__acceptance} - ${PROJECT_README} + ${env:PROJECT_README} + + + + + "@ @@ -177,7 +225,6 @@ function PACKAGE-Assemble-LIB-Content { return 1 } - $__dest = "lib${env:PROJECT_SKU}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}.nupkg" $null = I18N-Create-Package "${__dest}" $__dest = "${_directory}\${__dest}" diff --git a/src/.ci/_package-pdf_unix-any.sh b/src/.ci/_package-pdf_unix-any.sh index 34b1fe69..a9d87354 100644 --- a/src/.ci/_package-pdf_unix-any.sh +++ b/src/.ci/_package-pdf_unix-any.sh @@ -40,9 +40,9 @@ PACKAGE_Assemble_PDF_Content() { # execute - ___dest="${_directory}/$(FS_Get_File "$_target")" - I18N_Copy "$_target" "$___dest" - FS_Copy_File "$_target" "$___dest" + __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 561c81cb..e769fe54 100644 --- a/src/.ci/_package-pdf_windows-any.ps1 +++ b/src/.ci/_package-pdf_windows-any.ps1 @@ -41,9 +41,9 @@ function PACKAGE-Assemble-PDF-Content { # execute - $___dest = "${_directory}\$(FS-Get-File "${_target}")" - $null = I18N-Copy "${_target}" "${___dest}" - $___process = FS-Copy-File "${_target}" "${___dest}" + $__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 ab839634..14c68d3e 100644 --- a/src/.ci/_package-rpm_unix-any.sh +++ b/src/.ci/_package-rpm_unix-any.sh @@ -54,7 +54,7 @@ PACKAGE_Assemble_RPM_Content() { ## whenever possible for avoiding conflicts with your OS native ## system packages. _chroot="usr" - if [ ! "$(STRINGS_To_Lowercase "$PROJECT_DEBIAN_IS_NATIVE")" = "true" ]; then + if [ ! "$(STRINGS_To_Lowercase "$PROJECT_RPM_IS_NATIVE")" = "true" ]; then _chroot="${_chroot}/local" fi @@ -68,76 +68,76 @@ PACKAGE_Assemble_RPM_Content() { 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}" + __source="${PROJECT_SCOPE}/${PROJECT_SKU}" + __dest="${_directory}/BUILD/${__source}" + __target="${_chroot}/lib" - I18N_Assemble "$_target" "$___dest" - FS_Make_Directory "$___dest" - TAR_Extract_GZ "$___dest" "$_target" + 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" + 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}" + __source="${PROJECT_SCOPE}/${PROJECT_SKU}" + __dest="${_directory}/BUILD/${__source}" + __target="${_chroot}/lib" - I18N_Assemble "$_target" "$___dest" - FS_Make_Directory "$___dest" - TAR_Extract_XZ "$___dest" "$_target" + 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" + 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}" + __source="${PROJECT_SCOPE}/${PROJECT_SKU}" + __dest="${_directory}/BUILD/${__source}" + __target="${_chroot}/lib" - I18N_Assemble "$_target" "$___dest" - FS_Make_Directory "$___dest" - ZIP_Extract "$___dest" "$_target" + 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" + 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}" + __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" + 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" + RPM_Register "$_directory" "$__source" "$__target" if [ $? -ne 0 ]; then I18N_Assemble_Failed return 1 @@ -162,19 +162,19 @@ PACKAGE_Assemble_RPM_Content() { return 10 # not applicable else # copy main program - ___source="$(FS_Get_File "$_target")" - ___dest="${_directory}/BUILD/${___source}" - ___target="${_chroot}/bin/${___source}" + __source="$(FS_Get_File "$_target")" + __dest="${_directory}/BUILD/${__source}" + __target="${_chroot}/bin/${PROJECT_SKU}" - I18N_Assemble "$_target" "$___dest" - FS_Make_Housing_Directory "$___dest" - FS_Copy_File "$_target" "$___dest" + 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" + RPM_Register "$_directory" "$__source" "$__target" if [ $? -ne 0 ]; then I18N_Create_Failed return 1 @@ -185,12 +185,12 @@ PACKAGE_Assemble_RPM_Content() { # NOTE: REQUIRED file - ___source="copyright" - ___dest="${_directory}/BUILD/${___source}" - ___target="${_chroot}/share/doc/${PROJECT_SCOPE}/${PROJECT_SKU}/${___source}" - I18N_Create "$___source" + __source="copyright" + __dest="${_directory}/BUILD/${__source}" + __target="${_chroot}/share/doc/${PROJECT_SCOPE}/${PROJECT_SKU}/${__source}" + I18N_Create "$__source" COPYRIGHT_Create \ - "$___dest" \ + "$__dest" \ "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/licenses/deb-copyright" \ "$PROJECT_SKU" \ "$PROJECT_CONTACT_NAME" \ @@ -201,7 +201,7 @@ PACKAGE_Assemble_RPM_Content() { return 1 fi - RPM_Register "$_directory" "$___source" "$___target" + RPM_Register "$_directory" "$__source" "$__target" if [ $? -ne 0 ]; then I18N_Create_Failed return 1 @@ -209,12 +209,13 @@ PACKAGE_Assemble_RPM_Content() { # NOTE: REQUIRED file - ___source="${PROJECT_SCOPE}-${PROJECT_SKU}.1" - ___dest="${_directory}/BUILD/${___source}" - ___target="${_chroot}/share/man/man1/${___source}" - I18N_Create "$___source" + __source="${PROJECT_SCOPE}-${PROJECT_SKU}.1" + __dest="${_directory}/BUILD/${__source}" + __source="${__source}.gz" + __target="${_chroot}/share/man/man1/${__source}" + I18N_Create "$__source" MANUAL_Create \ - "$___dest" \ + "$__dest" \ "$PROJECT_SKU" \ "$PROJECT_CONTACT_NAME" \ "$PROJECT_CONTACT_EMAIL" \ @@ -224,7 +225,7 @@ PACKAGE_Assemble_RPM_Content() { return 1 fi - RPM_Register "$_directory" "$___source" "$___target" + RPM_Register "$_directory" "$__source" "$__target" if [ $? -ne 0 ]; then I18N_Create_Failed return 1 @@ -233,12 +234,25 @@ PACKAGE_Assemble_RPM_Content() { # NOTE: OPTIONAL (Comment to turn it off) I18N_Create "source.repo" + ___metalink="" + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_FLAT_MODE") -ne 0 ]; then + # flat mode enabled + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_METALINK") -eq 0 ]; then + I18N_Create_Failed + return 1 + fi + + ___metalink="${PROJECT_RPM_URL}/${PROJECT_RPM_METALINK}" + fi + RPM_Create_Source_Repo \ - "$PROJECT_SIMULATE_RELEASE_REPO" \ + "$PROJECT_SIMULATE_RUN" \ "$_directory" \ "$PROJECT_GPG_ID" \ - "$PROJECT_STATIC_URL" \ + "$PROJECT_RPM_URL" \ + "$___metalink" \ "$PROJECT_NAME" \ + "$PROJECT_SCOPE" \ "$_gpg_keyring" if [ $? -ne 0 ]; then I18N_Create_Failed diff --git a/src/.ci/_package-rpm_windows-any.ps1 b/src/.ci/_package-rpm_windows-any.ps1 index ebeceffa..30a7a59a 100644 --- a/src/.ci/_package-rpm_windows-any.ps1 +++ b/src/.ci/_package-rpm_windows-any.ps1 @@ -54,7 +54,7 @@ function PACKAGE-Assemble-RPM-Content { ## whenever possible for avoiding conflicts with your OS native ## system packages. $_chroot = "usr" - if ("$(STRINGS-To-Lowercase "$PROJECT_DEBIAN_IS_NATIVE")" -eq "true") { + if ("$(STRINGS-To-Lowercase "$PROJECT_RPM_IS_NATIVE")" -eq "true") { $_chroot = "${_chroot}/local" } @@ -68,13 +68,13 @@ function PACKAGE-Assemble-RPM-Content { 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}" + $__source = "${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + $__dest = "${_directory}\BUILD\${__source}" + $__target = "${_chroot}\lib" - $null = I18N-Assemble "${_target}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = TAR-Extract-GZ "${___dest}" "${_target}" + $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 @@ -82,8 +82,8 @@ function PACKAGE-Assemble-RPM-Content { $___process = RPM-Register ` "${_directory}" ` - "${___source}" ` - "${___target}" ` + "${__source}" ` + "${__target}" ` "true" if ($___process -ne 0) { $null = I18N-Assemble-Failed @@ -91,13 +91,13 @@ function PACKAGE-Assemble-RPM-Content { } } 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}" + $__source = "${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + $__dest = "${_directory}\BUILD\${__source}" + $__target = "${_chroot}\lib" - $null = I18N-Assemble "${_target}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = TAR-Extract-XZ "${___dest}" "${_target}" + $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 @@ -105,8 +105,8 @@ function PACKAGE-Assemble-RPM-Content { $___process = RPM-Register ` "${_directory}" ` - "${___source}" ` - "${___target}" ` + "${__source}" ` + "${__target}" ` "true" if ($___process -ne 0) { $null = I18N-Assemble-Failed @@ -114,13 +114,13 @@ function PACKAGE-Assemble-RPM-Content { } } 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}" + $__source = "${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + $__dest = "${_directory}\BUILD\${__source}" + $__target = "${_chroot}\lib" - $null = I18N-Assemble "${_target}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = ZIP-Extract "${___dest}" "${_target}" + $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 @@ -128,8 +128,8 @@ function PACKAGE-Assemble-RPM-Content { $___process = RPM-Register ` "${_directory}" ` - "${___source}" ` - "${___target}" ` + "${__source}" ` + "${__target}" ` "true" if ($___process -ne 0) { $null = I18N-Assemble-Failed @@ -137,19 +137,19 @@ function PACKAGE-Assemble-RPM-Content { } } else { # copy library file - $___source = "$(FS-Get-File "${_target}")" - $___dest = "${_directory}\BUILD\${___source}" - $___target = "${_chroot}\lib\${___source}" + $__source = "$(FS-Get-File "${_target}")" + $___dest = "${_directory}\BUILD\${__source}" + $__target = "${_chroot}\lib" - $null = I18N-Assemble "${_target}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-File "${_target}" "${___dest}" + $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}" + $___process = RPM-Register "${_directory}" "${__source}" "${__target}" if ($___process -ne 0) { $null = I18N-Assemble-Failed return 1 @@ -174,19 +174,19 @@ function PACKAGE-Assemble-RPM-Content { return 10 # not applicable } else { # copy main program - $___source = "$(FS-Get-File "${_target}")" - $___dest = "${_directory}\BUILD\${___source}" - $___target = "${_chroot}\lib\${___source}" + $__source = "$(FS-Get-File "${_target}")" + $__dest = "${_directory}\BUILD\${__source}" + $__target = "${_chroot}\bin\${env:PROJECT_SKU}" - $null = I18N-Assemble "${_target}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-File "${_target}" "${___dest}" + $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}" + $___process = RPM-Register "${_directory}" "${__source}" "${__target}" if ($___process -ne 0) { $null = I18N-Assemble-Failed return 1 @@ -197,12 +197,12 @@ function PACKAGE-Assemble-RPM-Content { # NOTE: REQUIRED file - $___source = "copyright" - $___dest = "${_directory}/BUILD/${___source}" - $___target = "${_chroot}/share/doc/${env:PROJECT_SCOPE}/${env:PROJECT_SKU}/${___source}" + $__source = "copyright" + $__dest = "${_directory}/BUILD/${__source}" + $__target = "${_chroot}/share/doc/${env:PROJECT_SCOPE}/${env:PROJECT_SKU}/${__source}" $null = I18N-Create "${___source}" $___process = COPYRIGHT-Create ` - "${___dest}" ` + "${__dest}" ` "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses\deb-copyright" ` "${env:PROJECT_SKU}" ` "${env:PROJECT_CONTACT_NAME}" ` @@ -213,7 +213,7 @@ function PACKAGE-Assemble-RPM-Content { return 1 } - $___process = RPM-Register "${_directory}" "${___source}" "${___target}" + $___process = RPM-Register "${_directory}" "${__source}" "${__target}" if ($___process -ne 0) { $null = I18N-Create-Failed return 1 @@ -221,12 +221,13 @@ function PACKAGE-Assemble-RPM-Content { # NOTE: REQUIRED file - $___source = "${env:PROJECT_SCOPE}-${env:PROJECT_SKU}.1" - $___dest = "${_directory}/BUILD/${___source}" - $___target = "${_chroot}/share/man/man1/${___source}" - $null = I18N-Create "${___source}" + $__source = "${env:PROJECT_SCOPE}-${env:PROJECT_SKU}.1" + $__dest = "${_directory}/BUILD/${__source}" + $__source = "${__source}.gz" + $__target = "${_chroot}/share/man/man1/${__source}" + $null = I18N-Create "${__source}" $___process = MANUAL-Create ` - "${___dest}" ` + "${__dest}" ` "${env:PROJECT_SKU}" ` "${env:PROJECT_CONTACT_NAME}" ` "${env:PROJECT_CONTACT_EMAIL}" ` @@ -236,7 +237,7 @@ function PACKAGE-Assemble-RPM-Content { return 1 } - $___process = RPM-Register "${_directory}" "${___source}" "${___target}" + $___process = RPM-Register "${_directory}" "${__source}" "${__target}" if ($___process -ne 0) { $null = I18N-Create-Failed return 1 @@ -245,13 +246,25 @@ function PACKAGE-Assemble-RPM-Content { # NOTE: OPTIONAL (Comment to turn it off) $null = I18N-Create "source.repo" + $___metalink = "" + if ($(STRINGS-IS-Empty "${env:PROJECT_RPM_FLAT_MODE}") -ne 0) { + # flat mode enabled + if ($(STRINGS-IS-Empty "${env:PROJECT_RPM_METALINK}") -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + $___metalink = "${env:PROJECT_RPM_URL}\${env:PROJECT_RPM_METALINK}" + } + $___process = RPM-Create-Source-Repo ` - "${env:PROJECT_SIMULATE_RELEASE_REPO}" ` + "${env:PROJECT_SIMULATE_RUN}" ` "${_directory}" ` "${env:PROJECT_GPG_ID}" ` - "${env:PROJECT_STATIC_URL}" ` - "${env:PROJECT_REPREPRO_CODENAME}" ` - "${env:PROJECT_DEBIAN_DISTRIBUTION}" ` + "${env:PROJECT_RPM_URL}" ` + "${___metalink}" ` + "${env:PROJECT_NAME}" ` + "${env:PROJECT_SCOPE}" ` "${_gpg_keyring}" if ($___process -ne 0) { $null = I18N-Create-Failed diff --git a/src/.ci/build_unix-any.sh b/src/.ci/build_unix-any.sh index 51ed6fd0..4aaa765b 100644 --- a/src/.ci/build_unix-any.sh +++ b/src/.ci/build_unix-any.sh @@ -21,6 +21,7 @@ if [ "$PROJECT_PATH_ROOT" = "" ]; then fi . "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/time.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" . "${LIBS_AUTOMATACI}/services/compilers/changelog.sh" @@ -39,9 +40,9 @@ fi # execute -__file="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/changelog" +__directory="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/changelog" I18N_Create "${PROJECT_VERSION} DATA CHANGELOG" -CHANGELOG_Build_Data_Entry "$__file" +CHANGELOG_Build_Data_Entry "$__directory" if [ $? -ne 0 ]; then I18N_Create_Failed return 1 @@ -50,14 +51,14 @@ fi I18N_Create "${PROJECT_VERSION} DEB CHANGELOG" CHANGELOG_Build_DEB_Entry \ - "$__file" \ + "$__directory" \ "$PROJECT_VERSION" \ "$PROJECT_SKU" \ - "$PROJECT_DEBIAN_DISTRIBUTION" \ - "$PROJECT_DEBIAN_URGENCY" \ + "$PROJECT_DEB_DISTRIBUTION" \ + "$PROJECT_DEB_URGENCY" \ "$PROJECT_CONTACT_NAME" \ "$PROJECT_CONTACT_EMAIL" \ - "$(date -R)" + "$(TIME_Format_Datetime_RFC5322 "$(TIME_Now)")" if [ $? -ne 0 ]; then I18N_Create_Failed return 1 diff --git a/src/.ci/build_windows-any.ps1 b/src/.ci/build_windows-any.ps1 index da75c4cf..cc4cdcd3 100644 --- a/src/.ci/build_windows-any.ps1 +++ b/src/.ci/build_windows-any.ps1 @@ -20,6 +20,7 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { } . "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\time.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" . "${env:LIBS_AUTOMATACI}\services\compilers\changelog.ps1" @@ -38,9 +39,9 @@ if ($___process -ne 0) { # execute -$__file = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\changelog" +$__directory = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\changelog" $null = I18N-Create "${env:PROJECT_VERSION} DATA CHANGELOG" -$___process = CHANGELOG-Build-DATA-Entry $__file +$___process = CHANGELOG-Build-DATA-Entry $__directory if ($___process -ne 0) { $null = I18N-Create-Failed return 1 @@ -49,14 +50,14 @@ if ($___process -ne 0) { $null = I18N-Create "${env:PROJECT_VERSION} DEB CHANGELOG" $___process = CHANGELOG-Build-DEB-Entry ` - "${__file}" ` + "${__directory}" ` "$env:PROJECT_VERSION" ` "$env:PROJECT_SKU" ` - "$env:PROJECT_DEBIAN_DISTRIBUTION" ` - "$env:PROJECT_DEBIAN_URGENCY" ` + "$env:PROJECT_DEB_DISTRIBUTION" ` + "$env:PROJECT_DEB_URGENCY" ` "$env:PROJECT_CONTACT_NAME" ` "$env:PROJECT_CONTACT_EMAIL" ` - (Get-Date -Format 'R') + "$(TIME-Format-Datetime-RFC5322 "$(TIME-Now)")" if ($___process -ne 0) { $null = I18N-Create-Failed return 1 diff --git a/srcC/.ci/_package-archive_unix-any.sh b/srcC/.ci/_package-archive_unix-any.sh deleted file mode 100644 index fd4a7a7a..00000000 --- a/srcC/.ci/_package-archive_unix-any.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/sh -# 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 -# 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. - - - - -# initialize -if [ "$PROJECT_PATH_ROOT" = "" ]; then - >&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" - - - - -PACKAGE_Assemble_ARCHIVE_Content() { - _target="$1" - _directory="$2" - _target_name="$3" - _target_os="$4" - _target_arch="$5" - - - # package based on target's nature - if [ $(FS_Is_Target_A_Source "$_target") -eq 0 ]; then - _target="${PROJECT_PATH_ROOT}/${PROJECT_C}/" - I18N_Assemble "$_target" "$_directory" - FS_Copy_All "$_target" "$_directory" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - FS_Remove_Silently "${_directory}/.ci" - elif [ $(FS_Is_Target_A_Docs "$_target") -eq 0 ]; then - ___source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_DOCS}/" - FS_Is_Directory "$___source" - if [ $? -ne 0 ]; then - return 10 # not applicable - fi - - I18N_Assemble "$___source" "$_directory" - FS_Copy_All "${___source}/" "$_directory" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - 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 - 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 - I18N_Assemble "$_target" "$_directory" - FS_Copy_File "$_target" "$_directory" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - ___source="$(FS_Extension_Remove "$_target" ".wasm").js" - FS_Is_File "$___source" - if [ $? -eq 0 ]; then - I18N_Assemble "$___source" "$_directory" - FS_Copy_File "$___source" "$_directory" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - fi - elif [ $(FS_Is_Target_A_Chocolatey "$_target") -eq 0 ]; then - return 10 # not applicable - elif [ $(FS_Is_Target_A_Homebrew "$_target") -eq 0 ]; then - return 10 # not applicable - elif [ $(FS_Is_Target_A_Cargo "$_target") -eq 0 ]; then - return 10 # not applicable - elif [ $(FS_Is_Target_A_MSI "$_target") -eq 0 ]; then - return 10 # not applicable - elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then - return 10 # not applicable - else - I18N_Assemble "$_target" "$_directory" - FS_Copy_File "$_target" "$_directory" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - fi - - - # copy user guide - ___source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/USER-GUIDES-EN.pdf" - I18N_Assemble "$___source" "$_directory" - FS_Copy_File "$___source" "${_directory}/." - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - - # copy license file - ___source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/licenses/LICENSE-EN.pdf" - I18N_Assemble "$___source" "$_directory" - FS_Copy_File "$___source" "${_directory}/." - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - - # report status - return 0 -} diff --git a/srcC/.ci/_package-archive_windows-any.ps1 b/srcC/.ci/_package-archive_windows-any.ps1 deleted file mode 100644 index a2593046..00000000 --- a/srcC/.ci/_package-archive_windows-any.ps1 +++ /dev/null @@ -1,131 +0,0 @@ -# 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 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. - - - - -# initialize -if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" - return 1 -} - -. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" -. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" - - - - -function PACKAGE-Assemble-ARCHIVE-Content { - param( - [string]$_target, - [string]$_directory, - [string]$_target_name, - [string]$_target_os, - [string]$_target_arch - ) - - - # package based on target's nature - if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { - $_target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_C}\" - $null = I18N-Assemble "${_target}" "${_directory}" - $___process = FS-Copy-All "${_target}" "${_directory}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $null = FS-Remove-Silently "${_directory}\.ci" - } elseif ($(FS-Is-Target-A-Docs "${_target}") -eq 0) { - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_DOCS}\" - $___process = FS-Is-Directory "${___source}" - if ($___process -ne 0) { - return 10 # not applicable - } - - $null = I18N-Assemble "${___source}" "${_directory}" - $___process = FS-Copy-All "${___source}" "${_directory}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { - I18N-Assemble "${_target}" "${_directory}" - $___process = FS-Copy-File "${_target}" "${_directory}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - } 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) { - $null = I18N-Assemble "${_target}" "${_directory}" - $___process = FS-Copy-File "${_target}" "${_directory}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___source = "$(FS-Extension-Remove "${_target}" ".wasm").js" - $___process = FS-Is-File "${___source}" - if ($___process -eq 0) { - $null = I18N-Assemble "${___source}" "${_directory}" - $___process = Fs-Copy-File "${___source}" "${_directory}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - } - } elseif ($(FS-Is-Target-A-Chocolatey "${_target}") -eq 0) { - 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) { - return 10 # not applicable - } else { - $null = I18N-Assemble "${_target}" "${_directory}" - $___process = FS-Copy-File "${_target}" "${_directory}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - } - - - # copy user guide - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\USER-GUIDES-EN.pdf" - $null = I18N-Assemble "${___source}" "${_directory}" - $___process = FS-Copy-File "${___source}" "${_directory}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - - # copy license file - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses\LICENSE-EN.pdf" - $null = I18N-Assemble "${___source}" "${_directory}" - $___process = FS-Copy-File "${___source}" "${_directory}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - - # report status - return 0 -} diff --git a/srcC/.ci/_package-chocolatey_unix-any.sh b/srcC/.ci/_package-chocolatey_unix-any.sh deleted file mode 100644 index e1cdeeea..00000000 --- a/srcC/.ci/_package-chocolatey_unix-any.sh +++ /dev/null @@ -1,260 +0,0 @@ -#!/bin/sh -# 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 -# 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. - - - - -# initialize -if [ "$PROJECT_PATH_ROOT" = "" ]; then - >&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" - - - - -PACKAGE_Assemble_CHOCOLATEY_Content() { - _target="$1" - _directory="$2" - _target_name="$3" - _target_os="$4" - _target_arch="$5" - - - # validate project - if [ $(FS_Is_Target_A_Chocolatey "$_target") -ne 0 ]; then - return 10 # not applicable - fi - - - # assemble the package - ___source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/" - ___dest="${_directory}/Data/${PROJECT_PATH_SOURCE}" - I18N_Assemble "$___source" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_All "$___source" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - ___source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/.ci/" - ___dest="${_directory}/Data/${PROJECT_PATH_SOURCE}/.ci" - I18N_Assemble "$___source" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_All "$___source" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - ___source="${PROJECT_PATH_ROOT}/${PROJECT_C}/" - ___dest="${_directory}/Data/${PROJECT_C}" - I18N_Assemble "$___source" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_All "$___source" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - ___source="${PROJECT_PATH_ROOT}/${PROJECT_C}/.ci/" - ___dest="${_directory}/Data/${PROJECT_C}/.ci" - I18N_Assemble "$___source" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_All "$___source" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - ___source="${PROJECT_PATH_ROOT}/automataCI/" - ___dest="${_directory}/Data/automataCI" - I18N_Assemble "$___source" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_All "$___source" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - ___source="${PROJECT_PATH_ROOT}/CONFIG.toml" - ___dest="${_directory}/Data" - I18N_Assemble "$___source" "$___dest" - FS_Copy_File "$___source" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - ___source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/icons/icon-128x128.png" - ___dest="${_directory}/icon.png" - I18N_Assemble "$___source" "$___dest" - FS_Copy_File "$___source" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - ___source="${PROJECT_PATH_ROOT}/README.md" - ___dest="${_directory}/README.md" - I18N_Assemble "$___source" "$___dest" - FS_Copy_File "$___source" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - - # REQUIRED: chocolatey required tools\ directory - ___dest="${_directory}/tools" - I18N_Create "$___dest" - FS_Make_Directory "${_directory}/tools" - if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 - fi - - - # OPTIONAL: chocolatey tools\chocolateyBeforeModify.ps1 - ___dest="${_directory}/tools/chocolateyBeforeModify.ps1" - I18N_Create "$___dest" - FS_Write_File "$___dest" "\ -# REQUIRED - BEGIN EXECUTION -Write-Host \"Performing pre-configurations...\" -" - if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 - fi - - - # REQUIRED: chocolatey tools\chocolateyinstall.ps1 - ___dest="${_directory}/tools/chocolateyinstall.ps1" - I18N_Create "$___dest" - FS_Write_File "$___dest" "\ -# REQUIRED - PREPARING INSTALLATION -\$tools_dir = \"\$(Split-Path -Parent -Path \$MyInvocation.MyCommand.Definition)\" -\$data_dir = \"\$(Split-Path -Parent -Path \$tools_dir)\\\\Data\" -\$root_dir = \"\$(Split-Path -Parent -Path \$root_dir)\" -\$current_dir = (Get-Location).Path - - - - -# REQUIRED - BEGIN EXECUTION -# Materialize the binary -Write-Host \"Building ${PROJECT_SKU} (${PROJECT_VERSION})...\" -Set-Location \"\$data_dir\" -.\\\\automataCI\\\\ci.sh.ps1 setup -if (\$LASTEXITCODE -ne 0) { - Set-Location \"\$current_dir\" - Set-PowerShellExitCode 1 - return -} - -.\\\\automataCI\\\\ci.sh.ps1 prepare -if (\$LASTEXITCODE -ne 0) { - Set-Location \"\$current_dir\" - Set-PowerShellExitCode 1 - return -} - -.\\\\automataCI\\\\ci.sh.ps1 materialize -if (\$LASTEXITCODE -ne 0) { - Set-Location \"\$current_dir\" - Set-PowerShellExitCode 1 - return -} - -if (-not (Test-Path \"\${data_dir}\\\\bin\\\\${PROJECT_SKU}.exe\")) { - Set-Location \"\$current_dir\" - Write-Host \"Compile Failed. Missing executable.\" - Set-PowerShellExitCode 1 - return -} - - -# Install -Write-Host \"assembling workspace for installation...\" -if (Test-Path -PathType Container -Path \"\${data_dir}\\\\bin\") { - Move-Item -Path \"\${data_dir}\\\\bin\" -Destination \"\${root_dir}\" -} -if (Test-Path -PathType Container -Path \"\${data_dir}\\\\lib\") { - Move-Item -Path \"\${data_dir}\\\\lib\" -Destination \"\${root_dir}\" -} -Set-Location \"\$current_dir\" -Remove-Item \$data_dir -Force -Recurse -ErrorAction SilentlyContinue -" - if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 - fi - - - # REQUIRED: chocolatey tools\chocolateyuninstall.ps1 - ___dest="${_directory}/tools/chocolateyuninstall.ps1" - I18N_Create "$___dest" - FS_Write_File "$___dest" "\ -# REQUIRED - PREPARING UNINSTALLATION -Write-Host \"Uninstalling ${PROJECT_SKU} (${PROJECT_VERSION})...\" -" - if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 - fi - - - # REQUIRED: chocolatey xml.nuspec file - ___dest="${_directory}/${PROJECT_SKU}.nuspec" - I18N_Create "$___dest" - FS_Write_File "$___dest" "\ - - - - ${PROJECT_SKU} - ${PROJECT_NAME} - ${PROJECT_VERSION} - ${PROJECT_CONTACT_NAME} - ${PROJECT_CONTACT_NAME} - ${PROJECT_CONTACT_WEBSITE} - ${PROJECT_LICENSE} - ${PROJECT_PITCH} - README.md - icon.png - - - - - - - - - - - - - -" - if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 - fi - - - # report status - return 0 -} diff --git a/srcC/.ci/_package-chocolatey_windows-any.ps1 b/srcC/.ci/_package-chocolatey_windows-any.ps1 deleted file mode 100644 index a4fd663e..00000000 --- a/srcC/.ci/_package-chocolatey_windows-any.ps1 +++ /dev/null @@ -1,260 +0,0 @@ -# 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 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. - - - - -# initialize -if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" - exit 1 -} - -. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" -. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" - - - - -function PACKAGE-Assemble-CHOCOLATEY-Content { - param ( - [string]$_target, - [string]$_directory, - [string]$_target_name, - [string]$_target_os, - [string]$_target_arch - ) - - - # validate project - if ($(FS-Is-Target-A-Chocolatey "${_target}") -ne 0) { - return 10 # not applicable - } - - - # assemble the package - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\" - $___dest = "${_directory}\Data\${env:PROJECT_PATH_SOURCE}" - $null = I18N-Assemble "${___source}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-All "${___source}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\.ci\" - $___dest = "${_directory}\Data\${env:PROJECT_PATH_SOURCE}\.ci" - $null = I18N-Assemble "${___source}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-All "${___source}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_C}\" - $___dest = "${_directory}\Data\${env:PROJECT_C}" - $null = I18N-Assemble "${___source}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-All "${___source}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_C}\.ci\" - $___dest = "${_directory}\Data\${env:PROJECT_C}\.ci" - $null = I18N-Assemble "${___source}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-All "${___source}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___source = "${env:PROJECT_PATH_ROOT}\automataCI\" - $___dest = "${_directory}\Data\automataCI" - $null = I18N-Assemble "${___source}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-All "${___source}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___source = "${env:PROJECT_PATH_ROOT}\CONFIG.toml" - $___dest = "${_directory}\Data" - $null = I18N-Assemble "${___source}" "${___dest}" - $___process = FS-Copy-File "${___source}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\icons\icon-128x128.png" - $___dest = "${_directory}\icon.png" - $null = I18N-Assemble "${___source}" "${___dest}" - $___process = FS-Copy-File "${___source}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___source = "${env:PROJECT_PATH_ROOT}\README.md" - $___dest = "${_directory}\README.md" - $null = I18N-Assemble "${___source}" "${___dest}" - $___process = FS-Copy-File "${___source}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - - # REQUIRED: chocolatey required tools\ directory - $___dest = "${_directory}\tools" - $null = I18N-Create "${___dest}" - $___process = FS-Make-Directory "${___dest}" - if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 - } - - - # OPTIONAL: chocolatey tools\chocolateyBeforeModify.ps1 - $___dest = "${_directory}\tools\chocolateyBeforeModify.ps1" - $null = I18N-Create "${___dest}" - $___process = FS-Write-File "${___dest}" @" -# REQUIRED - BEGIN EXECUTION -Write-Host "Performing pre-configurations..." -"@ - if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 - } - - - # REQUIRED: chocolatey tools\chocolateyinstall.ps1 - $___dest = "${_directory}\tools\chocolateyinstall.ps1" - $null = I18N-Create "${___dest}" - $___process = FS-Write-File "${___dest}" @" -# REQUIRED - PREPARING INSTALLATION -`$tools_dir = "`$(Split-Path -Parent -Path `$MyInvocation.MyCommand.Definition)" -`$data_dir = "`$(Split-Path -Parent -Path `$tools_dir)\Data" -`$root_dir = "`$(Split-Path -Parent -Path `$tools_dir)" -`$current_dir = (Get-Location).Path - - - - -# REQUIRED - BEGIN EXECUTION -# Materialize the binary -Write-Host "Building ${env:PROJECT_SKU} (${env:PROJECT_VERSION})..." -Set-Location "`$data_dir" -.\automataCI\ci.sh.ps1 setup -if (`$LASTEXITCODE -ne 0) { - Set-Location "`$current_dir" - Set-PowerShellExitCode 1 - return -} - -.\automataCI\ci.sh.ps1 prepare -if (`$LASTEXITCODE -ne 0) { - Set-Location "`$current_dir" - Set-PowerShellExitCode 1 - return -} - -.\automataCI\ci.sh.ps1 materialize -if (`$LASTEXITCODE -ne 0) { - Set-Location "`$current_dir" - Set-PowerShellExitCode 1 - return -} - -if (-not (Test-Path "`${data_dir}\bin\${env:PROJECT_SKU}.exe")) { - Set-Location "`$current_dir" - Write-Host "Compile Failed. Missing executable." - Set-PowerShellExitCode 1 - return -} - - -Write-Host "assembling workspace for installation..." -if (Test-Path -PathType Container -Path "`${data_dir}\bin") { - Move-Item -Path "`${data_dir}\bin" -Destination "`${root_dir}" -} -if (Test-Path -PathType Container -Path "`${data_dir}\lib") { - Move-Item -Path "`${data_dir}\lib" -Destination "`${root_dir}" -} -Set-Location "`$current_dir" -Remove-Item `$data_dir -Force -Recurse -ErrorAction SilentlyContinue -"@ - if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 - } - - - # REQUIRED: chocolatey tools\chocolateyuninstall.ps1 - $___dest = "${_directory}\tools\chocolateyuninstall.ps1" - $null = I18N-Create "${___dest}" - $___process = FS-Write-File "${___dest}" @" -# REQUIRED - PREPARING UNINSTALLATION -Write-Host "Uninstalling ${env:PROJECT_SKU} (${env:PROJECT_VERSION})..." -"@ - if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 - } - - - # REQUIRED: chocolatey xml.nuspec file - $___dest = "${_directory}\${env:PROJECT_SKU}.nuspec" - $null = I18N-Create "${___dest}" - $___process = FS-Write-File "${___dest}" @" - - - - ${env:PROJECT_SKU} - ${env:PROJECT_NAME} - ${env:PROJECT_VERSION} - ${env:PROJECT_CONTACT_NAME} - ${env:PROJECT_CONTACT_NAME} - ${env:PROJECT_CONTACT_WEBSITE} - ${env:PROJECT_LICENSE} - ${env:PROJECT_PITCH} - README.md - icon.png - - - - - - - - - - - - - -"@ - if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 - } - - - # report status - return 0 -} diff --git a/srcC/.ci/_package-docker_unix-any.sh b/srcC/.ci/_package-docker_unix-any.sh deleted file mode 100644 index 35d6943a..00000000 --- a/srcC/.ci/_package-docker_unix-any.sh +++ /dev/null @@ -1,151 +0,0 @@ -#!/bin/sh -# 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 -# 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. - - - - -# initialize -if [ "$PROJECT_PATH_ROOT" = "" ]; then - >&2 printf "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!\n" - return 1 -fi - -. "${LIBS_AUTOMATACI}/services/io/fs.sh" -. "${LIBS_AUTOMATACI}/services/io/strings.sh" -. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" - - - - -PACKAGE_Assemble_DOCKER_Content() { - _target="$1" - _directory="$2" - _target_name="$3" - _target_os="$4" - _target_arch="$5" - - - # validate project - 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 - return 10 # not applicable - elif [ $(FS_Is_Target_A_WASM_JS "$_target") -eq 0 ]; then - return 10 # not applicable - elif [ $(FS_Is_Target_A_WASM "$_target") -eq 0 ]; then - return 10 # not applicable - elif [ $(FS_Is_Target_A_Chocolatey "$_target") -eq 0 ]; then - return 10 # not applicable - elif [ $(FS_Is_Target_A_Homebrew "$_target") -eq 0 ]; then - return 10 # not applicable - elif [ $(FS_Is_Target_A_Cargo "$_target") -eq 0 ]; then - return 10 # not applicable - elif [ $(FS_Is_Target_A_MSI "$_target") -eq 0 ]; then - return 10 # not applicable - elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then - return 10 # not applicable - fi - - case "$_target_arch" in - avr|js) - return 10 # not applicable - ;; - *) - ;; - esac - - - # assemble the package - ___dest="${_directory}/${PROJECT_SKU}" - I18N_Assemble "$_target" "$___dest" - FS_Copy_File "$_target" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - ___dest="${_directory}/.blank" - I18N_Create "$___dest" - FS_Touch_File "$___dest" - if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 - fi - - - # generate the Dockerfile - ___dest="${_directory}/Dockerfile" - I18N_Create "$___dest" - FS_Write_File "$___dest" "\ -# Defining baseline image -FROM --platform=${_target_os}/${_target_arch} scratch -LABEL org.opencontainers.image.title=\"${PROJECT_NAME}\" -LABEL org.opencontainers.image.description=\"${PROJECT_PITCH}\" -LABEL org.opencontainers.image.authors=\"${PROJECT_CONTACT_NAME} <${PROJECT_CONTACT_EMAIL}>\" -LABEL org.opencontainers.image.version=\"${PROJECT_VERSION}\" -LABEL org.opencontainers.image.revision=\"${PROJECT_CADENCE}\" -LABEL org.opencontainers.image.licenses=\"${PROJECT_LICENSE}\" -" - if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 - fi - - - if [ $(STRINGS_Is_Empty "$PROJECT_CONTACT_WEBSITE") -ne 0 ]; then - FS_Append_File "$___dest" "\ -LABEL org.opencontainers.image.url=\"${PROJECT_CONTACT_WEBSITE}\" -" - if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 - fi - fi - - if [ $(STRINGS_Is_Empty "$PROJECT_SOURCE_URL") -ne 0 ]; then - FS_Append_File "$___dest" "\ -LABEL org.opencontainers.image.source=\"${PROJECT_SOURCE_URL}\" -" - if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 - fi - fi - - FS_Append_File "$___dest" "\ -# Defining environment variables -ENV ARCH ${_target_arch} -ENV OS ${_target_os} -ENV PORT 80 - -# Assemble the file structure -COPY .blank /tmp/.tmpfile -ADD ${PROJECT_SKU} /app/bin/${PROJECT_SKU} - -# Set network port exposures -EXPOSE 80 - -# Set entry point -ENTRYPOINT [\"/app/bin/${PROJECT_SKU}\"] -" - if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 - fi - - - # report status - return 0 -} diff --git a/srcC/.ci/_package-docker_windows-any.ps1 b/srcC/.ci/_package-docker_windows-any.ps1 deleted file mode 100644 index cb751f47..00000000 --- a/srcC/.ci/_package-docker_windows-any.ps1 +++ /dev/null @@ -1,150 +0,0 @@ -# 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 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. - - - - -# initialize -if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" - exit 1 -} - -. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" -. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" -. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" - - - - -function PACKAGE-Assemble-DOCKER-Content { - param ( - [string]$_target, - [string]$_directory, - [string]$_target_name, - [string]$_target_os, - [string]$_target_arch - ) - - - # validate project - if ($(FS-Is-Target-A-Source "${_target}") -ne 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}") -ne 0) { - return 10 # not applicable - } elseif ($(FS-Is-Target-A-WASM-JS "${_target}") -eq 0) { - return 10 # not applicable - } elseif ($(FS-Is-Target-A-WASM "${_target}") -eq 0) { - return 10 # not applicable - } elseif ($(FS-Is-Target-A-Chocolatey "${_target}") -eq 0) { - 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) { - return 10 # not applicable - } - - switch ($_target_arch) { - { $_ -in "avr", "js" } { - return 10 # not applicable - } default { - # accepted - }} - - - # assemble the package - $___dest = "${_directory}\${env:PROJECT_SKU}" - $null = I18N-Assemble "${_target}" "${___dest}" - $___process = FS-Copy-File "${_target}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___dest = "${_directory}\.blank" - $null = I18N-Create "${___dest}" - $___process = FS-Touch-File "${___dest}" - if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 - } - - - # generate the Dockerfile - $___dest = "${_directory}\Dockerfile" - $null = I18N-Create "${___dest}" - $___process = FS-Write-File "${___dest}" @" -# Defining baseline image -FROM --platform=${_target_os}/${_target_arch} scratch -LABEL org.opencontainers.image.title=`"${env:PROJECT_NAME}`" -LABEL org.opencontainers.image.description=`"${env:PROJECT_PITCH}`" -LABEL org.opencontainers.image.authors=`"${env:PROJECT_CONTACT_NAME} <${env:PROJECT_CONTACT_EMAIL}>`" -LABEL org.opencontainers.image.version=`"${env:PROJECT_VERSION}`" -LABEL org.opencontainers.image.revision=`"${env:PROJECT_CADENCE}`" -LABEL org.opencontainers.image.licenses=`"${env:PROJECT_LICENSE}`" -"@ - if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 - } - - if ($(STRINGS-Is-Empty "${env:PROJECT_CONTACT_WEBSITE}") -ne 0) { - $___process = FS-Append-File "${___dest}" @" -LABEL org.opencontainers.image.url=`"${env:PROJECT_CONTACT_WEBSITE}`" -"@ - if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 - } - } - - if ($(STRINGS-Is-Empty "${env:PROJECT_SOURCE_URL}") -ne 0) { - $___process = FS-Append-File "${___dest}" @" -LABEL org.opencontainers.image.source=`"${env:PROJECT_SOURCE_URL}`" -"@ - if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 - } - } - - $___process = FS-Append-File "${___dest}" @" -# Defining environment variables -ENV ARCH ${_target_arch} -ENV OS ${_target_os} -ENV PORT 80 - -# Assemble the file structure -COPY .blank /tmp/.tmpfile -ADD ${env:PROJECT_SKU} /app/bin/${env:PROJECT_SKU} - -# Set network port exposures -EXPOSE 80 - -# Set entry point -ENTRYPOINT ["/app/bin/${env:PROJECT_SKU}"] -"@ - if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 - } - - - # report status - return 0 -} diff --git a/srcC/.ci/_package-homebrew_unix-any.sh b/srcC/.ci/_package-homebrew_unix-any.sh deleted file mode 100644 index 25e39047..00000000 --- a/srcC/.ci/_package-homebrew_unix-any.sh +++ /dev/null @@ -1,150 +0,0 @@ -#!/bin/sh -# 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 -# 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. - - - - -# initialize -if [ "$PROJECT_PATH_ROOT" = "" ]; then - >&2 printf "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!\n" - return 1 -fi - -. "${LIBS_AUTOMATACI}/services/io/fs.sh" -. "${LIBS_AUTOMATACI}/services/io/strings.sh" -. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" - - - - -PACKAGE_Assemble_HOMEBREW_Content() { - _target="$1" - _directory="$2" - _target_name="$3" - _target_os="$4" - _target_arch="$5" - - - # validate project - if [ $(FS_Is_Target_A_Homebrew "$_target") -ne 0 ]; then - return 10 # not applicable - fi - - - # assemble the package - ___source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/" - ___dest="${_directory}/${PROJECT_PATH_SOURCE}" - I18N_Assemble "$___source" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_All "$___source" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - ___source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/.ci/" - ___dest="${_directory}/${PROJECT_PATH_SOURCE}/.ci" - I18N_Assemble "$___source" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_All "$___source" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - ___source="${PROJECT_PATH_ROOT}/${PROJECT_C}/" - ___dest="${_directory}/${PROJECT_C}" - I18N_Assemble "$___source" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_All "$___source" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - ___source="${PROJECT_PATH_ROOT}/${PROJECT_C}/.ci/" - ___dest="${_directory}/${PROJECT_C}/.ci" - I18N_Assemble "$___source" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_All "$___source" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - ___source="${PROJECT_PATH_ROOT}/automataCI/" - ___dest="${_directory}/automataCI" - I18N_Assemble "$___source" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_All "$___source" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - ___source="${PROJECT_PATH_ROOT}/CONFIG.toml" - ___dest="$_directory" - I18N_Assemble "$___source" "$___dest" - FS_Make_Directory "$___dest" - FS_Copy_File "$___source" "$___dest" - if [ $? -ne 0 ]; then - I18N_Assemble_Failed - return 1 - fi - - - # script formula.rb - ___dest="${_directory}/formula.rb" - I18N_Create "$___dest" - FS_Write_File "$___dest" "\ -class $(STRINGS_To_Titlecase "$PROJECT_SKU") < Formula - desc \"${PROJECT_PITCH}\" - homepage \"${PROJECT_CONTACT_WEBSITE}\" - license \"${PROJECT_LICENSE}\" - url \"${PROJECT_HOMEBREW_SOURCE_URL}/{{ TARGET_PACKAGE }}\" - sha256 \"{{ TARGET_SHASUM }}\" - - on_linux do - depends_on \"gcc\" => [:build, :test] - end - - on_macos do - depends_on \"clang\" => [:build, :test] - end - - def install - system \"./automataCI/ci.sh.ps1 setup\" - system \"./automataCI/ci.sh.ps1 prepare\" - system \"./automataCI/ci.sh.ps1 materialize\" - chmod 0755, \"bin/${PROJECT_SKU}\" - libexec.install \"bin/${PROJECT_SKU}\" - bin.install_symlink libexec/\"${PROJECT_SKU}\" => \"${PROJECT_SKU}\" - end - - test do - system \"./automataCI/ci.sh.ps1 setup\" - system \"./automataCI/ci.sh.ps1 prepare\" - system \"./automataCI/ci.sh.ps1 materialize\" - assert_predicate ./bin/${PROJECT_SKU}, :exist? - end -end -" - if [ $? -ne 0 ]; then - I18N_Create_Failed - return 1 - fi - - - # report status - return 0 -} diff --git a/srcC/.ci/_package-homebrew_windows-any.ps1 b/srcC/.ci/_package-homebrew_windows-any.ps1 deleted file mode 100644 index 0cc3c7eb..00000000 --- a/srcC/.ci/_package-homebrew_windows-any.ps1 +++ /dev/null @@ -1,151 +0,0 @@ -# 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 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. - - - - -# initialize -if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" - exit 1 -} - -. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" -. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" -. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" - - - - -function PACKAGE-Assemble-HOMEBREW-Content { - param ( - [string]$_target, - [string]$_directory, - [string]$_target_name, - [string]$_target_os, - [string]$_target_arch - ) - - - # validate project - if ($(FS-Is-Target-A-Homebrew "${_target}") -ne 0) { - return 10 # not applicable - } - - - # assemble the package - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\" - $___dest = "${_directory}\${env:PROJECT_PATH_SOURCE}" - $null = I18N-Assemble "${___source}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-All "${___source}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\.ci\" - $___dest = "${_directory}\${env:PROJECT_PATH_SOURCE}\.ci" - $null = I18N-Assemble "${___source}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-All "${___source}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_C}\" - $___dest = "${_directory}\${env:PROJECT_C}" - $null = I18N-Assemble "${___source}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-All "${___source}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_C}\.ci\" - $___dest = "${_directory}\${env:PROJECT_C}\.ci" - $null = I18N-Assemble "${___source}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-All "${___source}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___source = "${env:PROJECT_PATH_ROOT}\automataCI\" - $___dest = "${_directory}\automataCI" - $null = I18N-Assemble "${___source}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-All "${___source}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - $___source = "${env:PROJECT_PATH_ROOT}\CONFIG.toml" - $___dest = "${_directory}" - $null = I18N-Assemble "${___source}" "${___dest}" - $null = FS-Make-Directory "${___dest}" - $___process = FS-Copy-File "${___source}" "${___dest}" - if ($___process -ne 0) { - $null = I18N-Assemble-Failed - return 1 - } - - - # script formula.rb - $___dest = "${_directory}\formula.rb" - $null = I18N-Create "${___dest}" - $___process = FS-Write-File "${___dest}" @" -class $(STRINGS-To-Titlecase "${env:PROJECT_SKU}") < Formula - desc "${env:PROJECT_PITCH}" - homepage "${env:PROJECT_CONTACT_WEBSITE}" - license "${env:PROJECT_LICENSE}" - url "${env:PROJECT_HOMEBREW_SOURCE_URL}/{{ TARGET_PACKAGE }}" - sha256 "{{ TARGET_SHASUM }}" - - on_linux do - depends_on \"gcc\" => [:build, :test] - end - - on_macos do - depends_on \"clang\" => [:build, :test] - end - - def install - system "./automataCI/ci.sh.ps1 setup" - system "./automataCI/ci.sh.ps1 prepare" - system "./automataCI/ci.sh.ps1 materialize" - chmod 0755, "bin/${env:PROJECT_SKU}" - libexec.install "bin/${env:PROJECT_SKU}" - bin.install_symlink libexec/"${env:PROJECT_SKU}" => "${env:PROJECT_SKU}" - end - - test do - system "./automataCI/ci.sh.ps1 setup" - system "./automataCI/ci.sh.ps1 prepare" - system "./automataCI/ci.sh.ps1 materialize" - assert_predicate ./bin/${env:PROJECT_SKU}, :exist? - end -end -"@ - if ($___process -ne 0) { - $null = I18N-Create-Failed - return 1 - } - - - # report status - return 0 -} diff --git a/srcC/.ci/build_unix-any.sh b/srcC/.ci/build_unix-any.sh index 8774c732..4db7e2fd 100644 --- a/srcC/.ci/build_unix-any.sh +++ b/srcC/.ci/build_unix-any.sh @@ -24,27 +24,40 @@ fi . "${LIBS_AUTOMATACI}/services/io/fs.sh" . "${LIBS_AUTOMATACI}/services/io/strings.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/archive/zip.sh" . "${LIBS_AUTOMATACI}/services/compilers/c.sh" # execute +## define workspace configurations (avoid changes unless absolute necessary) +__source_directory="${PROJECT_PATH_ROOT}/${PROJECT_C}" __output_directory="${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}" -FS_Remake_Directory "$__output_directory" +FS_Make_Directory "$__output_directory" -__log_directory="${PROJECT_PATH_ROOT}/${PROJECT_PATH_LOG}" +__log_directory="${PROJECT_PATH_ROOT}/${PROJECT_PATH_LOG}/build-${PROJECT_C}" FS_Make_Directory "$__log_directory" __tmp_directory="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}" FS_Make_Directory "$__tmp_directory" -__parallel_directory="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/c-parallel" +__parallel_directory="${__tmp_directory}/build-parallel-C" FS_Remake_Directory "$__parallel_directory" +__output_lib_directory="${__tmp_directory}/build-lib${PROJECT_SKU}-C" +FS_Remake_Directory "$__output_lib_directory" + + +## define build targets +## +## Pattern: '[OS]|[ARCH]|[COMPILER]|[TYPE]|[CONTROL_FILE]' +## (1) '[TYPE]' - can either be 'executable' or 'library' only. +## (2) '[CONTROL_FILE]' - the full filepath for a AutomataCI list of +## targets text file. __executable="${PROJECT_PATH_ROOT}/${PROJECT_C}/executable.txt" __library="${PROJECT_PATH_ROOT}/${PROJECT_C}/library.txt" - __build_targets="\ darwin|amd64|clang|executable|${__executable} darwin|amd64|clang|library|${__library} @@ -84,14 +97,128 @@ windows|arm64|x86_64-w64-mingw32-gcc|executable|${__executable} windows|arm64|x86_64-w64-mingw32-gcc|library|${__library} " + +## NOTE: (1) Additional files like .h files, c source code files, assets files, +## and etc to pack into library bulk. +## +## (2) Basic package files like README.md and LICENSE.txt are not +## required. The Package CI job will package it automatically in later +## CI stage. Just focus on only the end-user consumption. +## +## (3) Pattern: '[FULL_PATH]|[NEW_FILENAME]' +__libs_files="\ +${__source_directory}/libs/greeters/Vanilla.h|lib${PROJECT_SKU}.h +" + + __placeholders="\ -${PROJECT_SKU}-src_any-any -${PROJECT_SKU}-homebrew_any-any -${PROJECT_SKU}-chocolatey_any-any ${PROJECT_SKU}-msi_any-any " +## NOTE: (1) C Compilers Optimization flags for known target OS and ARCH types. +Get_Optimization_Flags() { + __target_os="$1" + __target_arch="$2" + + + case "$__target_os" in + darwin) + __arguments="$(C_Get_Strict_Settings) -fPIC" + ;; + windows) + __arguments="\ +-Wall \ +-Wextra \ +-std=gnu89 \ +-pedantic \ +-Wstrict-prototypes \ +-Wold-style-definition \ +-Wundef \ +-Wno-trigraphs \ +-fno-strict-aliasing \ +-fno-common \ +-fshort-wchar \ +-fno-stack-protector \ +-Werror-implicit-function-declaration \ +-Wno-format-security \ +-Os \ +-static \ +" + ;; + *) + __arguments="$(C_Get_Strict_Settings) -static -pie -fPIE" + ;; + esac + + case "$__target_arch" in + armle|armel|armhf) + __arguments="\ +-Wall \ +-Wextra \ +-std=gnu89 \ +-pedantic \ +-Wstrict-prototypes \ +-Wold-style-definition \ +-Wundef \ +-Wno-trigraphs \ +-fno-strict-aliasing \ +-fno-common \ +-fstack-protector-all \ +-Werror-implicit-function-declaration \ +-Wno-format-security \ +-Os \ +-static \ +" + ;; + wasm) + __arguments="\ +-Wall \ +-Wextra \ +-std=gnu89 \ +-pedantic \ +-Wstrict-prototypes \ +-Wold-style-definition \ +-Wundef \ +-Wno-trigraphs \ +-fno-strict-aliasing \ +-fno-common \ +-fshort-wchar \ +-fno-stack-protector \ +-Werror-implicit-function-declaration \ +-Wno-format-security \ +-Os \ +-static \ +" + ;; + *) + ;; + esac + + + # report status + printf -- "%s" "$__arguments" + return 0 +} + + +## NOTE: (1) perform any hard-coded overriding restrictions or gatekeeping +## customization adjustments here (e.g. interim buggy compiler, +## geo-politic distruption). By default, it is returning 0. Any +## rejection shall return a non-zero value (e.g. 1). +Check_Host_Can_Build_Target() { + case "${__target_os}-${__target_arch}" in + *) + # no issue by default + return 0 + ;; + esac +} + + + + +# build algorithms - modify only when absolute necessary SUBROUTINE_Build() { __line="$1" @@ -117,7 +244,19 @@ SUBROUTINE_Build() { __line="${__line#*|}" __target_compiler="${__line%%|*}" - __arguments="${__line#*|}" + __line="${__line#*|}" + + __arguments="${__line%%|*}" + __line="${__line#*|}" + + __output_directory="${__line%%|*}" + __line="${__line#*|}" + + __output_lib_directory="${__line%%|*}" + __line="${__line#*|}" + + __tmp_directory="${__line%%|*}" + __log_directory="${__line#*|}" # validate input @@ -127,15 +266,19 @@ SUBROUTINE_Build() { [ $(STRINGS_Is_Empty "$__target_os") -eq 0 ] || [ $(STRINGS_Is_Empty "$__target_arch") -eq 0 ] || [ $(STRINGS_Is_Empty "$__target_compiler") -eq 0 ] || - [ $(STRINGS_Is_Empty "$__arguments") -eq 0 ]; then + [ $(STRINGS_Is_Empty "$__arguments") -eq 0 ] || + [ $(STRINGS_Is_Empty "$__output_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$__output_lib_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$__tmp_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$__log_directory") -eq 0 ]; then return 1 fi # prepare critical parameters __target="$(FS_Extension_Remove "$(FS_Get_File "$__file_output")" "*")" - __workspace="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/build-${__target}" - __log="${PROJECT_PATH_ROOT}/${PROJECT_PATH_LOG}/build-${__target}" + __workspace="${__tmp_directory}/build-${__target}" + __log="${__log_directory}/${__target}" __file_output="${__workspace}/$(FS_Get_File "$__file_output")" I18N_Build_Parallel "$__file_output" @@ -157,7 +300,11 @@ SUBROUTINE_Build() { # export target - __dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}/$(FS_Get_File "$__file_output")" + __dest="$__output_directory" + if [ "$__file_type" = "library" ]; then + __dest="$__output_lib_directory" + fi + __dest="${__dest}/$(FS_Get_File "$__file_output")" FS_Remove_Silently "$__dest" FS_Copy_File "$__file_output" "$__dest" if [ $? -ne 0 ]; then @@ -185,10 +332,8 @@ SUBROUTINE_Build() { } - - -# register targets and execute parallel build -old_IFS="$IFS" +## register targets and execute parallel build +__old_IFS="$IFS" while IFS="" read -r __line || [ -n "$__line" ]; do if [ $(STRINGS_Is_Empty "$__line") -eq 0 ]; then continue @@ -211,7 +356,6 @@ while IFS="" read -r __line || [ -n "$__line" ]; do __source="${__source#*|}" - # validate input case "$__target_type" in elf|exe|executable) @@ -271,94 +415,17 @@ while IFS="" read -r __line || [ -n "$__line" ]; do fi fi + Check_Host_Can_Build_Target + if [ $? -ne 0 ]; then + continue + fi - ## NOTE: perform any hard-coded host system restrictions or gatekeeping - ## customization adjustments here. - case "${__target_os}-${__target_arch}" in - *) - # accepted - ;; - esac - - - # formulate compiler optimization flags - case "$__target_os" in - darwin) - __arguments="$(C_Get_Strict_Settings) -fPIC" - ;; - windows) - __arguments="\ --Wall \ --Wextra \ --std=gnu89 \ --pedantic \ --Wstrict-prototypes \ --Wold-style-definition \ --Wundef \ --Wno-trigraphs \ --fno-strict-aliasing \ --fno-common \ --fshort-wchar \ --fno-stack-protector \ --Werror-implicit-function-declaration \ --Wno-format-security \ --Os \ --static \ -" - ;; - *) - __arguments="$(C_Get_Strict_Settings) -static -pie -fPIE" - ;; - esac - - case "$__target_arch" in - armle|armel|armhf) - __arguments="\ --Wall \ --Wextra \ --std=gnu89 \ --pedantic \ --Wstrict-prototypes \ --Wold-style-definition \ --Wundef \ --Wno-trigraphs \ --fno-strict-aliasing \ --fno-common \ --fstack-protector-all \ --Werror-implicit-function-declaration \ --Wno-format-security \ --Os \ --static \ -" - ;; - wasm) - __arguments="\ --Wall \ --Wextra \ --std=gnu89 \ --pedantic \ --Wstrict-prototypes \ --Wold-style-definition \ --Wundef \ --Wno-trigraphs \ --fno-strict-aliasing \ --fno-common \ --fshort-wchar \ --fno-stack-protector \ --Werror-implicit-function-declaration \ --Wno-format-security \ --Os \ --static \ -" - ;; - *) - ;; - esac + __arguments="$(Get_Optimization_Flags "$__target_os" "$__target_arch")" # target is healthy - register into build list FS_Append_File "${__parallel_directory}/parallel.txt" "\ -${__file_output}|${__source}|${__target_type}|${__target_os}|${__target_arch}|${__target_compiler}|${__arguments} +${__file_output}|${__source}|${__target_type}|${__target_os}|${__target_arch}|${__target_compiler}|${__arguments}|${__output_directory}|${__output_lib_directory}|${__tmp_directory}|${__log_directory} " done < -# -# 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. - - - - -# (0) initialize -if [ "$PROJECT_PATH_ROOT" = "" ]; then - >&2 printf "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!\n" - return 1 -fi - -. "${PROJECT_PATH_ROOT}/${PROJECT_C}/${PROJECT_PATH_CI}/_package-archive_unix-any.sh" -. "${PROJECT_PATH_ROOT}/${PROJECT_C}/${PROJECT_PATH_CI}/_package-chocolatey_unix-any.sh" -. "${PROJECT_PATH_ROOT}/${PROJECT_C}/${PROJECT_PATH_CI}/_package-docker_unix-any.sh" -. "${PROJECT_PATH_ROOT}/${PROJECT_C}/${PROJECT_PATH_CI}/_package-homebrew_unix-any.sh" - - - - -# report status -return 0 diff --git a/srcC/.ci/package_windows-any.ps1 b/srcC/.ci/package_windows-any.ps1 deleted file mode 100644 index 9596cac0..00000000 --- a/srcC/.ci/package_windows-any.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -# 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 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. - - - - -# initialize -if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { - Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" - return 1 -} - -. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_C}\${env:PROJECT_PATH_CI}\_package-archive_windows-any.ps1" -. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_C}\${env:PROJECT_PATH_CI}\_package-chocolatey_windows-any.ps1" -. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_C}\${env:PROJECT_PATH_CI}\_package-docker_windows-any.ps1" -. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_C}\${env:PROJECT_PATH_CI}\_package-homebrew_windows-any.ps1" - - - - -# report status -return 0 diff --git a/srcC/executable.txt b/srcC/executable.txt index c180cf31..656c3d67 100644 --- a/srcC/executable.txt +++ b/srcC/executable.txt @@ -3,12 +3,17 @@ # Step to do: # (1) List all the source codes for compilation in the following patterns: # [OS]-[ARCH] relative/path/to/code.[TYPE] -# Example: +# Example (1): # any-any main.c # linux-amd64 fx1_linux-amd64.c # linux-amd64 fx2_linux-amd64.o -# linux-arm64 fx1_linux-amd64.c -# linux-arm64 fx2_linux-amd64.o +# linux-amd64 lib1_linux-amd64.a +# +# Example (2): +# any-any main.c +# linux-arm64 fx1_linux-arm64.c +# linux-arm64 fx2_linux-arm64.o +# linux-arm64 lib1_linux-arm64.a # # (2) The leading platform tag is to tell AutomataCI when a source is compatible # with a target build during cross-compilation. Use the value 'any' to @@ -18,5 +23,5 @@ # (3) The list also accepts pre-built library object files (.o extension). # AutomataCI will register it for linking only and copy it into the # workspace. -any-any libs/sample/greeter_any-any.c +any-any libs/greeters/Vanilla.c any-any main.c diff --git a/srcC/library.txt b/srcC/library.txt index 96bd2628..3f5ba018 100644 --- a/srcC/library.txt +++ b/srcC/library.txt @@ -3,12 +3,17 @@ # Step to do: # (1) List all the source codes for compilation in the following patterns: # [OS]-[ARCH] relative/path/to/code.[TYPE] -# Example: +# Example (1): # any-any main.c # linux-amd64 fx1_linux-amd64.c # linux-amd64 fx2_linux-amd64.o -# linux-arm64 fx1_linux-amd64.c -# linux-arm64 fx2_linux-amd64.o +# linux-amd64 lib1_linux-amd64.a +# +# Example (2): +# any-any main.c +# linux-arm64 fx1_linux-arm64.c +# linux-arm64 fx2_linux-arm64.o +# linux-arm64 lib1_linux-arm64.a # # (2) The leading platform tag is to tell AutomataCI when a source is compatible # with a target build during cross-compilation. Use the value 'any' to @@ -18,4 +23,4 @@ # (3) The list also accepts pre-built library object files (.o extension). # AutomataCI will register it for linking only and copy it into the # workspace. -any-any libs/sample/greeter_any-any.c +any-any libs/greeters/Vanilla.c diff --git a/srcC/libs/sample/entity_any-any.h b/srcC/libs/entities/Vanilla.h similarity index 95% rename from srcC/libs/sample/entity_any-any.h rename to srcC/libs/entities/Vanilla.h index 2873d507..e212256d 100644 --- a/srcC/libs/sample/entity_any-any.h +++ b/srcC/libs/entities/Vanilla.h @@ -4,6 +4,12 @@ #ifndef SAMPLE_ENTITY_H #define SAMPLE_ENTITY_H + + + const char *NAME = "Jane"; + + + #endif diff --git a/srcC/libs/sample/greeter_any-any.c b/srcC/libs/greeters/Vanilla.c similarity index 100% rename from srcC/libs/sample/greeter_any-any.c rename to srcC/libs/greeters/Vanilla.c diff --git a/srcC/libs/sample/greeter_any-any.h b/srcC/libs/greeters/Vanilla.h similarity index 98% rename from srcC/libs/sample/greeter_any-any.h rename to srcC/libs/greeters/Vanilla.h index 79852117..e2ff7b36 100644 --- a/srcC/libs/sample/greeter_any-any.h +++ b/srcC/libs/greeters/Vanilla.h @@ -1,13 +1,18 @@ /* * [ LICENSE CLAUSE HERE ] */ - #ifndef SAMPLE_GREETER_H #define SAMPLE_GREETER_H + + + /* Process is a sample function of formatting string output with given name and * location. */ extern void Process(char writer[500], const char *name, const char *location); + + + #endif diff --git a/srcC/libs/sample/greeter_any-any_test.c b/srcC/libs/greeters/Vanilla_test.c similarity index 78% rename from srcC/libs/sample/greeter_any-any_test.c rename to srcC/libs/greeters/Vanilla_test.c index 5adc80ad..58bfb946 100644 --- a/srcC/libs/sample/greeter_any-any_test.c +++ b/srcC/libs/greeters/Vanilla_test.c @@ -1,33 +1,10 @@ /* * [ LICENSE CLAUSE HERE ] */ - - - - -/* define test libraries */ -#pragma GCC diagnostic ignored "-Wunknown-pragmas" -#pragma clang diagnostic ignored "-Wunknown-pragmas" -#pragma GCC diagnostic ignored "-Wvariadic-macros" -#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" - -#include - -struct Scenario { - long ID; - const char *Name; - const char *Description; -}; - -#define Logf(...) fprintf(stderr,##__VA_ARGS__); -/* define test libraries */ - - - - -/* import test target's source code (.c file directly) and setup test suite */ #include -#include "greeter_any-any.c" + +#include "../testing/Vanilla.h" +#include "./Vanilla.c" diff --git a/srcC/libs/sample/location_any-any.h b/srcC/libs/locations/Vanilla.h similarity index 95% rename from srcC/libs/sample/location_any-any.h rename to srcC/libs/locations/Vanilla.h index a62db0a5..1e1333f3 100644 --- a/srcC/libs/sample/location_any-any.h +++ b/srcC/libs/locations/Vanilla.h @@ -4,6 +4,12 @@ #ifndef SAMPLE_LOCATION_H #define SAMPLE_LOCATION_H + + + const char *LOCATION = "Sample"; + + + #endif diff --git a/srcC/libs/testing/Vanilla.h b/srcC/libs/testing/Vanilla.h new file mode 100644 index 00000000..f7ea2757 --- /dev/null +++ b/srcC/libs/testing/Vanilla.h @@ -0,0 +1,28 @@ +/* + * [ LICENSE CLAUSE HERE ] + */ +#ifndef TESTING_H +#define TESTING_H + + + + +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#pragma clang diagnostic ignored "-Wunknown-pragmas" +#pragma GCC diagnostic ignored "-Wvariadic-macros" +#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" + +#include + +struct Scenario { + long ID; + const char *Name; + const char *Description; +}; + +#define Logf(...) fprintf(stderr,##__VA_ARGS__); + + + + +#endif diff --git a/srcC/main.c b/srcC/main.c index 58a5a03a..4fdc927a 100644 --- a/srcC/main.c +++ b/srcC/main.c @@ -2,9 +2,10 @@ * [ LICENSE CLAUSE HERE ] */ #include -#include "libs/sample/entity_any-any.h" -#include "libs/sample/location_any-any.h" -#include "libs/sample/greeter_any-any.h" + +#include "libs/entities/Vanilla.h" +#include "libs/locations/Vanilla.h" +#include "libs/greeters/Vanilla.h"