diff --git a/.github/ISSUE_TEMPLATE/Artwork.yml b/.github/ISSUE_TEMPLATE/Artwork.yml new file mode 100644 index 0000000..ebacae3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Artwork.yml @@ -0,0 +1,45 @@ +name: "Art Directive" +description: "To report a case related to artwork and art direction." +labels: [ "Artwork", "Discussion" ] +body: + - type: textarea + id: description + attributes: + label: Description + description: > + Please provide a short description of what you are looking forward to + have. + placeholder: "E.g: I want a soup to be presented as smiling kitty cat face." + validations: + required: true + - type: textarea + id: expectation + attributes: + label: Expected Behavior + description: > + Please specify the expected behavior below of your request feature. You + may upload your associated artwork presentations here. + placeholder: "E.g: something like this one (attached sketch file)." + validations: + required: true + - type: textarea + id: current + attributes: + label: Current Behavior + description: > + Please specify the any current behavior. You may upload the current + artwork presentation here. + placeholder: "E.g: no art. A bit boring." + validations: + required: true + - type: textarea + id: attachments + attributes: + label: Associated Data Files + description: > + Please drag and drop all other necessary data files (e.g. screenshot, + logs, etc) into the box below. Each successful upload shall render an + URL link on its own. + placeholder: "Please drag and drop it here." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/Bug_n_Glitch.yml b/.github/ISSUE_TEMPLATE/Bug_n_Glitch.yml new file mode 100644 index 0000000..55a7ba2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bug_n_Glitch.yml @@ -0,0 +1,53 @@ +name: "Bug & Glitch" +description: "To report a bug or a glitch regarding about the project." +labels: [ "Bug", "Discussion" ] +body: + - type: textarea + id: description + attributes: + label: Description + description: > + Please provide a short description of what you had encountered. + placeholder: "E.g: Ginseng and white raddish together in a soup, are you crazy?!" + validations: + required: true + - type: textarea + id: expectation + attributes: + label: Expected Behavior + description: > + Please specify the expected behavior below. + placeholder: "E.g: split them into 2 different soup dishes and recipes." + validations: + required: true + - type: textarea + id: current + attributes: + label: Current Behavior + description: > + Please specify the current behavior below. + placeholder: "E.g: 1 recipe with those 2 are gonna be wasteful." + validations: + required: true + - type: textarea + id: reproduction + attributes: + label: Steps to Reproduce [COMPULSORY] + description: > + Please specify all the steps required to re-produce to the problem. If + the team are not able to reproduce the problem even a slighest symptom + of it, then this ticket shall be closed as "Will Not Implement". + placeholder: "E.g:\n1. Refer the menu. A.\n2. Order item 'Gala Soup'.\n3. Observe." + validations: + required: true + - type: textarea + id: attachments + attributes: + label: Associated Data Files + description: > + Please drag and drop all the necessary data files (e.g. screenshot, + logs, etc) into the box below. Each successful uploads shall render an + URL link on its own. + placeholder: "Please drag and drop it here." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/Communities.yml b/.github/ISSUE_TEMPLATE/Communities.yml new file mode 100644 index 0000000..4bfc1dc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Communities.yml @@ -0,0 +1,43 @@ +name: "Communities" +description: "To report a case solely related to the project's communities." +labels: [ "Communities", "Discussion" ] +body: + - type: textarea + id: description + attributes: + label: Description + description: > + Please provide a short description of what you are looking forward to + have. + placeholder: "E.g: I want a rave man!" + validations: + required: true + - type: textarea + id: expectation + attributes: + label: Expected Behavior + description: > + Please specify the expected behavior below of your request feature. + placeholder: "E.g: good food, good drink; lacks the party atmosphere." + validations: + required: true + - type: textarea + id: current + attributes: + label: Current Behavior + description: > + Please specify the any current behavior (e.g. workarounds). + placeholder: "E.g: no workaround. Need to spice up a little." + validations: + required: true + - type: textarea + id: attachments + attributes: + label: Associated Data Files + description: > + Please drag and drop all the necessary data files (e.g. screenshot, + logs, etc) into the box below. Each successful upload shall render an + URL link on its own. + placeholder: "Please drag and drop it here." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/Documentation.yml b/.github/ISSUE_TEMPLATE/Documentation.yml new file mode 100644 index 0000000..823bafd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Documentation.yml @@ -0,0 +1,51 @@ +name: "Documentations" +description: "To report something about the project's documentation." +labels: [ "Documentation", "Discussion" ] +body: + - type: textarea + id: description + attributes: + label: Description + description: > + Please provide a short description of what you had encountered. + placeholder: "E.g: I saw a typo at Section 2.1.3 - 'glicth' should be 'glitch'." + validations: + required: true + - type: input + id: url + attributes: + label: Page URL Address + description: > + Please provide the documentation link if applicable. + placeholder: "E.g: https://www.github.com/hollowaykeanho" + validations: + required: false + - type: textarea + id: expectation + attributes: + label: Expected Presentation + description: > + Please specify the expected presentation below. + placeholder: "E.g: ... report a glitch at ..." + validations: + required: true + - type: textarea + id: current + attributes: + label: Current Behavior + description: > + Please specify the current presentation below. + placeholder: "E.g: Section 2.1.3 -> ... report a glicth at ..." + validations: + required: true + - type: textarea + id: attachments + attributes: + label: Associated Data Files + description: > + Please drag and drop all the necessary data files (e.g. screenshot, + logs, etc) into the box below. Each successful uploads shall render an + URL link on its own. + placeholder: "Please drag and drop it here." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/Enhancement.yml b/.github/ISSUE_TEMPLATE/Enhancement.yml new file mode 100644 index 0000000..da55f19 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Enhancement.yml @@ -0,0 +1,44 @@ +name: "Enhance A Feature" +description: "To request a feature enhancement for the project." +labels: [ "Enhancement", "Discussion" ] +body: + - type: textarea + id: description + attributes: + label: Description + description: > + Please provide a short description of what you're looking forward to + enhance or remove. Please include the story behind the idea to better + visualize your case. + placeholder: "E.g: 15cm noodle instead of 5cm - slurp up too quickly." + validations: + required: true + - type: textarea + id: expectation + attributes: + label: Expected Behavior + description: > + Please specify the expected behavior below. + placeholder: "E.g: Noodle is at least 15cm longer." + validations: + required: true + - type: textarea + id: current + attributes: + label: Current Behavior + description: > + Please specify the current behavior below. + placeholder: "E.g: Noodle is 5cm long and slupped up in 2 seconds. Not enjoyable." + validations: + required: true + - type: textarea + id: attachments + attributes: + label: Associated Data Files + description: > + Please drag and drop all the necessary data files (e.g. screenshot, + logs, etc) into the box below. Each successful uploads shall render an + URL link on its own. + placeholder: "Please drag and drop it here." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/Infrastructure.yml b/.github/ISSUE_TEMPLATE/Infrastructure.yml new file mode 100644 index 0000000..60428b9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Infrastructure.yml @@ -0,0 +1,43 @@ +name: "Infrastructure (CI, Work System, etc)" +description: "To report a case solely related to infrastructure." +labels: [ "Infrastructure", "Discussion" ] +body: + - type: textarea + id: description + attributes: + label: Description + description: > + Please provide a short description of what you are looking forward to + have. + placeholder: "E.g: I want an ambient light at my noodle isle!" + validations: + required: true + - type: textarea + id: expectation + attributes: + label: Expected Behavior + description: > + Please specify the expected behavior below of your request feature. + placeholder: "E.g: LED light (lime is great!)." + validations: + required: true + - type: textarea + id: current + attributes: + label: Current Behavior + description: > + Please specify the any current behavior (e.g. workarounds). + placeholder: "E.g: Candles... are you serious?" + validations: + required: true + - type: textarea + id: attachments + attributes: + label: Associated Data Files + description: > + Please drag and drop all the necessary data files (e.g. screenshot, + logs, etc) into the box below. Each successful upload shall render an + URL link on its own. + placeholder: "Please drag and drop it here." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/New.yml b/.github/ISSUE_TEMPLATE/New.yml new file mode 100644 index 0000000..7c96458 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/New.yml @@ -0,0 +1,43 @@ +name: "New Feature Request" +description: "To request a new feature for the project." +labels: [ "New Feature", "Discussion" ] +body: + - type: textarea + id: description + attributes: + label: Description + description: > + Please provide a short description of what you are looking forward to + have. + placeholder: "E.g: I want a soup as a side dish!" + validations: + required: true + - type: textarea + id: expectation + attributes: + label: Expected Behavior + description: > + Please specify the expected behavior below of your request feature. + placeholder: "E.g: the soup must have tonkotsu, shio, shoyu, and miso." + validations: + required: true + - type: textarea + id: current + attributes: + label: Current Behavior + description: > + Please specify the any current behavior (e.g. workarounds). + placeholder: "E.g: no workaround." + validations: + required: true + - type: textarea + id: attachments + attributes: + label: Associated Data Files + description: > + Please drag and drop all the necessary data files (e.g. screenshot, + logs, etc) into the box below. Each successful upload shall render an + URL link on its own. + placeholder: "Please drag and drop it here." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/Payment.yml b/.github/ISSUE_TEMPLATE/Payment.yml new file mode 100644 index 0000000..9a758bd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Payment.yml @@ -0,0 +1,43 @@ +name: "Payment" +description: "To report a case related to a payment transaction for the project." +labels: [ "Payment", "Discussion" ] +body: + - type: textarea + id: description + attributes: + label: Description + description: > + Please provide a short description of what you are looking forward to + have. + placeholder: "E.g: You forgotten to discount my noodle meal. Please amend." + validations: + required: true + - type: textarea + id: expectation + attributes: + label: Expected Behavior + description: > + Please specify the expected behavior below of your request feature. + placeholder: "E.g: Should be USD8.00." + validations: + required: true + - type: textarea + id: current + attributes: + label: Current Behavior + description: > + Please specify the any current behavior (e.g. workarounds). + placeholder: "E.g: Being charged USD10.00." + validations: + required: true + - type: textarea + id: attachments + attributes: + label: Associated Data Files + description: > + Please drag and drop all the necessary data files (e.g. screenshot, + logs, etc) into the box below. Each successful upload shall render an + URL link on its own. + placeholder: "Please drag and drop it here." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/Question.yml b/.github/ISSUE_TEMPLATE/Question.yml new file mode 100644 index 0000000..3586d04 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Question.yml @@ -0,0 +1,28 @@ +name: "Question" +description: "To query something about the project." +labels: [ "Question", "Discussion" ] +body: + - type: textarea + id: description + attributes: + label: Description + description: > + Please provide a short description of your query. + placeholder: "E.g: what's that delicious meat in the meal?" + validations: + required: true + - type: textarea + id: current + attributes: + label: Current Researched Artifacts [COMPULSORY] + description: > + Please list out all your research artifacts that you did (e.g. link, + blog post, documentations, and etc) for us to gauge your context and + current efforts. You can drag and drop all the necessary data files + (e.g. screenshot, logs, etc) into the box as well. Each successful + upload shall render an URL link on its own. **NOTE: We may not reply + you and will close the ticket with perjuidice if this section remains + empty or unconvincing**. + placeholder: "E.g: I did a lab report as attached. They can't tell." + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/Sponsorship.yml b/.github/ISSUE_TEMPLATE/Sponsorship.yml new file mode 100644 index 0000000..ae626fe --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Sponsorship.yml @@ -0,0 +1,43 @@ +name: "Sponsorship" +description: "To report a case solely related to the project's sponsorship." +labels: [ "Sponsorship", "Discussion" ] +body: + - type: textarea + id: description + attributes: + label: Description + description: > + Please provide a short description of what you are looking forward to + have. + placeholder: "E.g: I want to sponsor your brand!" + validations: + required: true + - type: textarea + id: expectation + attributes: + label: Expected Behavior + description: > + Please specify the expected behavior below of your request feature. + placeholder: "E.g: Let's talk business, like ads, materials, etc." + validations: + required: true + - type: textarea + id: current + attributes: + label: Current Behavior + description: > + Please specify the any current behavior (e.g. workarounds). + placeholder: "E.g: I see potential future in your business." + validations: + required: true + - type: textarea + id: attachments + attributes: + label: Associated Data Files + description: > + Please drag and drop all the necessary data files (e.g. screenshot, + logs, etc) into the box below. Each successful upload shall render an + URL link on its own. + placeholder: "Please drag and drop it here." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..3ba13e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md new file mode 100644 index 0000000..984a426 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -0,0 +1,135 @@ +# Prologue + +**We DO NOT ACCEPT ANY PULL/MERGE REQUEST FOR THIS REPOSITORY**. + +The right procedure for contributing back via these platform services ARE: + +1. **Generate and submit your patches into your corresponding issue ticket**; +2. Feel free to ask any technical questions about patch generations; +3. Once the basic are cleared, We will `git am` (apply) the submitted patch. If + it works, it will then be treated as accepted. + + + + +# Why? + +We want to: + +1. **Retaining all changes and information inside git log ONLY**; and +2. **Avoiding complete vendor locked-in**; and +3. **Continue to facilitate offline and disconnected native git services** + +Like it or not, any GVCS (e.g. GitHub/GitLab/Gitea) are supplying vendors and +they can introduce drastic business changes overtime to the point where we can +terminate their supplying services. + +Hence, to prevent vendor lock-in problem, we are: + +1. use the native `git` functionalities to maintain the source codes; WHILE +2. only use the GVCS to facilitate mirror-ed hosting and communications only. + +In any cases, we do not mind losing the forum but we are very agitated if the +repository maintenance works are unnecessarily being threatened by a known and +identified supply-chain threat. + + + + +# What is Required in Your Commit Messages + +**Write the whole ESSAY of the issue ticket you are working on**. Remember the +goal is to capture your commitment from problem to why we should apply your +patch. + +A format template is as follows: + +``` +: # **REQUIRED**: max 65 characters + # **REQUIRED**: LEAVE THIS EMPTY new LINE +[1st Para: explain the issue problem] # **REQUIRED**: explain the problem + # presented by the issue ticket. It's a + # paragraph, so use as long as you want. + # + # line should wrap at MAX 80 characters. + # + # If can, include the submitted + # data problems (e.g. log data). + # + # Mentions about the severity of the + # problem (e.g. workaround? critical?). + # See applied labels. + # + # **REQUIRED**: LEAVE THIS EMPTY new LINE +[2nd Para: explain this patch's work] # Only explains what this patch does for + # its approach to solve the problem + # you mentioned above. It's a + # paragraph, so use as long as you want. + # + # line should wrap at MAX 80 characters. + # + # **REQUIRED**: leave THIS empty new line +Signed-off-by: [NAME] <[EMAIL]> # **REQUIRED**: Your git signature here. +``` + +You can refer to the `git log` for inspirations or just ask us in the issue +ticket you're working on. + +Note that: + +1. You **DO NOT NEED** to explain how the codes work or what are the +files involved. The patch already presented the data. +2. If your effort involves some kind of algorithm explaination, make sure to +include its documentations and mentions where to find them so that your +reviewers know where to digest them. + + + + +## GPG Signature for Commit Signature + +**Optional but highly recommended** since we are doing manual code-review and +automated CI testing internally on our side with our own automation tools. + +If you're signing, please provide your public key source so that we can verify +you internally in the future. + + + + +# To Generate Patches + +To create your patches, please use any of the following `git` command: + +```bash +$ git format-patch .. +``` + +> Example: +> +> `$ git format-patch fed1235..ab32123` +> `$ git format-patch HEAD~3..HEAD` + +This is recommended since: + +1. The smaller, single-purpose of the patches, the easier to review and accept. + +**OR Alternatively** + +```bash +$ git format-patch ^.. --stdout > my.patch +``` + +> Example: +> +> `$ git format-patch fed1235^..ab32123 --stdout > my.patch` + + + + +# Epilogue + +That's all from us. Your pull request **SHALL BE REJECTED WITH PERJUDICE** if +you choose to ignore this message. + +Thank you for your cooperation. diff --git a/.github/images/sponsor_en_100x30.svg b/.github/images/sponsor_en_100x30.svg new file mode 100644 index 0000000..2ca51a8 --- /dev/null +++ b/.github/images/sponsor_en_100x30.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/.github/images/sponsor_en_210x50.svg b/.github/images/sponsor_en_210x50.svg new file mode 100644 index 0000000..a959ae0 --- /dev/null +++ b/.github/images/sponsor_en_210x50.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/.github/images/sponsor_fr_100x30.svg b/.github/images/sponsor_fr_100x30.svg new file mode 100644 index 0000000..bbff257 --- /dev/null +++ b/.github/images/sponsor_fr_100x30.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/.github/images/sponsor_fr_210x50.svg b/.github/images/sponsor_fr_210x50.svg new file mode 100644 index 0000000..38f894b --- /dev/null +++ b/.github/images/sponsor_fr_210x50.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.github/images/sponsor_ms-my_100x30.svg b/.github/images/sponsor_ms-my_100x30.svg new file mode 100644 index 0000000..10f0037 --- /dev/null +++ b/.github/images/sponsor_ms-my_100x30.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.github/images/sponsor_ms-my_210x50.svg b/.github/images/sponsor_ms-my_210x50.svg new file mode 100644 index 0000000..76595a7 --- /dev/null +++ b/.github/images/sponsor_ms-my_210x50.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/.github/images/sponsor_zh-hans_100x30.svg b/.github/images/sponsor_zh-hans_100x30.svg new file mode 100644 index 0000000..a957d0f --- /dev/null +++ b/.github/images/sponsor_zh-hans_100x30.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/.github/images/sponsor_zh-hans_210x50.svg b/.github/images/sponsor_zh-hans_210x50.svg new file mode 100644 index 0000000..168fe12 --- /dev/null +++ b/.github/images/sponsor_zh-hans_210x50.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.github/workflows/git-push.yml b/.github/workflows/git-push.yml new file mode 100644 index 0000000..0a86c72 --- /dev/null +++ b/.github/workflows/git-push.yml @@ -0,0 +1,122 @@ +name: Git Push +run-name: CI - Git Push +on: + push: + branches: + - main + - stable + - next + - testing + - staging + - edge + - experimental +jobs: + develop_on: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + env: + TERM: xterm-256color + ROBOT_NAME: "github.actions.runner@github.com" + ROBOT_EMAIL: "Github Actions Autonomous Runner System" + REPO_NAME: ${{ github.repository }} + REPO_URL: "${{ github.server_url }}/${{ github.repository }}" + REPO_COMMIT: "${{ github.sha }}" + CONTAINER_USERNAME: ${{ secrets.CONTAINER_USERNAME }} + CONTAINER_PASSWORD: ${{ secrets.CONTAINER_PASSWORD }} + TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + PROJECT_SIMULATE_RELEASE_REPO: true + PROJECT_ROBOT_RUN: true + PROJECT_ROBOT_GITHUB_TOKEN: "${{ github.token }}" + steps: + - name: Git - INIT + id: git_init + run: | + git config --global user.email "${{ env.ROBOT_NAME }}" + git config --global user.name "${{ env.ROBOT_EMAIL }}" + git config --global advice.detachedHead false + git clone --depth=1 ${{ env.REPO_URL }} . + git fetch origin ${{ env.REPO_COMMIT }} + git checkout FETCH_HEAD + - name: AutomataCI - PURGE + id: automataci_ci_purge + run: | + ./automataCI/ci.sh.ps1 purge + - name: AutomataCI - CLEAN + id: automataci_ci_clean + run: | + ./automataCI/ci.sh.ps1 clean + - name: AutomataCI - ENVIRONMENT + id: automataci_ci_env + run: | + ./automataCI/ci.sh.ps1 env + - name: AutomataCI - SETUP + id: automataci_ci_setup + run: | + ./automataCI/ci.sh.ps1 setup + - name: AutomataCI - PREPARE + id: automataci_ci_prepare + run: | + ./automataCI/ci.sh.ps1 prepare + - name: AutomataCI - START + id: automataci_ci_start + run: | + ./automataCI/ci.sh.ps1 start + - name: AutomataCI - TEST + id: automataci_ci_test + run: | + ./automataCI/ci.sh.ps1 test + - name: AutomataCI - MATERIALIZE + id: automataci_ci_materialize + run: | + ./automataCI/ci.sh.ps1 materialize + - name: AutomataCI - BUILD + id: automataci_ci_build + run: | + ./automataCI/ci.sh.ps1 build + - name: AutomataCI - NOTARIZE + id: automataci_ci_notarize + run: | + ./automataCI/ci.sh.ps1 notarize + - name: AutomataCI - PACKAGE + id: automataci_ci_package + run: | + ./automataCI/ci.sh.ps1 package + - name: AutomataCI - RELEASE + id: automataci_ci_release + run: | + ./automataCI/ci.sh.ps1 release + - name: AutomataCI - STOP + id: automataci_ci_stop + run: | + ./automataCI/ci.sh.ps1 stop + - name: AutomataCI - DEPLOY + id: automataci_ci_deploy + run: | + ./automataCI/ci.sh.ps1 deploy + - name: AutomataCI - ARCHIVE + id: automataci_ci_archive + if: always() + run: | + ./automataCI/ci.sh.ps1 archive + - name: GITHUB ACTIONS - Upload Artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: build-${{ matrix.os }} + if-no-files-found: ignore + compression-level: 0 + path: | + artifact-build_* + - name: GITHUB ACTIONS - Upload Artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: workspace-${{ matrix.os }} + if-no-files-found: ignore + compression-level: 0 + path: | + artifact-workspace_* diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..81a7b15 --- /dev/null +++ b/.gitignore @@ -0,0 +1,198 @@ +##################### +# User defined +##################### + +##################### +# Standard FHS +##################### +vendor/ +output/ +/releases/ +!/*/releases/ + +##################### +# ZORALab's Monteur +##################### +/.monteurFS/ +/.configs/montuer/secrets/ +.bin/ + +##################### +# AutomataCI +##################### +/SECRETS.toml +/bin +/lib +/tools +/tmp +/log +/build +/pkg +/releases +/resources/changelog/*/.* +/artifact* +/pkgAUTOMATACI +/.internals/docs/*/*.pdf + +##################### +# Angular +##################### +/out-tsc +/bazel-out +cache/ +coverage/ +dist/ +.sass-cache/ +connect.lock +libpeerconnection.log +testem.log +typings + +##################### +# LibreOffice +##################### +.~lock* + +##################### +# Python +##################### +venv/ +__pycache__ +.coverage + +##################### +# Rust +##################### +target/ +*.profraw + +##################### +# Hugo +##################### +themes/ +public/ +.hugo_build.lock + +##################### +# LetsEncrypt +##################### +certbot.log + +##################### +# Android Studio +##################### +/build + +##################### +# vim +##################### +4913 +*.swp + +##################### +# C Language +##################### +*.d +!*.d/ +*.o +*.a +*.dll +*.exe +*.elf +*.hex +*.bin + +##################### +# Node +##################### +node_modules/ +npm-debug.log +yarn-error.log +coverage/ +dist/ +.nyc_output + +##################### +# Databases +##################### +*.db + +##################### +# SQLite +##################### +*.sqlite3 +*.sqlite +*.sqlite-journal +*.db-journal + +##################### +# GitHub +##################### +gh-pages/ + +##################### +# Logs +##################### +*.log + +##################### +# MacOS specifics +##################### +.DS_Store +Thumbs.db + +##################### +# AWS CLI credential blobs +##################### +.aws/credentials +aws/credentials +homefolder/aws/credentials + +##################### +# Private RSA SSH keys +##################### +/ssh/id_rsa +/.ssh/personal_rsa +/config/server_rsa +id_rsa +.id_rsa + +##################### +# Private DSA SSH keys +##################### +/ssh/id_dsa +/.ssh/personal_dsa +/config/server_dsa +id_dsa +.id_dsa + +##################### +# Private ed25519 SSH keys +##################### +/ssh/id_ed25519 +/.ssh/personal_ed25519 +/config/server_ed25519 +id_ed25519 +.id_ed25519 + +##################### +# Private ECDSA SSH keys +##################### +/ssh/id_ecdsa +/.ssh/personal_ecdsa +/config/server_ecdsa +id_ecdsa +.id_ecdsa + +##################### +# Any file with .pem or .key extensions +##################### +*.pem +*.key +*.crt + +##################### +# Any file ending with _history or .history extension +##################### +pry.history +bash_history diff --git a/.gitlab/issue_templates/Bug.md b/.gitlab/issue_templates/Bug.md new file mode 100644 index 0000000..4dfdb81 --- /dev/null +++ b/.gitlab/issue_templates/Bug.md @@ -0,0 +1,41 @@ +[comment]: # (GitLab Internal Operation Headers) +/label ~"Bug" ~"Discussion" +[comment]: # (GitLab Internal Operation Headers) + +# Description +``` +Please provide a short description of what you have encountered below. +``` + + + + +# Expected Behavior +``` +Please specify the expected behavior of your usage below. +``` + + + + +# Current Behavior +``` +Please specify the current behavior of software below. +``` + + + + +# Steps to Reproduce (COMPULSORY) +``` +Please specify all the steps required to re-produce the problem. +``` + + + + +# Attachment +``` +Please drag and drop the necessary data files (e.g. screenshot, logs, etc) +below. +``` diff --git a/.gitlab/issue_templates/Documentation Problem.md b/.gitlab/issue_templates/Documentation Problem.md new file mode 100644 index 0000000..4722ba3 --- /dev/null +++ b/.gitlab/issue_templates/Documentation Problem.md @@ -0,0 +1,41 @@ +[comment]: # (GitLab Internal Operation Headers) +/label ~"Documentation" ~"Discussion" +[comment]: # (GitLab Internal Operation Headers) + +# Description +``` +Please provide a short description of what you have encountered below. +``` + + + + +# Link +``` +Please provide the documentation link(s) below. +``` + + + + +# Expected Presentation +``` +Please specify the expected presentation of the documentation. +``` + + + + +# Current Presentation +``` +Please specify the current presentation of the documentation. +``` + + + + +# Attachment +``` +Please drag and drop the necessary data files (e.g. screenshot, logs, etc) +below. +``` diff --git a/.gitlab/issue_templates/Feature Enhancement.md b/.gitlab/issue_templates/Feature Enhancement.md new file mode 100644 index 0000000..db6a62c --- /dev/null +++ b/.gitlab/issue_templates/Feature Enhancement.md @@ -0,0 +1,37 @@ +[comment]: # (GitLab Internal Operation Headers) +/label ~"Enhancement" ~"Discussion" +[comment]: # (GitLab Internal Operation Headers) + +# Description +``` +Please provide a short description of what feature you're looking forward to +enhance below. Please include the story behind your idea as well to give a +better visualization of your idea. +``` + + + + +# Expected Behavior +``` +Please specify the expected behavior of your requested enhancement. Some great +and helpful pointers are your expected interface (e.g. command patterns, simple +sketches of the user interface, etc). +``` + + + + +# Current Behavior +``` +Please specify the current behavior (e.g. workaround, blockage, etc). +``` + + + + +# Attachment +``` +Please drag and drop the necessary data files (e.g. screenshot, logs, etc) +below. +``` diff --git a/.gitlab/issue_templates/New Feature Request.md b/.gitlab/issue_templates/New Feature Request.md new file mode 100644 index 0000000..535f17a --- /dev/null +++ b/.gitlab/issue_templates/New Feature Request.md @@ -0,0 +1,37 @@ +[comment]: # (GitLab Internal Operation Headers) +/label ~"New Feature" ~"Discussion" +[comment]: # (GitLab Internal Operation Headers) + +# Description +``` +Please provide a short description of what feature you're looking forward to +add into the existing repository below. Please include the story behind your +idea as well to give a better visualization of your idea. +``` + + + + +# Expected Behavior +``` +Please specify the expected behavior of your requested feature. Some great and +helpful pointers are your expected interface (e.g. command patterns, simple +sketches of the user interface, etc). +``` + + + + +# Current Absent Behavior +``` +Please specify the current behavior (e.g. workaround, blockage, etc). +``` + + + + +# Attachment +``` +Please drag and drop the necessary data files (e.g. screenshot, logs, etc) +below. +``` diff --git a/.gitlab/issue_templates/Question.md b/.gitlab/issue_templates/Question.md new file mode 100644 index 0000000..e2106ff --- /dev/null +++ b/.gitlab/issue_templates/Question.md @@ -0,0 +1,38 @@ +[comment]: # (GitLab Internal Operation Headers) +/label ~"Question" ~"Discussion" +[comment]: # (GitLab Internal Operation Headers) + +# Question +``` +Please state your question in a brief and ended with question mark (?). You may +include sub-questions with "if cases" to communicate more effectively instead of +many 'ping-pong' passing. +``` + + + + +# Background +``` +Please provide a short description of what you are trying to ask. +``` + + + + +# Current Research Artifacts (COMPULSORY) +``` +Please list out all your research artifacts that you did (e.g. link, blog post, +documentations, and etc) for us to gauge your context and current efforts. We +may not reply and will close the ticket if this section remains empty and +unconvincing. +``` + + + + +# Attachment +``` +Please drag and drop the necessary data files (e.g. screenshot, logs, etc) +below. +``` diff --git a/.gitlab/merge_request_templates/default.md b/.gitlab/merge_request_templates/default.md new file mode 100644 index 0000000..6ce6309 --- /dev/null +++ b/.gitlab/merge_request_templates/default.md @@ -0,0 +1,129 @@ +# Prologue +**We DO NOT ACCEPT ANY PULL/MERGE REQUEST FOR THIS REPOSITORY**. + +The right procedure for contributing back via these platform services ARE: + +1. **Generate and submit your patches into your corresponding issue ticket**; +2. Feel free to ask any technical questions about patch generations; +3. Once the basic are cleared, We will `git am` (apply) the submitted patch. If + it works, it will then be treated as accepted. + + + + +# Why? +We want to: + +1. **Retaining all changes and information inside git log ONLY**; and +2. **Avoiding complete vendor locked-in**; and +3. **Continue to facilitate offline and disconnected native git services** + +Like it or not, any GVCS (e.g. GitHub/GitLab/Gitea) are supplying vendors and +they can introduce drastic business changes overtime to the point where we can +terminate their supplying services. + +Hence, to prevent vendor lock-in problem, we are: + +1. use the native `git` functionalities to maintain the source codes; WHILE +2. only use the GVCS to facilitate mirror-ed hosting and communications only. + +In any cases, we do not mind losing the forum but we are very agitated if the +repository maintenance works are unnecessarily being threatened by a known and +identified supply-chain threat. + + + + +# What is Required in Your Commit Messages +**Write the whole ESSAY of the issue ticket you are working on**. Remember the +goal is to capture your commitment from problem to why we should apply your +patch. + +A format template is as follows: + +``` +: # **REQUIRED**: max 65 characters + # **REQUIRED**: LEAVE THIS EMPTY new LINE +[1st Para: explain the issue problem] # **REQUIRED**: explain the problem + # presented by the issue ticket. It's a + # paragraph, so use as long as you want. + # + # line should wrap at MAX 80 characters. + # + # If can, include the submitted + # data problems (e.g. log data). + # + # Mentions about the severity of the + # problem (e.g. workaround? critical?). + # See applied labels. + # + # **REQUIRED**: LEAVE THIS EMPTY new LINE +[2nd Para: explain this patch's work] # Only explains what this patch does for + # its approach to solve the problem + # you mentioned above. It's a + # paragraph, so use as long as you want. + # + # line should wrap at MAX 80 characters. + # + # **REQUIRED**: leave THIS empty new line +Signed-off-by: [NAME] <[EMAIL]> # **REQUIRED**: Your git signature here. +``` + +You can refer to the `git log` for inspirations or just ask us in the issue +ticket you're working on. + +Note that: + +1. You **DO NOT NEED** to explain how the codes work or what are the +files involved. The patch already presented the data. +2. If your effort involves some kind of algorithm explaination, make sure to +include its documentations and mentions where to find them so that your +reviewers know where to digest them. + + + + +## GPG Signature for Commit Signature +**Optional but highly recommended** since we are doing manual code-review and +automated CI testing internally on our side with our own automation tools. + +If you're signing, please provide your public key source so that we can verify +you internally in the future. + + + + +# To Generate Patches +To create your patches, please use any of the following `git` command: + +```bash +$ git format-patch .. +``` + +> Example: +> +> `$ git format-patch fed1235..ab32123` +> `$ git format-patch HEAD~3..HEAD` + +This is recommended since: + +1. The smaller, single-purpose of the patches, the easier to review and accept. + +**OR Alternatively** + +```bash +$ git format-patch ^.. --stdout > my.patch +``` + +> Example: +> +> `$ git format-patch fed1235^..ab32123 --stdout > my.patch` + + + + +# Epilogue +That's all from us. Your pull request **SHALL BE REJECTED WITH PERJUDICE** if +you choose to ignore this message. + +Thank you for your cooperation. diff --git a/.src/.ci/_package-archive_unix-any.sh b/.src/.ci/_package-archive_unix-any.sh new file mode 100644 index 0000000..fe1f995 --- /dev/null +++ b/.src/.ci/_package-archive_unix-any.sh @@ -0,0 +1,122 @@ +#!/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 + 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" + 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/.src/.ci/_package-archive_windows-any.ps1 b/.src/.ci/_package-archive_windows-any.ps1 new file mode 100644 index 0000000..039b401 --- /dev/null +++ b/.src/.ci/_package-archive_windows-any.ps1 @@ -0,0 +1,123 @@ +# 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 + ) + + + # copy main program + 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}" + 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) { + $null = 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/.src/.ci/_package-cargo_unix-any.sh b/.src/.ci/_package-cargo_unix-any.sh new file mode 100644 index 0000000..3072899 --- /dev/null +++ b/.src/.ci/_package-cargo_unix-any.sh @@ -0,0 +1,36 @@ +#!/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 + + + + +PACKAGE_Assemble_CARGO_Content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # execute + return 10 # IMPORTANT: please do it inside rust source instead. +} diff --git a/.src/.ci/_package-cargo_windows-any.ps1 b/.src/.ci/_package-cargo_windows-any.ps1 new file mode 100644 index 0000000..76ad385 --- /dev/null +++ b/.src/.ci/_package-cargo_windows-any.ps1 @@ -0,0 +1,37 @@ +# 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 +} + + + + +function PACKAGE-Assemble-CARGO-Content { + param ( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # execute + return 10 # IMPORTANT: please do it inside rust source instead. +} diff --git a/.src/.ci/_package-chocolatey_unix-any.sh b/.src/.ci/_package-chocolatey_unix-any.sh new file mode 100644 index 0000000..57b5cbc --- /dev/null +++ b/.src/.ci/_package-chocolatey_unix-any.sh @@ -0,0 +1,36 @@ +#!/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 + + + + +PACKAGE_Assemble_CHOCOLATEY_Content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # execute + return 10 # not applicable - should be tech-oriented. +} diff --git a/.src/.ci/_package-chocolatey_windows-any.ps1 b/.src/.ci/_package-chocolatey_windows-any.ps1 new file mode 100644 index 0000000..933639b --- /dev/null +++ b/.src/.ci/_package-chocolatey_windows-any.ps1 @@ -0,0 +1,37 @@ +# 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 +} + + + + +function PACKAGE-Assemble-CHOCOLATEY-Content { + param ( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # execute + return 10 # not applicable - should be tech-oriented. +} diff --git a/.src/.ci/_package-deb_unix-any.sh b/.src/.ci/_package-deb_unix-any.sh new file mode 100644 index 0000000..84cb601 --- /dev/null +++ b/.src/.ci/_package-deb_unix-any.sh @@ -0,0 +1,214 @@ +#!/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 autoamtaCI/ci.sh.ps1 instead!\n" + return 1 +fi + +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/copyright.sh" +. "${LIBS_AUTOMATACI}/services/compilers/deb.sh" +. "${LIBS_AUTOMATACI}/services/compilers/manual.sh" + + + + +PACKAGE_Assemble_DEB_Content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + _changelog="$6" + + + # validate target before job + case "$_target_os" in + android|ios|js|illumos|plan9|wasip1) + return 10 # not supported in apt ecosystem yet + ;; + windows) + return 10 # not applicable + ;; + *) + ;; + esac + + case "$_target_arch" in + avr|wasm) + return 10 # not applicable + ;; + *) + ;; + esac + + _gpg_keyring="$PROJECT_SKU" + _package="$PROJECT_SKU" + if [ $(FS_Is_Target_A_Source "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Docs "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Library "$_target") -eq 0 ]; then + # copy main libary + # TIP: (1) usually is: usr/local/lib + # (2) please avoid: lib/, lib{TYPE}/ usr/lib/, and usr/lib{TYPE}/ + ___dest="${_directory}/data/usr/local/lib/${PROJECT_SKU}" + + I18N_Copy "$_target" "$___dest" + FS_Make_Directory "$___dest" + FS_Copy_File "$_target" "$___dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + _gpg_keyring="lib$PROJECT_SKU" + _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 + # TIP: (1) usually is: usr/local/bin or usr/local/sbin + # (2) please avoid: bin/, usr/bin/, sbin/, and usr/sbin/ + ___dest="${_directory}/data/usr/local/bin" + + I18N_Copy "$_target" "$___dest" + FS_Make_Directory "$___dest" + FS_Copy_File "$_target" "$___dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + fi + + + # NOTE: REQUIRED file + _changelog_path="${_directory}/data/usr/local/share/doc/${PROJECT_SKU}/changelog.gz" + if [ "$PROJECT_DEBIAN_IS_NATIVE" = "true" ]; then + _changelog_path="${_directory}/data/usr/share/doc/${PROJECT_SKU}/changelog.gz" + fi + + I18N_Create "$_changelog_path" + DEB_Create_Changelog "$_changelog_path" "$_changelog" "$PROJECT_SKU" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # NOTE: REQUIRED file + _copyright="${_directory}/data/usr/local/share/doc/${PROJECT_SKU}/copyright" + if [ "$PROJECT_DEBIAN_IS_NATIVE" = "true" ]; then + _copyright="${_directory}/data/usr/share/doc/${PROJECT_SKU}/copyright" + fi + + I18N_Create "$_copyright" + COPYRIGHT_Create \ + "$_copyright" \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/licenses/deb-copyright" \ + "$PROJECT_SKU" \ + "$PROJECT_CONTACT_NAME" \ + "$PROJECT_CONTACT_EMAIL" \ + "$PROJECT_CONTACT_WEBSITE" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # NOTE: REQUIRED file + _manual="${_directory}/data/usr/local/share/man/man1/${PROJECT_SKU}.1" + if [ "$PROJECT_DEBIAN_IS_NATIVE" = "true" ]; then + _manual="${_directory}/data/usr/share/man/man1/${PROJECT_SKU}.1" + fi + + I18N_Create "$_manual" + MANUAL_Create \ + "$_manual" \ + "$PROJECT_SKU" \ + "$PROJECT_CONTACT_NAME" \ + "$PROJECT_CONTACT_EMAIL" \ + "$PROJECT_CONTACT_WEBSITE" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # NOTE: REQUIRED file + I18N_Create "${_directory}/control/md5sum" + DEB_Create_Checksum "$_directory" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # NOTE: OPTIONAL (Comment to turn it off) + I18N_Create "${_directory}/source.list" + DEB_Create_Source_List \ + "$_directory" \ + "$PROJECT_GPG_ID" \ + "$PROJECT_STATIC_URL" \ + "$PROJECT_REPREPRO_CODENAME" \ + "$PROJECT_DEBIAN_DISTRIBUTION" \ + "$_gpg_keyring" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # WARNING: THIS REQUIRED FILE MUST BE THE LAST ONE + I18N_Create "${_directory}/control/control" + DEB_Create_Control \ + "$_directory" \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}" \ + "$_package" \ + "$PROJECT_VERSION" \ + "$_target_arch" \ + "$_target_os" \ + "$PROJECT_CONTACT_NAME" \ + "$PROJECT_CONTACT_EMAIL" \ + "$PROJECT_CONTACT_WEBSITE" \ + "$PROJECT_PITCH" \ + "$PROJECT_DEBIAN_PRIORITY" \ + "$PROJECT_DEBIAN_SECTION" \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/ABSTRACTS.txt" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/.src/.ci/_package-deb_windows-any.ps1 b/.src/.ci/_package-deb_windows-any.ps1 new file mode 100644 index 0000000..716a8ab --- /dev/null +++ b/.src/.ci/_package-deb_windows-any.ps1 @@ -0,0 +1,221 @@ +# 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" +. "${env:LIBS_AUTOMATACI}\services\compilers\copyright.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\deb.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\manual.ps1" + + + + +function PACKAGE-Assemble-DEB-Content { + param( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch, + [string]$_changelog + ) + + + # validate target before job + switch ($_target_os) { + { $_ -in "android", "ios", "js", "illumos", "plan9", "wasip1" } { + return 10 # not supported in apt ecosystem yet + } { $_ -in "windows" } { + return 10 # not applicable + } default { + # accepted + }} + + switch ($_target_arch) { + { $_ -in "avr", "wasm" } { + return 10 # not applicable + } default { + # accepted + }} + + $_gpg_keyring = "${env:PROJECT_SKU}" + $_package = "${env:PROJECT_SKU}" + if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Docs "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { + # copy main libary + # TIP: (1) usually is: usr/local/lib + # (2) please avoid: lib/, lib{TYPE}/ usr/lib/, and usr/lib{TYPE}/ + $___dest = "${_directory}\data\usr\local\lib\${env:PROJECT_SKU}" + + $null = I18N-Assemble "${_target}" "${___dest}" + $___process = FS-Make-Directory "${___dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $___process = FS-Copy-File "${_target}" "${___dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $_gpg_keyring = "lib${env:PROJECT_SKU}" + $_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 + # TIP: (1) usually is: usr/local/bin or usr/local/sbin + # (2) please avoid: bin/, usr/bin/, sbin/, and usr/sbin/ + $___dest = "${_directory}\data\usr\local\bin" + + $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 + } + } + + + # NOTE: REQUIRED file + $_changelog_path = "${_directory}\data\usr\local\share\doc\${env:PROJECT_SKU}\changelog.gz" + if ("${env:PROJECT_DEBIAN_IS_NATIVE}" -eq "true") { + $_changelog_path = "${_directory}\data\usr\share\doc\${env:PROJECT_SKU}\changelog.gz" + } + + $null = I18N-Create "${_changelog_path}" + $___process = DEB-Create-Changelog ` + "${_changelog_path}" ` + "${_changelog}" ` + "${env:PROJECT_SKU}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # NOTE: REQUIRED file + $_copyright = "${_directory}\data\usr\local\share\doc\${env:PROJECT_SKU}\copyright" + if ("${env:PROJECT_DEBIAN_IS_NATIVE}" -eq "true") { + $_copyright = "${_directory}\data\usr\share\doc\${env:PROJECT_SKU}\copyright" + } + + $null = I18N-Create "${_copyright}" + $___process = COPYRIGHT-Create ` + "${_copyright}" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses\deb-copyright" ` + "${env:PROJECT_SKU}" ` + "${env:PROJECT_CONTACT_NAME}" ` + "${env:PROJECT_CONTACT_EMAIL}" ` + "${env:PROJECT_CONTACT_WEBSITE}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # NOTE: REQUIRED file + $_manual = "${_directory}\data\usr\local\share\man\man1\${env:PROJECT_SKU}.1" + if ("${env:PROJECT_DEBIAN_IS_NATIVE}" -eq "true") { + $_manual = "${_directory}\data\usr\share\man\man1\${env:PROJECT_SKU}.1" + } + + $null = I18N-Create "${_manual}" + $___process = MANUAL-Create ` + "${_manual}" ` + "${env:PROJECT_DEBIAN_IS_NATIVE}" ` + "${env:PROJECT_SKU}" ` + "${env:PROJECT_CONTACT_NAME}" ` + "${env:PROJECT_CONTACT_EMAIL}" ` + "${env:PROJECT_CONTACT_WEBSITE}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # NOTE: REQUIRED file + $null = I18N-Create "${_directory}\control\md5sum" + $___process = DEB-Create-Checksum "${_directory}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # NOTE: OPTIONAL (Comment to turn it off) + $null = I18N-Create "source.list" + $___process = DEB-Create-Source-List ` + "${_directory}" ` + "${env:PROJECT_GPG_ID}" ` + "${env:PROJECT_STATIC_URL}" ` + "${env:PROJECT_REPREPRO_CODENAME}" ` + "${env:PROJECT_DEBIAN_DISTRIBUTION}" ` + "${_gpg_keyring}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # WARNING: THIS REQUIRED FILE MUST BE THE LAST ONE + $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}" ` + "${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_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\ABSTRACTS.txt" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/.src/.ci/_package-docker_unix-any.sh b/.src/.ci/_package-docker_unix-any.sh new file mode 100644 index 0000000..cf3e477 --- /dev/null +++ b/.src/.ci/_package-docker_unix-any.sh @@ -0,0 +1,139 @@ +#!/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" + + + + +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_os" in + linux|windows) + ;; + *) + return 10 + ;; + esac + + + # assemble the package + FS_Copy_File "$_target" "${_directory}/${PROJECT_SKU}" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Touch_File "${_directory}/.blank" + if [ $? -ne 0 ]; then + return 1 + fi + + + # 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 + + 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}>\" +LABEL org.opencontainers.image.version=\"${PROJECT_VERSION}\" +LABEL org.opencontainers.image.revision=\"${PROJECT_CADENCE}\" +LABEL org.opencontainers.image.licenses=\"${PROJECT_LICENSE}\" +" + + if [ $(STRINGS_Is_Empty "$PROJECT_CONTACT_WEBSITE") -ne 0 ]; then + FS_Append_File "${_directory}/Dockerfile" "\ +LABEL org.opencontainers.image.url=\"${PROJECT_CONTACT_WEBSITE}\" +" + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_SOURCE_URL") -ne 0 ]; then + FS_Append_File "${_directory}/Dockerfile" "\ +LABEL org.opencontainers.image.source=\"${PROJECT_SOURCE_URL}\" +" + fi + + 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} + +# Set network port exposures +EXPOSE 80 + +# Set entry point +ENTRYPOINT [\"/app/bin/${PROJECT_SKU}\"] +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/.src/.ci/_package-docker_windows-any.ps1 b/.src/.ci/_package-docker_windows-any.ps1 new file mode 100644 index 0000000..fdfedee --- /dev/null +++ b/.src/.ci/_package-docker_windows-any.ps1 @@ -0,0 +1,137 @@ +# 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" + + + + +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}") -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) { + 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 + } + + switch ($_target_os) { + { $_ -in 'linux', 'windows' } { + # accepted + } default { + return 10 + }} + + + # assemble the package + $___process = FS-Copy-File "${_target}" "${_directory}\${env:PROJECT_SKU}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Touch-File "${_directory}\.blank" + if ($___process -ne 0) { + return 1 + } + + + # 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 +"@ + } 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}>`" +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 ($(STRINGS-Is-Empty "${env:PROJECT_CONTACT_WEBSITE}") -ne 0) { + $___process = 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" @" +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} + +# Set network port exposures +EXPOSE 80 + +# Set entry point +ENTRYPOINT ["/app/bin/${PROJECT_SKU}"] +"@ + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/.src/.ci/_package-flatpak_unix-any.sh b/.src/.ci/_package-flatpak_unix-any.sh new file mode 100644 index 0000000..4c7a151 --- /dev/null +++ b/.src/.ci/_package-flatpak_unix-any.sh @@ -0,0 +1,220 @@ +#!/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_FLATPAK_Content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # validate target before job + case "$_target_arch" in + avr) + return 10 # not applicable + ;; + *) + ;; + 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 + 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 + elif [ ! "$_target_os" = "linux" ] && [ ! "$_target_os" = "any" ]; then + return 10 # not applicable + fi + + + # copy main program + _target="$1" + _filepath="${_directory}/${PROJECT_SKU}" + I18N_Copy "$_target" "$_filepath" + FS_Copy_File "$_target" "$_filepath" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + + # copy icon.svg + _target="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/icons/icon.svg" + _filepath="${_directory}/icon.svg" + I18N_Copy "$_target" "$_filepath" + FS_Copy_File "$_target" "$_filepath" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + + # copy icon-48x48.png + _target="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/icons/icon-48x48.png" + _filepath="${_directory}/icon-48x48.png" + I18N_Copy "$_target" "$_filepath" + FS_Copy_File "$_target" "$_filepath" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + + # copy icon-128x128.png + _target="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/icons/icon-128x128.png" + _filepath="${_directory}/icon-128x128.png" + I18N_Copy "$_target" "$_filepath" + FS_Copy_File "$_target" "$_filepath" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + + # [ COMPULSORY ] script manifest.yml + __file="${_directory}/manifest.yml" + I18N_Create "$__file" + FS_Write_File "$__file" "\ +app-id: ${PROJECT_APP_ID} +branch: ${_target_arch} +default-branch: any +command: ${PROJECT_SKU} +runtime: ${PROJECT_FLATPAK_RUNTIME} +runtime-version: '${PROJECT_FLATPAK_RUNTIME_VERSION}' +sdk: ${PROJECT_FLATPAK_SDK} +finish-args: + - \"--share=network\" + - \"--socket=pulseaudio\" + - \"--filesystem=home\" +modules: + - name: ${PROJECT_SKU}-main + buildsystem: simple + no-python-timestamp-fix: true + build-commands: + - install -D ${PROJECT_SKU} /app/bin/${PROJECT_SKU} + sources: + - type: file + path: ${PROJECT_SKU} + - name: ${PROJECT_SKU}-appdata + buildsystem: simple + build-commands: + - install -D appdata.xml /app/share/metainfo/${PROJECT_APP_ID}.appdata.xml + sources: + - type: file + path: appdata.xml + - name: ${PROJECT_SKU}-icon-svg + buildsystem: simple + build-commands: + - install -D icon.svg /app/share/icons/hicolor/scalable/apps/${PROJECT_SKU}.svg + sources: + - type: file + path: icon.svg + - name: ${PROJECT_SKU}-icon-48x48-png + buildsystem: simple + build-commands: + - install -D icon-48x48.png /app/share/icons/hicolor/48x48/apps/${PROJECT_SKU}.png + sources: + - type: file + path: icon-48x48.png + - name: ${PROJECT_SKU}-icon-128x128-png + buildsystem: simple + build-commands: + - install -D icon-128x128.png /app/share/icons/hicolor/128x128/apps/${PROJECT_SKU}.png + sources: + - type: file + path: icon-128x128.png +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # [ COMPULSORY ] script appdata.xml + __file="${_directory}/appdata.xml" + I18N_Create "$__file" + FS_Write_File "$__file" "\ + + + + ${PROJECT_APP_ID} + ${PROJECT_NAME} + ${PROJECT_PITCH} + web-browser + CC0-1.0 + ${PROJECT_LICENSE} + + + Network + Web + + + internet + web + browser + + ${PROJECT_CONTACT_WEBSITE} + ${PROJECT_CONTACT_WEBSITE} + + + Example Use + + ${PROJECT_CONTACT_WEBSITE}/screenshot-800x600.png + + + + + ${PROJECT_SKU} + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/.src/.ci/_package-flatpak_windows-any.ps1 b/.src/.ci/_package-flatpak_windows-any.ps1 new file mode 100644 index 0000000..574197e --- /dev/null +++ b/.src/.ci/_package-flatpak_windows-any.ps1 @@ -0,0 +1,222 @@ +# 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-FLATPAK-Content { + param( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # validate target before job + switch ($_target_arch) { + { $_ -in "avr" } { + return 10 # not applicable + } default { + # accepted + }} + + 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) { + 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 + } elseif (($_target_os -ne "linux") -and ($_target_os -ne "any")) { + return 10 # not applicable + } + + + # copy main program + $_filepath = "${_directory}\${env:PROJECT_SKU}" + $null = I18N-Copy "${_target}" "${_filepath}" + $___process = FS-Copy-File "${_target}" "${_filepath}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + + # copy icon.svg + $_target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}" + $_target = "${_target}\icons\icon.svg" + $_filepath = "${_directory}\icon.svg" + $null = I18N-Copy "${_target}" "${_filepath}" + $___process = FS-Copy-File "${_target}" "${_filepath}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + + # copy icon-48x48.png + $_target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}" + $_target = "${_target}\icons\icon-48x48.png" + $_filepath = "${_directory}\icon-48x48.png" + $null = I18N-Copy "${_target}" "${_filepath}" + $___process = FS-Copy-File "${_target}" "${_filepath}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + + # copy icon-128x128.png + $_target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}" + $_target = "${_target}\icons\icon-128x128.png" + $_filepath = "${_directory}\icon-128x128.png" + $null = I18N-Copy "${_target}" "${_filepath}" + $___process = FS-Copy-File "${_target}" "${_filepath}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + + # [ COMPULSORY ] script manifest.yml + $__file = "${_directory}\manifest.yml" + $null = I18N-Create "${__file}" + $___process = FS-Write-File "${__file}" @" +app-id: ${env:PROJECT_APP_ID} +branch: ${_target_arch} +default-branch: any +command: ${env:PROJECT_SKU} +runtime: ${env:PROJECT_FLATPAK_RUNTIME} +runtime-version: '${env:PROJECT_FLATPAK_RUNTIME_VERSION}' +sdk: ${env:PROJECT_FLATPAK_SDK} +finish-args: + - "--share=network" + - "--socket=pulseaudio" + - "--filesystem=home" +modules: + - name: ${env:PROJECT_SKU}-main + buildsystem: simple + no-python-timestamp-fix: true + build-commands: + - install -D ${env:PROJECT_SKU} /app/bin/${env:PROJECT_SKU} + sources: + - type: file + path: ${env:PROJECT_SKU} + - name: ${env:PROJECT_SKU}-appdata + buildsystem: simple + build-commands: + - install -D appdata.xml /app/share/metainfo/${env:PROJECT_APP_ID}.appdata.xml + sources: + - type: file + path: appdata.xml + - name: ${env:PROJECT_SKU}-icon-svg + buildsystem: simple + build-commands: + - install -D icon.svg /app/share/icons/hicolor/scalable/apps/${env:PROJECT_SKU}.svg + sources: + - type: file + path: icon.svg + - name: ${env:PROJECT_SKU}-icon-48x48-png + buildsystem: simple + build-commands: + - install -D icon-48x48.png /app/share/icons/hicolor/48x48/apps/${env:PROJECT_SKU}.png + sources: + - type: file + path: icon-48x48.png + - name: ${env:PROJECT_SKU}-icon-128x128-png + buildsystem: simple + build-commands: + - install -D icon-128x128.png /app/share/icons/hicolor/128x128/apps/${env:PROJECT_SKU}.png + sources: + - type: file + path: icon-128x128.png +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # [ COMPULSORY ] script appdata.xml + $__file = "${_directory}\appdata.xml" + $null = I18N-Create "${__file}" + $___process = FS-Write-File "${__file}" @" + + + + ${env:PROJECT_APP_ID} + ${env:PROJECT_NAME} + ${env:PROJECT_PITCH} + web-browser + CC0-1.0 + ${env:PROJECT_LICENSE} + + + Network + Web + + + internet + web + browser + + ${env:PROJECT_CONTACT_WEBSITE} + ${env:PROJECT_CONTACT_WEBSITE} + + + Example Use + + ${env:PROJECT_CONTACT_WEBSITE}/screenshot-800x600.png + + + + + ${env:PROJECT_SKU} + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/.src/.ci/_package-homebrew_unix-any.sh b/.src/.ci/_package-homebrew_unix-any.sh new file mode 100644 index 0000000..44d5528 --- /dev/null +++ b/.src/.ci/_package-homebrew_unix-any.sh @@ -0,0 +1,36 @@ +#!/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 + + + + +PACKAGE_Assemble_HOMEBREW_Content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # execute + return 10 # not applicable - should be tech-oriented. +} diff --git a/.src/.ci/_package-homebrew_windows-any.ps1 b/.src/.ci/_package-homebrew_windows-any.ps1 new file mode 100644 index 0000000..1b84546 --- /dev/null +++ b/.src/.ci/_package-homebrew_windows-any.ps1 @@ -0,0 +1,37 @@ +# 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 +} + + + + +function PACKAGE-Assemble-HOMEBREW-Content { + param ( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # execute + return 10 # not applicable - should be tech-oriented. +} diff --git a/.src/.ci/_package-ipk_unix-any.sh b/.src/.ci/_package-ipk_unix-any.sh new file mode 100644 index 0000000..4e323d5 --- /dev/null +++ b/.src/.ci/_package-ipk_unix-any.sh @@ -0,0 +1,123 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/ipk.sh" + + + + +PACKAGE_Assemble_IPK_Content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # validate target before job + case "$_target_arch" in + avr|wasm) + return 10 # not applicable + ;; + *) + ;; + esac + + _gpg_keyring="$PROJECT_SKU" + _package="$PROJECT_SKU" + if [ $(FS_Is_Target_A_Source "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Docs "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Library "$_target") -eq 0 ]; then + # copy main libary + # TIP: (1) usually is: usr/local/lib + # (2) please avoid: lib/, lib{TYPE}/ usr/lib/, and usr/lib{TYPE}/ + ___dest="${_directory}/data/usr/local/lib/${PROJECT_SKU}" + I18N_Copy "$_target" "$___dest" + FS_Make_Directory "$___dest" + FS_Copy_File "$_target" "$___dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + _gpg_keyring="lib$PROJECT_SKU" + _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 + # TIP: (1) usually is: usr/local/bin or usr/local/sbin + # (2) please avoid: bin/, usr/bin/, sbin/, and usr/sbin/ + ___dest="${_directory}/data/usr/local/bin" + + I18N_Assemble "$_target" "$___dest" + FS_Make_Directory "$___dest" + FS_Copy_File "$_target" "$___dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + fi + + + # WARNING: THIS REQUIRED FILE MUST BE THE LAST ONE + I18N_Create "control/control" + IPK_Create_Control \ + "$_directory" \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}" \ + "$_package" \ + "$PROJECT_VERSION" \ + "$_target_arch" \ + "$_target_os" \ + "$PROJECT_CONTACT_NAME" \ + "$PROJECT_CONTACT_EMAIL" \ + "$PROJECT_CONTACT_WEBSITE" \ + "$PROJECT_PITCH" \ + "$PROJECT_DEBIAN_PRIORITY" \ + "$PROJECT_DEBIAN_SECTION" \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/ABSTRACTS.txt" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/.src/.ci/_package-ipk_windows-any.ps1 b/.src/.ci/_package-ipk_windows-any.ps1 new file mode 100644 index 0000000..2ce9eb3 --- /dev/null +++ b/.src/.ci/_package-ipk_windows-any.ps1 @@ -0,0 +1,122 @@ +# 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\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\deb.ps1" + + + + +function PACKAGE-Assemble-IPK-Content { + param( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # validate target before job + switch ($_target_arch) { + { $_ -in "avr", "wasm" } { + return 10 # not applicable + } default { + # accepted + }} + + $_gpg_keyring = "${env:PROJECT_SKU}" + $_package = "${env:PROJECT_SKU}" + if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Docs "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { + # copy main libary + # TIP: (1) usually is: usr/local/lib + # (2) please avoid: lib/, lib{TYPE}/ usr/lib/, and usr/lib{TYPE}/ + $___dest = "${_directory}\data\usr\local\lib\${env:PROJECT_SKU}" + + $null = I18N-Assemble "${_target}" "${___dest}" + $null = FS-Make-Directory "${___dest}" + $___process = FS-Copy-File "${_target}" "${___dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $_gpg_keyring = "lib${env:PROJECT_SKU}" + $_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-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 + # TIP: (1) usually is: usr/local/bin or usr/local/sbin + # (2) please avoid: bin/, usr/bin/, sbin/, and usr/sbin/ + $___dest = "${_directory}\data\usr\local\bin" + + $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 + } + } + + + # WARNING: THIS REQUIRED FILE MUST BE THE LAST ONE + $null = I18N-Create "control\control" + $___process = IPK-Create-Control ` + "${_directory}" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}" ` + "${_package}" ` + "${env:PROJECT_VERSION}" ` + "${_target_arch}" ` + "${_target_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_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\ABSTRACTS.txt" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/.src/.ci/_package-msi_unix-any.sh b/.src/.ci/_package-msi_unix-any.sh new file mode 100644 index 0000000..06c9b83 --- /dev/null +++ b/.src/.ci/_package-msi_unix-any.sh @@ -0,0 +1,630 @@ +#!/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" +. "${LIBS_AUTOMATACI}/services/crypto/random.sh" + + + + +PACKAGE_Assemble_MSI_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_MSI "$_target") -ne 0 ]; then + return 10 # not applicable + fi + + + # validate critical inputs + if [ -z "$PRODUCT_APP_UUID" ]; then + return 1 + fi + + + # Assemble all files across all languages. Checking is not required + # since it will be checked during the scripting phase. + __build_path="${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}" + __source_path="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}" + __files="\ +${__build_path}/${PROJECT_SKU}_windows-amd64.exe|none +${__build_path}/${PROJECT_SKU}_windows-arm64.exe|none +${__build_path}/${PROJECT_SKU}_windows-i386.exe|none +${__build_path}/${PROJECT_SKU}_windows-arm.exe|none +${__source_path}/licenses/LICENSE_en.rtf|LICENSE_en.rtf +${__source_path}/licenses/LICENSE_en.rtf|LICENSE_zh-hans.rtf +${__source_path}/licenses/LICENSE-EN.pdf|LICENSE_en.pdf +${__source_path}/licenses/LICENSE-EN.pdf|LICENSE_zh-hans.pdf +${__source_path}/docs/USER-GUIDES-EN.pdf|USER-GUIDES_en.pdf +${__source_path}/docs/USER-GUIDES-EN.pdf|USER-GUIDES_zh-hans.pdf +${__source_path}/icons/icon.ico|none +${__source_path}/icons/msi-banner_en.jpg|none +${__source_path}/icons/msi-banner_zh-hans.jpg|none +${__source_path}/icons/msi-dialog_en.jpg|none +${__source_path}/icons/msi-dialog_zh-hans.jpg|none +" + __selections="\ +amd64|en +amd64|zh-hans +arm64|en +arm64|zh-hans +i386|en +i386|zh-hans +arm|en +arm|zh-hans +" + + + # Assemble all files across all languages. Checking is not required + # since it will be checked during the scripting phase. + old_IFS="$IFS" + printf -- '%s' "$__files" | while IFS="" read -r __line || [ -n "$__line" ]; do + ## parse line + __target="${__line%%|*}" + __dest="${__line##*|}" + + ## validate inputs + if [ ! -z "$_dest" ] && [ ! "$__dest" = "none" ]; then + __dest="${_directory}/${__dest}" + else + __dest="$_directory" + fi + + ## execute + I18N_Assemble "$__target" "$__dest" + if [ -e "$__target" ]; then + FS_Copy_File "$__target" "$__dest" &> /dev/null + fi + done + IFS="$__old_IFS" && unset __old_IFS + + + # generate all arch & i18n independent variables and tags + __tag_ICON='Icon.exe' + __const_ICON_SOURCE="${_directory}/icon.ico" + + __tag_DIR_INSTALL='INSTALLDIR' + __tag_ARP_INSTALL_LOCATION='ARPINSTALLLOCATION' + __const_INSTALLER_VERSION='400' # Windows Installer 4.0 (included in Vista) + __const_INSTALLER_COMPRESSED_MODE='yes' # 'yes'|'no' only + __const_INSTALLER_INSTALL_SCOPE='perMachine' + __const_INSTALLER_REGISTRY_KEY="\ +Software\\\\${PROJECT_CONTACT_NAME}\\\\InstalledProducts\\\\${PROJECT_NAME}" + __const_INSTALLER_REGISTRY_NAME='InstallLocation' + + __tag_COMPONENT_BIN='ComponentBin' + __uuid_COMPONENT_BIN="$(RANDOM_Create_UUID)" # replace with persistent one + __tag_COMPONENT_BIN_OPTIONAL='ComponentBinOptional' + __uuid_COMPONENT_BIN_OPTIONAL="$(RANDOM_Create_UUID)" # replace with persistent one + __tag_COMPONENT_CONFIG='ComponentConfig' + __uuid_COMPONENT_CONFIG="$(RANDOM_Create_UUID)" # replace with persistent one + __tag_COMPONENT_CONFIG_OPTIONAL='ComponentConfigOptional' + __uuid_COMPONENT_CONFIG_OPTIONAL="$(RANDOM_Create_UUID)" # replace with persistent one + __tag_COMPONENT_LIB='ComponentLib' + __uuid_COMPONENT_LIB="$(RANDOM_Create_UUID)" # replace with persistent one + __tag_COMPONENT_LIB_OPTIONAL='ComponentLibOptional' + __uuid_COMPONENT_LIB_OPTIONAL="$(RANDOM_Create_UUID)" # replace with persistent one + __tag_COMPONENT_DOCS='ComponentDocs' + __uuid_COMPONENT_DOCS="$(RANDOM_Create_UUID)" # replace with persistent one + __tag_COMPONENT_DOCS_OPTIONAL='ComponentDocsOptional' + __uuid_COMPONENT_DOCS_OPTIONAL="$(RANDOM_Create_UUID)" # replace with persistent one + + __tag_COMPONENT_INSTALLER='INSTALLDIR_comp' + __uuid_COMPONENT_INSTALLER="$(RANDOM_Create_UUID)" # replace with persistent one + __tag_COMPONENT_REGISTRIES='RegValInstallLocation_comp' + __uuid_COMPONENT_REGISTRIES="$(RANDOM_Create_UUID)" # replace with persistent one + + __tag_FEATURE_ID='FeaturesAll' + __tag_FEATURE_MAIN_ID='FeaturesMain' + __tag_FEATURE_BIN_ID='FeaturesBin' + __tag_FEATURE_CONFIG_ID='FeaturesConfig' + __tag_FEATURE_LIB_ID='FeaturesLib' + __tag_FEATURE_DOCS_ID='FeaturesDocs' + + + # script the .wxs XML file (MSItools version) + old_IFS="$IFS" + printf -- '%s' "$__selections" | while IFS="" read -r __line || [ -n "$__line" ]; do + # parse line + __arch="$(STRINGS_To_Lowercase "${__line%%|*}")" + __line="${__line#*|}" + + __i18n="$(STRINGS_To_Lowercase "${__line%%|*}")" + __line="${__line#*|}" + + + # generate all arch-specific variables and validate readiness for compilation + case "$__arch" in + amd64) + __var_DIR_PROGRAM_FILES="ProgramFiles64Folder" + __var_INSTALLER_REQUIRED_VERSION_ERROR_MESSAGE="\ +Unfortunately, you can only install this package on a 64-bit Windows." + __var_INSTALLER_REQUIRED_VERSION_CONDITION="" + ;; + arm64) + __var_DIR_PROGRAM_FILES="ProgramFiles64Folder" + __var_INSTALLER_REQUIRED_VERSION_ERROR_MESSAGE="\ +Unfortunately, you can only install this package on a 64-bit Windows." + __var_INSTALLER_REQUIRED_VERSION_CONDITION="" + ;; + i386) + __var_DIR_PROGRAM_FILES="ProgramFilesFolder" + __var_INSTALLER_REQUIRED_VERSION_ERROR_MESSAGE="\ +Unfortunately, you can only install this package on a 32-bit Windows." + __var_INSTALLER_REQUIRED_VERSION_CONDITION="" + ;; + arm) + __var_DIR_PROGRAM_FILES="ProgramFilesFolder" + __var_INSTALLER_REQUIRED_VERSION_ERROR_MESSAGE="\ +Unfortunately, you can only install this package on a 32-bit Windows." + __var_INSTALLER_REQUIRED_VERSION_CONDITION="" + ;; + *) + return 1 + ;; + esac + + + # check required executables for packaging + __var_MAIN_EXE_SOURCE="${_directory}/${PROJECT_SKU}_windows-${__arch}.exe" + I18N_Check "${__var_MAIN_EXE_SOURCE}" + FS_Is_File "$__var_MAIN_EXE_SOURCE" + if [ $? -ne 0 ]; then + I18N_Check_Failed_Skipped + continue + fi + + + # generate all i18n variables and validate readiness for compilation + _wxs="${PROJECT_SKU}_${PROJECT_VERSION}" + case "$__i18n" in + zh-hans) + ## Simplified Chinese (International) + __i18n="zh-hans" + + ## NOTE: MSFT uses LCID instead of ISO indicator. Refer: + ## https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f + __var_LANGUAGE_ID='2052' + + ## NOTE: DO NOT change the format. AutomataCI relies on + ## it to parse wix4 culture settings. + ## https://wixtoolset.org/docs/tools/wixext/wixui/#localization + _wxs="${_wxs}_zh-CN" + + __var_INSTALLER_DESCRIPTION="\ +${PROJECT_NAME} (${PROJECT_VERSION}) 安装包" + __var_INSTALLER_COMMENTS="(C) ${PROJECT_CONTACT_NAME}" + + __var_INSTALLER_BANNER_SOURCE="${_directory}/msi-banner_${__i18n}.jpg" + __var_INSTALLER_DIALOG_SOURCE="${_directory}/msi-dialog_${__i18n}.jpg" + + __var_INSTALLER_DOWNGRADE_COMMENT="\ +您的${PROJECT_NAME}已经是同样|更新版本。如此就不需要任何步骤了。谢谢。 +" + + __var_MAIN_LICENSE_SOURCE="${_directory}/LICENSE_zh-hans.pdf" + + __var_USER_GUIDE_ID='DocsUserGuideZHHANS' + __var_USER_GUIDE_SOURCE="${_directory}/USER-GUIDES_zh-hans.pdf" + + __var_FEATURE_TITLE="${PROJECT_NAME}" + __var_FEATURE_DESCRIPTION='完整全部包装。' + + __var_FEATURE_MAIN_TITLE='主要元件配套' + __var_FEATURE_MAIN_DESCRIPTION='所有第一重要无法缺乏的元件。' + + __var_FEATURE_BIN_TITLE='软件类元件配套' + __var_FEATURE_BIN_DESCRIPTION='所有可有可无的可多加软件类元件。' + + __var_FEATURE_CONFIG_TITLE='配置类元件配套' + __var_FEATURE_CONFIG_DESCRIPTION='所有可有可无的可多加配置类元件。' + + __var_FEATURE_LIB_TITLE='代码库类元件配套' + __var_FEATURE_LIB_DESCRIPTION='所有可有可无的可多加代码库类元件。' + + __var_FEATURE_DOCS_TITLE='文件类元件配套' + __var_FEATURE_DOCS_DESCRIPTION='所有可有可无的可多加文件类元件。' + ;; + *) + # default to English (International) + __i18n="en" + + ## NOTE: MSFT uses LCID instead of ISO indicator. Refer: + ## https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f + __var_LANGUAGE_ID='1033' + + ## NOTE: DO NOT change the format. AutomataCI relies on + ## it to parse wix4 culture settings. + ## https://wixtoolset.org/docs/tools/wixext/wixui/#localization + _wxs="${_wxs}_en-US" + + __var_INSTALLER_DESCRIPTION="\ +${PROJECT_NAME} (${PROJECT_VERSION}) Installer" + __var_INSTALLER_COMMENTS="(C) ${PROJECT_CONTACT_NAME}" + + __var_INSTALLER_BANNER_SOURCE="${_directory}/msi-banner_${__i18n}.jpg" + __var_INSTALLER_DIALOG_SOURCE="${_directory}/msi-dialog_${__i18n}.jpg" + + __var_INSTALLER_DOWNGRADE_COMMENT="\ +Your ${PROJECT_NAME} is the same/later version. No further action is required. Thank you. +" + + __var_MAIN_LICENSE_SOURCE="${_directory}/LICENSE_en.pdf" + + __var_USER_GUIDE_ID='DocsUserGuideEN' + __var_USER_GUIDE_SOURCE="${_directory}/USER-GUIDES_en.pdf" + + __var_FEATURE_TITLE="${PROJECT_NAME}" + __var_FEATURE_DESCRIPTION='The complete package.' + + __var_FEATURE_MAIN_TITLE='Main Components' + __var_FEATURE_MAIN_DESCRIPTION='All core and critical components.' + + __var_FEATURE_BIN_TITLE='Additional Components' + __var_FEATURE_BIN_DESCRIPTION='All optional addition components.' + + __var_FEATURE_CONFIG_TITLE='Additional Configurations Components' + __var_FEATURE_CONFIG_DESCRIPTION='All optional configurations components.' + + __var_FEATURE_LIB_TITLE='Additional Libraries Components' + __var_FEATURE_LIB_DESCRIPTION='All optional libraries components.' + + __var_FEATURE_DOCS_TITLE='Documentation Components' + __var_FEATURE_DOCS_DESCRIPTION='All documentations components.' + ;; + esac + _wxs="${_directory}/${_wxs}_windows-${__arch}.wxs" + + + # check required files for packaging + I18N_Check "$__var_MAIN_LICENSE_SOURCE" + FS_Is_File "$__var_MAIN_LICENSE_SOURCE" + if [ $? -ne 0 ]; then + I18N_Check_Failed_Skipped + continue + fi + + I18N_Check "$__var_USER_GUIDE_SOURCE" + FS_Is_File "$__var_USER_GUIDE_SOURCE" + if [ $? -ne 0 ]; then + I18N_Check_Failed_Skipped + continue + fi + + I18N_Check "$_wxs" + FS_Is_File "$_wxs" + if [ $? -eq 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # creating wxs recipe + I18N_Create "$_wxs" + FS_Write_File "$_wxs" "\ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMDLINE_${__tag_DIR_INSTALL} + + + + + + CMDLINE_${__tag_DIR_INSTALL} + + + + + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # Assemble Components + FS_Append_File "$_wxs" "\ + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + if [ "$__packager_type" = "full" ]; then + FS_Append_File "$_wxs" "\ + + + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + fi + + + FS_Append_File "$_wxs" "\ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + FS_Append_File "$_wxs" "\ + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + FS_Append_File "$_wxs" "\ + + + + + + + + + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # Define all feature components + FS_Append_File "$_wxs" "\ + + + + + + + + + + + + + + + + + + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # conclude the wxs write-up + FS_Append_File "$_wxs" "\ + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + done + __exit=$? + IFS="$__old_IFS" && unset __old_IFS + + case "$__exit" in + 0) + ;; + *) + return $__exit + ;; + esac + + + # report status + return 0 +} diff --git a/.src/.ci/_package-msi_windows-any.ps1 b/.src/.ci/_package-msi_windows-any.ps1 new file mode 100644 index 0000000..7105ba2 --- /dev/null +++ b/.src/.ci/_package-msi_windows-any.ps1 @@ -0,0 +1,714 @@ +#!/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 (-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" +. "${env:LIBS_AUTOMATACI}\services\crypto\random.ps1" +. "${env:LIBS_AUTOMATACI}\services\publishers\dotnet.ps1" + + + + +function PACKAGE-Assemble-MSI-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-MSI "${_target}") -ne 0) { + return 10 # not applicable + } + + + # validate critical inputs + if ($(STRINGS-Is-Empty "${env:PRODUCT_APP_UUID}") -eq 0) { + return 1 + } + + + # configure packaging settings + $__build_path = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}" + $__source_path = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}" + $__files = @( + "${__build_path}\${env:PROJECT_SKU}_windows-amd64.exe|none" + "${__build_path}\${env:PROJECT_SKU}_windows-arm64.exe|none" + "${__build_path}\${env:PROJECT_SKU}_windows-i386.exe|none" + "${__build_path}\${env:PROJECT_SKU}_windows-arm.exe|none" + "${__source_path}\licenses\LICENSE_en.rtf|LICENSE_en.rtf" + "${__source_path}\licenses\LICENSE_en.rtf|LICENSE_zh-hans.rtf" + "${__source_path}\licenses\LICENSE-EN.pdf|LICENSE_en.pdf" + "${__source_path}\licenses\LICENSE-EN.pdf|LICENSE_zh-hans.pdf" + "${__source_path}\docs\USER-GUIDES-EN.pdf|USER-GUIDES_en.pdf" + "${__source_path}\docs\USER-GUIDES-EN.pdf|USER-GUIDES_zh-hans.pdf" + "${__source_path}\icons\icon.ico|none" + "${__source_path}\icons\msi-banner_en.jpg|none" + "${__source_path}\icons\msi-banner_zh-hans.jpg|none" + "${__source_path}\icons\msi-dialog_en.jpg|none" + "${__source_path}\icons\msi-dialog_zh-hans.jpg|none" + ) + $__selections = @( + "amd64|en" + "amd64|zh-hans" + "arm64|en" + "arm64|zh-hans" + ) + + + # download required UI extensions + $__toolkit_ui = 'WixToolset.UI.wixext' + $___process = DOTNET-Add ` + "${__toolkit_ui}" ` + "4.0.3" ` + "${_directory}\ext" ` + "wixext4\${__toolkit_ui}.dll" + if ($___process -ne 0) { + return 1 + } + + + # Assemble all files across all languages. Checking is not required + # since it will be checked during the scripting phase. + foreach ($__line in $__files) { + ## parse line + $__list = $__line -split "\|" + $__target = $__list[0] + $__dest = $__list[1] + + ## validate inputs + if (($(STRINGS-Is-Empty "${__dest}") -ne 0) -and ("${__dest}" -ne "none")) { + $__dest = "${_directory}\${__dest}" + } else { + $__dest = "${_directory}" + } + + ## execute + $null = I18N-Assemble "${__target}" "${__dest}" + if (Test-Path "${__target}") { + $null = FS-Copy-File "${__target}" "${__dest}" ` + -ErrorAction SilentlyContinue + } + } + + + # generate all arch & i18n independent variables and tags + $__tag_ICON = 'Icon.exe' + $__const_ICON_SOURCE = "${_directory}\icon.ico" + + $__tag_DIR_INSTALL = 'INSTALLDIR' + $__tag_ARP_INSTALL_LOCATION = 'ARPINSTALLLOCATION' + $__const_INSTALLER_VERSION = '500' + $__const_INSTALLER_COMPRESSED_MODE = 'yes' # 'yes'|'no' only + $__const_INSTALLER_CODEPAGE = '65001' # UTF-8 + $__const_INSTALLER_INSTALL_SCOPE = 'perMachine' + $__const_INSTALLER_REGISTRY_KEY = @" +Software\\\\${env:PROJECT_CONTACT_NAME}\\\\InstalledProducts\\\\${env:PROJECT_NAME} +"@ + $__const_INSTALLER_REGISTRY_NAME = 'InstallLocation' + + $__tag_COMPONENT_BIN = 'ComponentBin' + $__uuid_COMPONENT_BIN = RANDOM-Create-UUID # replace with persistent one + $__tag_COMPONENT_BIN_OPTIONAL = 'ComponentBinOptional' + $__uuid_COMPONENT_BIN_OPTIONAL = Random-Create-UUID # replace with persistent one + $__tag_COMPONENT_CONFIG = 'ComponentConfig' + $__uuid_COMPONENT_CONFIG = RANDOM-Create-UUID # replace with persistent one + $__tag_COMPONENT_CONFIG_OPTIONAL = 'ComponentConfigOptional' + $__uuid_COMPONENT_CONFIG_OPTIONAL = RANDOM-Create-UUID # replace with persistent one + $__tag_COMPONENT_LIB = 'ComponentLib' + $__uuid_COMPONENT_LIB = RANDOM-Create-UUID # replace with persistent one + $__tag_COMPONENT_LIB_OPTIONAL = 'ComponentLibOptional' + $__uuid_COMPONENT_LIB_OPTIONAL = RANDOM-Create-UUID # replace with persistent one + $__tag_COMPONENT_DOCS = 'ComponentDocs' + $__uuid_COMPONENT_DOCS = RANDOM-Create-UUID # replace with persistent one + $__tag_COMPONENT_DOCS_OPTIONAL = 'ComponentDocsOptional' + $__uuid_COMPONENT_DOCS_OPTIONAL = RANDOM-Create-UUID # replace with persistent one + + $__tag_COMPONENT_INSTALLER = 'INSTALLDIR_comp' + $__uuid_COMPONENT_INSTALLER = RANDOM-Create-UUID # replace with persistent one + $__tag_COMPONENT_REGISTRIES = 'ComponentRegistries' + $__uuid_COMPONENT_REGISTRIES = RANDOM-Create-UUID # replace with persistent one + + $__tag_FEATURE_ID = 'FeaturesAll' + $__tag_FEATURE_MAIN_ID = 'FeaturesMain' + $__tag_FEATURE_BIN_ID = 'FeaturesBin' + $__tag_FEATURE_CONFIG_ID = 'FeaturesConfig' + $__tag_FEATURE_LIB_ID = 'FeaturesLib' + $__tag_FEATURE_DOCS_ID = 'FeaturesDocs' + + $__const_OPTIONALITY = " AllowAbsent='yes'" + $__const_DIR_PROGRAM_FILES = "ProgramFiles6432Folder" + + + # script the .wxs XML file + foreach ($__line in $__selections) { + # parse line + $__list = $__line -split "\|" + $__arch = STRINGS-To-Lowercase $__list[0] + $__i18n = STRINGS-To-Lowercase $__list[1] + + + # generate all arch-specific variables and validate readiness for compilation + switch ($__arch) { + amd64 { + $__var_INSTALLER_REQUIRED_VERSION_ERROR_MESSAGE = @" +Unfortunately, you can only install this package on a 64-bit Windows. +"@ + $__var_INSTALLER_REQUIRED_VERSION_CONDITION = "VersionNT64" + } arm64 { + $__var_INSTALLER_REQUIRED_VERSION_ERROR_MESSAGE = @" +Unfortunately, you can only install this package on a 64-bit Windows. +"@ + $__var_INSTALLER_REQUIRED_VERSION_CONDITION = "VersionNT64" + } i386 { + $__var_INSTALLER_REQUIRED_VERSION_ERROR_MESSAGE = @" +Unfortunately, you can only install this package on a 32-bit Windows. +"@ + $__var_INSTALLER_REQUIRED_VERSION_CONDITION = "Not VersionNT64" + } arm { + $__var_INSTALLER_REQUIRED_VERSION_ERROR_MESSAGE = @" +Unfortunately, you can only install this package on a 32-bit Windows. +"@ + $__var_INSTALLER_REQUIRED_VERSION_CONDITION = "Not VersionNT64" + } default { + return 1 + }} + + + # check required executables for packaging + $__var_MAIN_EXE_SOURCE = "${_directory}\${env:PROJECT_SKU}_windows-${__arch}.exe" + $null = I18N-Check "${__var_MAIN_EXE_SOURCE}" + $___process = FS-Is-File "${__var_MAIN_EXE_SOURCE}" + if ($___process -ne 0) { + $null = I18N-Check-Failed-Skipped + continue + } + + + # generate all i18n variables and validate readiness for compilation + $_wxs = "${env:PROJECT_SKU}_${env:PROJECT_VERSION}" + switch ($__i18n) { + zh-hans { + ## Simplified Chinese (International) + $__i18n = "zh-hans" + + ## NOTE: MSFT uses LCID instead of ISO indicator. Refer: + ## https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f + $__var_LANGUAGE_ID = '2052' + + ## NOTE: DO NOT change the format. AutomataCI relies on + ## it to parse wix4 culture settings. + ## https://wixtoolset.org/docs/tools/wixext/wixui/#localization + $_wxs = "${_wxs}_zh-cn" + + $__var_INSTALLER_DESCRIPTION = @" +${env:PROJECT_NAME} (${env:PROJECT_VERSION}) 安装包 +"@ + $__var_INSTALLER_COMMENTS = "(C) ${env:PROJECT_CONTACT_NAME}" + $__var_INSTALLER_BANNER_SOURCE = "${_directory}\msi-banner_${__i18n}.jpg" + $__var_INSTALLER_DIALOG_SOURCE = "${_directory}\msi-dialog_${__i18n}.jpg" + $__var_INSTALLER_DOWNGRADE_COMMENT = @" +您的${env:PROJECT_NAME}已经是同样|更新版本。如此就不需要任何步骤了。谢谢。 +"@ + $__var_MAIN_LICENSE_SOURCE = "${_directory}\LICENSE_zh-hans.pdf" + + $__var_USER_GUIDE_ID = 'DocsUserGuideZHHANS' + $__var_USER_GUIDE_SOURCE = "${_directory}\USER-GUIDES_zh-hans.pdf" + + $__var_FEATURE_TITLE = "${env:PROJECT_NAME}" + $__var_FEATURE_DESCRIPTION = '完整全部包装。' + + $__var_FEATURE_MAIN_TITLE = '主要元件配套' + $__var_FEATURE_MAIN_DESCRIPTION = '所有第一重要无法缺乏的元件。' + + $__var_FEATURE_BIN_TITLE = '软件类元件配套' + $__var_FEATURE_BIN_DESCRIPTION = '所有可有可无的可多加软件类元件。' + + $__var_FEATURE_CONFIG_TITLE = '配置类元件配套' + $__var_FEATURE_CONFIG_DESCRIPTION = '所有可有可无的可多加配置类元件。' + + $__var_FEATURE_LIB_TITLE = '代码库类元件配套' + $__var_FEATURE_LIB_DESCRIPTION = '所有可有可无的可多加代码库类元件。' + + $__var_FEATURE_DOCS_TITLE = '文件类元件配套' + $__var_FEATURE_DOCS_DESCRIPTION = '所有可有可无的可多加文件类元件。' + } default { + ## default to English (International) + $__i18n = "en" + + ## NOTE: MSFT uses LCID instead of ISO indicator. Refer: + ## https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f + $__var_LANGUAGE_ID = '1033' + + ## NOTE: DO NOT change the format. AutomataCI relies on + ## it to parse wix4 culture settings. Refer: + ## https://wixtoolset.org/docs/tools/wixext/wixui/#localization + $_wxs = "${_wxs}_en-us" + + $__var_INSTALLER_DESCRIPTION=@" +${env:PROJECT_NAME} (${env:PROJECT_VERSION}) Installer +"@ + $__var_INSTALLER_COMMENTS = "(C) ${env:PROJECT_CONTACT_NAME}" + + $__var_INSTALLER_BANNER_SOURCE = "${_directory}\msi-banner_${__i18n}.jpg" + $__var_INSTALLER_DIALOG_SOURCE = "${_directory}\msi-dialog_${__i18n}.jpg" + + $__var_INSTALLER_DOWNGRADE_COMMENT = @" +Your ${env:PROJECT_NAME} is the same/later version. No further action is required. Thank you. +"@ + + $__var_MAIN_LICENSE_SOURCE = "${_directory}\LICENSE_en.pdf" + + $__var_USER_GUIDE_ID = 'DocsUserGuideEN' + $__var_USER_GUIDE_SOURCE = "${_directory}\USER-GUIDES_en.pdf" + + $__var_FEATURE_TITLE = "${env:PROJECT_NAME}" + $__var_FEATURE_DESCRIPTION = 'The complete package.' + + $__var_FEATURE_MAIN_TITLE = 'Main Components' + $__var_FEATURE_MAIN_DESCRIPTION = 'All core and critical components.' + + $__var_FEATURE_BIN_TITLE = 'Additional Components' + $__var_FEATURE_BIN_DESCRIPTION = 'All optional addition components.' + + $__var_FEATURE_CONFIG_TITLE = 'Additional Configurations Components' + $__var_FEATURE_CONFIG_DESCRIPTION = 'All optional configurations components.' + + $__var_FEATURE_LIB_TITLE = 'Additional Libraries Components' + $__var_FEATURE_LIB_DESCRIPTION = 'All optional libraries components.' + + $__var_FEATURE_DOCS_TITLE = 'Documentation Components' + $__var_FEATURE_DOCS_DESCRIPTION = 'All documentations components.' + }} + $__var_UI_LICENSE_SOURCE = "${_directory}\LICENSE_${__i18n}.rtf" + $_wxs = "${_directory}\${_wxs}_windows-${__arch}.wxs" + + + # check required files for packaging + $null = I18N-Check "${__var_MAIN_LICENSE_SOURCE}" + $___process = FS-Is-File "${__var_MAIN_LICENSE_SOURCE}" + if ($___process -ne 0) { + $null = I18N-Check-Failed-Skipped + continue + } + + $null = I18N-Check "${__var_USER_GUIDE_SOURCE}" + $___process = FS-Is-File "${__var_USER_GUIDE_SOURCE}" + if ($___process -ne 0) { + $null = I18N-Check-Failed-Skipped + continue + } + + $null = I18N-Check "${__var_UI_LICENSE_SOURCE}" + $___process = FS-Is-File "${__var_UI_LICENSE_SOURCE}" + if ($___process -ne 0) { + $null = I18N-Check-Failed-Skipped + continue + } + + $null = I18N-Check "${_wxs}" + if (Test-Path "${_wxs}") { + $null = I18N-Check-Failed + return 1 + } + + + # creating wxs recipe + $null = I18N-Create "${_wxs}" + $___process = FS-Write-File "${_wxs}" @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # Define filesystem + $___process = FS-Append-File "${_wxs}" @" + + + + + + + + + + + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + ## BEGIN - Assemble components + $___process = FS-Append-File "${_wxs}" @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # create registry key + $___process = FS-Append-File "${_wxs}" @" + + + + + + + + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # Define all feature components + $___process = FS-Append-File "${_wxs}" @" + + + + + + + + + + + + + + + + + + + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # Add standard UI support + $___process = FS-Append-File "${_wxs}" @" + + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # conclude the wxs write-up + $___process = FS-Append-File "${_wxs}" @" + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + + # report status + return 0 +} diff --git a/.src/.ci/_package-pdf_unix-any.sh b/.src/.ci/_package-pdf_unix-any.sh new file mode 100644 index 0000000..3528282 --- /dev/null +++ b/.src/.ci/_package-pdf_unix-any.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +PACKAGE_Assemble_PDF_Content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # validate project + if [ $(FS_Is_Target_A_PDF "$_target") -ne 0 ]; then + return 10 # not applicable + fi + + + # execute + I18N_Copy "$_target" "${_directory}/$(FS_Get_File "$_target")" + FS_Copy_File "$_target" "${_directory}/$(FS_Get_File "$_target")" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/.src/.ci/_package-pdf_windows-any.ps1 b/.src/.ci/_package-pdf_windows-any.ps1 new file mode 100644 index 0000000..a1d781a --- /dev/null +++ b/.src/.ci/_package-pdf_windows-any.ps1 @@ -0,0 +1,54 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + exit 1 +} + + + + +function PACKAGE-Assemble-PDF-Content { + param ( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # validate project + if ($(FS-Is-Target-A-PDF "${_target}") -ne 0) { + return 10 # not applicable + } + + + # execute + $null = I18N-Copy "${_target}" "${_directory}\$(FS-Get-File "${_target}")" + $___process = FS-Copy-File "${_target}" "${_directory}\$(FS-Get-File "${_target}")" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/.src/.ci/_package-pypi_unix-any.sh b/.src/.ci/_package-pypi_unix-any.sh new file mode 100644 index 0000000..bd8308d --- /dev/null +++ b/.src/.ci/_package-pypi_unix-any.sh @@ -0,0 +1,36 @@ +#!/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 + + + + +PACKAGE_Assemble_PYPI_Content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # execute + return 10 # IMPORTANT: please do it inside python source instead. +} diff --git a/.src/.ci/_package-pypi_windows-any.ps1 b/.src/.ci/_package-pypi_windows-any.ps1 new file mode 100644 index 0000000..af4f437 --- /dev/null +++ b/.src/.ci/_package-pypi_windows-any.ps1 @@ -0,0 +1,37 @@ +# 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 +} + + + + +function PACKAGE-Assemble-PYPI-Content { + param ( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # execute + return 10 # IMPORTANT: please do it inside python source instead. +} diff --git a/.src/.ci/_package-rpm_unix-any.sh b/.src/.ci/_package-rpm_unix-any.sh new file mode 100644 index 0000000..bdcf014 --- /dev/null +++ b/.src/.ci/_package-rpm_unix-any.sh @@ -0,0 +1,234 @@ +#!/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_RPM_Content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # validate target before job + case "$_target_arch" in + avr) + return 10 # not applicable + ;; + *) + ;; + esac + + _gpg_keyring="$PROJECT_SKU" + if [ $(FS_Is_Target_A_Source "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Docs "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Library "$_target") -eq 0 ]; then + # copy main library + # TIP: (1) usually is: usr/local/lib + # (2) please avoid: lib/, lib{TYPE}/ usr/lib/, and usr/lib{TYPE}/ + _filepath="${_directory}/BUILD/lib${PROJECT_SKU}.a" + I18N_Copy "$_target" "$_filepath" + FS_Make_Housing_Directory "$_filepath" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + FS_Copy_File "$_target" "$_filepath" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + + # generate AutomataCI's required RPM spec instructions (INSTALL) + __file="${_directory}/SPEC_INSTALL" + I18N_Create "$__file" + FS_Write_File "$__file" "\ +install --directory %{buildroot}/usr/local/lib/${PROJECT_SKU} +install -m 0644 lib${PROJECT_SKU}.a %{buildroot}/usr/local/lib/${PROJECT_SKU} + +install --directory %{buildroot}/usr/local/share/doc/lib${PROJECT_SKU}/ +install -m 0644 copyright %{buildroot}/usr/local/share/doc/lib${PROJECT_SKU}/ +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # generate AutomataCI's required RPM spec instructions (FILES) + __file="${_directory}/SPEC_FILES" + I18N_Create "$__file" + FS_Write_File "$__file" "\ +/usr/local/lib/${PROJECT_SKU}/lib${PROJECT_SKU}.a +/usr/local/share/doc/lib${PROJECT_SKU}/copyright +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + _gpg_keyring="lib$PROJECT_SKU" + _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 + # TIP: (1) copy all files into "${__directory}/BUILD" directory. + _filepath="${_directory}/BUILD/${PROJECT_SKU}" + I18N_Copy "$_target" "$_filepath" + FS_Make_Housing_Directory "$_filepath" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + FS_Copy_File "$_target" "$_filepath" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + + # generate AutomataCI's required RPM spec instructions (INSTALL) + __file="${_directory}/SPEC_INSTALL" + I18N_Create "$__file" + FS_Write_File "$__file" "\ +install --directory %{buildroot}/usr/local/bin +install -m 0755 ${PROJECT_SKU} %{buildroot}/usr/local/bin + +install --directory %{buildroot}/usr/local/share/doc/${PROJECT_SKU}/ +install -m 0644 copyright %{buildroot}/usr/local/share/doc/${PROJECT_SKU}/ + +install --directory %{buildroot}/usr/local/share/man/man1/ +install -m 0644 ${PROJECT_SKU}.1.gz %{buildroot}/usr/local/share/man/man1/ +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # generate AutomataCI's required RPM spec instructions (FILES) + __file="${_directory}/SPEC_FILES" + I18N_Create "$__file" + FS_Write_File "$__file" "\ +/usr/local/bin/${PROJECT_SKU} +/usr/local/share/doc/${PROJECT_SKU}/copyright +/usr/local/share/man/man1/${PROJECT_SKU}.1.gz +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + _package="$PROJECT_SKU" + fi + + + # NOTE: REQUIRED file + I18N_Create "copyright.gz" + COPYRIGHT_Create \ + "${_directory}/BUILD/copyright" \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/licenses/deb-copyright" \ + "$PROJECT_SKU" \ + "$PROJECT_CONTACT_NAME" \ + "$PROJECT_CONTACT_EMAIL" \ + "$PROJECT_CONTACT_WEBSITE" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # NOTE: REQUIRED file + I18N_Create "MAN PAGES" + MANUAL_Create \ + "${_directory}/BUILD/${PROJECT_SKU}.1" \ + "$PROJECT_SKU" \ + "$PROJECT_CONTACT_NAME" \ + "$PROJECT_CONTACT_EMAIL" \ + "$PROJECT_CONTACT_WEBSITE" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # NOTE: OPTIONAL (Comment to turn it off) + I18N_Create "source.repo" + RPM_Create_Source_Repo \ + "$PROJECT_SIMULATE_RELEASE_REPO" \ + "$_directory" \ + "$PROJECT_GPG_ID" \ + "$PROJECT_STATIC_URL" \ + "$PROJECT_NAME" \ + "$_gpg_keyring" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # WARNING: THIS REQUIRED FILE MUST BE THE LAST ONE + I18N_Create "spec" + RPM_Create_Spec \ + "$_directory" \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}" \ + "$_package" \ + "$PROJECT_VERSION" \ + "$PROJECT_CADENCE" \ + "$PROJECT_PITCH" \ + "$PROJECT_CONTACT_NAME" \ + "$PROJECT_CONTACT_EMAIL" \ + "$PROJECT_CONTACT_WEBSITE" \ + "$PROJECT_LICENSE" \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/ABSTRACTS.txt" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/.src/.ci/_package-rpm_windows-any.ps1 b/.src/.ci/_package-rpm_windows-any.ps1 new file mode 100644 index 0000000..50f833b --- /dev/null +++ b/.src/.ci/_package-rpm_windows-any.ps1 @@ -0,0 +1,237 @@ +# 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-RPM-Content { + param( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # validate target before job + switch ($_target_arch) { + { $_ -in "avr" } { + return 10 # not applicable + } default { + # accepted + }} + + + $_gpg_keyring = "${env:PROJECT_SKU}" + if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Docs "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { + # copy main libary + # TIP: (1) usually is: usr/local/lib + # (2) please avoid: lib/, lib{TYPE}/ usr/lib/, and usr/lib{TYPE}/ + $_filepath = "${_directory}\BUILD\lib${env:PROJECT_SKU}.a" + $null = I18N-Copy "${_target}" "${_filepath}" + $___process = FS-Make-Housing-Directory "${_filepath}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + $___process = FS-Copy-File "${_target}" "${_filepath}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + + # generate AutomataCI's required RPM spec instructions (INSTALL) + $__file = "${_directory}\SPEC_INSTALL" + $null = I18N-Create "${__file}" + $___process = FS-Write-File "${__file}" @" +install --directory %{buildroot}/usr/local/lib/${env:PROJECT_SKU} +install -m 0644 lib${env:PROJECT_SKU}.a %{buildroot}/usr/local/lib/${env:PROJECT_SKU} + +install --directory %{buildroot}/usr/local/share/doc/lib${env:PROJECT_SKU}/ +install -m 0644 copyright %{buildroot}/usr/local/share/doc/lib${env:PROJECT_SKU}/ +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # generate AutomataCI's required RPM spec instructions (FILES) + $__file = "${_directory}\SPEC_FILES" + $null = I18N-Create "${__file}" + $___process = FS-Write-File "${__file}" @" +/usr/local/lib/${env:PROJECT_SKU}/lib${env:PROJECT_SKU}.a +/usr/local/share/doc/lib${env:PROJECT_SKU}/copyright +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + $_gpg_keyring = "lib${env:PROJECT_SKU}" + $_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 + # TIP: (1) usually is: usr/local/bin or usr/local/sbin + # (2) please avoid: bin/, usr/bin/, sbin/, and usr/sbin/ + $_filepath = "${_directory}\BUILD\${env:PROJECT_SKU}" + $null = I18N-Copy "${_target}" "${_filepath}" + $___process = FS-Make-Housing-Directory "${_filepath}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + $___process = FS-Copy-File "${_target}" "${_filepath}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + + # generate AutomataCI's required RPM spec instructions (INSTALL) + $__file = "${_directory}\SPEC_INSTALL" + $null = I18N-Create "${__file}" + $___process = FS-Write-File "${__file}" @" +install --directory %{buildroot}/usr/local/bin +install -m 0755 ${env:PROJECT_SKU} %{buildroot}/usr/local/bin + +install --directory %{buildroot}/usr/local/share/doc/${env:PROJECT_SKU}/ +install -m 644 copyright %{buildroot}/usr/local/share/doc/${env:PROJECT_SKU}/ + +install --directory %{buildroot}/usr/local/share/man/man1/ +install -m 644 ${env:PROJECT_SKU}.1.gz %{buildroot}/usr/local/share/man/man1/ +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # generate AutomataCI's required RPM spec instructions (FILES) + $__file = "${_directory}\SPEC_FILES" + $null = I18N-Create "${__file}" + $___process = FS-Write-File "${__file}" @" +/usr/local/bin/${env:PROJECT_SKU} +/usr/local/share/doc/${env:PROJECT_SKU}/copyright +/usr/local/share/man/man1/${env:PROJECT_SKU}.1.gz +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + $_package = "${env:PROJECT_SKU}" + } + + + # NOTE: REQUIRED file + $null = I18N-Create "copyright.gz" + $___process = COPYRIGHT-Create ` + "${_directory}\BUILD\copyright" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses\deb-copyright" ` + ${env:PROJECT_SKU} ` + ${env:PROJECT_CONTACT_NAME} ` + ${env:PROJECT_CONTACT_EMAIL} ` + ${env:PROJECT_CONTACT_WEBSITE} + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # NOTE: REQUIRED file + $null = I18N-Create "MAN PAGES" + $___process = MANUAL-Create ` + "${_directory}\BUILD\${env:PROJECT_SKU}.1" ` + ${env:PROJECT_SKU} ` + ${env:PROJECT_CONTACT_NAME} ` + ${env:PROJECT_CONTACT_EMAIL} ` + ${env:PROJECT_CONTACT_WEBSITE} + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # NOTE: OPTIONAL (Comment to turn it off) + $null = I18N-Create "source.repo" + $___process = RPM-Create-Source-Repo ` + "${env:PROJECT_SIMULATE_RELEASE_REPO}" ` + "${_directory}" ` + "${env:PROJECT_GPG_ID}" ` + "${env:PROJECT_STATIC_URL}" ` + "${env:PROJECT_REPREPRO_CODENAME}" ` + "${env:PROJECT_DEBIAN_DISTRIBUTION}" ` + "${_gpg_keyring}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # WARNING: THIS REQUIRED FILE MUST BE THE LAST ONE + $null = I18N-Create "spec" + $___process = RPM-Create-Spec ` + "${_directory}" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}" ` + "${_package}" ` + "${env:PROJECT_VERSION}" ` + "${env:PROJECT_CADENCE}" ` + "${env:PROJECT_PITCH}" ` + "${env:PROJECT_CONTACT_NAME}" ` + "${env:PROJECT_CONTACT_EMAIL}" ` + "${env:PROJECT_CONTACT_WEBSITE}" ` + "${env:PROJECT_LICENSE}" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\ABSTRACTS.txt" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/.src/.ci/build_unix-any.sh b/.src/.ci/build_unix-any.sh new file mode 100644 index 0000000..51ed6fd --- /dev/null +++ b/.src/.ci/build_unix-any.sh @@ -0,0 +1,70 @@ +#!/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" +. "${LIBS_AUTOMATACI}/services/compilers/changelog.sh" + + + + +# safety checking control surfaces +I18N_Check_Availability 'CHANGELOG' +CHANGELOG_Is_Available +if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 +fi + + + + +# execute +__file="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/changelog" +I18N_Create "${PROJECT_VERSION} DATA CHANGELOG" +CHANGELOG_Build_Data_Entry "$__file" +if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 +fi + + +I18N_Create "${PROJECT_VERSION} DEB CHANGELOG" +CHANGELOG_Build_DEB_Entry \ + "$__file" \ + "$PROJECT_VERSION" \ + "$PROJECT_SKU" \ + "$PROJECT_DEBIAN_DISTRIBUTION" \ + "$PROJECT_DEBIAN_URGENCY" \ + "$PROJECT_CONTACT_NAME" \ + "$PROJECT_CONTACT_EMAIL" \ + "$(date -R)" +if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 +fi + + + + +# report status +return 0 diff --git a/.src/.ci/build_windows-any.ps1 b/.src/.ci/build_windows-any.ps1 new file mode 100644 index 0000000..da75c4c --- /dev/null +++ b/.src/.ci/build_windows-any.ps1 @@ -0,0 +1,69 @@ +# 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" +. "${env:LIBS_AUTOMATACI}\services\compilers\changelog.ps1" + + + + +# safety checking control surfaces +$null = I18N-Check-Availability "CHANGELOG" +$___process = CHANGELOG-Is-Available +if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 +} + + + + +# execute +$__file = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\changelog" +$null = I18N-Create "${env:PROJECT_VERSION} DATA CHANGELOG" +$___process = CHANGELOG-Build-DATA-Entry $__file +if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 +} + + +$null = I18N-Create "${env:PROJECT_VERSION} DEB CHANGELOG" +$___process = CHANGELOG-Build-DEB-Entry ` + "${__file}" ` + "$env:PROJECT_VERSION" ` + "$env:PROJECT_SKU" ` + "$env:PROJECT_DEBIAN_DISTRIBUTION" ` + "$env:PROJECT_DEBIAN_URGENCY" ` + "$env:PROJECT_CONTACT_NAME" ` + "$env:PROJECT_CONTACT_EMAIL" ` + (Get-Date -Format 'R') +if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 +} + + + + +# report status +return 0 diff --git a/.src/.ci/clean_unix-any.sh b/.src/.ci/clean_unix-any.sh new file mode 100644 index 0000000..49cd732 --- /dev/null +++ b/.src/.ci/clean_unix-any.sh @@ -0,0 +1,32 @@ +#!/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 + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/.ci/clean_windows-any.ps1 b/.src/.ci/clean_windows-any.ps1 new file mode 100644 index 0000000..0855d36 --- /dev/null +++ b/.src/.ci/clean_windows-any.ps1 @@ -0,0 +1,31 @@ +# 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 +} + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/.ci/deploy_unix-any.sh b/.src/.ci/deploy_unix-any.sh new file mode 100644 index 0000000..19c163e --- /dev/null +++ b/.src/.ci/deploy_unix-any.sh @@ -0,0 +1,32 @@ +#!/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 + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/.ci/deploy_windows-any.ps1 b/.src/.ci/deploy_windows-any.ps1 new file mode 100644 index 0000000..0855d36 --- /dev/null +++ b/.src/.ci/deploy_windows-any.ps1 @@ -0,0 +1,31 @@ +# 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 +} + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/.ci/materialize_unix-any.sh b/.src/.ci/materialize_unix-any.sh new file mode 100644 index 0000000..19c163e --- /dev/null +++ b/.src/.ci/materialize_unix-any.sh @@ -0,0 +1,32 @@ +#!/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 + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/.ci/materialize_windows-any.ps1 b/.src/.ci/materialize_windows-any.ps1 new file mode 100644 index 0000000..0855d36 --- /dev/null +++ b/.src/.ci/materialize_windows-any.ps1 @@ -0,0 +1,31 @@ +# 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 +} + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/.ci/notarize_unix-any.sh b/.src/.ci/notarize_unix-any.sh new file mode 100644 index 0000000..eafcdd6 --- /dev/null +++ b/.src/.ci/notarize_unix-any.sh @@ -0,0 +1,102 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/crypto/notary.sh" + + + + +NOTARIZE_Certify() { + _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_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 + fi + + + # notarize + case "$_target_os" in + darwin) + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + return 12 + fi + + NOTARY_Apple_Is_Available + if [ $? -ne 0 ]; then + return 11 + fi + + _dest="$(FS_Get_Directory "$_target")" + _dest="${_dest}/${_target_name}-signed_${_target_os}-${_target_arch}" + NOTARY_Sign_Apple "$_dest" "$_target" + if [ $? -ne 0 ]; then + return 1 + fi + ;; + windows) + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + return 12 + fi + + NOTARY_Microsoft_Is_Available + if [ $? -ne 0 ]; then + return 11 + fi + + _dest="$(FS_Get_Directory "$_target")" + _dest="${_dest}/${_target_name}-signed_${_target_os}-${_target_arch}.exe" + NOTARY_Sign_Microsoft \ + "$_dest" \ + "$_target" \ + "$PROJECT_CONTACT_NAME" \ + "$PROJECT_CONTACT_WEBSITE" + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + return 10 # not applicable + ;; + esac + + + # report status + return 0 +} diff --git a/.src/.ci/notarize_windows-any.ps1 b/.src/.ci/notarize_windows-any.ps1 new file mode 100644 index 0000000..2673e0a --- /dev/null +++ b/.src/.ci/notarize_windows-any.ps1 @@ -0,0 +1,107 @@ +# 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\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\crypto\notary.ps1" + + + + +function NOTARIZE-Certify { + param ( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # validate project + if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 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 + } + + + # notarize + switch ($_target_os) { + darwin { + if ($(OS-Is-Run-Simulated) -eq 0) { + return 12 + } + + $___process = NOTARY-Apple-Is-Available + if ($___process -ne 0) { + return 11 + } + + $_dest = "$(FS-Get-Directory "${_target}")" + $_dest = "${_dest}\${_target_name}-signed_${_target_os}-${_target_arch}" + $___process = NOTARY-Sign-Apple "${_dest}" "${_target}" + if ($___process -ne 0) { + return 1 + } + } windows { + if ($(OS-Is-Run-Simulated) -eq 0) { + return 12 + } + + $___process = NOTARY-Microsoft-Is-Available + if ($___process -ne 0) { + return 11 + } + + $_dest = "$(FS-Get-Directory "${_target}")" + $_dest = "${_dest}\${_target_name}-signed_${_target_os}-${_target_arch}.exe" + $___process = NOTARY-Sign-Microsoft ` + "${_dest}" ` + "${_target}" ` + "${env:PROJECT_CONTACT_NAME}" ` + "${env:PROJECT_CONTACT_WEBSITE}" + if ($___process -ne 0) { + return 1 + } + } default { + return 10 # not applicable + }} + + + # report status + return 0 +} + + + + +# report status +return 0 diff --git a/.src/.ci/package_unix-any.sh b/.src/.ci/package_unix-any.sh new file mode 100644 index 0000000..a3231e0 --- /dev/null +++ b/.src/.ci/package_unix-any.sh @@ -0,0 +1,40 @@ +#!/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 + +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-archive_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-cargo_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-chocolatey_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-deb_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-docker_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-flatpak_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-homebrew_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-ipk_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-msi_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-pdf_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-pypi_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-rpm_unix-any.sh" + + + + +# report status +return 0 diff --git a/.src/.ci/package_windows-any.ps1 b/.src/.ci/package_windows-any.ps1 new file mode 100644 index 0000000..fb5b4fd --- /dev/null +++ b/.src/.ci/package_windows-any.ps1 @@ -0,0 +1,39 @@ +# 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_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-archive_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-cargo_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-chocolatey_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-deb_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-docker_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-flatpak_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-homebrew_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-ipk_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-msi_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-pdf_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-pypi_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-rpm_windows-any.ps1" + + + + +# report status +return 0 diff --git a/.src/.ci/prepare_unix-any.sh b/.src/.ci/prepare_unix-any.sh new file mode 100644 index 0000000..19c163e --- /dev/null +++ b/.src/.ci/prepare_unix-any.sh @@ -0,0 +1,32 @@ +#!/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 + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/.ci/prepare_windows-any.ps1 b/.src/.ci/prepare_windows-any.ps1 new file mode 100644 index 0000000..41a2e45 --- /dev/null +++ b/.src/.ci/prepare_windows-any.ps1 @@ -0,0 +1,31 @@ +# 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 +} + + + + +# execute + + + + +# return status +return 0 diff --git a/.src/.ci/release_unix-any.sh b/.src/.ci/release_unix-any.sh new file mode 100644 index 0000000..c7223ba --- /dev/null +++ b/.src/.ci/release_unix-any.sh @@ -0,0 +1,57 @@ +#!/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 + + + + +RELEASE_Run_Package_Processor() { + #___target="$1" + + + return 0 +} + + + + +RELEASE_Run_Post_Processor() { + #___directory="$1" + + + return 0 +} + + + + +RELEASE_Run_Pre_Processor() { + #___directory="$1" + + + return 0 +} + + + + +# report status +return 0 diff --git a/.src/.ci/release_windows-any.ps1 b/.src/.ci/release_windows-any.ps1 new file mode 100644 index 0000000..c0fe163 --- /dev/null +++ b/.src/.ci/release_windows-any.ps1 @@ -0,0 +1,59 @@ +# 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 +} + + + + +function RELEASE-Run-Package-Processor { + param( + [string]$___target + ) + + return 0 +} + + + + +function RELEASE-Run-Post-Processor { + param( + [string]$___directory + ) + + return 0 +} + + + + +function RELEASE-Run-Pre-Processor { + param( + [string]$___directory + ) + + return 0 +} + + + + +# report status +return 0 diff --git a/.src/.ci/setup_unix-any.sh b/.src/.ci/setup_unix-any.sh new file mode 100644 index 0000000..19c163e --- /dev/null +++ b/.src/.ci/setup_unix-any.sh @@ -0,0 +1,32 @@ +#!/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 + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/.ci/setup_windows-any.ps1 b/.src/.ci/setup_windows-any.ps1 new file mode 100644 index 0000000..e40c14c --- /dev/null +++ b/.src/.ci/setup_windows-any.ps1 @@ -0,0 +1,31 @@ +# 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 +} + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/.ci/start_unix-any.sh b/.src/.ci/start_unix-any.sh new file mode 100644 index 0000000..19c163e --- /dev/null +++ b/.src/.ci/start_unix-any.sh @@ -0,0 +1,32 @@ +#!/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 + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/.ci/start_windows-any.ps1 b/.src/.ci/start_windows-any.ps1 new file mode 100644 index 0000000..0855d36 --- /dev/null +++ b/.src/.ci/start_windows-any.ps1 @@ -0,0 +1,31 @@ +# 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 +} + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/.ci/stop_unix-any.sh b/.src/.ci/stop_unix-any.sh new file mode 100644 index 0000000..19c163e --- /dev/null +++ b/.src/.ci/stop_unix-any.sh @@ -0,0 +1,32 @@ +#!/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 + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/.ci/stop_windows-any.ps1 b/.src/.ci/stop_windows-any.ps1 new file mode 100644 index 0000000..0855d36 --- /dev/null +++ b/.src/.ci/stop_windows-any.ps1 @@ -0,0 +1,31 @@ +# 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 +} + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/.ci/test_unix-any.sh b/.src/.ci/test_unix-any.sh new file mode 100644 index 0000000..19c163e --- /dev/null +++ b/.src/.ci/test_unix-any.sh @@ -0,0 +1,32 @@ +#!/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 + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/.ci/test_windows-any.ps1 b/.src/.ci/test_windows-any.ps1 new file mode 100644 index 0000000..0855d36 --- /dev/null +++ b/.src/.ci/test_windows-any.ps1 @@ -0,0 +1,31 @@ +# 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 +} + + + + +# execute + + + + +# report status +return 0 diff --git a/.src/icons/banner_1200x270.svg b/.src/icons/banner_1200x270.svg new file mode 100644 index 0000000..064388a --- /dev/null +++ b/.src/icons/banner_1200x270.svg @@ -0,0 +1,77 @@ + +Chew, Kean Ho's Hestia LibrariesChew, Kean Ho's Hestia LibrariesJune 4, 2024(Holloway) Chew, Kean HoApache 2.0(Holloway) Chew, Kean Hochewkeanho/Hestiagithub.com/chewkeanho/hestiaprogramming languages' super librariesHestia LibrariesLibrariesProgramming LanguagesOne Peaceful Frontend+Backend Software Library Suite.(Holloway) Chew, Kean Ho diff --git a/.src/icons/icon-128x128.png b/.src/icons/icon-128x128.png new file mode 100644 index 0000000..fd7d2aa Binary files /dev/null and b/.src/icons/icon-128x128.png differ diff --git a/.src/icons/icon-48x48.png b/.src/icons/icon-48x48.png new file mode 100644 index 0000000..cb9b0b6 Binary files /dev/null and b/.src/icons/icon-48x48.png differ diff --git a/.src/icons/icon.ico b/.src/icons/icon.ico new file mode 100644 index 0000000..b2f1369 Binary files /dev/null and b/.src/icons/icon.ico differ diff --git a/.src/icons/icon.svg b/.src/icons/icon.svg new file mode 100644 index 0000000..fe5ce07 --- /dev/null +++ b/.src/icons/icon.svg @@ -0,0 +1,125 @@ + + + Chew, Kean Ho's Hestia Libraries + + + + + + + + + + + + + + + Chew, Kean Ho's Hestia Libraries + June 4, 2024 + + + (Holloway) Chew, Kean Ho + + + + + Apache 2.0 + + + + + (Holloway) Chew, Kean Ho + + + chewkeanho/Hestia + github.com/chewkeanho/hestia + programming languages' super libraries + + + Hestia Libraries + Libraries + + + Programming Languages + One Peaceful Frontend+Backend Software Library Suite. + + + (Holloway) Chew, Kean Ho + + + + + + + + + + + + + diff --git a/.src/icons/icon_grayscale.svg b/.src/icons/icon_grayscale.svg new file mode 100644 index 0000000..8d20d87 --- /dev/null +++ b/.src/icons/icon_grayscale.svg @@ -0,0 +1,125 @@ + + + Chew, Kean Ho's Hestia Libraries + + + + + + + + + + + + + + + Chew, Kean Ho's Hestia Libraries + June 4, 2024 + + + (Holloway) Chew, Kean Ho + + + + + Apache 2.0 + + + + + (Holloway) Chew, Kean Ho + + + chewkeanho/Hestia + github.com/chewkeanho/hestia + programming languages' super libraries + + + Hestia Libraries + Libraries + + + Programming Languages + One Peaceful Frontend+Backend Software Library Suite. + + + (Holloway) Chew, Kean Ho + + + + + + + + + + + + + diff --git a/.src/icons/icon_monochrome.svg b/.src/icons/icon_monochrome.svg new file mode 100644 index 0000000..617308f --- /dev/null +++ b/.src/icons/icon_monochrome.svg @@ -0,0 +1,122 @@ + + + Chew, Kean Ho's Hestia Libraries + + + + + + + + + + + + + + + Chew, Kean Ho's Hestia Libraries + June 4, 2024 + + + (Holloway) Chew, Kean Ho + + + + + Apache 2.0 + + + + + (Holloway) Chew, Kean Ho + + + chewkeanho/Hestia + github.com/chewkeanho/hestia + programming languages' super libraries + + + Hestia Libraries + Libraries + + + Programming Languages + One Peaceful Frontend+Backend Software Library Suite. + + + (Holloway) Chew, Kean Ho + + + + + + + + + + + + + diff --git a/.src/icons/msi-banner_en.jpg b/.src/icons/msi-banner_en.jpg new file mode 100644 index 0000000..fd2d04f Binary files /dev/null and b/.src/icons/msi-banner_en.jpg differ diff --git a/.src/icons/msi-banner_zh-hans.jpg b/.src/icons/msi-banner_zh-hans.jpg new file mode 100644 index 0000000..03238ef Binary files /dev/null and b/.src/icons/msi-banner_zh-hans.jpg differ diff --git a/.src/icons/msi-dialog_en.jpg b/.src/icons/msi-dialog_en.jpg new file mode 100644 index 0000000..e9aac76 Binary files /dev/null and b/.src/icons/msi-dialog_en.jpg differ diff --git a/.src/icons/msi-dialog_zh-hans.jpg b/.src/icons/msi-dialog_zh-hans.jpg new file mode 100644 index 0000000..fab36fb Binary files /dev/null and b/.src/icons/msi-dialog_zh-hans.jpg differ diff --git a/.src/licenses/LICENSE-EN.pdf b/.src/licenses/LICENSE-EN.pdf new file mode 100644 index 0000000..f969d71 Binary files /dev/null and b/.src/licenses/LICENSE-EN.pdf differ diff --git a/.src/licenses/LICENSE_en.rtf b/.src/licenses/LICENSE_en.rtf new file mode 100644 index 0000000..0cf3890 --- /dev/null +++ b/.src/licenses/LICENSE_en.rtf @@ -0,0 +1,277 @@ +{\rtf1\ansi\deff4\adeflang1025 +{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset0 Liberation Serif{\*\falt Times New Roman};}{\f4\fswiss\fprq0\fcharset128 Noto Sans;}{\f5\fswiss\fprq0\fcharset128 Liberation Mono{\*\falt Courier New};}{\f6\fswiss\fprq0\fcharset128 Noto Sans CJK SC Light;}{\f7\fswiss\fprq0\fcharset128 Noto Serif CJK SC Black;}{\f8\fswiss\fprq0\fcharset128 Noto Sans Mono CJK SC;}{\f9\fswiss\fprq0\fcharset128 FreeSans;}} +{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;} +{\stylesheet{\s0\snext0\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052 Normal;} +{\s1\sbasedon84\snext1\rtlch\af9\afs36\alang1081\ab0 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs35\lang1033\b\kerning1\dbch\af7\langfe2052 Heading 1;} +{\s2\sbasedon84\snext2\rtlch\af9\afs32\alang1081\ab \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb200\sa120\keepn\ltrpar\cf0\f4\fs32\lang1033\b\kerning1\dbch\af7\langfe2052 Heading 2;} +{\s3\sbasedon84\snext3\rtlch\af9\afs28\alang1081\ab \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb140\sa120\keepn\ltrpar\cf0\f4\fs28\lang1033\b\kerning1\dbch\af7\langfe2052 Heading 3;} +{\s4\sbasedon84\snext4\rtlch\af9\afs26\alang1081\ai\ab \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb120\sa120\keepn\ltrpar\cf0\f4\fs26\lang1033\i\b\kerning1\dbch\af7\langfe2052 Heading 4;} +{\s5\sbasedon84\snext5\rtlch\af9\afs23\alang1081\ab \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb120\sa60\keepn\ltrpar\cf0\f4\fs23\lang1033\b\kerning1\dbch\af7\langfe2052 Heading 5;} +{\s6\sbasedon84\snext6\rtlch\af9\afs23\alang1081\ai\ab \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb60\sa60\keepn\ltrpar\cf0\f4\fs23\lang1033\i\b\kerning1\dbch\af7\langfe2052 Heading 6;} +{\s7\sbasedon84\snext7\rtlch\af9\afs22\alang1081\ab \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb60\sa60\keepn\ltrpar\cf0\f4\fs22\lang1033\b\kerning1\dbch\af7\langfe2052 Heading 7;} +{\s8\sbasedon84\snext8\rtlch\af9\afs22\alang1081\ai\ab \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb60\sa60\keepn\ltrpar\cf0\f4\fs22\lang1033\i\b\kerning1\dbch\af7\langfe2052 Heading 8;} +{\s9\sbasedon84\snext9\rtlch\af9\afs21\alang1081\ab \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb60\sa60\keepn\ltrpar\cf0\f4\fs21\lang1033\b\kerning1\dbch\af7\langfe2052 Heading 9;} +{\*\cs15\snext15\loch\cf9\ul\ulc0 Hyperlink;} +{\*\cs16\snext16 Numbering Symbols;} +{\*\cs17\snext17 ListLabel 1;} +{\*\cs18\snext18 ListLabel 2;} +{\*\cs19\snext19 ListLabel 3;} +{\*\cs20\snext20 ListLabel 4;} +{\*\cs21\snext21 ListLabel 5;} +{\*\cs22\snext22 ListLabel 6;} +{\*\cs23\snext23 ListLabel 7;} +{\*\cs24\snext24 ListLabel 8;} +{\*\cs25\snext25 ListLabel 9;} +{\*\cs26\snext26 ListLabel 10;} +{\*\cs27\snext27 ListLabel 11;} +{\*\cs28\snext28 ListLabel 12;} +{\*\cs29\snext29 ListLabel 13;} +{\*\cs30\snext30 ListLabel 14;} +{\*\cs31\snext31 ListLabel 15;} +{\*\cs32\snext32 ListLabel 16;} +{\*\cs33\snext33 ListLabel 17;} +{\*\cs34\snext34 ListLabel 18;} +{\*\cs35\snext35 ListLabel 19;} +{\*\cs36\snext36 ListLabel 20;} +{\*\cs37\snext37 ListLabel 21;} +{\*\cs38\snext38 ListLabel 22;} +{\*\cs39\snext39 ListLabel 23;} +{\*\cs40\snext40 ListLabel 24;} +{\*\cs41\snext41 ListLabel 25;} +{\*\cs42\snext42 ListLabel 26;} +{\*\cs43\snext43 ListLabel 27;} +{\*\cs44\snext44\rtlch\af5 \ltrch\hich\af5\loch\f5\dbch\af8 Source Text;} +{\*\cs45\snext45\loch\cf13\ul\ulc0 FollowedHyperlink;} +{\*\cs46\snext46 Index Link;} +{\*\cs47\snext47 ListLabel 28;} +{\*\cs48\snext48 ListLabel 29;} +{\*\cs49\snext49 ListLabel 30;} +{\*\cs50\snext50 ListLabel 31;} +{\*\cs51\snext51 ListLabel 32;} +{\*\cs52\snext52 ListLabel 33;} +{\*\cs53\snext53 ListLabel 34;} +{\*\cs54\snext54 ListLabel 35;} +{\*\cs55\snext55 ListLabel 36;} +{\*\cs56\snext56 ListLabel 37;} +{\*\cs57\snext57 ListLabel 38;} +{\*\cs58\snext58 ListLabel 39;} +{\*\cs59\snext59 ListLabel 40;} +{\*\cs60\snext60 ListLabel 41;} +{\*\cs61\snext61 ListLabel 42;} +{\*\cs62\snext62 ListLabel 43;} +{\*\cs63\snext63 ListLabel 44;} +{\*\cs64\snext64 ListLabel 45;} +{\*\cs65\snext65 ListLabel 46;} +{\*\cs66\snext66 ListLabel 47;} +{\*\cs67\snext67 ListLabel 48;} +{\*\cs68\snext68 ListLabel 49;} +{\*\cs69\snext69 ListLabel 50;} +{\*\cs70\snext70 ListLabel 51;} +{\*\cs71\snext71 ListLabel 52;} +{\*\cs72\snext72 ListLabel 53;} +{\*\cs73\snext73 ListLabel 54;} +{\*\cs74\snext74 ListLabel 55;} +{\*\cs75\snext75 ListLabel 56;} +{\*\cs76\snext76 ListLabel 57;} +{\*\cs77\snext77 ListLabel 58;} +{\*\cs78\snext78 ListLabel 59;} +{\*\cs79\snext79 ListLabel 60;} +{\*\cs80\snext80 ListLabel 61;} +{\*\cs81\snext81 ListLabel 62;} +{\*\cs82\snext82 ListLabel 63;} +{\*\cs83\snext83\loch\cf9\ul\ulc0 ListLabel 64;} +{\s84\sbasedon0\snext85\rtlch\af9\afs28\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs28\lang1033\kerning1\dbch\af7\langfe2052 Heading;} +{\s85\sbasedon0\snext85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052 Body Text;} +{\s86\sbasedon85\snext86\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs20\lang1033\kerning1\dbch\af6\langfe2052 List;} +{\s87\sbasedon0\snext87\rtlch\af9\afs24\alang1081\ai \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb120\sa120\ltrpar\cf0\f4\fs20\lang1033\i\kerning1\dbch\af6\langfe2052 Caption;} +{\s88\sbasedon0\snext88\rtlch\af9\afs24\alang255 \ltrch\lang255\langfe255\hich\af4\loch\ql\widctlpar\hyphpar0\ltrpar\cf0\f4\fs20\lang255\kerning1\dbch\af6\langfe255 Index;} +{\s89\sbasedon84\snext85\rtlch\af9\afs56\alang1081\ab \ltrch\lang1033\langfe2052\hich\af4\loch\qc\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs56\lang1033\b\kerning1\dbch\af7\langfe2052 Title;} +{\s90\sbasedon84\snext85\rtlch\af9\afs36\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\qc\widctlpar\hyphpar0\sb60\sa120\keepn\ltrpar\cf0\f4\fs36\lang1033\kerning1\dbch\af7\langfe2052 Subtitle;} +{\s91\sbasedon0\snext85\rtlch\af9\afs12\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb0\sa283\brdrt\brdrnone\brdrl\brdrnone\brdrb\brdrdb\brdrw15\brdrcf15\brsp0\brdrr\brdrnone\ltrpar\cf0\f4\fs12\lang1033\kerning1\dbch\af6\langfe2052 Horizontal Line;} +{\s92\sbasedon88\snext92\rtlch\af9\afs24\alang255 \ltrch\lang255\langfe255\hich\af4\loch\ql\widctlpar\tldot\tqr\tx8555\hyphpar0\li1417\lin1417\ltrpar\cf0\f4\fs20\lang255\kerning1\dbch\af6\langfe255 TOC 6;} +{\s93\sbasedon88\snext93\rtlch\af9\afs24\alang255 \ltrch\lang255\langfe255\hich\af4\loch\ql\widctlpar\tldot\tqr\tx8838\hyphpar0\li1134\lin1134\ltrpar\cf0\f4\fs20\lang255\kerning1\dbch\af6\langfe255 TOC 5;} +{\s94\sbasedon0\snext94\rtlch\af5\afs20\alang1081 \ltrch\lang1033\langfe2052\hich\af5\loch\ql\widctlpar\hyphpar0\sb0\sa0\ltrpar\cf0\f5\fs20\lang1033\kerning1\dbch\af8\langfe2052 Preformatted Text;} +{\s95\sbasedon88\snext95\rtlch\af9\afs24\alang255 \ltrch\lang255\langfe255\hich\af4\loch\ql\widctlpar\tldot\tqr\tx9122\hyphpar0\li850\lin850\ltrpar\cf0\f4\fs20\lang255\kerning1\dbch\af6\langfe255 TOC 4;} +{\s96\sbasedon88\snext96\rtlch\af9\afs24\alang255 \ltrch\lang255\langfe255\hich\af4\loch\ql\widctlpar\tldot\tqr\tx9405\hyphpar0\li567\lin567\ltrpar\cf0\f4\fs20\lang255\kerning1\dbch\af6\langfe255 TOC 3;} +{\s97\sbasedon87\snext97\rtlch\af9\afs24\alang1081\ai \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb120\sa120\ltrpar\cf0\f4\fs20\lang1033\i\kerning1\dbch\af6\langfe2052 Illustration;} +{\s98\sbasedon85\snext98\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\fi283\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052 Body Text First Indent;} +{\s99\sbasedon0\snext99\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052 Frame Contents;} +{\s100\sbasedon88\snext100\rtlch\af9\afs24\alang255 \ltrch\lang255\langfe255\hich\af4\loch\ql\widctlpar\tldot\tqr\tx9689\hyphpar0\li283\lin283\ltrpar\cf0\f4\fs20\lang255\kerning1\dbch\af6\langfe255 TOC 2;} +{\s101\sbasedon88\snext101\rtlch\af9\afs24\alang255 \ltrch\lang255\langfe255\hich\af4\loch\ql\widctlpar\tldot\tqr\tx9972\hyphpar0\ltrpar\cf0\f4\fs20\lang255\kerning1\dbch\af6\langfe255 TOC 1;} +{\s102\sbasedon84\snext102\rtlch\af9\afs32\alang1081\ab \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs32\lang1033\b\kerning1\dbch\af7\langfe2052 Index Heading;} +{\s103\sbasedon102\snext103\rtlch\af9\afs32\alang1081\ab \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs32\lang1033\b\kerning1\dbch\af7\langfe2052 TOC Heading;} +{\s104\sbasedon0\snext104\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\tqc\tx4986\tqr\tx9972\hyphpar0\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052 Header and Footer;} +{\s105\sbasedon104\snext105\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\tqc\tx4986\tqr\tx9972\hyphpar0\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052 Footer;} +{\s106\sbasedon0\snext106\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052 Table Contents;} +{\s107\sbasedon106\snext107\rtlch\af9\afs24\alang1081\ab \ltrch\lang1033\langfe2052\hich\af4\loch\qc\nowidctlpar\hyphpar0\ltrpar\cf0\f4\fs24\lang1033\b\kerning1\dbch\af6\langfe2052 Table Heading;} +{\s108\sbasedon104\snext108\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\tqc\tx4986\tqr\tx9972\hyphpar0\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052 Header;} +{\s109\sbasedon87\snext109\rtlch\af9\afs24\alang1081\ai \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb120\sa120\ltrpar\cf0\f4\fs20\lang1033\i\kerning1\dbch\af6\langfe2052 Text;} +{\s110\sbasedon84\snext85\rtlch\af9\afs21\alang1081\ab \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb60\sa60\keepn\ltrpar\cf0\f4\fs21\lang1033\b\kerning1\dbch\af7\langfe2052 Heading 10;} +{\s111\sbasedon87\snext111\rtlch\af9\afs24\alang1081\ai \ltrch\lang1033\langfe2052\hich\af4\loch\qc\widctlpar\hyphpar0\sb120\sa120\ltrpar\cf0\f4\fs20\lang1033\i\kerning1\dbch\af6\langfe2052 Drawing;} +{\s112\sbasedon87\snext112\rtlch\af9\afs24\alang1081\ai \ltrch\lang1033\langfe2052\hich\af4\loch\qc\widctlpar\hyphpar0\sb120\sa120\ltrpar\cf0\f4\fs20\lang1033\i\kerning1\dbch\af6\langfe2052 Table;} +{\s113\sbasedon87\snext113\rtlch\af9\afs24\alang1081\ai \ltrch\lang1033\langfe2052\hich\af4\loch\qc\widctlpar\hyphpar0\sb120\sa120\ltrpar\cf0\f4\fs20\lang1033\i\kerning1\dbch\af6\langfe2052 Figure;} +}{\*\listtable{\list\listtemplateid1 +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'01\'00;}{\levelnumbers\'01;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'01\'01;}{\levelnumbers\'01;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'01\'02;}{\levelnumbers\'01;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'01\'03;}{\levelnumbers\'01;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'01\'04;}{\levelnumbers\'01;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'01\'05;}{\levelnumbers\'01;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'01\'06;}{\levelnumbers\'01;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'01\'07;}{\levelnumbers\'01;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'01\'08;}{\levelnumbers\'01;}\fi0\li0}\listid1} +{\list\listtemplateid2 +{\listlevel\levelnfc1\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'00.;}{\levelnumbers\'01;}\fi-360\li720} +{\listlevel\levelnfc1\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'01.;}{\levelnumbers\'01;}\fi-360\li1080} +{\listlevel\levelnfc1\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'02.;}{\levelnumbers\'01;}\fi-360\li1440} +{\listlevel\levelnfc1\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'03.;}{\levelnumbers\'01;}\fi-360\li1800} +{\listlevel\levelnfc1\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'04.;}{\levelnumbers\'01;}\fi-360\li2160} +{\listlevel\levelnfc1\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'05.;}{\levelnumbers\'01;}\fi-360\li2520} +{\listlevel\levelnfc1\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'06.;}{\levelnumbers\'01;}\fi-360\li2880} +{\listlevel\levelnfc1\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'07.;}{\levelnumbers\'01;}\fi-360\li3240} +{\listlevel\levelnfc1\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'08.;}{\levelnumbers\'01;}\fi-360\li3600}\listid2} +{\list\listtemplateid3 +{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'00.;}{\levelnumbers\'01;}\fi-360\li720} +{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'01.;}{\levelnumbers\'01;}\fi-360\li1080} +{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'02.;}{\levelnumbers\'01;}\fi-360\li1440} +{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'03.;}{\levelnumbers\'01;}\fi-360\li1800} +{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'04.;}{\levelnumbers\'01;}\fi-360\li2160} +{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'05.;}{\levelnumbers\'01;}\fi-360\li2520} +{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'06.;}{\levelnumbers\'01;}\fi-360\li2880} +{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'07.;}{\levelnumbers\'01;}\fi-360\li3240} +{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'08.;}{\levelnumbers\'01;}\fi-360\li3600}\listid3} +{\list\listtemplateid4 +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'00;}{\levelnumbers;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'00;}{\levelnumbers;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'00;}{\levelnumbers;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'00;}{\levelnumbers;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'00;}{\levelnumbers;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'00;}{\levelnumbers;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'00;}{\levelnumbers;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'00;}{\levelnumbers;}\fi0\li0} +{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow2{\leveltext \'00;}{\levelnumbers;}\fi0\li0}\listid4} +}{\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}{\listoverride\listid3\listoverridecount0\ls3}{\listoverride\listid4\listoverridecount0\ls4}}{\*\generator LibreOffice/24.2.3.2$Linux_X86_64 LibreOffice_project/433d9c2ded56988e8a90e6b2e771ee4e6a5ab2ba}{\info{\title default}{\author Kean Ho Chew}{\creatim\yr2023\mo11\dy10\hr11\min54}{\author Kean Ho Chew}{\revtim\yr2024\mo6\dy4\hr19\min11}{\printim\yr0\mo0\dy0\hr0\min0}}{\*\userprops}\deftab709 +\hyphauto1\viewscale100\formshade\nobrkwrptbl\paperh15840\paperw12240\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\sftnnar\saftnnrlc\sectunlocked1\pgwsxn12240\pghsxn15840\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc +{\*\ftnsep\chftnsep}\pgndec\pard\plain \s89\rtlch\af9\afs56\alang1081\ab \ltrch\lang1033\langfe2052\hich\af4\loch\qc\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs56\lang1033\b\kerning1\dbch\af7\langfe2052\ql\sb240\sa120{\loch +CHEW KEAN HO\uc2 \u8217\'81\'66S HESTIA \uc1 }{\loch +LICENSE AGREEMENT} +\par \pard\plain \s90\rtlch\af9\afs36\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\qc\widctlpar\hyphpar0\sb60\sa120\keepn\ltrpar\cf0\f4\fs36\lang1033\kerning1\dbch\af7\langfe2052\ql{\loch +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +(c) 2023 \u8211\'3f (Holloway) Chew, Kean Ho <}{\loch +hello@hollowaykeanho.com}{\loch +>} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +Apache 2.0 Software License \u8211\'3f }{{\field{\*\fldinst HYPERLINK "http://www.apache.org/licenses/" }{\fldrslt {\loch\loch\cf9\ul\ulc0\cf9\ul\ulc0\loch +http://www.apache.org/licenses/}}}} +\par \pard\plain \s91\rtlch\af9\afs12\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb0\sa283\brdrt\brdrnone\brdrl\brdrnone\brdrb\brdrdb\brdrw15\brdrcf15\brsp0\brdrr\brdrnone\ltrpar\cf0\f4\fs12\lang1033\kerning1\dbch\af6\langfe2052\brdrt\brdrnone\brdrl\brdrnone\brdrb\brdrdb\brdrw15\brdrcf15\brsp0\brdrr\brdrnone\loch + +\par \pard\plain \s1\rtlch\af9\afs36\alang1081\ab0 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs35\lang1033\b\kerning1\dbch\af7\langfe2052{\listtext\pard\plain }\ilvl0\ls1 \fi0\li0\lin0\fi0\li0\lin0{\loch +{\*\bkmkstart __RefHeading___Toc526_557546903}{\*\bkmkend __RefHeading___Toc526_557546903}Definitions} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +"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} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052{\listtext\pard\plain I.\tab}\ilvl0\ls2 \fi-360\li720\lin720\sl276\slmult1{\loch +the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052{\listtext\pard\plain II.\tab}\ilvl0\ls2 \fi-360\li720\lin720\sl276\slmult1{\loch +ownership of fifty percent (50%) or more of the outstanding shares, or} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052{\listtext\pard\plain III.\tab}\ilvl0\ls2 \fi-360\li720\lin720\sl276\slmult1{\loch +beneficial ownership of such entity.} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +"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.} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +"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).} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +"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.} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +"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."} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +"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.} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s1\rtlch\af9\afs36\alang1081\ab0 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs35\lang1033\b\kerning1\dbch\af7\langfe2052{\listtext\pard\plain }\ilvl0\ls1 \fi0\li0\lin0\fi0\li0\lin0{\loch +{\*\bkmkstart __RefHeading___Toc520_557546903}{\*\bkmkend __RefHeading___Toc520_557546903}Grant of Copyright License} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +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, sub-license, and distribute the Work and such Derivative Works in Source or Object form.} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s1\rtlch\af9\afs36\alang1081\ab0 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs35\lang1033\b\kerning1\dbch\af7\langfe2052{\listtext\pard\plain }\ilvl0\ls1 \fi0\li0\lin0\fi0\li0\lin0{\loch +{\*\bkmkstart __RefHeading___Toc522_557546903}{\*\bkmkend __RefHeading___Toc522_557546903}Grant of Patent License} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +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.} +\par \pard\plain \s1\rtlch\af9\afs36\alang1081\ab0 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs35\lang1033\b\kerning1\dbch\af7\langfe2052\pagebb{\listtext\pard\plain }\ilvl0\ls1 \fi0\li0\lin0\fi0\li0\lin0{\loch +{\*\bkmkstart __RefHeading___Toc524_557546903}{\*\bkmkend __RefHeading___Toc524_557546903}Redistribution} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +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:} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052{\listtext\pard\plain 1.\tab}\ilvl0\ls3 \fi-360\li720\lin720\sl276\slmult1{\loch +You must give any other recipients of the Work or Derivative Works a copy of this License; and} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052{\listtext\pard\plain 2.\tab}\ilvl0\ls3 \fi-360\li720\lin720\sl276\slmult1{\loch +You must cause any modified files to carry prominent notices stating that You changed the files; and} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052{\listtext\pard\plain 3.\tab}\ilvl0\ls3 \fi-360\li720\lin720\sl276\slmult1{\loch +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} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052{\listtext\pard\plain 4.\tab}\ilvl0\ls3 \fi-360\li720\lin720\sl276\slmult1{\loch +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.} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052{\listtext\pard\plain 5.\tab}\ilvl0\ls3 \fi-360\li720\lin720\sl276\slmult1{\loch +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.} +\par \pard\plain \s1\rtlch\af9\afs36\alang1081\ab0 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs35\lang1033\b\kerning1\dbch\af7\langfe2052{\listtext\pard\plain }\ilvl0\ls1 \fi0\li0\lin0\fi0\li0\lin0{\loch +Submission of Contributions} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +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.} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s1\rtlch\af9\afs36\alang1081\ab0 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs35\lang1033\b\kerning1\dbch\af7\langfe2052{\listtext\pard\plain }\ilvl0\ls1 \fi0\li0\lin0\fi0\li0\lin0{\loch +Trademarks} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +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.} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s1\rtlch\af9\afs36\alang1081\ab0 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs35\lang1033\b\kerning1\dbch\af7\langfe2052{\listtext\pard\plain }\ilvl0\ls1 \fi0\li0\lin0\fi0\li0\lin0{\loch +Disclaimer of Warranty} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +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.} +\par \pard\plain \s1\rtlch\af9\afs36\alang1081\ab0 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs35\lang1033\b\kerning1\dbch\af7\langfe2052\pagebb{\listtext\pard\plain }\ilvl0\ls1 \fi0\li0\lin0\fi0\li0\lin0{\loch +Limitation of Liability} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1{\loch +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.} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\loch + +\par \pard\plain \s1\rtlch\af9\afs36\alang1081\ab0 \ltrch\lang1033\langfe2052\hich\af4\loch\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\f4\fs35\lang1033\b\kerning1\dbch\af7\langfe2052{\listtext\pard\plain }\ilvl0\ls1 \fi0\li0\lin0\fi0\li0\lin0{\loch +Accepting Warranty or Additional Liability} +\par \pard\plain \s85\rtlch\af9\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af4\loch\sl276\slmult1\ql\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\f4\fs24\lang1033\kerning1\dbch\af6\langfe2052\sl276\slmult1\sb0\sa140{\loch +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.} +\par } \ No newline at end of file diff --git a/.src/licenses/deb-copyright b/.src/licenses/deb-copyright new file mode 100644 index 0000000..7f76c5e --- /dev/null +++ b/.src/licenses/deb-copyright @@ -0,0 +1,14 @@ +Files: * +Copyright: 2023 (Holloway) Chew, Kean Ho +License: Apache-2.0 + 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/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..0d426d4 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,132 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement by raising a +matter forum in the Issues section. All complaints will be reviewed and +investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/CONFIG.toml b/CONFIG.toml new file mode 100644 index 0000000..35b91d0 --- /dev/null +++ b/CONFIG.toml @@ -0,0 +1,943 @@ +# AutomataCI - Project Configurations Data File +################################################################################ +# WARNING: STRICTLY ONLY THESE PATTERN ARE ALLOWED: # +# # +# 'key' = 'value: string type' # 1 line tailing comment # +# # +# OR # +# # +# # full line comment # +# # +# Both Batch and POSIX Shell do not have sophisicated functions # +# (e.g. POSIX Shell does not have array at all!). # +# # +# DO NOT get too creative with TOML! # +################################################################################ +#################### +# PROJECT METADATA # +#################### +# PROJECT_SKU +# 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 = "hestiaerror" + + +# 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 = "hestiaERROR" + + +# PROJECT_APP_ID +# This is the known application complying to the unique 3-parts identifier +# (e.g. com.example.www) used in Flatpak, Google Play Store, etc. The triples +# 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.hestiaerror" + + +# PRODUCT_APP_UUID +# This is the 128-bits known application GUID code complying to: +# (1) Microsoft GUID Format +# See: https://learn.microsoft.com/en-us/windows/win32/msi/guid +# (2) RFC4412 UUID Format +# See: https://datatracker.ietf.org/doc/html/rfc4122 +# +# As such, the UUID **MUST** be: +# 1. all UPPERCASE; AND +# 2. only in hexadecimal format (0-9-A-F); AND +# 3. shall be retained as the first point of origin; AND +# 4. comply to this format: {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} +# +# For minimal collision, Binary wire format is preferred such that: +# (1) 8 octets - UTC time in 64-bits hexadecimal format since Epoch. +# (2) Remaining octets - Randomized data with own definitions. +# (3) Shuffle each octet positions with cryptography random algorithm. +# +# 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 = "7E665EAF-446B-7738-84D9-FE18BE03949E" + + +# PROJECT_NAME +# This is the name of the product used in documentation, marketing addresses +# etc only. For programming purposes, PROJECT_SKU is used instead. +PROJECT_NAME = "Chew Kean Ho's hestiaERROR" + + +# PROJECT_PITCH +# A short elevator pitch about the project used as a short description. Max +# Max: 60 characters. +PROJECT_PITCH = "One Peaceful Frontend+Backend Software Library Suite." + + +# PROJECT_VERSION +# This is to declare the current project's version. It can be used for +# generating version declaration files (e.g. VERSION, version.go, etc). You +# should only update this field and leave the AutomataCI to generate those +# output files. +# +# In case of a release with purpose like release candidates, tlide (~) is used +# 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 = "0.0.1" + + +# 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'. +# +# When it doubt or unused, set to 1 and use numerical increment only. +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_CONTACT_BRAND +# 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_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_NAME +# Entity's full name for inquiries. +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_WEBSITE +# Entity's website channel for sourcing information. +PROJECT_CONTACT_WEBSITE = "https://www.hollowaykeanho.com" + + +# PROJECT_SOURCE_URL +# The Project's source code URL. This URL points to the source code location. +# The URL can be used for other purposes such as The Docker's OCI Image source +# field (org.opencontainers.image.source) which can be used for other connecting +# purposes like GitHub Repo-Packages linking. See: +# 1. https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package +# +# Example: +# 1. GitHub Packages : https://github.com/OWNER/REPO +PROJECT_SOURCE_URL = "https://github.com/ChewKeanHo/hestiaERROR" + + +# AUTOMATACI_LANG +# Overrides AutomataCI to operate in 1 specific language. Otherwise, AutomataCI +# shall query the system language settings. Only accepts language code complying +# 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 = "" + + + + +###################### +# ANGULAR TECHNOLOGY # +###################### +# PROJECT_ANGULAR +# This is a control variable used for enabling Angular technology and also +# defining its source codes directory relative to PROJECT_PATH_ROOT. Depending +# on the offered service (e.g. GitHub Actions), setting this variable with value +# shall notify the CI provider to setup Go development environment +# automatically. +# +# To enable it: simply supply the path (e.g. default is 'srcANGULAR'). +# To disable it: simply supply an empty path (e.g. default is ''). +PROJECT_ANGULAR = '' + + + + +###################### +# C TECHNOLOGY # +###################### +# PROJECT_C +# This is a control variable used for enabling C technology and also defining +# its source codes directory relative to PROJECT_PATH_ROOT. Depending on the +# offered service (e.g. GitHub Actions), setting this variable with value shall +# notify the CI provider to setup Go development environment automatically. +# +# To enable it: simply supply the path (e.g. default is 'srcC'). +# To disable it: simply supply an empty path (e.g. default is ''). +PROJECT_C = '' + + + + +###################### +# CITATION # +###################### +# PROJECT_CITATION +# This is the control variable used to generate the CITATION.cff file during the +# Release CI Job. It is the cff-version field's value. +# +# 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_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" + + + + +###################### +# DOTNET TECHNOLOGY # +###################### +# PROJECT_DOTNET +# This is a control variable used for enabling .NET technology in the +# repository. Unlike other technologies, due to .NET nature, it is basically +# a passive library located in the following directory: +# ${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS/${PROJECT_PATH_DOTNET_ENGINE} +# +# IMPORTANT NOTE: .NET is always enabled for Windows OS due to other +# dependencies like MSI wix toolkits and etc. This variable only affects UNIX +# side of stuffs. +# +# WARNING: installing .NET can increase setup time dramatically (e.g. ~+2mins +# in GitHub Actions). Only include when it's absolutely used or needed. +# +# To enable it: simply supply the path (e.g. default is 'true'). +# To disable it: simply supply an empty path (e.g. default is ''). +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_DOTNET_CHANNEL +# This is to configure the .NET version to be installed by AutomataCI. It SHALL +# NOT be empty. +# +# Refer the following doc "channel" section to learn more: +# https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script +# +# When in doubt, use "LTS" +PROJECT_DOTNET_CHANNEL = "LTS" + + +# DOTNET_CLI_TELEMETRY_OPTOUT +# .NET default telemetry setting that will transmit its usage data back to +# Microsoft. +# +# To preserve privacy and considering UNIX environments, it is enabled by +# default. +# +# To enable: "1" +# To disable: commit it out. +DOTNET_CLI_TELEMETRY_OPTOUT = "1" + + +# PROJECT_PATH_NUPKG +# This is a relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_TOOLS + +# 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" + + + + +###################### +# GOOGLE AI # +###################### +# PROJECT_GOOGLEAI +# This is a control variable used for enabling the Google AI demo workspace in +# the repository. It's entirely facilitated just to demonstrate and test the +# integrated Google AI libraries. +# +# To enable it: simply supply the path (e.g. default is 'srcGOOGLEAI'). +# To disable it: simply supply an empty path (e.g. default is ''). +PROJECT_GOOGLEAI = '' + + +# GOOGLEAI_API_URL +# This is the base URL for Google AI API interfaces. It is specified in +# (1) https://ai.google.dev/api/rest +# (2) https://ai.google.dev/tutorials/rest_quickstart +# +# This is used to enable Google AI interfacing for terminal. Note that without +# the GOOGLE_AI_API_TOKEN (in SECRETS.toml), Google AI cloud services are +# unavailable. +GOOGLEAI_API_URL = 'https://generativelanguage.googleapis.com' + + +# GOOGLEAI_API_VERSION +# This specifies the API interface version. It is specified in +# (1) https://ai.google.dev/api/rest +# +# This is used to configure Google AI API interfaces for terminal. +GOOGLEAI_API_VERSION = 'v1beta' + + +# GOOGLEAI_MODEL +# This specifies the AI model to be used. It is specified in: +# (1) https://ai.google.dev/models/ +# +# This is used to configure Google AI API interfaces for terminal and it's part +# of its url. Hence, the correct value is usually leads with 'models/[TYPE]'. +# +# Default is: models/gemini-pro +GOOGLEAI_MODEL = 'models/gemini-pro' + + +# GOOGLEAI_BLOCK_HATE_SPEECH +# This specifies the AI filtering category for hate speeches. It uses the +# string-type enumerated values stated in: +# (1) https://ai.google.dev/api/rest/v1beta/HarmCategory +# (2) https://ai.google.dev/api/rest/v1beta/SafetySetting#HarmBlockThreshold +# +# Acceptable values are: +# (1) 'HARM_BLOCK_THRESHOLD_UNSPECIFIED' - not specified +# (2) 'BLOCK_LOW_AND_ABOVE' - NEGLIGIBLE is allowed. +# (3) 'BLOCK_MEDIUM_AND_ABOVE' - LOW & NEGLIGIBLE allowed. +# (4) 'BLOCK_ONLY_HIGH' - MEDIUM, LOW & NEGLIGIBLE allowed. +# (5) 'BLOCK_NONE' - All content will be allowed. +# +# If value is unavailable (empty string), then 'BLOCK_NONE' is the default. +GOOGLEAI_BLOCK_HATE_SPEECH = 'BLOCK_NONE' + + +# GOOGLEAI_BLOCK_SEXUALLY_EXPLICIT +# This specifies the AI filtering category for sexually explicit content. It +# uses the string-type enumerated values stated in: +# (1) https://ai.google.dev/api/rest/v1beta/HarmCategory +# (2) https://ai.google.dev/api/rest/v1beta/SafetySetting#HarmBlockThreshold +# +# Acceptable values are: +# (1) 'HARM_BLOCK_THRESHOLD_UNSPECIFIED' - not specified +# (2) 'BLOCK_LOW_AND_ABOVE' - NEGLIGIBLE is allowed. +# (3) 'BLOCK_MEDIUM_AND_ABOVE' - LOW & NEGLIGIBLE allowed. +# (4) 'BLOCK_ONLY_HIGH' - MEDIUM, LOW & NEGLIGIBLE allowed. +# (5) 'BLOCK_NONE' - All content will be allowed. +# +# If value is unavailable (empty string), then 'BLOCK_NONE' is the default. +GOOGLEAI_BLOCK_SEXUALLY_EXPLICIT = 'BLOCK_NONE' + + +# GOOGLEAI_BLOCK_DANGEROUS_CONTENT +# This specifies the AI filtering category for dangerous content. It +# uses the string-type enumerated values stated in: +# (1) https://ai.google.dev/api/rest/v1beta/HarmCategory +# (2) https://ai.google.dev/api/rest/v1beta/SafetySetting#HarmBlockThreshold +# +# Acceptable values are: +# (1) 'HARM_BLOCK_THRESHOLD_UNSPECIFIED' - not specified +# (2) 'BLOCK_LOW_AND_ABOVE' - NEGLIGIBLE is allowed. +# (3) 'BLOCK_MEDIUM_AND_ABOVE' - LOW & NEGLIGIBLE allowed. +# (4) 'BLOCK_ONLY_HIGH' - MEDIUM, LOW & NEGLIGIBLE allowed. +# (5) 'BLOCK_NONE' - All content will be allowed. +# +# If value is unavailable (empty string), then 'BLOCK_NONE' is the default. +GOOGLEAI_BLOCK_DANGEROUS_CONTENT = 'BLOCK_NONE' + + +# GOOGLEAI_BLOCK_HARASSMENT +# This specifies the AI filtering category for harassment content. It +# uses the string-type enumerated values stated in: +# (1) https://ai.google.dev/api/rest/v1beta/HarmCategory +# (2) https://ai.google.dev/api/rest/v1beta/SafetySetting#HarmBlockThreshold +# +# Acceptable values are: +# (1) 'HARM_BLOCK_THRESHOLD_UNSPECIFIED' - not specified +# (2) 'BLOCK_LOW_AND_ABOVE' - NEGLIGIBLE is allowed. +# (3) 'BLOCK_MEDIUM_AND_ABOVE' - LOW & NEGLIGIBLE allowed. +# (4) 'BLOCK_ONLY_HIGH' - MEDIUM, LOW & NEGLIGIBLE allowed. +# (5) 'BLOCK_NONE' - All content will be allowed. +# +# If value is unavailable (empty string), then 'BLOCK_NONE' is the default. +GOOGLEAI_BLOCK_HARASSMENT = 'BLOCK_NONE' + + + + +########################## +# LIBREOFFICE TECHNOLOGY # +########################## +# PROJECT_LIBREOFFICE +# This is a control variable used for enabling LibreOffice technology and also +# defining its source directory relative to PROJECT_PATH_ROOT. Depending on the +# offered service (e.g. GitHub Actions), setting this variable with value shall +# notify the CI provider to setup Go development environment automatically. +# +# To enable it: simply supply the path (e.g. default is 'srcLIBREOFFICE'). +# To disable it: simply supply an empty path (e.g. default is ''). +PROJECT_LIBREOFFICE = '' + + +# PROJECT_LIBREOFFICE_MIRROR +# This is the base URL for downloading the libreoffice installer. The pathing +# shall be the directory listing each distribution type (as in you will see +# 'flatpak', 'portable', 'src', 'stable', 'testing', ...). You should include +# the URL without the suffixing the '/' symbol. +# +# Refer to the following mirror list for value selection: +# (1) https://download.documentfoundation.org/mirmon/allmirrors.html +PROJECT_LIBREOFFICE_MIRROR = "https://ftp.osuosl.org/pub/tdf/libreoffice" + + +# PROJECT_LIBREOFFICE_VERSION +# This is for defining the LibreOffice version to install into the local OS. +# +# Refer the the following list for value selection: +# (1) https://www.libreoffice.org/download/download-libreoffice/ +# +# Example: '24.2.1' for 'LibreOffice 24.2.1' +PROJECT_LIBREOFFICE_VERSION = "24.2.1" + + + + +###################### +# GO TECHNOLOGY # +###################### +# PROJECT_GO +# This is a control variable used for enabling Go technology and also defining +# its source codes directory relative to PROJECT_PATH_ROOT. Depending on the +# offered service (e.g. GitHub Actions), setting this variable with value shall +# notify the CI provider to setup Go development environment automatically. +# +# To enable it: simply supply the path (e.g. default is 'srcGO'). +# To disable it: simply supply an empty path (e.g. default is ''). +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" + + + + +###################### +# NIM TECHNOLOGY # +###################### +# PROJECT_NIM +# This is a control variable used for enabling Nim technology and also defining +# its source codes directory relative to PROJECT_PATH_ROOT. Depending on the +# offered service (e.g. GitHub Actions), setting this variable with value shall +# notify the CI provider to setup Go development environment automatically. +# +# To enable it: simply supply the path (e.g. default is 'srcNIM'). +# To disable it: simply supply an empty path (e.g. default is ''). +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" + + + + +###################### +# PYTHON TECHNOLOGY # +###################### +# PROJECT_PYTHON +# This is a control variable used for enabling Python technology and also +# defining its source codes directory relative to PROJECT_PATH_ROOT. +# Depending on the offered service (e.g. GitHub Actions), setting this +# variable with value shall notify the CI provider to setup Python development +# environment automatically. +# +# To enable it: simply supply the path (e.g. default is 'srcPYTHON'). +# To disable it: simply supply an empty path (e.g. default is ''). +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_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_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_MIME +# The PyPi README file's MIME type data. Default is 'text/markdown'. +PROJECT_PYPI_README_MIME = "text/markdown" + + + + +###################### +# RESEARCH PAPER # +###################### +# PROJECT_RESEARCH +# This is the control variable used for enabling research paper generation and +# also defining its source directory relative to PROJECT_PATH_ROOT. Depending on +# the offered service (e.g. GitHub Actions), setting this variable with value +# shall notify the CI provider to setup the necessary software automatically. +# +# To enable it: simply supply the path (e.g. default is 'srcRESEARCH'). +# To disable it: simply supply an empty path (e.g. default is ''). +PROJECT_RESEARCH = '' + + + + +###################### +# RUST TECHNOLOGY # +###################### +# PROJECT_RUST +# This is a control variable used for enabling Rust technology and also +# defining its source codes directory relative to PROJECT_PATH_ROOT. +# Depending on the offered service (e.g. GitHub Actions), setting this +# variable with value shall notify the CI provider to setup Rust development +# environment automatically. +# +# To enable it: simply supply the path (e.g. default is 'srcRUST'). +# To disable it: simply supply an empty path (e.g. default is ''). +PROJECT_RUST = '' + + +# PROJECT_RUST_EDITION +# The Rust's formatter and linting edition (Cargo.toml's edition field). +# +# Default is '2021'. +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_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" + + +# CARGO_REGISTRY +# The Cargo registry. +# +# Default is: crates-io +CARGO_REGISTRY = "crates-io" + + + + +########################## +# DISTRIBUTION ECOSYSTEM # +########################## +# PROJECT_CHANGELOG_TITLE +# The title of the changelog file. +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_SHA512 +# Perform SHA512 checksum file generation. To disable it, simply let it +# empty. +# +# Otherwise, as long as it's not empty, it is enabled. +PROJECT_RELEASE_SHA512 = "enabled" + + +# PROJECT_DEBIAN_IS_NATIVE +# Flag to determine the project is Debian natively sponsored package. Usually +# is false. +# Only accept: "true/false" +PROJECT_DEBIAN_IS_NATIVE = "false" + + +# PROJECT_DEBIAN_PRIORITY +# Indicate the current package's distribution priority. Strictly the following +# values +# (1) required +# (2) important +# (3) standard +# (4) optional +# (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" + + +# PROJECT_DEBIAN_URGENCY +# The urgency value 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 +# (3) high = for user diversions +# (4) emergency +# (5) critical +PROJECT_DEBIAN_URGENCY = "low" + + +# PROJECT_DEBIAN_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_FLATPAK_RUNTIME +# The runtime module where the Flatpak is operating on. +PROJECT_FLATPAK_RUNTIME = "org.freedesktop.Platform" + + +# PROJECT_FLATPAK_RUNTIME_VERSION +# The runtime module where the Flatpak is operating on. +PROJECT_FLATPAK_RUNTIME_VERSION = "22.08" + + +# PROJECT_FLATPAK_SDK +# The runtime module where the Flatpak is operating on. +PROJECT_FLATPAK_SDK = "org.freedesktop.Sdk" + + +# 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. +# +# When in doubt or unused, set the value to 'main'. +PROJECT_REPREPRO_CODENAME = "main" + + +# 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. +# +# This is mainly used to group the packages by categories (e.g. 'firmware', +# 'gui', 'models', etc). +# +# When in doubt or unused, set the value matching PROJECT_DEBIAN_DISTRIBUTION. +PROJECT_REPREPRO_COMPONENT = "stable" + + +# 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. +# +# When left empty, AutomataCI shall generate a full list of arch-only hard-coded +# arch values. +PROJECT_REPREPRO_ARCH = "" + + +# 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/hestiaERROR.wiki.git" + + +# PROJECT_STATIC_REPO_KEY +# The git upstream key. Default is 'origin'. +PROJECT_STATIC_REPO_KEY = "origin" + + +# PROJECT_STATIC_REPO_BRANCH +# The git upstream branch. Default is 'master' or 'main'. +PROJECT_STATIC_REPO_BRANCH = "master" + + +# 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). +# +# PROJECT_SIMULATE_RELEASE_REPO = "" # Reserved - provided by external. + + +# PROJECT_ROBOT_RUN +# A flag to indicate the run is operating inside a CI service by its +# autonomous robot. +# +# PROJECT_ROBOT_RUN = "" # Reserved - provided by external. + + +# 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/hestiaERROR/wiki/" + + +# 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" + + +# 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_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_HOMEBREW_REPO_KEY +# The git upstream key. Default is 'origin'. +PROJECT_HOMEBREW_REPO_KEY = "origin" + + +# PROJECT_HOMEBREW_REPO_BRANCH +# The git upstream branch. Default is 'main' or 'master'. +PROJECT_HOMEBREW_REPO_BRANCH = "main" + + +# 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. +# +# NOTE: Please avoid ending with the URL slash. +PROJECT_HOMEBREW_SOURCE_URL = "https://github.com/ChewKeanHo/hestiaERROR/releases/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_CHOCOLATEY_REPO_KEY +# The git upstream key. Default is 'origin'. +PROJECT_CHOCOLATEY_REPO_KEY = "origin" + + +# PROJECT_CHOCOLATEY_REPO_BRANCH +# The git upstream branch. Default is 'main' or 'master'. +PROJECT_CHOCOLATEY_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. +# +# NOTE: Please avoid ending with the URL slash. +PROJECT_CHOCOLATEY_SOURCE_URL = "https://github.com/ChewKeanHo/hestiaERROR/releases/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/hestiaERROR.git" + + +# PROJECT_DOCS_REPO_KEY +# The git upstream key. Default is 'origin'. +PROJECT_DOCS_REPO_KEY = "origin" + + +# PROJECT_DOCS_REPO_BRANCH +# The git upstream branch. Default is 'gh-pages'. +PROJECT_DOCS_REPO_BRANCH = "gh-pages" + + +# PROJECT_DOCS_REPO_DIRECTORY +# The directory name housing the docs repo. Value CANNOT be empty. +# Default is 'docs'. +PROJECT_DOCS_REPO_DIRECTORY = "docs" + + +# 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. +# +# NOTE: Please avoid ending with the URL slash. +PROJECT_DOCS_SOURCE_URL = "https://github.io/ChewKeanHo/hestiaERROR" + + + + +###################### +# PROJECT FILESYSTEM # +###################### +# PROJECT_PATH_ROOT +# This is an absolute pathing to locate the root directory of the project +# repository. +# PROJECT_PATH_ROOT = '...' # Reserved - determined by ci.cmd automatically. + + +# PROJECT_PATH_AUTOMATA +# This is the reserved pathing to PROJECT_PATH_ROOT where it locates the +# AutomataCI working directory. +# +# WARNING: DO NOT attempt to change/override this naming convention. It will +# break AutomataCI. +# 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. + + +# 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_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_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_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_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_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_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_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_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_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_DOCS +# This is the relative pathing to PROJECT_PATH_ROOT where it locates the +# project's documentation directory. +PROJECT_PATH_DOCS = "public" diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,201 @@ + 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/README.md b/README.md new file mode 100644 index 0000000..14cb616 --- /dev/null +++ b/README.md @@ -0,0 +1,90 @@ +# Hestia Libraries - `hestiaERROR` + +[![Hestia Libraries](.src/icons/banner_1200x270.svg)](#) + +One Peaceful Frontend+Backend Software Library Suite. + +This repository houses the operating components of the error code numbering +definitions and representations for various supported programming languages. The +repository splits itself into multiple parts depending on its language-specific +or deployment-specific usage. + + + + +## Why It Matters + +This project was initiated primarily because of: + +1. **Ensures proper interoperability between programming languages** - + making sure the `hestiaERROR` library talks to each other seamlessly across + programming languages with the same context. +2. **Utilizing low memory, language-free, and simple error reporting** - + using simple 1 byte number across the projects and software layers for + highest efficiency and works as a signal. +3. **Keeping string representations within the project's language + internationalization libraries** - making string processing and translations + a lot more simple to manage and operate. +4. **Simple to integrate** - simple enough to use the supported programming + language's package manager. + + + + +## Setup + +This library supports multiple programming languages for the same dataset. +Hence, in order to use it, please import based on your deployed programming +language: + +> **NOTE** +> +> To be updated. + + + + +## Data Source + +The libraries are based on the following data sources: + +1. Linux Kernel - Universal Base Error Numbers + 1. Source: `include/uapi/asm-generic/errno-base.h` +2. Linux Kernel - Generic Assembly Error Numbers + 1. Source: `include/uapi/asm-generic/errno.h` +3. Linux Kernel - Extended Error Numbers + 1. Source: `include/linux/errno.h` +4. BASH Exit Status list + 1. Source: https://tldp.org/LDP/abs/html/exitcodes.html +5. PowerShell Error Handling + 1. Source: https://learn.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-exceptions + +These sources are strongly referencing from the Linux Kernel while maintaining +the definitions usable even at operating system scripting level for both UNIX +and Windows OSes. + +The definitions complies to only the following rules: + +1. **STRICTLY**: **`0` represents OK**. +2. Restricts within 8-bits unsigned integer (1 byte) range (`0` to `255`). +3. Numbers' definitions are context free (e.g. each software layers can response + differently). +4. Avoid redefining existing codes (can but frown upon). + +Based on years of programming experiences across multiple languages, these error +codes are newly defined and each software layers can redefine the list whenever +needed for independent packaging purposes. + + + + +## Test Cases + +The library is heavily guarded with unit tests whenever available. + + + + +## License + +This project is licensed under [OSI compliant Apache 2.0 License](LICENSE.txt). diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..4d3ab4d --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,14 @@ +# Security Policy - Reporting a Vulnerability +We take security issues seriously AND WITHOUT CAUSING PUBLIC PANICS. Therefore, +if you find any security vulnerability (both suspicious or confirmed), please +feel free to communicate with my team at: + +``` +security@hollowaykeanho.com +``` + +or raise a report under **Report a security vulnerability** title in the +GitHub's Issues section. + + +**REMEMBER**: DO NOT CAUSE PUBLIC PANICS. Please be professional. diff --git a/automataCI/SECRETS-template.toml b/automataCI/SECRETS-template.toml new file mode 100644 index 0000000..c37a4ce --- /dev/null +++ b/automataCI/SECRETS-template.toml @@ -0,0 +1,129 @@ +###################### +# PYTHON TECHNOLOGY # +###################### +# TWINE_USERNAME +# Use for logging in a PyPi server. This is the account username. Only used +# when PROJECT_PYTHON is enabled. +TWINE_USERNAME = "" + + +# TWINE_PASSWORD +# Use for logging in a PyPi server. This is the account password. Only used +# when PROJECT_PYTHON is enabled. +TWINE_PASSWORD = "" + + + + +###################### +# RUST TECHNOLOGY # +###################### +# CARGO_PASSWORD +# Use for logging in a Cargo registry server. This is the account +# password/secret token. Only used when PROJECT_RUST is enabled. +CARGO_PASSWORD = "" + + + + +########################## +# DISTRIBUTION ECOSYSTEM # +########################## +# PROJECT_GPG_ID +# Your GPG ID for signing here. Note that this requires GPG to be installed in +# the system and the secret key is available for performing such transaction. +PROJECT_GPG_ID ="" + + +# CONTAINER_USERNAME +# Use to login your container image's registry's service provider (e.g. Docker, +# GitHub Packages) etc. This is the account username. +CONTAINER_USERNAME = "" + + +# CONTAINER_PASSWORD +# Use to login your container image's registry's service provider (e.g. Docker, +# GitHub Packages) etc. This is the account password or token value. +CONTAINER_PASSWORD = "" + + + + +########################## +# MICROSOFT # +########################## +# MICROSOFT_CERT +# The cert file for Microsoft Windows' code-signing certifcate use. The format +# can be normal certifcate, SPC, or PKCS12. +MICROSOFT_CERT = "" + + +# MICROSOFT_CERT_HASH +# The shasum algorithm of the certificate for Microsoft Windows' code-signing +# certifcate use. It can be of the following values: +# 1) 'SHA256' +# 2) 'MD5' +# 3) 'SHA1' +# 4) 'SHA2' +# 5) 'SHA384' +# 6) 'SHA512' +MICROSOFT_CERT_HASH = "" + + +# MICROSOFT_CERT_TYPE +# The cert type for Microsoft Windows' code-signing certifcate use. It can only +# be the following values: +# 1. 'CERT' - conventional cert format +# 2. 'SPC' - SPC format +# 3. 'PKCS12' - PKCS12 container format +MICROSOFT_CERT_TYPE = "" + + +# MICROSOFT_CERT_TIMESTAMP +# The URL for sourcing the timestamp used in Microsoft Windows' code-signing +# process. Although specification stated not required, AutomataCI set it as +# compulsory. Known good cert location are: +# 1. http://timestamp.digicert.com +# 2. http://timestamp.sectigo.com +MICROSOFT_CERT_TIMESTAMP = "" + + +# MICROSOFT_KEYFILE +# The private keyfile for Microsoft Windows' code-signing certifcate use. It is +# optional if MICROSOFT_CERT is a PKCS12 format. +MICROSOFT_CERT_KEYFILE = "" + + +# MICROSOFT_CERT_PASSWORD +# Private password to unlock the Microsoft Windows' code-signing certifcate and +# private key for signing. Only used with osslsigncode and equivalent usually +# in Notary stage. +MICROSOFT_CERT_PASSWORD = "" + + + + +########################## +# APPLE # +########################## +# APPLE_DEVELOPER_ID +# The developer ID used for notarization process. +APPLE_DEVELOPER_ID = "" + +# APPLE_KEYCHAIN_PROFILE +# The keychain access used for accessing notarization credentials. +APPLE_KEYCHAIN_PROFILE = "" + + + + +###################### +# GOOGLE AI # +###################### +# GOOGLEAI_API_TOKEN +# This is the authentication API token provided by Google AI using Google AI +# Studio. A token can be procured from: +# (1) https://aistudio.google.com/ (look for 'Get API Key' button) +# +# Without this token, GOOGLEAI library will not function at all. +GOOGLEAI_API_TOKEN = '' diff --git a/automataCI/_package-archive_unix-any.sh b/automataCI/_package-archive_unix-any.sh new file mode 100644 index 0000000..2f82340 --- /dev/null +++ b/automataCI/_package-archive_unix-any.sh @@ -0,0 +1,140 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/archive/zip.sh" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +PACKAGE_Run_ARCHIVE() { + #__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#*|}" + + + # validate input + I18N_Check_Availability "TAR" + TAR_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + I18N_Check_Availability "ZIP" + TAR_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # prepare workspace and required values + 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}" + I18N_Remake "$_src" + FS_Remake_Directory "$_src" + if [ $? -ne 0 ]; then + I18N_Remake_Failed + return 1 + fi + + + # copy all complimentary files to the workspace + cmd="PACKAGE_Assemble_ARCHIVE_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" "$_src" "$_target_filename" "$_target_os" "$_target_arch" + case $? in + 10) + I18N_Assemble_Skipped + FS_Remove_Silently "$_src" + return 0 + ;; + 0) + ;; + *) + I18N_Assemble_Failed + return 1 + ;; + esac + + + # change location into the workspace + __current_path="$PWD" && cd "$_src" + + + # archive the assembled payload + case "$_target_os" in + windows) + _target_path="${_target_path}.zip" + I18N_Package "$_target_path" + ZIP_Create "$_target_path" "*" + ___process=$? + ;; + *) + _target_path="${_target_path}.tar.xz" + I18N_Package "$_target_path" + TAR_Create_XZ "$_target_path" "*" + ___process=$? + ;; + esac + + + # head back to current directory + cd "$__current_path" && unset __current_path + + + # report status + if [ $___process -ne 0 ]; then + return 1 + fi + + return 0 +} diff --git a/automataCI/_package-archive_windows-any.ps1 b/automataCI/_package-archive_windows-any.ps1 new file mode 100644 index 0000000..47b397d --- /dev/null +++ b/automataCI/_package-archive_windows-any.ps1 @@ -0,0 +1,132 @@ +# 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\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\zip.ps1" + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataIC/ci.sh.ps1 instead!`n" + return +} + + + + +function PACKAGE-Run-ARCHIVE { + 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] + + + # validate input + $null = I18N-Check-Availability "TAR" + $___process = TAR-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + $null = I18N-Check-Availability "ZIP" + $___process = ZIP-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + + # prepare workspace and required values + $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}" + $null = I18N-Remake "${_src}" + $___process = FS-Remake-Directory "${_src}" + if ($___process -ne 0) { + $null = I18N-Remake-Failed + return 1 + } + + + # copy all complimentary files to the workspace + $cmd = "PACKAGE-Assemble-ARCHIVE-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-ARCHIVE-Content ` + ${_target} ` + ${_src} ` + ${_target_filename} ` + ${_target_os} ` + ${_target_arch} + switch ($___process) { + 10 { + $null = I18N-Assemble-Skipped + $null = FS-Remove-Silently "${_src}" + return 0 + } 0 { + # accepted + } Default { + $null = I18N-Assemble-Failed + return 1 + }} + + + # change location into the workspace + $__current_path = Get-Location + $null = Set-Location -Path "${_src}" + + + # archive the assembled payload + switch ($_target_os) { + windows { + $_target_path = "${_target_path}.zip" + $null = I18N-Package "${_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}" "*" + }} + + + # head 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/_package-cargo_unix-any.sh b/automataCI/_package-cargo_unix-any.sh new file mode 100644 index 0000000..c7c0e0b --- /dev/null +++ b/automataCI/_package-cargo_unix-any.sh @@ -0,0 +1,125 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/rust.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_CARGO() { + #__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#*|}" + + + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_RUST") -eq 0 ]; then + return 0 + fi + + I18N_Check_Availability "RUST" + RUST_Activate_Local_Environment + RUST_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 0 + fi + + + # prepare workspace and required values + 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}" + I18N_Remake "$_src" + FS_Remake_Directory "$_src" + if [ $? -ne 0 ]; then + I18N_Remake_Failed + return 1 + fi + + I18N_Check "$_target_path" + FS_Is_Directory "$_target_path" + if [ $? -eq 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # copy all complimentary files to the workspace + cmd="PACKAGE_Assemble_CARGO_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" "$_src" "$_target_filename" "$_target_os" "$_target_arch" + case $? in + 10) + I18N_Assemble_Skipped + FS_Remove_Silently "$_src" + return 0 + ;; + 0) + ;; + *) + I18N_Assemble_Failed + return 1 + ;; + esac + + + # archive the assembled payload + I18N_Package "$_target_path" + FS_Make_Directory "$_target_path" + RUST_Create_Archive "$_src" "$_target_path" + if [ $? -ne 0 ]; then + I18N_Package_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/_package-cargo_windows-any.ps1 b/automataCI/_package-cargo_windows-any.ps1 new file mode 100644 index 0000000..0c6831b --- /dev/null +++ b/automataCI/_package-cargo_windows-any.ps1 @@ -0,0 +1,116 @@ +# 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\rust.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-CARGO { + 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] + + + # validate input + if ($(STRINGS-Is-Empty "${env:PROJECT_RUST}") -eq 0) { + return 0 + } + + $null = I18N-Check-Availability "RUST" + $null = RUST-Activate-Local-Environment + $___process = RUST-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 0 + } + + + # prepare workspace and required values + $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}" + $null = I18N-Remake "${_src}" + $___process = FS-Remake-Directory "${_src}" + if ($___process -ne 0) { + $null = I18N-Remake-Failed + return 1 + } + + $null = I18N-Check "${_target_path}" + $___process = FS-Is-Directory "${_target_path}" + if ($___process -eq 0) { + $null = I18N-Check-Failed + return 1 + } + + + # copy all complimentary files to the workspace + $cmd = "PACKAGE-Assemble-CARGO-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-CARGO-Content ` + ${_target} ` + ${_src} ` + ${_target_filename} ` + ${_target_os} ` + ${_target_arch} + if ($___process -eq 10) { + $null = I18N-Assemble-Skipped + $null = FS-Remove-Silently "${_src}" + return 0 + } elseif ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + + # archive the assembled payload + $null = I18N-Package "${_target_path}" + $null = FS-Make-Directory "${_target_path}" + $___process = RUST-Create-Archive "${_src}" "${_target_path}" + if ($___process -ne 0) { + $null = I18N-Package-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/_package-changelog_unix-any.sh b/automataCI/_package-changelog_unix-any.sh new file mode 100644 index 0000000..0e8131b --- /dev/null +++ b/automataCI/_package-changelog_unix-any.sh @@ -0,0 +1,89 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/changelog.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_CHANGELOG() { + __changelog_md="$1" + __changelog_deb="$2" + + + I18N_Check_Availability "CHANGELOG" + CHANGELOG_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # validate input + I18N_Validate "${PROJECT_VERSION} CHANGELOG" + CHANGELOG_Compatible_DATA_Version \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/changelog" \ + "$PROJECT_VERSION" + if [ $? -ne 0 ]; then + I18N_Validate_Failed + return 1 + fi + + I18N_Validate "${PROJECT_VERSION} DEB CHANGELOG" + CHANGELOG_Compatible_DEB_Version \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/changelog" \ + "$PROJECT_VERSION" + if [ $? -ne 0 ]; then + I18N_Validate_Failed + return 1 + fi + + + # assemble changelog + I18N_Create "$__changelog_md" + CHANGELOG_Assemble_MD \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/changelog" \ + "$__changelog_md" \ + "$PROJECT_VERSION" \ + "$PROJECT_CHANGELOG_TITLE" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + I18N_Create "$__changelog_deb" + FS_Make_Directory "${__changelog_deb%/*}" + CHANGELOG_Assemble_DEB \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/changelog" \ + "$__changelog_deb" \ + "$PROJECT_VERSION" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/_package-changelog_windows-any.ps1 b/automataCI/_package-changelog_windows-any.ps1 new file mode 100644 index 0000000..5e3048e --- /dev/null +++ b/automataCI/_package-changelog_windows-any.ps1 @@ -0,0 +1,90 @@ +# 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" + + + + +# 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-CHANGELOG { + param ( + [string]$__changelog_md, + [string]$__changelog_deb + ) + + + $null = I18N-Check-Availability "CHANGELOG" + $___process = CHANGELOG-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + + # validate input + $null = I18N-Validate "${env:PROJECT_VERSION} CHANGELOG" + $___process = CHANGELOG-Compatible-DATA-Version ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\changelog" ` + "${env:PROJECT_VERSION}" + if ($___process -ne 0) { + $null = I18N-Validate-Failed + return 1 + } + + $null = I18N-Validate "${env:PROJECT_VERSION} DEB CHANGELOG" + $___process = CHANGELOG-Compatible-DEB-Version ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\changelog" ` + "${env:PROJECT_VERSION}" + if ($___process -ne 0) { + $null = I18N-Validate-Failed + return 1 + } + + + # assemble changelog + $null = I18N-Create "${__changelog_md}" + $___process = CHANGELOG-Assemble-MD ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\changelog" ` + "${__changelog_md}" ` + "${env:PROJECT_VERSION}" ` + "${env:PROJECT_CHANGELOG_TITLE}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + $null = I18N-Create "${__changelog_deb}" + $null = FS-Make-Housing-Directory "${__changelog_deb}" + $___process = CHANGELOG-Assemble-DEB ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\changelog" ` + "${__changelog_deb}" ` + "${env:PROJECT_VERSION}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/_package-chocolatey_unix-any.sh b/automataCI/_package-chocolatey_unix-any.sh new file mode 100644 index 0000000..59a6be9 --- /dev/null +++ b/automataCI/_package-chocolatey_unix-any.sh @@ -0,0 +1,151 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.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 + + + + +PACKAGE_Run_CHOCOLATEY() { + #__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#*|}" + + + # validate input + I18N_Check_Availability "ZIP" + ZIP_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # prepare workspace and required values + 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}" + I18N_Remake "$_src" + FS_Remake_Directory "$_src" + if [ $? -ne 0 ]; then + I18N_Remake_Failed + return 1 + fi + + + # copy all complimentary files to the workspace + cmd="PACKAGE_Assemble_CHOCOLATEY_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" "$_src" "$_target_filename" "$_target_os" "$_target_arch" + case $? in + 10) + I18N_Assemble_Skipped + FS_Remove_Silently "$_src" + return 0 + ;; + 0) + ;; + *) + I18N_Assemble_Failed + return 1 + ;; + esac + + + # check nuspec file is available + I18N_Check ".nuspec metadata" + __name="" + for __file in "${_src}/"*.nuspec; do + FS_Is_File "${__file}" + if [ $? -eq 0 ]; then + if [ $(STRINGS_Is_Empty "$__name") -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + __name="${__file##*/}" + __name="${__name%.nuspec*}" + fi + done + + if [ $(STRINGS_Is_Empty "$__name") -eq 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # archive the assembled payload + __name="${__name}-chocolatey_${PROJECT_VERSION}_${_target_os}-${_target_arch}.nupkg" + __name="${_dest}/${__name}" + I18N_Archive "$__name" + CHOCOLATEY_Archive "$__name" "$_src" + if [ $? -ne 0 ]; then + I18N_Archive_Failed + return 1 + fi + + + # test the package + I18N_Test "$__name" + CHOCOLATEY_Is_Available + if [ $? -eq 0 ]; then + CHOCOLATEY_Test "$__name" + if [ $? -ne 0 ]; then + I18N_Test_Failed + return 1 + fi + else + I18N_Test_Skipped + fi + + + # report status + return 0 +} diff --git a/automataCI/_package-chocolatey_windows-any.ps1 b/automataCI/_package-chocolatey_windows-any.ps1 new file mode 100644 index 0000000..1f1a32c --- /dev/null +++ b/automataCI/_package-chocolatey_windows-any.ps1 @@ -0,0 +1,141 @@ +# 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\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.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 PACKAGE-Run-CHOCOLATEY { + 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] + + + # validate input + $null = I18N-Check-Availability "ZIP" + $___process = ZIP-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + + # prepare workspace and required values + $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}" + $null = I18N-Remake "${_src}" + $___process = FS-Remake-Directory "${_src}" + if ($___process -ne 0) { + $null = I18N-Remake-Failed + return 1 + } + + + # copy all complimentary files to the workspace + $cmd = "PACKAGE-Assemble-CHOCOLATEY-Content" + $null = I18N-Check-Function "${cmd}" + $___process = OS-Is-Command-Available "PACKAGE-Assemble-CHOCOLATEY-Content" + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + $null = I18N-Assemble-Package + $___process = PACKAGE-Assemble-CHOCOLATEY-Content ` + "${_target}" ` + "${_src}" ` + "${_target_filename}" ` + "${_target_os}" ` + "${_target_arch}" + switch ($___process) { + 10 { + $null = I18N-Assemble-Skipped + $null = FS-Remove-Silently "${_src}" + return 0 + } 0 { + # accepted + } Default { + $null = I18N-Assemble-Failed + return 1 + }} + + + # check nuspec is available + $null = I18N-Check ".nuspec metadata" + $__name = "" + foreach ($__file in (Get-ChildItem -File -Path "${_src}\*.nuspec")) { + if ($(STRINGS-Is-Empty "${__name}") -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + $__name = $__file.Name -replace '\.nuspec.*$', '' + } + + if ($(STRINGS-Is-Empty "${__name}") -eq 0) { + $null = I18N-Check-Failed + return 1 + } + + + # archive the assembled payload + $__name = "${__name}-chocolatey_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}.nupkg" + $__name = "${_dest}\${__name}" + $null = I18N-Archive "${__name}" + $___process = CHOCOLATEY-Archive "${__name}" "${_src}" + if ($___process -ne 0) { + $null = I18N-Archive-Failed + return 1 + } + + + # test the package + $null = I18N-Test "${__name}" + $___process = CHOCOLATEY-Is-Available + if ($___process -eq 0) { + $___process = CHOCOLATEY-Test "${__name}" + if ($___process -ne 0) { + $null = I18N-Test-Failed + return 1 + } + } else { + $null = I18N-Test-Skipped + } + + + # report status + return 0 +} diff --git a/automataCI/_package-citation_unix-any.sh b/automataCI/_package-citation_unix-any.sh new file mode 100644 index 0000000..3811a39 --- /dev/null +++ b/automataCI/_package-citation_unix-any.sh @@ -0,0 +1,60 @@ +#!/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/time.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/citation.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_CITATION() { + __citation_cff="$1" + + + # assemble citation + I18N_Create "$__citation_cff" + CITATION_Build \ + "$__citation_cff" \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/ABSTRACTS.txt" \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/CITATIONS.yml" \ + "$PROJECT_CITATION" \ + "$PROJECT_CITATION_TYPE" \ + "$(TIME_Format_ISO8601_Date "$(TIME_Now)")" \ + "$PROJECT_NAME" \ + "$PROJECT_VERSION" \ + "$PROJECT_LICENSE" \ + "$PROJECT_SOURCE_URL" \ + "$PROJECT_SOURCE_URL" \ + "$PROJECT_STATIC_URL" \ + "$PROJECT_CONTACT_NAME" \ + "$PROJECT_CONTACT_WEBSITE" \ + "$PROJECT_CONTACT_EMAIL" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/_package-citation_windows-any.ps1 b/automataCI/_package-citation_windows-any.ps1 new file mode 100644 index 0000000..4289268 --- /dev/null +++ b/automataCI/_package-citation_windows-any.ps1 @@ -0,0 +1,60 @@ +# 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\time.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\citation.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-CITATION { + param( + [string]$__citation_cff + ) + + # execute + $null = I18N-Create "${__citation_cff}" + $___process = CITATION-Build ` + "${__citation_cff}" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\ABSTRACTS.txt" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\CITATIONS.yml" ` + "${env:PROJECT_CITATION}" ` + "${env:PROJECT_CITATION_TYPE}" ` + "$(TIME-Format-ISO8601-Date "$(TIME-Now)")" ` + "${env:PROJECT_NAME}" ` + "${env:PROJECT_VERSION}" ` + "${env:PROJECT_LICENSE}" ` + "${env:PROJECT_SOURCE_URL}" ` + "${env:PROJECT_SOURCE_URL}" ` + "${env:PROJECT_STATIC_URL}" ` + "${env:PROJECT_CONTACT_NAME}" ` + "${env:PROJECT_CONTACT_WEBSITE}" ` + "${env:PROJECT_CONTACT_EMAIL}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/_package-deb_unix-any.sh b/automataCI/_package-deb_unix-any.sh new file mode 100644 index 0000000..5b3d576 --- /dev/null +++ b/automataCI/_package-deb_unix-any.sh @@ -0,0 +1,151 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/deb.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_DEB() { + #__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#*|}" + + _changelog_deb="${__line%%|*}" + + + # validate input + I18N_Check_Availability "DEB" + DEB_Is_Available "$_target_os" "$_target_arch" + case $? in + 2) + I18N_Check_Incompatible_Skipped + return 0 + ;; + 0|3) + # accepted + ;; + *) + I18N_Check_Failed + return 0 + ;; + esac + + + # prepare workspace and required values + 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}" + I18N_Remake "$_src" + FS_Remake_Directory "${_src}" + if [ $? -ne 0 ]; then + I18N_Remake_Failed + return 1 + fi + FS_Make_Directory "${_src}/control" + FS_Make_Directory "${_src}/data" + + + # execute + I18N_Check "$_target_path" + FS_Is_File "$_target_path" + if [ $? -eq 0 ]; then + I18N_Check_Failed + return 1 + fi + + cmd="PACKAGE_Assemble_DEB_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" \ + "$_src" \ + "$_target_filename" \ + "$_target_os" \ + "$_target_arch" \ + "$_changelog_deb" + case $? in + 10) + I18N_Assemble_Skipped + FS_Remove_Silently "$_src" + return 0 + ;; + 0) + # accepted + ;; + *) + I18N_Assemble_Failed + return 1 + ;; + esac + + I18N_Check "${_src}/control/md5sums" + FS_Is_File "${_src}/control/md5sums" + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + I18N_Check "${_src}/control/control" + FS_Is_File "${_src}/control/control" + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + I18N_Package "$_target_path" + DEB_Create_Archive "$_src" "$_target_path" + if [ $? -ne 0 ]; then + I18N_Package_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/_package-deb_windows-any.ps1 b/automataCI/_package-deb_windows-any.ps1 new file mode 100644 index 0000000..a3a2be8 --- /dev/null +++ b/automataCI/_package-deb_windows-any.ps1 @@ -0,0 +1,135 @@ +# 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\deb.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-DEB { + 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] + $_changelog_deb = $__list[5] + + + # validate input + $null = I18N-Check-Availability "DEB" + $___process = DEB-Is-Available "${_target_os}" "${_target_arch}" + switch ($___process) { + 2 { + $null = I18N-Check-Incompatible-Skipped + return 0 + } { $_ -in 0, 3 } { + # accepted + } Default { + $null = I18N-Check-Failed + return 0 + }} + + + # prepare workspace and required values + $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}" + $null = I18N-Remake "${_src}" + $___process = FS-Remake-Directory "${_src}" + if ($___process -ne 0) { + $null = I18N-Remake-Failed + return 1 + } + $null = FS-Make-Directory "${_src}\control" + $null = FS-Make-Directory "${_src}\data" + + + # execute + $null = I18N-Check "${_target_path}" + $___process = FS-Is-File "${_target_path}" + if ($___process -eq 0) { + $null = I18N-Check-Failed + return 1 + } + + $cmd = "PACKAGE-Assemble-DEB-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-DEB-Content ` + "${_target}" ` + "${_src}" ` + "${_target_filename}" ` + "${_target_os}" ` + "${_target_arch}" ` + "${_changelog_deb}" + switch ($___process) { + 10 { + $null = I18N-Assemble-Skipped + $null = FS-Remove-Silently "${_src}" + return 0 + } 0 { + # accepted + } Default { + $null = I18N-Assemble-Failed + return 1 + }} + + $null = I18N-Check "${_src}\control\md5sums" + $___process = FS-Is-File "${_src}\control\md5sums" + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + $null = I18N-Check "${_src}\control\control" + $___process = FS-Is-File "${_src}\control\control" + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + $null = I18N-Package "${_target_path}" + $___process = DEB-Create-Archive "${_src}" "${_target_path}" + if ($___process -ne 0) { + $null = I18N-Package-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/_package-docker_unix-any.sh b/automataCI/_package-docker_unix-any.sh new file mode 100644 index 0000000..bab3609 --- /dev/null +++ b/automataCI/_package-docker_unix-any.sh @@ -0,0 +1,173 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/docker.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_DOCKER() { + #__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#*|}" + + + # validate input + I18N_Check_Availability "DOCKER" + DOCKER_Is_Available + case $? in + 2|3) + I18N_Check_Incompatible + return 0 + ;; + 0) + # accepted + ;; + *) + I18N_Check_Failed_Skipped + return 0 + ;; + esac + + I18N_Check_Login "DOCKER" + DOCKER_Check_Login + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # prepare workspace and required values + 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}" + I18N_Remake "$_src" + FS_Remake_Directory "$_src" + if [ $? -ne 0 ]; then + I18N_Remake_Failed + return 1 + fi + + + # copy all complimentary files to the workspace + cmd="PACKAGE_Assemble_DOCKER_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" "$_src" "$_target_filename" "$_target_os" "$_target_arch" + case $? in + 10) + I18N_Assemble_Skipped + FS_Remove_Silently "$_src" + return 0 + ;; + 0) + # accepted + ;; + *) + I18N_Assemble_Failed + return 1 + ;; + esac + + + # check required files + I18N_Check "${_src}/Dockerfile" + FS_Is_File "${_src}/Dockerfile" + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # change location into the workspace + __current_path="$PWD" && cd "$_src" + + + # archive the assembled payload + I18N_Package "$_target_path" + DOCKER_Create \ + "$_target_path" \ + "$_target_os" \ + "$_target_arch" \ + "$PROJECT_CONTAINER_REGISTRY" \ + "$PROJECT_SKU" \ + "$PROJECT_VERSION" + if [ $? -ne 0 ]; then + cd "$__current_path" && unset __current_path + I18N_Package_Failed "$_target_path" + return 1 + fi + + + # logout + I18N_Logout "DOCKER" + DOCKER_Logout + if [ $? -ne 0 ]; then + cd "$__current_path" && unset __current_path + I18N_Logout_Failed + return 1 + fi + + + # clean up dangling images + I18N_Clean "DOCKER" + DOCKER_Clean_Up + if [ $? -ne 0 ]; then + cd "$__current_path" && unset __current_path + I18N_Clean_Failed + return 1 + fi + + + # head back to current directory + cd "$__current_path" && unset __current_path + + + # report status + return 0 +} diff --git a/automataCI/_package-docker_windows-any.ps1 b/automataCI/_package-docker_windows-any.ps1 new file mode 100644 index 0000000..8c49b9b --- /dev/null +++ b/automataCI/_package-docker_windows-any.ps1 @@ -0,0 +1,159 @@ +# 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\docker.ps1" + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!`n" + return 1 +} + + + + +function PACKAGE-Run-DOCKER { + 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] + + + # validate input + $null = I18N-Check-Availability "DOCKER" + $___process = DOCKER-Is-Available + switch ($___process) { + { $_ -in 2, 3 } { + $null = I18N-Check-Incompatible-Skipped + return 0 + } 0 { + # accepted + } Default { + $null = I18N-Check-Failed-Skipped + return 0 + }} + + + # prepare workspace and required values + $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}" + $null = I18N-Remake "${_src}" + $___process = FS-Remake-Directory "${_src}" + if ($___process -ne 0) { + $null = I18N-Remake-Failed + return 1 + } + + + # copy all complimentary files to the workspace + $cmd = "PACKAGE-Assemble-DOCKER-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-DOCKER-Content ` + "${_target}" ` + "${_src}" ` + "${_target_filename}" ` + "${_target_os}" ` + "${_target_arch}" + switch ($___process) { + 10 { + $null = I18N-Assemble-Skipped + $null = FS-Remove-Silently "${_src}" + return 0 + } 0 { + # accepted + } Default { + $null = I18N-Assemble-Failed + return 1 + }} + + + # check required files + $null = I18N-Check "${_src}/Dockerfile" + $___process = FS-Is-File "${_src}/Dockerfile" + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + + # change location into the workspace + $__current_path = Get-Location + $null = Set-Location -Path "${_src}" + + + # archive the assembled payload + $null = I18N-Package "${_target_path}" + $___process = DOCKER-Create ` + "${_target_path}" ` + "${_target_os}" ` + "${_target_arch}" ` + "${env:PROJECT_CONTAINER_REGISTRY}" ` + "${env:PROJECT_SKU}" ` + "${env:PROJECT_VERSION}" + if ($___process -ne 0) { + $null = Set-Location -Path "${__current_path}" + $null = Remove-Variable -Name __current_path + $null = I18N-Package-Failed "${_target_path}" + return 1 + } + + + # logout + $null = I18N-Logout "DOCKER" + $___process = DOCKER-Logout + if ($___process -ne 0) { + $null = Set-Location -Path "${___current_path}" + $null = Remove-Variable -Name ___current_path + $null = I18N-Logout-Failed + return 1 + } + + $null = I18N-Clean "DOCKER" + $___process = DOCKER-Clean-Up + if ($___process -ne 0) { + $null = Set-Location -Path "${___current_path}" + $null = Remove-Variable -Name ___current_path + $null = I18N-Clean-Failed + return 1 + } + + + # head back to current directory + $null = Set-Location -Path "${__current_path}" + $null = Remove-Variable -Name __current_path + + + # report status + return 0 +} diff --git a/automataCI/_package-flatpak_unix-any.sh b/automataCI/_package-flatpak_unix-any.sh new file mode 100644 index 0000000..d65367d --- /dev/null +++ b/automataCI/_package-flatpak_unix-any.sh @@ -0,0 +1,151 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/flatpak.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_FLATPAK() { + #__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#*|}" + + _repo="${__line%%|*}" + + + # validate input + I18N_Check_Availability "FLATPAK" + FLATPAK_Is_Available "$_target_os" "$_target_arch" + case $? in + 2) + I18N_Check_Incompatible_Skipped + return 0 + ;; + 0|3) + ;; + *) + I18N_Check_Failed + return 0 + ;; + esac + + + # prepare workspace and required values + 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}" + I18N_Remake "$_src" + FS_Remake_Directory "${_src}" + if [ $? -ne 0 ]; then + I18N_Remake_Failed + return 1 + fi + + I18N_Check "$_target_path" + FS_Is_File "$_target_path" + if [ $? -eq 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # copy all complimentary files to the workspace + cmd="PACKAGE_Assemble_FLATPAK_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" "$_src" "$_target_filename" "$_target_os" "$_target_arch" + case $? in + 10) + I18N_Assemble_Skipped + FS_Remove_Silently "$_src" + return 0 + ;; + 0) + # accepted + ;; + *) + I18N_Assemble_Failed + return 1 + ;; + esac + + + # generate required files + I18N_Check "${_src}/manifest.yml" + FS_Is_File "${_src}/manifest.yml" + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + I18N_Check "${_src}/appdata.xml" + FS_Is_File "${_src}/appdata.xml" + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # archive the assembled payload + I18N_Package "$_target_path" + FLATPAK_Create_Archive \ + "$_src" \ + "$_target_path" \ + "$_repo" \ + "$PROJECT_APP_ID" \ + "$PROJECT_GPG_ID" + if [ $? -ne 0 ]; then + I18N_Package_Failed "$_target_path" + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/_package-flatpak_windows-any.ps1 b/automataCI/_package-flatpak_windows-any.ps1 new file mode 100644 index 0000000..766e8d5 --- /dev/null +++ b/automataCI/_package-flatpak_windows-any.ps1 @@ -0,0 +1,139 @@ +# 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\flatpak.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-FLATPAK { + 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] + $_repo = $__list[5] + + + # validate input + $null = I18N-Check-Availability "FLATPAK" + $___process = FLATPAK-Is-Available "${_target_os}" "${_target_arch}" + switch ($___process) { + 2 { + $null = I18N-Check-Incompatible-Skipped + return 0 + } { $_ -in 0, 3 } { + break + } Default { + $null = I18N-Check-Failed + return 0 + }} + + + # prepare workspace and required values + $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}" + $null = I18N-Remake "${_src}" + $___process = FS-Remake-Directory "${_src}" + if ($___process -ne 0) { + $null = I18N-Remake-Failed + return 1 + } + + $null = I18N-Check "${_target_path}" + if ($(FS-Is-File "${_target_path}") -eq 0) { + $null = I18N-Check-Failed + return 1 + } + + + # copy all complimentary files to the workspace + $cmd = "PACKAGE-Assemble-FLATPAK-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-FLATPAK-Content ` + "${_target}" ` + "${_src}" ` + "${_target_filename}" ` + "${_target_os}" ` + "${_target_arch}" + switch ($___process) { + 10 { + $null = I18N-Assemble-Skipped + $null = FS-Remove-Silently "${_src}" + return 0 + } 0 { + # accepted + } default { + $null = I18N-Assemble-Failed + }} + + + # generate required files + $null = I18N-Check "${_src}\manifest.yml" + $___process = FS-Is-File "${_src}\manifest.yml" + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + $null = I18N-Check "${_src}\appdata.xml" + $___process = FS-Is-File "${_src}\appdata.xml" + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + + # archive the assembled payload + $null = I18N-Package "${_target_path}" + $___process = FLATPAK-Create-Archive ` + "${_src}" ` + "${_target_path}" ` + "${_repo}" ` + "${env:PROJECT_APP_ID}" ` + "${env:PROJECT_GPG_ID}" + if ($___process -ne 0) { + $null = I18N-Package-Failed "${_target_path}" + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/_package-homebrew_unix-any.sh b/automataCI/_package-homebrew_unix-any.sh new file mode 100644 index 0000000..7644521 --- /dev/null +++ b/automataCI/_package-homebrew_unix-any.sh @@ -0,0 +1,163 @@ +#!/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/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" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +PACKAGE_Run_HOMEBREW() { + #__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#*|}" + + + # 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 + cmd="PACKAGE_Assemble_HOMEBREW_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" "$_src" "$_target_filename" "$_target_os" "$_target_arch" + case $? in + 10) + I18N_Assemble_Skipped + FS_Remove_Silently "$_src" + return 0 + ;; + 0) + # accepted + ;; + *) + I18N_Assemble_Failed + return 1 + ;; + 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 new file mode 100644 index 0000000..9ab2bde --- /dev/null +++ b/automataCI/_package-homebrew_windows-any.ps1 @@ -0,0 +1,153 @@ +# 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\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\checksum\shasum.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-HOMEBREW { + 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] + + + # 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 + $cmd = "PACKAGE-Assemble-HOMEBREW-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-HOMEBREW-Content ` + "${_target}" ` + "${_src}" ` + "${_target_filename}" ` + "${_target_os}" ` + "${_target_arch}" + switch ($___process) { + 10 { + $null = I18N-Assemble-Skipped + $null = FS-Remove-Silently "${_src}" + return 0 + } 0 { + # accepted + } Default { + $null = I18N-Assemble-Failed + return 1 + }} + + + # 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}" + 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 new file mode 100644 index 0000000..6386a30 --- /dev/null +++ b/automataCI/_package-ipk_unix-any.sh @@ -0,0 +1,136 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/ipk.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_IPK() { + #__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#*|}" + + + # validate input + I18N_Check_Availability "IPK" + IPK_Is_Available "$_target_os" "$_target_arch" + case $? in + 2) + I18N_Check_Incompatible_Skipped + return 0 + ;; + 0|3) + # accepted + ;; + *) + I18N_Check_Failed + return 0 + ;; + esac + + + # prepare workspace and required values + 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}" + I18N_Remake "$_src" + FS_Remake_Directory "${_src}" + if [ $? -ne 0 ]; then + I18N_Remake_Failed + return 1 + fi + FS_Make_Directory "${_src}/control" + FS_Make_Directory "${_src}/data" + + + # execute + I18N_Check "$_target_path" + FS_Is_File "$_target_path" + if [ $? -eq 0 ]; then + I18N_Check_Failed + return 1 + fi + + cmd="PACKAGE_Assemble_IPK_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" "$_src" "$_target_filename" "$_target_os" "$_target_arch" + case $? in + 10) + I18N_Assemble_Skipped + FS_Remove_Silently "$_src" + return 0 + ;; + 0) + # accepted + ;; + *) + I18N_Assemble_Failed + return 1 + ;; + esac + + I18N_Check "control/control" + FS_Is_File "${_src}/control/control" + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + I18N_Package "$_target_path" + IPK_Create_Archive "$_src" "$_target_path" + if [ $? -ne 0 ]; then + I18N_Package_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/_package-ipk_windows-any.ps1 b/automataCI/_package-ipk_windows-any.ps1 new file mode 100644 index 0000000..90c71a4 --- /dev/null +++ b/automataCI/_package-ipk_windows-any.ps1 @@ -0,0 +1,126 @@ +# 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\ipk.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-IPK { + 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] + + + # validate input + $null = I18N-Check-Availability "IPK" + $___process = IPK-Is-Available "${_target_os}" "${_target_arch}" + switch ($___process) { + 2 { + $null = I18N-Check-Incompatible-Skipped + return 0 + } { $_ -in 0, 3 } { + # accepted + } Default { + $null = I18N-Check-Failed + return 0 + }} + + + # prepare workspace and required values + $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}" + $null = I18N-Remake "${_src}" + $___process = FS-Remake-Directory "${_src}" + if ($___process -ne 0) { + $null = I18N-Remake-Failed + return 1 + } + $null = FS-Make-Directory "${_src}\control" + $null = FS-Make-Directory "${_src}\data" + + + # execute + $null = I18N-Check "${_target_path}" + $___process = FS-Is-File "${_target_path}" + if ($___process -eq 0) { + $null = I18N-Check-Failed + return 1 + } + + $cmd = "PACKAGE-Assemble-IPK-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-IPK-Content ` + "${_target}" ` + "${_src}" ` + "${_target_filename}" ` + "${_target_os}" ` + "${_target_arch}" + switch ($___process) { + 10 { + $null = I18N-Assemble-Skipped + $null = FS-Remove-Silently "${_src}" + return 0 + } 0 { + # accepted + } Default { + $null = I18N-Assemble-Failed + return 1 + }} + + $null = I18N-Check "control\control" + $___process = FS-Is-File "${_src}\control\control" + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + $null = I18N-Package "${_target_path}" + $___process = IPK-Create-Archive "${_src}" "${_target_path}" + if ($___process -ne 0) { + $null = I18N-Package-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/_package-msi_unix-any.sh b/automataCI/_package-msi_unix-any.sh new file mode 100644 index 0000000..15c5e6e --- /dev/null +++ b/automataCI/_package-msi_unix-any.sh @@ -0,0 +1,224 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/sync.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/msi.sh" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +SUBROUTINE_Package_MSI() { + # parse input + __line="$1" + + __target="${__line%%|*}" + __line="${__line#*|}" + + __dest="${__line%%|*}" + __line="${__line#*|}" + + __log="${__line%%|*}" + + __subject="${__log##*/}" + __subject="${__subject%.*}" + __subject="${__subject#*msi-wxs_}" + + __arch="${__subject##*windows-}" + __arch="${__arch%%_*}" + + + # execute + I18N_Package "$__subject" + MSI_Compile "$__target" "$__arch" &> "$__log" + if [ $? -ne 0 ]; then + I18N_Package_Failed + return 1 + fi + + __target="$(FS_Extension_Replace "$__target" ".wxs" ".msi")" + I18N_Export "$__subject" + if [ ! -f "$__target" ]; then + I18N_Export_Missing "$__subject" + return 1 + fi + + FS_Copy_File "$__target" "${__dest}/${__target##*/}" &> "$__log" + if [ $? -ne 0 ]; then + I18N_Export_Failed "$__subject" + return 1 + fi + + + # report status + return 0 +} + + + + +PACKAGE_Run_MSI() { + #__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#*|}" + + + # validate input + I18N_Check_Availability "MSI" + MSI_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 0 + fi + + + # 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}" + I18N_Remake "$_src" + FS_Remake_Directory "$_src" + if [ $? -ne 0 ]; then + I18N_Remake_Failed + return 1 + fi + + __control_directory="${_src}/.automataCI" + I18N_Remake "$__control_directory" + FS_Remake_Directory "$__control_directory" + if [ ! -d "$__control_directory" ]; then + I18N_Remake_Failed + return 1 + fi + + __parallel_control="${__control_directory}/control-parallel.txt" + FS_Remove_Silently "$__parallel_control" + + + # copy all complimentary files to the workspace + cmd="PACKAGE_Assemble_MSI_Content" + I18N_Check_Function "$cmd" + OS_Is_Command_Available "$cmd" + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + I18N_Assemble_Package + PACKAGE_Assemble_MSI_Content \ + "$_target" \ + "$_src" \ + "$_target_filename" \ + "$_target_os" \ + "$_target_arch" + case $? in + 10) + FS_Remove_Silently "$_src" + I18N_Assemble_Skipped + return 0 + ;; + 0) + ;; + *) + I18N_Assemble_Failed + return 1 + ;; + esac + + + # archive the assembled payload + for __recipe in "${_src}/"*.wxs; do + if [ ! -e "$__recipe" ]; then + continue + fi + + FS_Is_File "$__recipe" + if [ $? -ne 0 ]; then + continue + fi + + + # register for packaging in parallel + I18N_Sync_Register "$__recipe" + __log="${__recipe##*/}" + __log="${__log%.wxs*}" + __log="${__control_directory}/msi-wxs_${__log}.log" + FS_Append_File "$__parallel_control" "\ +${__recipe}|${_dest}|${__log} +" + if [ $? -ne 0 ]; then + return 1 + fi + done + + I18N_Sync_Run + FS_Is_File "$__parallel_control" + if [ $? -eq 0 ]; then + SYNC_Exec_Parallel "SUBROUTINE_Package_MSI" "$__parallel_control" + ___process=$? + return 0 + else + I18N_Sync_Run_Skipped + ___process=0 + fi + + for __log in "${__control_directory}/"*.log; do + if [ ! -e "$__log" ]; then + continue + fi + + I18N_Sync_Report_Log "${__log##*/}" + old_IFS="$IFS" + while IFS="" read -r __line || [ -n "$__line" ]; do + I18N_Status_Print plain "$__line" + done < "$__log" + IFS="$old_IFS" && unset old_IFS + I18N_Newline + done + + + # report status + if [ $? -ne 0 ]; then + I18N_Sync_Failed + return 1 + fi + + return 0 +} diff --git a/automataCI/_package-msi_windows-any.ps1 b/automataCI/_package-msi_windows-any.ps1 new file mode 100644 index 0000000..a951fd2 --- /dev/null +++ b/automataCI/_package-msi_windows-any.ps1 @@ -0,0 +1,215 @@ +# 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\io\sync.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\msi.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 SUBROUTINE-Package-MSI { + param( + [string]$__line + ) + + + # initialize libraries from scratch + $null = . "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" + $null = . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + $null = . "${env:LIBS_AUTOMATACI}\services\compilers\msi.ps1" + + + # parse input + $__list = $__line -split "\|" + $__target = $__list[0] + $__dest = $__list[1] + $__log = $__list[2] + + $__subject = Split-Path -Leaf -Path "${__log}" + $__subject = FS-Extension-Remove "${__subject}" "*" + $__subject = $__subject -replace "^msi-wxs_", "" + + $__arch = $__subject -replace '.*windows-','' + $__arch = $__arch -replace '_.*','' + + $__lang = $__subject -split "_" + $__lang = $__lang[2] + + + # execute + $null = I18N-Package "${__subject}" + $($___process = MSI-Compile "${__target}" "${__arch}" "${__lang}") *> "${__log}" + if ($___process -ne 0) { + $null = I18N-Package-Failed + return 1 + } + + $__target = FS-Extension-Replace "${__target}" ".wxs" ".msi" + $null = I18N-Export "${__target}" + if (-not (Test-Path "${__target}")) { + $null = I18N-Export-Missing "${__subject}" + return 1 + } + + $___process = FS-Copy-File ` + "${__target}" ` + "${__dest}\$(Split-Path -Leaf -Path "${__target}")" + if ($___process -ne 0) { + $null = I18N-Export-Failed "${__subject}" + return 1 + } + + + # report status + return 0 +} + + + + +function PACKAGE-Run-MSI { + 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] + + + # validate input + $null = I18N-Check-Availability "MSI" + $___process = MSI-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 0 + } + + + # 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}" + $null = I18N-Remake "${_src}" + $___process = FS-Remake-Directory "${_src}" + if ($___process -ne 0) { + $null = I18N-Remake-Failed + return 1 + } + + $__control_directory = "${_src}\.automataCI" + $null = I18N-Remake "${__control_directory}" + $___process = FS-Remake-Directory "${__control_directory}" + if ($___process -ne 0) { + $null = I18N-Remake-Failed + return 1 + } + + $__parallel_control = "${__control_directory}\control-parallel.txt" + $null = FS-Remove-Silently "${__parallel_control}" + + + # copy all complimentary files to the workspace + $null = I18N-Check-Function "PACKAGE-Assemble-MSI-Content" + $___process = OS-Is-Command-Available "PACKAGE-Assemble-MSI-Content" + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + $null = I18N-Assemble-Package + $___process = PACKAGE-Assemble-MSI-Content ` + "${_target}" ` + "${_src}" ` + "${_target_filename}" ` + "${_target_os}" ` + "${_target_arch}" + switch ($___process) { + 10 { + $null = I18N-Assemble-Skipped + $null = FS-Remove-Silently "${_src}" + return 0 + } 0 { + # accepted + } Default { + $null = I18N-Assemble-Failed + return 1 + }} + + + # archive the assembled payload + foreach ($__recipe in (Get-ChildItem -Path "${_src}" -Filter *.wxs)) { + $___process = FS-Is-File "${__recipe}" + if ($___process -ne 0) { + continue + } + + + # register for packaging in parallel + $null = I18N-Sync-Register "${__recipe}" + $__log = Split-Path -Leaf -Path "${__recipe}" + $__log = FS-Extension-Remove "${__log}" "*" + $__log = "${__control_directory}\msi-wxs_${__log}.log" + $___process = FS-Append-File "${__parallel_control}" @" +${__recipe}|${_dest}|${__log} +"@ + if ($___process -ne 0) { + return 1 + } + } + + $null = I18N-Sync-Run + $___process = FS-Is-File "${__parallel_control}" + if ($___process -eq 0) { + $___process = SYNC-Exec-Parallel ` + ${function:SUBROUTINE-Package-MSI}.ToString() ` + "${__parallel_control}" ` + "${__control_directory}" ` + "$([System.Environment]::ProcessorCount)" + } else { + $null = I18N-Sync-Run-Skipped + $___process = 0 + } + + foreach ($__log in (Get-ChildItem -Path "${__control_directory}" -Filter *.log)) { + $null = I18N-Sync-Report-Log "${__log}" + foreach ($__line in (Get-Content "${__log}")) { + $null = I18N-Status-Print plain "${__line}" + } + $null = I18N-Newline + } + + + # report status + if ($___process -ne 0) { + $null = I18N-Sync-Failed + return 1 + } + + return 0 +} diff --git a/automataCI/_package-pdf_unix-any.sh b/automataCI/_package-pdf_unix-any.sh new file mode 100644 index 0000000..6f486b7 --- /dev/null +++ b/automataCI/_package-pdf_unix-any.sh @@ -0,0 +1,80 @@ +#!/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/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_PDF() { + #__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_PDF_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-pdf_windows-any.ps1 b/automataCI/_package-pdf_windows-any.ps1 new file mode 100644 index 0000000..bd94f19 --- /dev/null +++ b/automataCI/_package-pdf_windows-any.ps1 @@ -0,0 +1,73 @@ +# 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" + + + + +# 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-PDF { + 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-PDF-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-PDF-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-pypi_unix-any.sh b/automataCI/_package-pypi_unix-any.sh new file mode 100644 index 0000000..6f89f8f --- /dev/null +++ b/automataCI/_package-pypi_unix-any.sh @@ -0,0 +1,164 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/python.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_PYPI() { + #__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#*|}" + + + # validate input + if [ $(FS_Is_Target_A_PYPI "$_target") -ne 0 ]; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_PYTHON") -eq 0 ]; then + return 0 + fi + + I18N_Check_Availability "PYTHON" + PYTHON_Activate_VENV + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + I18N_Check_Availability "PYPI" + PYTHON_PYPI_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # prepare workspace and required values + 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}" + I18N_Remake "$_src" + FS_Remake_Directory "$_src" + if [ $? -ne 0 ]; then + I18N_Remake_Failed + return 1 + fi + + I18N_Check "$_target_path" + FS_Is_Directory "$_target_path" + if [ $? -eq 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # copy all complimentary files to the workspace + cmd="PACKAGE_Assemble_PYPI_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" "$_src" "$_target_filename" "$_target_os" "$_target_arch" + case $? in + 10) + I18N_Assemble_Skipped + FS_Remove_Silently "$_src" + return 0 + ;; + 0) + # accepted + ;; + *) + I18N_Assemble_Failed + return 1 + ;; + esac + + + # generate required files + I18N_Create "pyproject.toml" + PYTHON_Create_PYPI_Config \ + "$_src" \ + "$PROJECT_NAME" \ + "$PROJECT_VERSION" \ + "$PROJECT_CONTACT_NAME" \ + "$PROJECT_CONTACT_EMAIL" \ + "$PROJECT_CONTACT_WEBSITE" \ + "$PROJECT_PITCH" \ + "$PROJECT_PYPI_README" \ + "$PROJECT_PYPI_README_MIME" \ + "$PROJECT_LICENSE" + case $? in + 2) + I18N_Injection_Manual_Detected + ;; + 0) + ;; + *) + I18N_Create_Failed + return 1 + ;; + esac + + + # archive the assembled payload + I18N_Package "$_target_path" + FS_Make_Directory "$_target_path" + PYTHON_Create_PYPI_Archive "$_src" "$_target_path" + if [ $? -ne 0 ]; then + I18N_Package_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/_package-pypi_windows-any.ps1 b/automataCI/_package-pypi_windows-any.ps1 new file mode 100644 index 0000000..200e835 --- /dev/null +++ b/automataCI/_package-pypi_windows-any.ps1 @@ -0,0 +1,155 @@ +# 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\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\python.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-PYPI { + 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] + + + # validate input + if ($(FS-Is-Target-A-PYPI "${_target}") -ne 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_PYTHON}") -eq 0) { + return 0 + } + + $null = I18N-Check-Availability "PYTHON" + $___process = PYTHON-Activate-VENV + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + $null = I18N-Check-Availability "PYPI" + $___process = PYTHON-PYPI-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + + # prepare workspace and required values + $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}" + $null = I18N-Remake "${_src}" + $___process = FS-Remake-Directory "${_src}" + if ($___process -ne 0) { + $null = I18N-Remake-Failed + return 1 + } + + + $null = I18N-Check "${_target_path}" + $___process = FS-Is-Directory "${_target_path}" + if ($___process -eq 0) { + $null = I18N-Check-Failed + return 1 + } + + + # copy all complimentary files to the workspace + $cmd = "PACKAGE-Assemble-PYPI-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-PYPI-Content ` + ${_target} ` + ${_src} ` + ${_target_filename} ` + ${_target_os} ` + ${_target_arch} + switch ($___process) { + 10 { + $null = I18N-Assemble-Skipped + $null = FS-Remove-Silently "${_src}" + return 0 + } 0 { + # accepted + } default { + $null = I18N-Assemble-Failed + return 1 + }} + + + # generate required files + $null = I18N-Create "${_src}\pyproject.toml" + $___process = PYTHON-Create-PYPI-Config ` + "${_src}" ` + "${env:PROJECT_NAME}" ` + "${env:PROJECT_VERSION}" ` + "${env:PROJECT_CONTACT_NAME}" ` + "${env:PROJECT_CONTACT_EMAIL}" ` + "${env:PROJECT_CONTACT_WEBSITE}" ` + "${env:PROJECT_PITCH}" ` + "${env:PROJECT_PYPI_README}" ` + "${env:PROJECT_PYPI_README_MIME}" ` + "${env:PROJECT_LICENSE}" + switch ($___process) { + 2 { + $null = I18N-Injection-Manual-Detected + } 0 { + # accepted + } default { + $null = I18N-Create-Failed + return 1 + }} + + + # archive the assembled payload + $null = I18N-Package "${_target_path}" + $null = FS-Make-Directory "${_target_path}" + $___process = PYTHON-Create-PYPI-Archive "${_src}" "${_target_path}" + if ($___process -ne 0) { + $null = I18N-Package-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/_package-rpm_unix-any.sh b/automataCI/_package-rpm_unix-any.sh new file mode 100644 index 0000000..cdf8b6f --- /dev/null +++ b/automataCI/_package-rpm_unix-any.sh @@ -0,0 +1,132 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/copyright.sh" +. "${LIBS_AUTOMATACI}/services/compilers/manual.sh" +. "${LIBS_AUTOMATACI}/services/compilers/rpm.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_RPM() { + #__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#*|}" + + + # validate input + I18N_Check_Availability "RPM" + RPM_Is_Available "$_target_os" "$_target_arch" + case $? in + 2) + I18N_Check_Incompatible_Skipped + return 0 + ;; + 0|3) + # accepted + ;; + *) + I18N_Check_Failed_Skipped + return 0 + ;; + esac + + I18N_Check_Availability "MANUAL DOCS" + MANUAL_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # 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}" + I18N_Remake "$_src" + FS_Remake_Directory "$_src" + if [ $? -ne 0 ]; then + I18N_Remake_Failed + return 1 + fi + FS_Make_Directory "${_src}/BUILD" + FS_Make_Directory "${_src}/SPECS" + + + # copy all complimentary files to the workspace + cmd="PACKAGE_Assemble_RPM_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" "$_src" "$_target_filename" "$_target_os" "$_target_arch" + case $? in + 10) + I18N_Assemble_Skipped + FS_Remove_Silently "$_src" + return 0 + ;; + 0) + # accepted + ;; + *) + I18N_Assemble_Failed + return 1 + ;; + esac + + + # archive the assembled payload + I18N_Package "$_dest" + RPM_Create_Archive "$_src" "$_dest" "$_target_arch" + if [ $? -ne 0 ]; then + I18N_Package_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/_package-rpm_windows-any.ps1 b/automataCI/_package-rpm_windows-any.ps1 new file mode 100644 index 0000000..fd39f62 --- /dev/null +++ b/automataCI/_package-rpm_windows-any.ps1 @@ -0,0 +1,122 @@ +# 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\copyright.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\manual.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\rpm.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-RPM { + 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] + + + # validate input + $null = I18N-Check-Availability "RPM" + $___process = RPM-Is-Available "${_target_os}" "${_target_arch}" + switch ($___process) { + 2 { + $null = I18N-Check-Incompatible-Skipped + return 0 + } { $_ -in 0, 3 } { + # accepted + } Default { + $null = I18N-Check-Failed-Skipped + return 0 + }} + + $null = I18N-Check-Availability "MANUAL DOCS" + $___process = MANUAL-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed "MANUAL DOCS" + return 1 + } + + + # 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}" + $null = I18N-Remake "${_src}" + $___process = FS-Remake-Directory "${_src}" + if ($___process -ne 0) { + $null = I18N-Remake-Failed + return 1 + } + $null = FS-Make-Directory "${_src}/BUILD" + $null = FS-Make-Directory "${_src}/SPECS" + + + # copy all complimentary files to the workspace + $cmd = "PACKAGE-Assemble-RPM-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-RPM-Content ` + ${_target} ` + ${_src} ` + ${_target_filename} ` + ${_target_os} ` + ${_target_arch} + switch ($___process) { + 10 { + $null = I18N-Assemble-Skipped + $null = FS-Remove-Silently ${_src} + return 0 + } 0 { + # accepted + } default { + $null = I18N-Assemble-Failed + return 1 + }} + + + # archive the assembled payload + $null = I18N-Package "${_dest}" + $___process = RPM-Create-Archive "${_src}" "${_dest}" "${_target_arch}" + if ($___process -ne 0) { + $null = I18N-Package-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/_package-sourcing_unix-any.sh b/automataCI/_package-sourcing_unix-any.sh new file mode 100644 index 0000000..ed4ee7b --- /dev/null +++ b/automataCI/_package-sourcing_unix-any.sh @@ -0,0 +1,70 @@ +#!/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" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +# source from baseline +tech_list="\ +${PROJECT_PATH_SOURCE:-none} +${PROJECT_ANGULAR:-none} +${PROJECT_C:-none} +${PROJECT_GO:-none} +${PROJECT_NIM:-none} +${PROJECT_PYTHON:-none} +${PROJECT_RESEARCH:-none} +${PROJECT_RUST:-none} +" + +old_IFS="$IFS" +while IFS="" read -r tech || [ -n "$tech" ]; do + # validate input + if [ $(STRINGS_Is_Empty "$tech") -eq 0 ] || + [ "$(STRINGS_To_Uppercase "$tech")" = "NONE" ]; then + continue + fi + + + # execute + package_fx="${PROJECT_PATH_ROOT}/${tech}/${PROJECT_PATH_CI}/package_unix-any.sh" + FS_Is_File "$package_fx" + if [ $? -eq 0 ]; then + I18N_Source "$package_fx" + . "$package_fx" + if [ $? -ne 0 ]; then + I18N_Source_Failed + return 1 + fi + fi +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. +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.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 +} + + + + +# execute +## IMPORTANT NOTE: +## (1) Appearently, PowerShell disallowed globally scoped dot import inside +## a function. Hence, we don't have a choice but to do repetition. +if ($(STRINGS-Is-Empty "${env:PROJECT_PATH_SOURCE}") -ne 0) { + $package_fx = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}" + $package_fx = "${package_fx}\${env:PROJECT_PATH_CI}\package_windows-any.ps1" + if ($(FS-Is-File "$package_fx") -eq 0) { + $null = I18N-Source "${package_fx}" + + $___process = . $package_fx + if ($___process -ne 0) { + $null = I18N-Source-Failed + return 1 + } + } +} + +if ($(STRINGS-Is-Empty "${env:PROJECT_ANGULAR}") -ne 0) { + $package_fx = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_ANGULAR}" + $package_fx = "${package_fx}\${env:PROJECT_PATH_CI}\package_windows-any.ps1" + if ($(FS-Is-File "$package_fx") -eq 0) { + $null = I18N-Source "${package_fx}" + + $___process = . $package_fx + if ($___process -ne 0) { + $null = I18N-Source-Failed + return 1 + } + } +} + +if ($(STRINGS-Is-Empty "${env:PROJECT_C}") -ne 0) { + $package_fx = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_C}" + $package_fx = "${package_fx}\${env:PROJECT_PATH_CI}\package_windows-any.ps1" + if ($(FS-Is-File "$package_fx") -eq 0) { + $null = I18N-Source "${package_fx}" + + $___process = . $package_fx + if ($___process -ne 0) { + $null = I18N-Source-Failed + return 1 + } + } +} + +if ($(STRINGS-Is-Empty "${env:PROJECT_GO}") -ne 0) { + $package_fx = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_GO}" + $package_fx = "${package_fx}\${env:PROJECT_PATH_CI}\package_windows-any.ps1" + if ($(FS-Is-File "$package_fx") -eq 0) { + $null = I18N-Source "${package_fx}" + + $___process = . $package_fx + if ($___process -ne 0) { + $null = I18N-Source-Failed + return 1 + } + } +} + +if ($(STRINGS-Is-Empty "${env:PROJECT_NIM}") -ne 0) { + $package_fx = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_NIM}" + $package_fx = "${package_fx}\${env:PROJECT_PATH_CI}\package_windows-any.ps1" + if ($(FS-Is-File "$package_fx") -eq 0) { + $null = I18N-Source "${package_fx}" + + $___process = . $package_fx + if ($___process -ne 0) { + $null = I18N-Source-Failed + return 1 + } + } +} + +if ($(STRINGS-Is-Empty "${env:PROJECT_PYTHON}") -ne 0) { + $package_fx = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PYTHON}" + $package_fx = "${package_fx}\${env:PROJECT_PATH_CI}\package_windows-any.ps1" + if ($(FS-Is-File "$package_fx") -eq 0) { + $null = I18N-Source "${package_fx}" + + $___process = . $package_fx + if ($___process -ne 0) { + $null = I18N-Source-Failed + return 1 + } + } +} + +if ($(STRINGS-Is-Empty "${env:PROJECT_RESEARCH}") -ne 0) { + $package_fx = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_RESEARCH}" + $package_fx = "${package_fx}\${env:PROJECT_PATH_CI}\package_windows-any.ps1" + if ($(FS-Is-File "$package_fx") -eq 0) { + $null = I18N-Source "${package_fx}" + + $___process = . $package_fx + if ($___process -ne 0) { + $null = I18N-Source-Failed + return 1 + } + } +} + +if ($(STRINGS-Is-Empty "${env:PROJECT_RUST}") -ne 0) { + $package_fx = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_RUST}" + $package_fx = "${package_fx}\${env:PROJECT_PATH_CI}\package_windows-any.ps1" + if ($(FS-Is-File "$package_fx") -eq 0) { + $null = I18N-Source "${package_fx}" + + $___process = . $package_fx + if ($___process -ne 0) { + $null = I18N-Source-Failed + return 1 + } + } +} diff --git a/automataCI/_release-cargo_unix-any.sh b/automataCI/_release-cargo_unix-any.sh new file mode 100644 index 0000000..97fca9b --- /dev/null +++ b/automataCI/_release-cargo_unix-any.sh @@ -0,0 +1,85 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/rust.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_CARGO() { + _target="$1" + + + # validate input + RUST_Crate_Is_Valid "$_target" + if [ $? -ne 0 ]; then + return 0 + fi + + I18N_Check_Availability "RUST" + RUST_Activate_Local_Environment + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # execute + I18N_Publish "CARGO" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Publish "CARGO" + else + I18N_Check_Login "CARGO" + RUST_Cargo_Login + if [ $? -ne 0 ]; then + I18N_Check_Failed + I18N_Logout "CARGO" + RUST_Cargo_Logout + return 1 + fi + + RUST_Cargo_Release_Crate "$_target" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + I18N_Logout "CARGO" + RUST_Cargo_Logout + return 1 + fi + + I18N_Logout "CARGO" + RUST_Cargo_Logout + if [ $? -ne 0 ]; then + I18N_Logout_Failed + return 1 + fi + fi + + I18N_Clean "$_target" + FS_Remove_Silently "$_target" + + + # report status + return 0 +} diff --git a/automataCI/_release-cargo_windows-any.ps1 b/automataCI/_release-cargo_windows-any.ps1 new file mode 100644 index 0000000..43a8522 --- /dev/null +++ b/automataCI/_release-cargo_windows-any.ps1 @@ -0,0 +1,85 @@ +# 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\compilers\rust.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-CARGO { + param( + [string]$_target + ) + + + # validate input + $___process = RUST-Crate-Is-Valid "${_target}" + if ($___process -ne 0) { + return 0 + } + + $null = I18N-Check-Availability "RUST" + $___process = RUST-Activate-Local-Environment + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + + # execute + $null = I18N-Publish "CARGO" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Publish "CARGO" + } else { + $null = I18N-Check-Login "CARGO" + $___process = RUST-Cargo-Login + if ($___process -ne 0) { + $null = I18N-Check-Failed + $null = I18N-Logout "CARGO" + $null = RUST-Cargo-Logout + return 1 + } + + $___process = RUST-Cargo-Release-Crate "${_target}" + if ($___process -ne 0) { + $null = I18N-Logout "CARGO" + $null = RUST-Cargo-Logout + $null = I18N-Publish-Failed + return 1 + } + + $null = I18N-Logout "CARGO" + $___process = RUST-Cargo-Logout "CARGO" + if ($___process -ne 0) { + $null = I18N-Logout-Failed + return 1 + } + } + + $null = I18N-Clean "${_target}" + $null = FS-Remove-Silently "${_target}" + + + # report status + return 0 +} diff --git a/automataCI/_release-changelog_unix-any.sh b/automataCI/_release-changelog_unix-any.sh new file mode 100644 index 0000000..fa28289 --- /dev/null +++ b/automataCI/_release-changelog_unix-any.sh @@ -0,0 +1,42 @@ +#!/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/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/changelog.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_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 + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-changelog_windows-any.ps1 b/automataCI/_release-changelog_windows-any.ps1 new file mode 100644 index 0000000..7aa330e --- /dev/null +++ b/automataCI/_release-changelog_windows-any.ps1 @@ -0,0 +1,41 @@ +# 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\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\changelog.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-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 + } + + + # report status + return 0 +} diff --git a/automataCI/_release-checksum_unix-any.sh b/automataCI/_release-checksum_unix-any.sh new file mode 100644 index 0000000..799db64 --- /dev/null +++ b/automataCI/_release-checksum_unix-any.sh @@ -0,0 +1,185 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/crypto/gpg.sh" +. "${LIBS_AUTOMATACI}/services/checksum/shasum.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_CHECKSUM() { + #__static_repo="$1" + + + # execute + __sha256_file="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/sha256.txt" + FS_Remove_Silently "$__sha256_file" + + __sha256_target="${PROJECT_SKU}-sha256_${PROJECT_VERSION}.txt" + __sha256_target="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}/${__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}" + FS_Remove_Silently "$__sha512_target" + + + # gpg sign all packages + 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 + + FS_Copy_File "$__keyfile" "${1}/${__keyfile##*/}" + if [ $? -ne 0 ]; then + I18N_Export_Failed + return 1 + fi + + # gpg sign all packages + for TARGET in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}"/*; do + if [ ! "${TARGET%%.asc*}" = "${TARGET}" ]; then + continue # it's a gpg cert + fi + + I18N_Sign "$TARGET" "GPG" + FS_Remove_Silently "${TARGET}.asc" + GPG_Detach_Sign_File "$TARGET" "$PROJECT_GPG_ID" + if [ $? -ne 0 ]; then + I18N_Sign_Failed + return 1 + fi + done + fi + + + # shasum all files + for TARGET in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}"/*; do + FS_Is_Directory "$TARGET" + if [ $? -eq 0 ]; then + I18N_Is_Directory_Skipped "$TARGET" + continue + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_SHA256") -ne 0 ]; then + I18N_Checksum "$TARGET" "SHA256" + __value="$(SHASUM_Create_From_File "$TARGET" "256")" + if [ $(STRINGS_Is_Empty "${__value}") -eq 0 ]; then + I18N_Checksum_Failed + return 1 + fi + + FS_Append_File "${__sha256_file}" "\ +${__value} ${TARGET##*/} +" + if [ $? -ne 0 ]; then + I18N_Checksum_Failed + return 1 + fi + fi + + + 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 + I18N_Checksum_Failed + return 1 + fi + + FS_Append_File "${__sha512_file}" "\ +${__value} ${TARGET##*/} +" + if [ $? -ne 0 ]; then + I18N_Checksum_Failed + return 1 + fi + fi + done + + + FS_Is_File "$__sha256_file" + if [ $? -eq 0 ]; then + I18N_Export "$__sha256_target" + FS_Move "${__sha256_file}" "$__sha256_target" + if [ $? -ne 0 ]; then + I18N_Export_Failed + return 1 + fi + fi + + + FS_Is_File "$__sha512_file" + if [ $? -eq 0 ]; then + I18N_Export "$__sha512_target" + FS_Move "${__sha512_file}" "$__sha512_target" + if [ $? -ne 0 ]; then + I18N_Export_Failed + return 1 + fi + fi + + + # report status + return 0 +} + + + + +RELEASE_Initiate_CHECKSUM() { + # execute + I18N_Check_Availability "SHASUM" + SHASUM_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + I18N_Check_Availability "GPG" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Available "GPG" + else + GPG_Is_Available "$PROJECT_GPG_ID" + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-checksum_windows-any.ps1 b/automataCI/_release-checksum_windows-any.ps1 new file mode 100644 index 0000000..a9b4727 --- /dev/null +++ b/automataCI/_release-checksum_windows-any.ps1 @@ -0,0 +1,187 @@ +# 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\crypto\gpg.ps1" +. "${env:LIBS_AUTOMATACI}\services\checksum\shasum.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-CHECKSUM { + param ( + [string]$__static_repo + ) + + + # execute + $__sha256_file = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\sha256.txt" + $null = FS-Remove-Silently "${__sha256_file}" + + $__sha256_target = "${env:PROJECT_SKU}-sha256_${env:PROJECT_VERSION}.txt" + $__sha256_target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\${__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}" + $null = FS-Remove-Silently "${__sha512_target}" + + + # gpg sign all packages + $___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}" + + $___process = GPG-Export-Public-Key "${__keyfile}" "${env:PROJECT_GPG_ID}" + if ($___process -ne 0) { + $null = I18N-Export-Failed + return 1 + } + + $___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 "${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 + } + + $null = I18N-Sign "${TARGET}" "GPG" + FS-Remove-Silently "${TARGET}.asc" + $___process = GPG-Detach-Sign-File "${TARGET}" "${env:PROJECT_GPG_ID}" + if ($___process -ne 0) { + $null = I18N-Sign-Failed + return 1 + } + } + } + + + # shasum all files + foreach ($TARGET in (Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}")) { + $___process = FS-Is-Directory "${TARGET}" + if ($___process -eq 0) { + $null = I18N-Is-Directory-Skipped "${TARGET}" + continue + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_SHA256}") -ne 0) { + $null = I18N-Checksum "$TARGET" "SHA256" + $__value = SHASUM-Checksum-From-File $TARGET.FullName "256" + if ($(STRINGS-Is-Empty "${__value}") -eq 0) { + $null = I18N-Checksum-Failed + return 1 + } + + $___process = FS-Append-File "${__sha256_file}" @" +${__value} $TARGET +"@ + if ($___process -ne 0) { + $null = I18N-Checksum-Failed + return 1 + } + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_SHA512}") -ne 0) { + $null = I18N-Checksum "$TARGET" "SHA512" + $__value = SHASUM-Checksum-From-File $TARGET.FullName "512" + if ($(STRINGS-Is-Empty "${__value}") -eq 0) { + $null = I18N-Checksum-Failed + return 1 + } + + $___process = FS-Append-File "${__sha512_file}" @" +${__value} $TARGET +"@ + if ($___process -ne 0) { + $null = I18N-Checksum-Failed + return 1 + } + } + } + + + $___process = FS-Is-File "${__sha256_file}" + if ($___process -eq 0) { + $null = I18N-Export "${__sha256_target}" + $___process = FS-Move "${__sha256_file}" "${__sha256_target}" + if ($___process -ne 0) { + $null = I18N-Export-Failed + return 1 + } + } + + + $___process = FS-Is-File "${__sha512_file}" + if ($___process -eq 0) { + $null = I18N-Export "${__sha512_target}" + $___process = FS-Move "${__sha512_file}" "${__sha512_target}" + if ($___process -ne 0) { + $null = I18N-Export-Failed + return 1 + } + } + + + # report status + return 0 +} + + + + +function RELEASE-Initiate-CHECKSUM { + # execute + $null = I18N-Check-Availability "SHASUM" + $___process = SHASUM-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + $null = I18N-Check-Availability "GPG" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Available "GPG" + } else { + $___process = GPG-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + } + + + # report status + return 0 +} diff --git a/automataCI/_release-chocolatey_unix-any.sh b/automataCI/_release-chocolatey_unix-any.sh new file mode 100644 index 0000000..b42534a --- /dev/null +++ b/automataCI/_release-chocolatey_unix-any.sh @@ -0,0 +1,143 @@ +#!/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 new file mode 100644 index 0000000..c35f6c7 --- /dev/null +++ b/automataCI/_release-chocolatey_windows-any.ps1 @@ -0,0 +1,155 @@ +# 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 new file mode 100644 index 0000000..8a758bb --- /dev/null +++ b/automataCI/_release-citation_unix-any.sh @@ -0,0 +1,49 @@ +#!/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/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 + + + + +RELEASE_Run_CITATION_CFF() { + _target="$1" + + + # validate + if [ $(FS_Is_Target_A_Citation_CFF "$_target") -ne 0 ]; then + return 0 + fi + + + # execute + I18N_Export "CITATION.cff" + FS_Copy_File "$_target" "${PROJECT_PATH_ROOT}/CITATION.cff" + if [ $? -ne 0 ]; then + I18N_Export_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-citation_windows-any.ps1 b/automataCI/_release-citation_windows-any.ps1 new file mode 100644 index 0000000..4b0fc0e --- /dev/null +++ b/automataCI/_release-citation_windows-any.ps1 @@ -0,0 +1,51 @@ +# 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\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 RELEASE-Run-CITATION-CFF { + param( + [string]$_target + ) + + + # validate input + $___process = FS-Is-Target-A-Citation-CFF "${_target}" + if ($___process -ne 0) { + return 0 + } + + + # 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 + } + + + # report status + return 0 +} diff --git a/automataCI/_release-deb_unix-any.sh b/automataCI/_release-deb_unix-any.sh new file mode 100644 index 0000000..751c752 --- /dev/null +++ b/automataCI/_release-deb_unix-any.sh @@ -0,0 +1,96 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/deb.sh" +. "${LIBS_AUTOMATACI}/services/publishers/reprepro.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_DEB() { + __target="$1" + __directory="$2" + + + # validate input + DEB_Is_Valid "$__target" + if [ $? -ne 0 ]; then + return 0 + fi + + I18N_Check_Availability "REPREPRO" + REPREPRO_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed_Skipped + return 0 + 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" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + fi + + __dest="${2}/deb" + I18N_Create "$__dest" + FS_Make_Directory "${__dest}" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + 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" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-deb_windows-any.ps1 b/automataCI/_release-deb_windows-any.ps1 new file mode 100644 index 0000000..f7ad6b8 --- /dev/null +++ b/automataCI/_release-deb_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\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\deb.ps1" +. "${env:LIBS_AUTOMATACI}\services\publishers\reprepro.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-DEB { + param( + [string]$__target, + [string]$__directory + ) + + + # validate input + $___process = DEB-Is-Valid "${__target}" + if ($___process -ne 0) { + return 0 + } + + $null = I18N-Check-Availability "REPREPRO" + $___process = REPREPRO-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed-Skipped + return 0 + } + + + # 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}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + $__dest = "${__directory}/deb" + $null = I18N-Create "${__dest}" + $___process = FS-Make-Directory "${__dest}" + if ($___process -ne 0) { + $null = I18N-Create-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 + } + } + + + # report status + return 0 +} diff --git a/automataCI/_release-docker_unix-any.sh b/automataCI/_release-docker_unix-any.sh new file mode 100644 index 0000000..55e1c1c --- /dev/null +++ b/automataCI/_release-docker_unix-any.sh @@ -0,0 +1,67 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/docker.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_DOCKER() { + _target="$1" + _directory="$2" + + + # validate input + DOCKER_Is_Valid "$_target" + if [ $? -ne 0 ]; then + return 0 + fi + + I18N_Check_Availability "DOCKER" + DOCKER_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # execute + I18N_Publish "DOCKER" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Publish "DOCKER" + else + DOCKER_Release "$_target" "$PROJECT_VERSION" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + + I18N_Clean "$_target" + FS_Remove_Silently "$_target" + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-docker_windows-any.ps1 b/automataCI/_release-docker_windows-any.ps1 new file mode 100644 index 0000000..1ecb8a1 --- /dev/null +++ b/automataCI/_release-docker_windows-any.ps1 @@ -0,0 +1,68 @@ +# 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\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\docker.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-DOCKER { + param( + [string]$_target, + [string]$_directory + ) + + + # validate input + $___process = DOCKER-Is-Valid "${_target}" + if ($___process -ne 0) { + return 0 + } + + $null = I18N-Check-Availability "DOCKER" + $___process = DOCKER-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + + # 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 ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + + $null = I18N-Clean "${_target}" + $null = FS-Remove-Silently "${_target}" + } + + + # report status + return 0 +} diff --git a/automataCI/_release-docsrepo_unix-any.sh b/automataCI/_release-docsrepo_unix-any.sh new file mode 100644 index 0000000..4cbee00 --- /dev/null +++ b/automataCI/_release-docsrepo_unix-any.sh @@ -0,0 +1,95 @@ +#!/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/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_DOCS() { + # validate input + I18N_Check "DOCS" + FS_Is_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_DOCS}" + if [ $? -ne 0 ]; then + return 0 + fi + + 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 "DOCS" + GIT_Clone_Repo \ + "$PROJECT_PATH_ROOT" \ + "$PROJECT_PATH_RELEASE" \ + "$PWD" \ + "$PROJECT_DOCS_REPO" \ + "$PROJECT_SIMULATE_RELEASE_REPO" \ + "$PROJECT_DOCS_REPO_DIRECTORY" \ + "$PROJECT_DOCS_REPO_BRANCH" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + + + # export contents + __staging="${PROJECT_PATH_ROOT}/${PROJECT_PATH_DOCS}" + __dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/${PROJECT_DOCS_REPO_DIRECTORY}" + + I18N_Export "$__staging" + FS_Copy_All "${__staging}/" "$__dest" + if [ $? -ne 0 ]; then + I18N_Export_Failed + return 1 + fi + + I18N_Commit "DOCS" + __tag="$(GIT_Get_Latest_Commit_ID)" + if [ $(STRINGS_Is_Empty "$__tag") -eq 0 ]; then + I18N_Commit_Failed + return 1 + fi + + ___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 + + if [ $___process -ne 0 ]; then + I18N_Commit_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-docsrepo_windows-any.ps1 b/automataCI/_release-docsrepo_windows-any.ps1 new file mode 100644 index 0000000..2730fdf --- /dev/null +++ b/automataCI/_release-docsrepo_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\fs.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-DOCS { + # validate input + $null = I18N-Check "DOCS" + $___process = FS-Is-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_DOCS}" + if ($___process -ne 0) { + return 0 + } + + $___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 "DOCS" + $___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_DOCS_REPO_BRANCH}" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + + + # 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}" + + $null = I18N-Export "${__staging}" + $___process = FS-Copy-All "${__staging}\" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Export-Failed + return 1 + } + + $null = I18N-Commit "DOCS" + $__tag = GIT-Get-Latest-Commit-ID + if ($(STRINGS-Is-Empty "${__tag}") -eq 0) { + $null = I18N-Commit-Failed + return 1 + } + + $___current_path = Get-Location + $null = Set-Location "${__dest}" + + $___process = Git-Autonomous-Force-Commit ` + "${__tag}" ` + "${env:PROJECT_DOCS_REPO_KEY}" ` + "${env:PROJECT_DOCS_REPO_BRANCH}" + + $null = Set-Location "${___current_path}" + $null = Remove-Variable ___current_path + + if ($___process -ne 0) { + $null = I18N-Commit-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/_release-homebrew_unix-any.sh b/automataCI/_release-homebrew_unix-any.sh new file mode 100644 index 0000000..627210a --- /dev/null +++ b/automataCI/_release-homebrew_unix-any.sh @@ -0,0 +1,143 @@ +#!/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/homebrew.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_HOMEBREW() { + #___target="$1" + #___repo="$2" + + + # validate input + HOMEBREW_Is_Valid_Formula "$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 + HOMEBREW_Publish "$1" "${2}/Formula/${PROJECT_SKU}.rb" + if [ $? -ne 0 ]; then + I18N_Export_Failed + return 1 + fi + + + # report status + return 0 +} + + + + +RELEASE_Conclude_HOMEBREW() { + #___directory="$1" + + + # validate input + I18N_Commit "HOMEBREW" + 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_HOMEBREW() { + # clean up base directory + I18N_Check "HOMEBREW" + 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 "HOMEBREW" + GIT_Clone_Repo \ + "$PROJECT_PATH_ROOT" \ + "$PROJECT_PATH_RELEASE" \ + "$PWD" \ + "$PROJECT_HOMEBREW_REPO" \ + "$PROJECT_SIMULATE_RELEASE_REPO" \ + "$PROJECT_HOMEBREW_DIRECTORY" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-homebrew_windows-any.ps1 b/automataCI/_release-homebrew_windows-any.ps1 new file mode 100644 index 0000000..30c4871 --- /dev/null +++ b/automataCI/_release-homebrew_windows-any.ps1 @@ -0,0 +1,153 @@ +# 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\homebrew.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-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 +} + + + + +function RELEASE-Conclude-HOMEBREW { + param( + [string]$___directory + ) + + + # validate input + $null = I18N-Commit "HOMEBREW" + 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_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 + return 1 + } + + + # return status + return 0 +} + + + + +function RELEASE-Setup-HOMEBREW { + # clean up base directory + $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 + } + $null = FS-Make-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + + + # execute + $null = I18N-Setup "HOMEBREW" + $___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 + } + + + # report status + return 0 +} diff --git a/automataCI/_release-pypi_unix-any.sh b/automataCI/_release-pypi_unix-any.sh new file mode 100644 index 0000000..95444c2 --- /dev/null +++ b/automataCI/_release-pypi_unix-any.sh @@ -0,0 +1,80 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/python.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_PYPI() { + #_target="$1" + + + # validate input + PYTHON_Is_Valid_PYPI "$1" + if [ $? -ne 0 ]; then + return 0 + fi + + I18N_Check_Availability "PYTHON" + PYTHON_Activate_VENV + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + I18N_Check_Availability "PYPI" + PYTHON_PYPI_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed "PYPI" + return 1 + fi + + + # execute + I18N_Publish "PYPI" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Publish "PYPI" + else + I18N_Check_Login "PYPI" + PYTHON_Check_PYPI_Login + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + PYTHON_Release_PYPI "$_target" "$PROJECT_GPG_ID" "$PROJECT_PYPI_REPO_URL" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + fi + + I18N_Clean "$_target" + FS_Remove_Silently "$_target" + + + # report status + return 0 +} diff --git a/automataCI/_release-pypi_windows-any.ps1 b/automataCI/_release-pypi_windows-any.ps1 new file mode 100644 index 0000000..416e673 --- /dev/null +++ b/automataCI/_release-pypi_windows-any.ps1 @@ -0,0 +1,84 @@ +# 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\python.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-PYPI { + param( + [string]$_target + ) + + + # validate input + $___process = PYTHON-Is-Valid-PYPI "${_target}" + if ($___process -ne 0) { + return 0 + } + + $null = I18N-Check-Availability "PYTHON" + $___process = PYTHON-Activate-VENV + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + $null = I18N-Check-Availability "PYPI" + $___process = PYTHON-PYPI-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + + # execute + $null = I18N-Publish "PYPI" + if ($(OS-Is-Run-Simulated) -ne 0) { + $null = I18N-Simulate-Publish "PYPI" + } else { + $null = I18N-Check-Login "PYPI" + $___process = PYHTON-Check-PYPI-Login + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + $___process = PYTHON-Release-PYPI ` + "${_target}" ` + "${env:PROJECT_GPG_ID}" ` + "${env:PROJECT_PYPI_REPO_URL}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + } + + $null = I18N-Clean "${_target}" + $null = FS-Remove-Silently "${_target}" + + + # report status + return 0 +} diff --git a/automataCI/_release-rpm_unix-any.sh b/automataCI/_release-rpm_unix-any.sh new file mode 100644 index 0000000..e422fd3 --- /dev/null +++ b/automataCI/_release-rpm_unix-any.sh @@ -0,0 +1,68 @@ +#!/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/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/rpm.sh" +. "${LIBS_AUTOMATACI}/services/publishers/createrepo.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_RPM() { + __target="$1" + __directory="$2" + + + # validate input + RPM_Is_Valid "$__target" + if [ $? -ne 0 ]; then + return 0 + fi + + I18N_Check_Availability "CREATEREPO" + CREATEREPO_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed_Skipped + return 0 + fi + + + # execute + __dest="${__directory}/rpm" + I18N_Create "$__dest" + FS_Make_Directory "${__dest}" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + I18N_Publish "CREATEREPO" + CREATEREPO_Publish "$__target" "${__dest}" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-rpm_windows-any.ps1 b/automataCI/_release-rpm_windows-any.ps1 new file mode 100644 index 0000000..5780304 --- /dev/null +++ b/automataCI/_release-rpm_windows-any.ps1 @@ -0,0 +1,69 @@ +# 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\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\rpm.ps1" +. "${env:LIBS_AUTOMATACI}\services\publishers\createrepo.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-RPM { + param( + [string]$__target, + [string]$__directory + ) + + + # validate input + $___process = RPM-Is-Valid "${__target}" + if ($___process -ne 0) { + return 0 + } + + $null = I18N-Check-Availability "CREATEREPO" + $___process = CREATEREPO-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed-Skipped + return 0 + } + + + # execute + $__dest = "${__directory}/rpm" + $null = I18N-Create "${__dest}" + $___process = FS-Make-Directory "${__dest}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + $null = I18N-Publish "CREATEREPO" + $___process = CREATEREPO-Publish "${__target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/_release-staticrepo_unix-any.sh b/automataCI/_release-staticrepo_unix-any.sh new file mode 100644 index 0000000..fc7605b --- /dev/null +++ b/automataCI/_release-staticrepo_unix-any.sh @@ -0,0 +1,119 @@ +#!/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 new file mode 100644 index 0000000..ecd7367 --- /dev/null +++ b/automataCI/_release-staticrepo_windows-any.ps1 @@ -0,0 +1,114 @@ +# 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/archive_unix-any.sh b/automataCI/archive_unix-any.sh new file mode 100644 index 0000000..9e432a1 --- /dev/null +++ b/automataCI/archive_unix-any.sh @@ -0,0 +1,116 @@ +#!/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/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + + + + +# validate dependency +I18N_Check "TAR" +TAR_Is_Available +if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 +fi + + + + +# execute tech specific CI jobs if available +old_IFS="$IFS" +printf -- "%s" "\ +${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_BIN} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_DOCS} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_LIB} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_LOG} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS} +" | while IFS="" read -r __line || [ -n "$__line" ]; do + if [ "$__line" = "${PROJECT_PATH_ROOT}" ]; then + continue + fi + + if [ "$__line" = "${PROJECT_PATH_ROOT}/" ]; then + continue + fi + + + FS_Make_Directory "$__line" +done +cd "$PROJECT_PATH_ROOT" + + + + +# package build +___artifact_build="artifact-build_${PROJECT_OS}-${PROJECT_ARCH}.tar.gz" +I18N_Archive "$___artifact_build" +FS_Remove_Silently "$___artifact_build" +tar czvf "$___artifact_build" \ + "$PROJECT_PATH_BUILD" \ + "$PROJECT_PATH_LOG" \ + "$PROJECT_PATH_PKG" \ + "$PROJECT_PATH_DOCS" + + + + +# package workspace +___artifact_workspace="artifact-workspace_${PROJECT_OS}-${PROJECT_ARCH}.tar.gz" +I18N_Archive "$___artifact_workspace" +FS_Remove_Silently "$___artifact_workspace" +tar czvf "$___artifact_workspace" \ + "$PROJECT_PATH_BIN" \ + "$PROJECT_PATH_LIB" \ + "$PROJECT_PATH_TEMP" \ + "$PROJECT_PATH_RELEASE" + + + + +# check existences +I18N_Check "$___artifact_build" +FS_Is_File "$___artifact_build" +if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 +fi + +I18N_Check "$___artifact_workspace" +FS_Is_File "$___artifact_workspace" +if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 +fi + + + + +# report status +I18N_Run_Successful +return 0 diff --git a/automataCI/archive_windows-any.ps1 b/automataCI/archive_windows-any.ps1 new file mode 100644 index 0000000..c20dc37 --- /dev/null +++ b/automataCI/archive_windows-any.ps1 @@ -0,0 +1,114 @@ +# 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\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + + + + +# validate dependency +$null = I18N-Check "TAR" +$___process = TAR-Is-Available +if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 +} + + + + +# execute tech specific CI jobs if available +foreach ($__line in @( + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BIN}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_DOCS}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_LIB}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_LOG}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}" +)) { + if ("${__line}" -eq ${env:PROJECT_PATH_ROOT}) { + continue + } + + if ("${__line}" -eq "${env:PROJECT_PATH_ROOT}\") { + continue + } + + $null = FS-Make-Directory "${__line}" +} +$null = Set-Location "${env:PROJECT_PATH_ROOT}" + + + + +# package build +$___artifact_build = "${env:PROJECT_PATH_ROOT}\artifact-build_${env:PROJECT_OS}-${env:PROJECT_ARCH}.tar.gz" +$null = I18N-Archive "${___artifact_build}" +$null = FS-Remove-Silently "${___artifact_build}" +$___arguments = ".\${env:PROJECT_PATH_BUILD}" ` + + " .\${env:PROJECT_PATH_LOG}" ` + + " .\${env:PROJECT_PATH_PKG}" ` + + " .\${env:PROJECT_PATH_DOCS}" +$null = OS-Exec "tar" "czvf ${___artifact_build} ${___arguments}" + + + + +# package workspace +$___artifact_workspace = "${env:PROJECT_PATH_ROOT}\artifact-workspace_${env:PROJECT_OS}-${env:PROJECT_ARCH}.tar.gz" +$null = I18N-Archive "${___artifact_workspace}" +$null = FS-Remove-Silently "${___artifact_workspace}" +$___arguments = ".\${env:PROJECT_PATH_BIN}" ` + + " .\${env:PROJECT_PATH_LIB}" ` + + " .\${env:PROJECT_PATH_TEMP}" ` + + " .\${env:PROJECT_PATH_RELEASE}" +$null = OS-Exec "tar" "czvf ${___artifact_workspace} ${___arguments}" + + + + +# check existences +$null = I18N-Check "${___artifact_build}" +$___process = FS-Is-File "${___artifact_build}" +if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 +} + +$null = I18N-Check "${___artifact_workspace}" +$___process = FS-Is-File "${___artifact_workspace}" +if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 +} + + + + +# report status +$null = I18N-Run-Successful +return 0 diff --git a/automataCI/ci.ps1 b/automataCI/ci.ps1 new file mode 100644 index 0000000..5f06254 --- /dev/null +++ b/automataCI/ci.ps1 @@ -0,0 +1,221 @@ +# 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. + + + + +# make sure is by run initialization +if (-not (Test-Path -Path "${env:PROJECT_PATH_ROOT}")) { + $null = Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + return 1 +} + + + + +# configure charset encoding +$PSDefaultParameterValues['*:Encoding'] = 'utf8' +$OutputEncoding = [console]::InputEncoding ` + = [console]::OutputEncoding ` + = New-Object System.Text.UTF8Encoding + + + + +# determine PROJECT_PATH_PWD +$env:PROJECT_PATH_PWD = Get-Location +$env:PROJECT_PATH_AUTOMATA = "automataCI" +$env:PROJECT_PATH_ROOT = "" + + + + +# determine PROJECT_PATH_ROOT +if (Test-Path ".\ci.ps1") { + # currently inside the automataCI directory. + ${env:PROJECT_PATH_ROOT} = Split-Path -Parent "${env:PROJECT_PATH_PWD}" +} elseif (Test-Path ".\${env:PROJECT_PATH_AUTOMATA}\ci.ps1") { + # current directory is the root directory. + ${env:PROJECT_PATH_ROOT} = "${env:PROJECT_PATH_PWD}" +} else { + # scan from current directory - bottom to top + $__pathing = "${env:PROJECT_PATH_PWD}" + ${env:PROJECT_PATH_ROOT} = "" + foreach ($__pathing in (${env:PROJECT_PATH_PWD}.Split("\"))) { + if (-not [string]::IsNullOrEmpty($env:PROJECT_PATH_ROOT)) { + ${env:PROJECT_PATH_ROOT} += "\" + } + ${env:PROJECT_PATH_ROOT} += "${__pathing}" + + if (Test-Path -Path ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\ci.ps1") { + break + } + } + $null = Remove-Variable -Name __pathing + + if (-not (Test-Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\ci.ps1")) { + Write-Error "[ ERROR ] Missing root directory.`n`n" + exit 1 + } +} + +${env:LIBS_AUTOMATACI} = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}" + + + + +# import fundamental libraries +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + + + + +# determine host system parameters +$env:PROJECT_OS = "$(OS-Get)" +if ($(STRINGS-Is-Empty "$env:PROJECT_OS") -eq 0) { + $null = I18N-Unsupported-OS + return 1 +} + +${env:PROJECT_ARCH} = "$(OS-Get-Arch)" +if($(STRINGS-Is-Empty "${env:PROJECT_ARCH}") -eq 0) { + $null = I18N-Unsupported-ARCH + return 1 +} + + + + +# parse repo CI configurations +if (-not (Test-Path -Path "${env:PROJECT_PATH_ROOT}\CONFIG.toml")) { + $null = I18N-Missing "CONFIG.toml" + return 1 +} + + +foreach ($__line in (Get-Content "${env:PROJECT_PATH_ROOT}\CONFIG.toml")) { + $__line = $__line -replace '#.*', '' + + $__process = STRINGS-Is-Empty "${__line}" + if ($__process -eq 0) { + continue + } + + $__key, $__value = $__line -split '=', 2 + $__key = $__key.Trim() -replace '^''|''$|^"|"$' + $__value = $__value.Trim() -replace '^''|''$|^"|"$' + + $null = Set-Item -Path "env:$__key" -Value $__value +} + + + + +# parse repo CI secret configurations +if (Test-Path -Path "${env:PROJECT_PATH_ROOT}\SECRETS.toml" -PathType leaf) { + foreach ($__line in (Get-Content "${env:PROJECT_PATH_ROOT}\SECRETS.toml")) { + $__line = $__line -replace '#.*', '' + $__process = STRINGS-Is-Empty "${__line}" + if ($__process -eq 0) { + continue + } + + $__key, $__value = $__line -split '=', 2 + $__key = $__key.Trim() -replace '^''|''$|^"|"$' + $__value = $__value.Trim() -replace '^''|''$|^"|"$' + + $null = Set-Item -Path "env:$__key" -Value $__value + } +} + + + + +# determine language +if ($(STRINGS-Is-Empty "${env:AUTOMATACI_LANG}") -eq 0) { + $env:AUTOMATACI_LANG = "$(OS-Get-Lang)" + if ($(STRINGS-Is-Empty "${env:AUTOMATACI_LANG}") -eq 0) { + $env:AUTOMATACI_LANG = "en" # fallback to english + } +} + + + + +# update environment variables +$null = OS-Sync + + + + +# execute command +switch ($args[0]) { +{ $_ -in 'env', 'Env', 'ENV' } { + $env:PROJECT_CI_JOB = "env" + $__exit_code = . "${env:LIBS_AUTOMATACI}\env_windows-any.ps1" +} { $_ -in 'setup', 'Setup', 'SETUP' } { + $env:PROJECT_CI_JOB = "setup" + $__exit_code = . "${env:LIBS_AUTOMATACI}\common_windows-any.ps1" +} { $_ -in 'start', 'Start', 'START' } { + $env:PROJECT_CI_JOB = "start" + $__exit_code = . "${env:LIBS_AUTOMATACI}\common_windows-any.ps1" +} { $_ -in 'test', 'Test', 'TEST' } { + $env:PROJECT_CI_JOB = "test" + $__exit_code = . "${env:LIBS_AUTOMATACI}\common_windows-any.ps1" +} { $_ -in 'prepare', 'Prepare', 'PREPARE' } { + $env:PROJECT_CI_JOB = "prepare" + $__exit_code = . "${env:LIBS_AUTOMATACI}\common_windows-any.ps1" +} { $_ -in 'materialize', 'Materialize', 'MATERIALIZE' } { + $env:PROJECT_CI_JOB = "materialize" + $__exit_code = . "${env:LIBS_AUTOMATACI}\common_windows-any.ps1" +} { $_ -in 'build', 'Build', 'BUILD' } { + $env:PROJECT_CI_JOB = "build" + $__exit_code = . "${env:LIBS_AUTOMATACI}\common_windows-any.ps1" +} { $_ -in 'notarize', 'Notarize', 'NOTARIZE' } { + $env:PROJECT_CI_JOB = "notarize" + $__exit_code = . "${env:LIBS_AUTOMATACI}\notarize_windows-any.ps1" +} { $_ -in 'package', 'Package', 'PACKAGE' } { + $env:PROJECT_CI_JOB = "package" + $__exit_code = . "${env:LIBS_AUTOMATACI}\package_windows-any.ps1" +} { $_ -in 'release', 'Release', 'RELEASE' } { + $env:PROJECT_CI_JOB = "release" + $__exit_code = . "${env:LIBS_AUTOMATACI}\release_windows-any.ps1" +} { $_ -in 'stop', 'Stop', 'STOP' } { + $env:PROJECT_CI_JOB = "stop" + $__exit_code = . "${env:LIBS_AUTOMATACI}\common_windows-any.ps1" +} { $_ -in 'deploy', 'Deploy', 'DEPLOY' } { + $env:PROJECT_CI_JOB = "deploy" + $__exit_code = . "${env:LIBS_AUTOMATACI}\common_windows-any.ps1" +} { $_ -in 'archive', 'Archive', 'ARCHIVE' } { + $env:PROJECT_CI_JOB = "archive" + $__exit_code = . "${env:LIBS_AUTOMATACI}\archive_windows-any.ps1" +} { $_ -in 'clean', 'Clean', 'CLEAN' } { + $env:PROJECT_CI_JOB = "clean" + $__exit_code = . "${env:LIBS_AUTOMATACI}\common_windows-any.ps1" +} { $_ -in 'purge', 'Purge', 'PURGE' } { + $env:PROJECT_CI_JOB = "purge" + $__exit_code = . "${env:LIBS_AUTOMATACI}\purge_windows-any.ps1" +} default { + switch ($args[0]) { + { $_ -in '-h', '--help', 'help', '--Help', 'Help', '--HELP', 'HELP' } { + $null = I18N-Help info + $__exit_code = 0 + } default { + $null = I18N-Unknown-Action + $null = I18N-Help note + $__exit_code = 1 + }} +}} +return $__exit_code diff --git a/automataCI/ci.sh b/automataCI/ci.sh new file mode 100644 index 0000000..7e68f21 --- /dev/null +++ b/automataCI/ci.sh @@ -0,0 +1,271 @@ +#!/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 + + + + +# determine PROJECT_PATH_PWD +export PROJECT_PATH_PWD="$PWD" +export PROJECT_PATH_AUTOMATA="automataCI" + + + + +# determine PROJECT_PATH_ROOT +if [ -f "./ci.sh" ]; then + PROJECT_PATH_ROOT="${PWD%/*}/" +elif [ -f "./${PROJECT_PATH_AUTOMATA}/ci.sh" ]; then + # current directory is the root directory. + PROJECT_PATH_ROOT="$PWD" +else + __pathing="$PROJECT_PATH_PWD" + __previous="" + while [ "$__pathing" != "" ]; do + PROJECT_PATH_ROOT="${PROJECT_PATH_ROOT}${__pathing%%/*}/" + __pathing="${__pathing#*/}" + if [ -f "${PROJECT_PATH_ROOT}${PROJECT_PATH_AUTOMATA}/ci.sh" ]; then + break + fi + + # stop the scan if the previous pathing is the same as current + if [ "$__previous" = "$__pathing" ]; then + 1>&2 printf "[ ERROR ] [ ERROR ] Missing root directory.\n" + return 1 + fi + __previous="$__pathing" + done + unset __pathing __previous + export PROJECT_PATH_ROOT="${PROJECT_PATH_ROOT%/*}" + + if [ ! -f "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/ci.sh" ]; then + 1>&2 printf "[ ERROR ] [ ERROR ] Missing root directory.\n" + exit 1 + fi +fi + +export LIBS_AUTOMATACI="${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}" + + + + +# import fundamental libraries +. "${LIBS_AUTOMATACI}/services/io/os.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + + + + +# determine host system parameters +export PROJECT_OS="$(OS_Get)" +if [ "$(STRINGS_Is_Empty "$PROJECT_OS")" -eq 0 ]; then + I18N_Unsupported_OS + return 1 +fi + +export PROJECT_ARCH="$(OS_Get_Arch)" +if [ "$(STRINGS_Is_Empty "$PROJECT_ARCH")" -eq 0 ]; then + I18N_Unsupported_ARCH + return 1 +fi + + + + +# parse repo CI configurations +if [ ! -f "${PROJECT_PATH_ROOT}/CONFIG.toml" ]; then + I18N_Missing "CONFIG.toml" + return 1 +fi + + +__old_IFS="$IFS" +while IFS= read -r __line || [ -n "$__line" ]; do + __line="${__line%%#*}" + if [ "$(STRINGS_Is_Empty "$__line")" -eq 0 ]; then + continue + fi + + key="${__line%%=*}" + key="${key#"${key%%[![:space:]]*}"}" + key="${key%"${key##*[![:space:]]}"}" + key="${key%\"}" + key="${key#\"}" + key="${key%\'}" + key="${key#\'}" + + value="${__line##*=}" + value="${value#"${value%%[![:space:]]*}"}" + value="${value%"${value##*[![:space:]]}"}" + value="${value%\"}" + value="${value#\"}" + value="${value%\'}" + value="${value#\'}" + + export "$key"="$value" +done < "${PROJECT_PATH_ROOT}/CONFIG.toml" +IFS="$__old_IFS" && unset __old_IFS + + + + +# parse repo CI secret configurations +if [ -f "${PROJECT_PATH_ROOT}/SECRETS.toml" ]; then + __old_IFS="$IFS" + while IFS= read -r __line || [ -n "$__line" ]; do + __line="${__line%%#*}" + if [ "$(STRINGS_Is_Empty "$__line")" -eq 0 ]; then + continue + fi + + key="${__line%%=*}" + key="${key#"${key%%[![:space:]]*}"}" + key="${key%"${key##*[![:space:]]}"}" + key="${key%\"}" + key="${key#\"}" + key="${key%\'}" + key="${key#\'}" + + value="${__line##*=}" + value="${value#"${value%%[![:space:]]*}"}" + value="${value%"${value##*[![:space:]]}"}" + value="${value%\"}" + value="${value#\"}" + value="${value%\'}" + value="${value#\'}" + + export "$key"="$value" + done < "${PROJECT_PATH_ROOT}/SECRETS.toml" + IFS="$__old_IFS" && unset __old_IFS +fi + + + + +# determine language +export AUTOMATACI_LANG="${AUTOMATACI_LANG:-$(OS_Get_Lang)}" +if [ "$(STRINGS_Is_Empty "$AUTOMATACI_LANG")" -eq 0 ]; then + export AUTOMATACI_LANG="en" # fall back to english +fi + + + + +# update environment variable +OS_Sync + + + + +# execute command +case "$1" in +env|Env|ENV) + export PROJECT_CI_JOB="env" + . "${LIBS_AUTOMATACI}/env_unix-any.sh" + __exit_code=$? + ;; +setup|Setup|SETUP) + export PROJECT_CI_JOB="setup" + . "${LIBS_AUTOMATACI}/common_unix-any.sh" + __exit_code=$? + ;; +start|Start|START) + export PROJECT_CI_JOB="start" + . "${LIBS_AUTOMATACI}/common_unix-any.sh" + __exit_code=$? + ;; +test|Test|TEST) + export PROJECT_CI_JOB="test" + . "${LIBS_AUTOMATACI}/common_unix-any.sh" + __exit_code=$? + ;; +prepare|Prepare|PREPARE) + export PROJECT_CI_JOB="prepare" + . "${LIBS_AUTOMATACI}/common_unix-any.sh" + __exit_code=$? + ;; +materialize|Materialize|MATERIALIZE) + export PROJECT_CI_JOB="materialize" + . "${LIBS_AUTOMATACI}/common_unix-any.sh" + __exit_code=$? + ;; +build|Build|BUILD) + export PROJECT_CI_JOB="build" + . "${LIBS_AUTOMATACI}/common_unix-any.sh" + __exit_code=$? + ;; +notarize|Notarize|NOTARIZE) + export PROJECT_CI_JOB="notarize" + . "${LIBS_AUTOMATACI}/notarize_unix-any.sh" + __exit_code=$? + ;; +package|Package|PACKAGE) + export PROJECT_CI_JOB="package" + . "${LIBS_AUTOMATACI}/package_unix-any.sh" + __exit_code=$? + ;; +release|Release|RELEASE) + export PROJECT_CI_JOB="release" + . "${LIBS_AUTOMATACI}/release_unix-any.sh" + __exit_code=$? + ;; +stop|Stop|STOP) + export PROJECT_CI_JOB="stop" + . "${LIBS_AUTOMATACI}/common_unix-any.sh" + __exit_code=$? + unset PROJECT_ARCH PROJECT_OS PROJECT_PATH_PWD PROJECT_PATH_ROOT + ;; +deploy|Deploy|DEPLOY) + export PROJECT_CI_JOB="deploy" + . "${LIBS_AUTOMATACI}/common_unix-any.sh" + __exit_code=$? + ;; +archive|Archive|ARCHIVE) + export PROJECT_CI_JOB="archive" + . "${LIBS_AUTOMATACI}/archive_unix-any.sh" + __exit_code=$? + ;; +clean|Clean|CLEAN) + export PROJECT_CI_JOB="clean" + . "${LIBS_AUTOMATACI}/common_unix-any.sh" + __exit_code=$? + ;; +purge|Purge|PURGE) + export PROJECT_CI_JOB="purge" + . "${LIBS_AUTOMATACI}/purge_unix-any.sh" + __exit_code=$? + ;; +*) + case "$1" in + -h|--help|help|--Help|Help|--HELP|HELP) + I18N_Help info + __exit_code=0 + ;; + *) + I18N_Unknown_Action + I18N_Help note + __exit_code=1 + ;; + esac + ;; +esac +return $__exit_code diff --git a/automataCI/ci.sh.ps1 b/automataCI/ci.sh.ps1 new file mode 100755 index 0000000..0ca1bb0 --- /dev/null +++ b/automataCI/ci.sh.ps1 @@ -0,0 +1,123 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +echo "[ ERROR ] --> powershell.exe !!!" +exit /b 1 +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +$PSDefaultParameterValues['*:Encoding'] = 'utf8' +$OutputEncoding = [console]::InputEncoding ` + = [console]::OutputEncoding ` + = New-Object System.Text.UTF8Encoding + + +# Scan for fundamental pathing +${env:PROJECT_PATH_PWD} = Get-Location +${env:PROJECT_PATH_AUTOMATA} = "automataCI" + +if (Test-Path ".\ci.ps1") { + # currently inside the automataCI directory. + ${env:PROJECT_PATH_ROOT} = Split-Path -Parent "${env:PROJECT_PATH_PWD}" +} elseif (Test-Path ".\${env:PROJECT_PATH_AUTOMATA}\ci.ps1") { + # current directory is the root directory. + ${env:PROJECT_PATH_ROOT} = "${env:PROJECT_PATH_PWD}" +} else { + # scan from current directory - bottom to top + $__pathing = "${env:PROJECT_PATH_PWD}" + ${env:PROJECT_PATH_ROOT} = "" + foreach ($__pathing in (${env:PROJECT_PATH_PWD}.Split("\"))) { + if (-not [string]::IsNullOrEmpty($env:PROJECT_PATH_ROOT)) { + ${env:PROJECT_PATH_ROOT} += "\" + } + ${env:PROJECT_PATH_ROOT} += "${__pathing}" + + if (Test-Path -Path ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\ci.ps1") { + break + } + } + $null = Remove-Variable -Name __pathing + + if (-not (Test-Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\ci.ps1")) { + Write-Error "[ ERROR ] Missing root directory.`n`n" + exit 1 + } +} + + +# execute +$__process = . "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\ci.ps1" $args +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +exit $__process +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +# Scan for fundamental pathing +export PROJECT_PATH_PWD="$PWD" +export PROJECT_PATH_AUTOMATA="automataCI" + +if [ -f "./ci.sh" ]; then + PROJECT_PATH_ROOT="${PWD%/*}/" +elif [ -f "./${PROJECT_PATH_AUTOMATA}/ci.sh" ]; then + # current directory is the root directory. + PROJECT_PATH_ROOT="$PWD" +else + __pathing="$PROJECT_PATH_PWD" + __previous="" + while [ "$__pathing" != "" ]; do + PROJECT_PATH_ROOT="${PROJECT_PATH_ROOT}${__pathing%%/*}/" + __pathing="${__pathing#*/}" + if [ -f "${PROJECT_PATH_ROOT}${PROJECT_PATH_AUTOMATA}/ci.sh" ]; then + break + fi + + # stop the scan if the previous pathing is the same as current + if [ "$__previous" = "$__pathing" ]; then + 1>&2 printf "[ ERROR ] [ ERROR ] Missing root directory.\n" + return 1 + fi + __previous="$__pathing" + done + unset __pathing __previous + export PROJECT_PATH_ROOT="${PROJECT_PATH_ROOT%/*}" + + if [ ! -f "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/ci.sh" ]; then + 1>&2 printf "[ ERROR ] [ ERROR ] Missing root directory.\n" + exit 1 + fi +fi + +# execute +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/ci.sh" "$@" +################################################################################ +# Unix Main Codes # +################################################################################ +exit $? +#> diff --git a/automataCI/common_unix-any.sh b/automataCI/common_unix-any.sh new file mode 100644 index 0000000..0a97551 --- /dev/null +++ b/automataCI/common_unix-any.sh @@ -0,0 +1,141 @@ +#!/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 autoamtaCI/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" + + + + +# validate input +I18N_Validate_Job +if [ $(STRINGS_Is_Empty "$PROJECT_CI_JOB") -eq 0 ]; then + I18N_Validate_Failed + return 1 +fi + + + + +# execute +Run_Subroutine_Exec() { + __directory="$1" + __name="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$__directory") -eq 0 ] || + [ "$(STRINGS_To_Uppercase "$__directory")" = "NONE" ]; then + return 0 + fi + + if [ ! "$(STRINGS_To_Uppercase "$__name")" = "BASELINE" ]; then + case "$__job" in + deploy) + return 0 # skipped + ;; + *) + # accepted + ;; + esac + fi + + + # execute + ci_job="$(STRINGS_To_Lowercase "${PROJECT_CI_JOB}_unix-any.sh")" + ci_job="${PROJECT_PATH_ROOT}/${__directory}/${PROJECT_PATH_CI}/${ci_job}" + FS_Is_File "$ci_job" + if [ $? -eq 0 ]; then + I18N_Run "$__name" + . "$ci_job" + if [ $? -ne 0 ]; then + I18N_Run_Failed + return 1 + fi + fi + + + # report status + return 0 +} + + +Run_Subroutine_Exec "$PROJECT_ANGULAR" "ANGULAR" +if [ $? -ne 0 ]; then + return 1 +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 +fi + + +Run_Subroutine_Exec "$PROJECT_NIM" "NIM" +if [ $? -ne 0 ]; then + return 1 +fi + + +Run_Subroutine_Exec "$PROJECT_PYTHON" "PYTHON" +if [ $? -ne 0 ]; then + return 1 +fi + + +Run_Subroutine_Exec "$PROJECT_RUST" "RUST" +if [ $? -ne 0 ]; then + return 1 +fi + + +Run_Subroutine_Exec "$PROJECT_RESEARCH" "RESEARCH" +if [ $? -ne 0 ]; then + return 1 +fi + + +Run_Subroutine_Exec "$PROJECT_GOOGLEAI" "GOOGLE AI" +if [ $? -ne 0 ]; then + return 1 +fi + + +Run_Subroutine_Exec "$PROJECT_PATH_SOURCE" "BASELINE" +if [ $? -ne 0 ]; then + return 1 +fi + + + + +# report status +I18N_Run_Successful +return 0 diff --git a/automataCI/common_windows-any.ps1 b/automataCI/common_windows-any.ps1 new file mode 100644 index 0000000..8c8d9c1 --- /dev/null +++ b/automataCI/common_windows-any.ps1 @@ -0,0 +1,131 @@ +# 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\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + + + + +# validate input +$null = I18N-Validate-Job +if ($(STRINGS-Is-Empty "${env:PROJECT_CI_JOB}") -eq 0) { + $null = I18N-Validate-Failed + return 1 +} + + + + +# execute +function RUN-Subroutine-Exec { + param( + [string]$__directory, + [string]$__name + ) + + + # validate input + if (($(STRINGS-Is-Empty "${__directory}") -eq 0) -or + ($(STRINGS-To-Uppercase "${__directory}") -eq "NONE")) { + return 0 + } + + if ($(STRINGS-To-Uppercase "${__name}") -ne "BASELINE") { + switch ($__job) { + { $_ -in "deploy" } { + return 0 # skipped + } default { + # accepted + }} + } + + + # execute + $ci_job = STRINGS-To-Lowercase "${env:PROJECT_CI_JOB}_windows-any.ps1" + $ci_job = "${env:PROJECT_PATH_ROOT}\${__directory}\${env:PROJECT_PATH_CI}\${ci_job}" + if ($(FS-Is-File "$ci_job") -eq 0) { + $null = I18N-Run "${__name}" + $___process = . $ci_job + if ($___process -ne 0) { + $null = I18N-Run-Failed + return 1 + } + } + + + # report status + return 0 +} + + +$___process = RUN-Subroutine-Exec "${env:PROJECT_ANGULAR}" "ANGULAR" +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 +} + +$___process = RUN-Subroutine-Exec "${env:PROJECT_NIM}" "NIM" +if ($___process -ne 0) { + return 1 +} + +$___process = RUN-Subroutine-Exec "${env:PROJECT_PYTHON}" "PYTHON" +if ($___process -ne 0) { + return 1 +} + +$___process = RUN-Subroutine-Exec "${env:PROJECT_RUST}" "RUST" +if ($___process -ne 0) { + return 1 +} + +$___process = RUN-Subroutine-Exec "${env:PROJECT_RESEARCH}" "RESEARCH" +if ($___process -ne 0) { + return 1 +} + +$___process = RUN-Subroutine-Exec "${env:PROJECT_GOOGLEAI}" "GOOGLE AI" +if ($___process -ne 0) { + return 1 +} + +$___process = RUN-Subroutine-Exec "${env:PROJECT_PATH_SOURCE}" "BASELINE" +if ($___process -ne 0) { + return 1 +} + + + + +# report status +I18N-Run-Successful +return 0 diff --git a/automataCI/env_unix-any.sh b/automataCI/env_unix-any.sh new file mode 100644 index 0000000..0778594 --- /dev/null +++ b/automataCI/env_unix-any.sh @@ -0,0 +1,199 @@ +#!/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/strings.sh" +. "${LIBS_AUTOMATACI}/services/io/net/http.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/appimage.sh" +. "${LIBS_AUTOMATACI}/services/compilers/angular.sh" +. "${LIBS_AUTOMATACI}/services/compilers/c.sh" +. "${LIBS_AUTOMATACI}/services/compilers/docker.sh" +. "${LIBS_AUTOMATACI}/services/compilers/go.sh" +. "${LIBS_AUTOMATACI}/services/compilers/libreoffice.sh" +. "${LIBS_AUTOMATACI}/services/compilers/msi.sh" +. "${LIBS_AUTOMATACI}/services/compilers/nim.sh" +. "${LIBS_AUTOMATACI}/services/compilers/node.sh" +. "${LIBS_AUTOMATACI}/services/compilers/python.sh" +. "${LIBS_AUTOMATACI}/services/crypto/notary.sh" +. "${LIBS_AUTOMATACI}/services/publishers/dotnet.sh" +. "${LIBS_AUTOMATACI}/services/publishers/github.sh" +. "${LIBS_AUTOMATACI}/services/publishers/homebrew.sh" +. "${LIBS_AUTOMATACI}/services/publishers/reprepro.sh" + + + + +# begin service +I18N_Install "GITHUB ACTION" +GITHUB_Setup_Actions +if [ $? -ne 0 ]; then + I18N_Install_Failed + return 1 +fi + + +I18N_Install "BREW" +HOMEBREW_Setup +if [ $? -ne 0 ]; then + I18N_Install_Failed + return 1 +fi + + +I18N_Install "CURL" +HTTP_Setup +if [ $? -ne 0 ]; then + I18N_Install_Failed + return 1 +fi + + +I18N_Install "APPIMAGE" +APPIMAGE_Setup +if [ $? -ne 0 ]; then + I18N_Install_Failed + return 1 +fi + + +I18N_Install "MSITOOLS" +MSI_Setup +if [ $? -ne 0 ]; then + I18N_Install_Failed + return 1 +fi + + +I18N_Install "DOCKER" +DOCKER_Setup +if [ $? -ne 0 ]; then + I18N_Install_Failed + return 1 +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 + I18N_Install_Failed + return 1 +fi + + +if [ $(STRINGS_Is_Empty "$PROJECT_PYTHON") -ne 0 ]; then + I18N_Install "PYTHON" + PYTHON_Setup + if [ $? -ne 0 ]; then + I18N_Install_Failed + return 1 + fi +fi + + +if [ $(STRINGS_Is_Empty "$PROJECT_GO") -ne 0 ]; then + I18N_Install "GO" + GO_Setup + if [ $? -ne 0 ]; then + I18N_Install_Failed + return 1 + fi +fi + + +if [ $(STRINGS_Is_Empty "$PROJECT_C") -ne 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_GO") -ne 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_NIM") -ne 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_RUST") -ne 0 ]; then + I18N_Install "C/C++" + C_Setup + if [ $? -ne 0 ]; then + I18N_Install_Failed + return 1 + fi +fi + + +if [ $(STRINGS_Is_Empty "$PROJECT_DOTNET") -ne 0 ]; then + I18N_Install "DOTNET" + DOTNET_Setup + if [ $? -ne 0 ]; then + I18N_Install_Failed + return 1 + fi +fi + + +if [ $(STRINGS_Is_Empty "$PROJECT_NIM") -ne 0 ]; then + I18N_Install "NIM" + NIM_Setup + if [ $? -ne 0 ]; then + I18N_Install_Failed + return 1 + fi +fi + + +if [ $(STRINGS_Is_Empty "$PROJECT_NODE") -ne 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_ANGULAR") -ne 0 ]; then + I18N_Install "NODE" + NODE_Setup + if [ $? -ne 0 ]; then + I18N_Install_Failed + return 1 + fi +fi + + +if [ $(STRINGS_Is_Empty "$PROJECT_ANGULAR") -ne 0 ]; then + I18N_Install "ANGULAR" + ANGULAR_Setup + if [ $? -ne 0 ]; then + I18N_Install_Failed + return 1 + fi +fi + + +if [ $(STRINGS_Is_Empty "$PROJECT_LIBREOFFICE") -ne 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_RESEARCH") -ne 0 ]; then + I18N_Install "LIBREOFFICE" + LIBREOFFICE_Setup + if [ $? -ne 0 ]; then + I18N_Install_Failed + return 1 + fi +fi + + + + +# report status +I18N_Run_Successful +return 0 diff --git a/automataCI/env_windows-any.ps1 b/automataCI/env_windows-any.ps1 new file mode 100644 index 0000000..43e15f8 --- /dev/null +++ b/automataCI/env_windows-any.ps1 @@ -0,0 +1,172 @@ +# 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\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\net\http.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\appimage.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\angular.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\c.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\docker.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\go.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\libreoffice.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\msi.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\nim.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\node.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\python.ps1" +. "${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" + + + + +# begin service +$null = I18N-Install "GITHUB ACTIONS" +if ($(GITHUB-Setup-Actions) -ne 0) { + $null = I18N-Install-Failed + return 1 +} + + +$null = I18N-Install "DOTNET" +if ($(DOTNET-Setup) -ne 0) { + $null = I18N-Install-Failed + return 1 +} + + +$null = I18N-Install "CHOCOLATEY" +if ($(CHOCOLATEY-Setup) -ne 0) { + $null = I18N-Install-Failed + return 1 +} + + +$null = I18N-Install "CURL" +if ($(HTTP-Setup) -ne 0) { + $null = I18N-Install-Failed + return 1 +} + + +$null = I18N-Install "DOCKER" +if ($(DOCKER-Setup) -ne 0) { + $null = I18N-Install-Failed + return 1 +} + + +$null = I18N-Install "APPIMAGE" +if ($(APPIMAGE-Setup) -ne 0) { + $null = I18N-Install-Failed + return 1 +} + + +$null = I18N-Install "MSI (WIX)" +if ($(MSI-Setup) -ne 0) { + $null = I18N-Install-Failed + return 1 +} + + +$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) { + $null = I18N-Install-Failed + return 1 + } +} + + +if ($(STRINGS-Is-Empty "${env:PROJECT_GO}") -ne 0) { + $null = I18N-Install "GO" + if ($(GO-Setup) -ne 0) { + $null = I18N-Install-Failed + return 1 + } +} + + +if (($(STRINGS-Is-Empty "${env:PROJECT_C}") -ne 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_GO}") -ne 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_NIM}") -ne 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_RUST}") -ne 0)) { + $null = I18N-Install "C/C++" + if ($(C-Setup) -ne 0) { + $null = I18N-Install-Failed + return 1 + } +} + + +if ($(STRINGS-Is-Empty "${env:PROJECT_NIM}") -ne 0) { + $null = I18N-Install "NIM" + if ($(NIM-Setup) -ne 0) { + $null = I18N-Install-Failed + return 1 + } +} + + +if (($(STRINGS-Is-Empty "${env:PROJECT_NODE}") -ne 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_ANGULAR}") -ne 0)) { + $null = I18N-Install "NODE" + if ($(NODE-Setup) -ne 0) { + $null = I18N-Install-Failed + return 1 + } +} + + +if ($(STRINGS-Is-Empty "${env:PROJECT_ANGULAR}") -ne 0) { + $null = I18N-Install "ANGULAR" + if ($(ANGULAR-Setup) -ne 0) { + $null = I18N-Install-Failed + return 1 + } +} + + +if (($(STRINGS-Is-Empty "${env:PROJECT_LIBREOFFICE}") -ne 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_RESEARCH}") -ne 0)) { + $null = I18N-Install "LIBREOFFICE" + if ($(LIBREOFFICE-Setup) -ne 0) { + $null = I18N-Install-Failed + return 1 + } +} + + + + +# report status +$null = I18N-Run-Successful +return 0 diff --git a/automataCI/notarize_unix-any.sh b/automataCI/notarize_unix-any.sh new file mode 100644 index 0000000..8c6ec6a --- /dev/null +++ b/automataCI/notarize_unix-any.sh @@ -0,0 +1,122 @@ +#!/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 me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + +. "${LIBS_AUTOMATACI}/services/io/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + + + + +# source locally provided functions +__recipe="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}" +__recipe="${__recipe}/notarize_unix-any.sh" +FS_Is_File "$__recipe" +if [ $? -eq 0 ]; then + I18N_Run "$__recipe" + . "$__recipe" + if [ $? -ne 0 ]; then + I18N_Run_Failed + return 1 + fi +fi + + + + +# begin notarize +FS_Is_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}" +if [ $? -ne 0 ]; then + # nothing build - bailing + return 0 +fi + +for i in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}"/*; do + FS_Is_File "$i" + if [ $? -ne 0 ]; then + continue + fi + + + # parse build candidate + I18N_Detected "$i" + TARGET_FILENAME="${i##*${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}/}" + TARGET_FILENAME="${TARGET_FILENAME%.*}" + TARGET_OS="${TARGET_FILENAME##*_}" + TARGET_FILENAME="${TARGET_FILENAME%%_*}" + TARGET_ARCH="${TARGET_OS##*-}" + TARGET_OS="${TARGET_OS%%-*}" + + if [ "$(STRINGS_Is_Empty "$TARGET_OS")" -eq 0 ] || + [ $(STRINGS_Is_Empty "$TARGET_ARCH") -eq 0 ] || + [ $(STRINGS_Is_Empty "$TARGET_FILENAME") -eq 0 ]; then + I18N_File_Has_Bad_Stat_Skipped + continue + fi + + STRINGS_Has_Prefix "$PROJECT_SKU" "$TARGET_FILENAME" + if [ $? -ne 0 ]; then + I18N_Is_Incompatible_Skipped "$TARGET_FILENAME" + continue + fi + + + # execute + cmd="NOTARIZE_Certify" + I18N_Check_Availability "$cmd" + OS_Is_Command_Available "$cmd" + if [ $? -ne 0 ]; then + I18N_Check_Failed + continue + fi + + "$cmd" "$i" \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}" \ + "$TARGET_FILENAME" \ + "$TARGET_OS" \ + "$TARGET_ARCH" + case $? in + 12) + I18N_Simulate_Notarize + ;; + 11) + I18N_Notarize_Unavailable + ;; + 10) + I18N_Notarize_Not_Applicable + ;; + 0) + I18N_Run_Successful + ;; + *) + I18N_Notarize_Failed + return 1 + ;; + esac +done + + + + +# report status +return 0 diff --git a/automataCI/notarize_windows-any.ps1 b/automataCI/notarize_windows-any.ps1 new file mode 100644 index 0000000..f78324d --- /dev/null +++ b/automataCI/notarize_windows-any.ps1 @@ -0,0 +1,116 @@ +# 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 me from automataCI\ci.sh.ps1 instead!`n" + return 1 +} + +. "${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" + + + + +# source locally provided functions +$__recipe = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}" +$__recipe = "${__recipe}\notarize_windows-any.ps1" +$___process = FS-Is-File "${__recipe}" +if ($___process -eq 0) { + $null = I18N-Run "${__recipe}" + $___process = . "${__recipe}" + if ($___process -ne 0) { + $null = I18N-Run-Failed + return 1 + } +} + + + + +# begin notarize +$___process = FS-Is-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}" +if ($___process -ne 0) { + # nothing build - bailing + return 0 +} + +foreach ($i in (Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}")) { + $___process = FS-Is-File "$i" + if ($___process -ne 0) { + continue + } + + + # parse build candidate + $null = I18N-Detected "$i" + $TARGET_FILENAME = Split-Path -Leaf $i + $TARGET_FILENAME = $TARGET_FILENAME -replace ` + (Join-Path $env:PROJECT_PATH_ROOT $env:PROJECT_PATH_BUILD), "" + $TARGET_FILENAME = $TARGET_FILENAME -replace "\..*$" + $TARGET_OS = $TARGET_FILENAME -replace ".*_" + $TARGET_FILENAME = $TARGET_FILENAME -replace "_.*" + $TARGET_ARCH = $TARGET_OS -replace ".*-" + $TARGET_OS = $TARGET_OS -replace "-.*" + + if (($(STRINGS-Is-Empty "$TARGET_OS") -eq 0) -or + ($(STRINGS-Is-Empty "$TARGET_ARCH") -eq 0) -or + ($(STRINGS-Is-Empty "$TARGET_FILENAME") -eq 0)) { + $null = I18N-File-Has-Bad-Stat-Skipped + continue + } + + $___process = STRINGS-Has-Prefix "${env:PROJECT_SKU}" "${TARGET_FILENAME}" + if ($___process -ne 0) { + $null = I18N-Is-Incompatible-Skipped "${TARGET_FILENAME}" + continue + } + + $cmd = "NOTARIZE-Certify" + $null = I18N-Check-Availability "$cmd" + $___process = OS-Is-Command-Available "$cmd" + if ($___process -ne 0) { + $null = I18N-Check-Failed + continue + } + + $___process = NOTARIZE-Certify "$i" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}" ` + "${TARGET_FILENAME}" ` + "${TARGET_OS}" ` + "${TARGET_ARCH}" + switch ($___process) { + 12 { + $null = I18N-Simulate-Notarize + } 11 { + $null = I18N-Notarize-Unavailable + } 10 { + $null = I18N-Notarize-Not-Applicable + } 0 { + $null = I18N-Run-Successful + } default { + $null = I18N-Notarize-Failed + return 1 + }} +} + + + + +# report status +return 0 diff --git a/automataCI/package_unix-any.sh b/automataCI/package_unix-any.sh new file mode 100644 index 0000000..bd90175 --- /dev/null +++ b/automataCI/package_unix-any.sh @@ -0,0 +1,308 @@ +#!/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 me 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/io/sync.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + +. "${LIBS_AUTOMATACI}/_package-archive_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-cargo_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-changelog_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-chocolatey_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-citation_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-deb_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-docker_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-flatpak_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-homebrew_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-ipk_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-msi_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-pdf_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-pypi_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-rpm_unix-any.sh" + + + + +# source locally provided functions +. "${LIBS_AUTOMATACI}/_package-sourcing_unix-any.sh" + + + + +# 1-time setup job required materials +DEST="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}" +I18N_Remake "$DEST" +FS_Remake_Directory "$DEST" +if [ $? -ne 0 ]; then + I18N_Remake_Failed + return 1 +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" +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" +if [ $? -ne 0 ]; then + return 1 +fi + + +I18N_Newline + + + + +# prepare for parallel package +__log_directory="${PROJECT_PATH_ROOT}/${PROJECT_PATH_LOG}/packagers" +I18N_Remake "$__log_directory" +FS_Remake_Directory "$__log_directory" +FS_Is_Directory "$__log_directory" +if [ $? -ne 0 ]; then + I18N_Remake_Failed + return 1 +fi + +__control_directory="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-parallel" +I18N_Remake "${__control_directory}" +FS_Remake_Directory "$__control_directory" +FS_Is_Directory "$__control_directory" +if [ $? -ne 0 ]; then + I18N_Remake_Failed + return 1 +fi + +__parallel_control="${__control_directory}/control-parallel.txt" +FS_Remove_Silently "$__parallel_control" + +__serial_control="${__control_directory}/control-serial.txt" +FS_Remove_Silently "$__serial_control" + + +SUBROUTINE_Package() { + #__line="$1" + + + # parse input + __command="${1##*|}" + __arguments="${1%|*}" + + __log="${__arguments##*|}" + __arguments="${__arguments%|*}|" + + __subject="${__log##*/}" + __subject="${__subject%.*}" + + + # execute + I18N_Package "$__subject" + FS_Remove_Silently "$__log" + + $__command "$__arguments" &> "$__log" + if [ $? -ne 0 ]; then + I18N_Package_Failed + return 1 + fi + + + # report status + return 0 +} + + + + +# begin registering packagers +FS_Is_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}" +if [ $? -eq 0 ]; then +for i in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}"/*; do + FS_Is_File "$i" + if [ $? -ne 0 ]; then + continue + fi + + + # parse build candidate + I18N_Detected "$i" + TARGET_FILENAME="${i##*${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD}/}" + TARGET_FILENAME="${TARGET_FILENAME%.*}" + TARGET_OS="${TARGET_FILENAME##*_}" + TARGET_FILENAME="${TARGET_FILENAME%%_*}" + TARGET_ARCH="${TARGET_ARCH##*-}" + TARGET_ARCH="${TARGET_ARCH%%.*}" + TARGET_OS="${TARGET_OS%%-*}" + TARGET_OS="${TARGET_OS%%.*}" + + if [ "$(STRINGS_Is_Empty "$TARGET_OS")" -eq 0 ] || + [ "$(STRINGS_Is_Empty "$TARGET_ARCH")" -eq 0 ] || + [ "$(STRINGS_Is_Empty "$TARGET_FILENAME")" -eq 0 ]; then + I18N_File_Has_Bad_Stat_Skipped + continue + fi + + STRINGS_Has_Prefix "$PROJECT_SKU" "$TARGET_FILENAME" + if [ $? -ne 0 ]; then + STRINGS_Has_Prefix "lib${PROJECT_SKU}" "$TARGET_FILENAME" + if [ $? -ne 0 ]; then + I18N_Is_Incompatible_Skipped "$TARGET_FILENAME" + continue + 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" "\ +${__common}|${__log}|PACKAGE_Run_ARCHIVE +" + if [ $? -ne 0 ]; then + return 1 + fi + + __log="${__log_directory}/cargo_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_CARGO +" + if [ $? -ne 0 ]; then + return 1 + fi + + __log="${__log_directory}/chocolatey_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_CHOCOLATEY +" + if [ $? -ne 0 ]; then + return 1 + fi + + __log="${__log_directory}/deb_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + FS_Append_File "$__parallel_control" "\ +${__common}|${FILE_CHANGELOG_DEB}|${__log}|PACKAGE_Run_DEB +" + if [ $? -ne 0 ]; then + return 1 + fi + + __log="${__log_directory}/docker_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + FS_Append_File "$__serial_control" "\ +${__common}|${__log}|PACKAGE_Run_DOCKER +" + if [ $? -ne 0 ]; then + return 1 + 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 +" + if [ $? -ne 0 ]; then + return 1 + fi + + __log="${__log_directory}/homebrew_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_HOMEBREW +" + if [ $? -ne 0 ]; then + return 1 + fi + + __log="${__log_directory}/ipk_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_IPK +" + if [ $? -ne 0 ]; then + return 1 + fi + + __log="${__log_directory}/msi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + FS_Append_File "$__serial_control" "\ +${__common}|${__log}|PACKAGE_Run_MSI +" + if [ $? -ne 0 ]; then + return 1 + fi + + __log="${__log_directory}/pdf_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_PDF +" + if [ $? -ne 0 ]; then + return 1 + fi + + __log="${__log_directory}/pypi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_PYPI +" + if [ $? -ne 0 ]; then + return 1 + fi + + __log="${__log_directory}/rpm_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_RPM +" + if [ $? -ne 0 ]; then + return 1 + fi +done +fi + + +I18N_Sync_Run +FS_Is_File "$__parallel_control" +if [ $? -eq 0 ]; then + SYNC_Exec_Parallel "SUBROUTINE_Package" "$__parallel_control" + if [ $? -ne 0 ]; then + I18N_Sync_Failed + return 1 + fi +fi + + +I18N_Sync_Run_Series +FS_Is_File "$__serial_control" +if [ $? -eq 0 ]; then + SYNC_Exec_Serial "SUBROUTINE_Package" "$__serial_control" + if [ $? -ne 0 ]; then + I18N_Sync_Failed + return 1 + fi +fi + + + + +# report status +I18N_Run_Successful +return 0 diff --git a/automataCI/package_windows-any.ps1 b/automataCI/package_windows-any.ps1 new file mode 100644 index 0000000..cc2f523 --- /dev/null +++ b/automataCI/package_windows-any.ps1 @@ -0,0 +1,328 @@ +# 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 me from automataCI\ci.sh.ps1 instead!`n" + return 1 +} + +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\sync.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + +. "${env:LIBS_AUTOMATACI}\_package-changelog_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_package-citation_windows-any.ps1" + + + + +# 1-time setup job required materials +$DEST = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}" +$null = I18N-Remake "${DEST}" +$___process = FS-Remake-Directory "${DEST}" +if ($___process -ne 0) { + $null = I18N-Remake-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" +$___process = Package-Run-CHANGELOG "$FILE_CHANGELOG_MD" "$FILE_CHANGELOG_DEB" +if ($___process -ne 0) { + return 1 +} + + +$FILE_CITATION_CFF = "${env:PROJECT_SKU}-CITATION_${env:PROJECT_VERSION}.cff" +$FILE_CITATION_CFF = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\${FILE_CITATION_CFF}" +$___process = Package-Run-CITATION "$FILE_CITATION_CFF" +if ($___process -ne 0) { + return 1 +} + + +$null = I18N-Newline + + + + +# prepare for parallel package +$__log_directory = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_LOG}\packagers" +$null = I18N-Remake "${__log_directory}" +$null = FS-Remake-Directory "${__log_directory}" +$___process = FS-Is-Directory "${__log_directory}" +if ($___process -ne 0) { + $null = I18N-Remake-Failed + return 1 +} + + +$__control_directory = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-parallel" +$null = I18N-Remake "${__control_directory}" +$null = FS-Remake-Directory "${__control_directory}" +$___process = FS-Is-Directory "${__control_directory}" +if ($___process -ne 0) { + $null = I18N-Remake-Failed + return 1 +} + + +$__parallel_control = "${__control_directory}\control-parallel.txt" +$null = FS-Remove-Silently "${__parallel_control}" + + +$__serial_control = "${__control_directory}\control-serial.txt" +$null = FS-Remove-Silently "${__serial_control}" + + +function SUBROUTINE-Package { + param( + [string]$__line + ) + + + # initialize libraries from scratch + $null = . "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" + $null = . "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" + $null = . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + + $null = . "${env:LIBS_AUTOMATACI}\_package-archive_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-cargo_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-changelog_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-chocolatey_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-deb_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-docker_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-flatpak_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-homebrew_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-ipk_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-msi_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-pdf_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-pypi_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-rpm_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-sourcing_windows-any.ps1" + + + # parse input + $__command = $__line.Split("|")[-1] + $__log = $__line.Split("|")[-2] + $__arguments = $__line.Split("|") + $__arguments = $__arguments[0..$($__arguments.Length - 3)] + $__arguments = $__arguments -Join "|" + + $__subject = Split-Path -Leaf -Path "${__log}" + $__subject = FS-Extension-Remove "${__subject}" "*" + + + # execute + $null = I18N-Package "${__subject}" + $null = FS-Remove-Silently "${__log}" + + try { + ${function:SUBROUTINE-Exec} = Get-Command ` + "${__command}" ` + -ErrorAction SilentlyContinue + $($___process = SUBROUTINE-Exec "${__arguments}") *> "${__log}" + } catch { + $___process = 1 + } + if ($___process -ne 0) { + $null = I18N-Package-Failed + return 1 + } + + + # report status + return 0 +} + + + + +# 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" + if ($___process -ne 0) { + continue + } + + + # parse build candidate + $null = I18N-Detected "${file}" + $TARGET_FILENAME = Split-Path -Leaf $file + $TARGET_FILENAME = $TARGET_FILENAME -replace "\..*$" + $TARGET_OS = $TARGET_FILENAME -replace ".*_" + $TARGET_FILENAME = $TARGET_FILENAME -replace "_.*" + $TARGET_ARCH = $TARGET_ARCH -replace ".*-" + $TARGET_ARCH = $TARGET_ARCH -replace "\..*$" + $TARGET_OS = $TARGET_OS -replace "-.*" + $TARGET_OS = $TARGET_OS -replace "\..*$" + + if (($(STRINGS-Is-Empty "${TARGET_OS}") -eq 0) -or + ($(STRINGS-Is-Empty "${TARGET_ARCH}") -eq 0) -or + ($(STRINGS-Is-Empty "${TARGET_FILENAME}") -eq 0)) { + $null = I18N-File-Has-Bad-Stat-Skipped + continue + } + + $___process = STRINGS-Has-Prefix "${env:PROJECT_SKU}" "${TARGET_FILENAME}" + if ($___process -ne 0) { + $___process = STRINGS-Has-Prefix "lib${env:PROJECT_SKU}" "${TARGET_FILENAME}" + if ($___process -ne 0) { + $null = I18N-Is-Incompatible-Skipped "${TARGET_FILENAME}" + continue + } + } + + $null = I18N-Sync-Register "$file" + $__common = "${DEST}|${file}|${TARGET_FILENAME}|${TARGET_OS}|${TARGET_ARCH}" + + $__log = "${__log_directory}\archive_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-ARCHIVE +"@ + if ($___process -ne 0) { + return 1 + } + + $__log = "${__log_directory}\cargo_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-CARGO +"@ + if ($___process -ne 0) { + return 1 + } + + $__log = "${__log_directory}\chocolatey_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-CHOCOLATEY +"@ + if ($___process -ne 0) { + return 1 + } + + $__log = "${__log_directory}\deb_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${FILE_CHANGELOG_DEB}|${__log}|PACKAGE-Run-DEB +"@ + if ($___process -ne 0) { + return 1 + } + + $__log = "${__log_directory}\docker_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $___process = FS-Append-File "${__serial_control}" @" +${__common}|${__log}|PACKAGE-Run-DOCKER +"@ + if ($___process -ne 0) { + return 1 + } + + $__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 +"@ + if ($___process -ne 0) { + return 1 + } + + $__log = "${__log_directory}\homebrew_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-HOMEBREW +"@ + if ($___process -ne 0) { + return 1 + } + + $__log = "${__log_directory}\ipk_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-IPK +"@ + if ($___process -ne 0) { + return 1 + } + + $__log = "${__log_directory}\msi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $___process = FS-Append-File "${__serial_control}" @" +${__common}|${__log}|PACKAGE-Run-MSI +"@ + if ($___process -ne 0) { + return 1 + } + + $__log = "${__log_directory}\PDF_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-PDF +"@ + if ($___process -ne 0) { + return 1 + } + + $__log = "${__log_directory}\pypi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-PYPI +"@ + if ($___process -ne 0) { + return 1 + } + + $__log = "${__log_directory}\rpm_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-RPM +"@ + if ($___process -ne 0) { + return 1 + } +} +} + + +$null = I18N-Sync-Run +$___process = FS-Is-File "${__parallel_control}" +if ($___process -eq 0) { + $___process = SYNC-Exec-Parallel ` + ${function:SUBROUTINE-Package}.ToString() ` + "${__parallel_control}" ` + "${__control_directory}" + if ($___process -ne 0) { + $null = I18N-Sync-Failed + return 1 + } +} + + +$null = I18N-Sync-Run-Series +$___process = FS-Is-File "${__serial_control}" +if ($___process -eq 0) { + $___process = SYNC-Exec-Serial ` + ${function:SUBROUTINE-Package}.ToString() ` + "${__serial_control}" + if ($___process -ne 0) { + $null = I18N-Sync-Failed + return 1 + } +} + + + + +# report status +$null = I18N-Run-Successful +return 0 diff --git a/automataCI/purge_unix-any.sh b/automataCI/purge_unix-any.sh new file mode 100644 index 0000000..21117e1 --- /dev/null +++ b/automataCI/purge_unix-any.sh @@ -0,0 +1,67 @@ +#!/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" + + + + +# execute tech specific CI jobs if available +old_IFS="$IFS" +printf -- "%s" "\ +${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_BUILD} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_BIN} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_DOCS} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_LIB} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_LOG} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE} +${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS} +" | while IFS="" read -r __line || [ -n "$__line" ]; do + if [ "$__line" = "${PROJECT_PATH_ROOT}" ]; then + continue + fi + + if [ "$__line" = "${PROJECT_PATH_ROOT}/" ]; then + continue + fi + + + I18N_Purge "$__line" + FS_Remove_Silently "$__line" +done + + + + +# clean archive artifacts +cd "$PROJECT_PATH_ROOT" +rm artifact-*.* &> /dev/null + + + + +# report status +I18N_Run_Successful +return 0 diff --git a/automataCI/purge_windows-any.ps1 b/automataCI/purge_windows-any.ps1 new file mode 100644 index 0000000..7c25b68 --- /dev/null +++ b/automataCI/purge_windows-any.ps1 @@ -0,0 +1,64 @@ +# 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" + + + + +# execute tech specific CI jobs if available +foreach ($__target in @( + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BIN}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_DOCS}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_LIB}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_LOG}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}" +)) { + if ("${__target}" -eq ${env:PROJECT_PATH_ROOT}) { + continue + } + + if ("${__target}" -eq "${env:PROJECT_PATH_ROOT}/") { + continue + } + + $null = I18N-Purge "${__target}" + $null = FS-Remove-Silently "${__target}" +} + + + + +# clean archive artifacts +$null = Set-Location -Path "${PROJECT_PATH_ROOT}" +$null = Remove-Item -Path "artifact-*.*" -ErrorAction SilentlyContinue + + + + +# report status +$null = I18N-Run-Successful +return 0 diff --git a/automataCI/release_unix-any.sh b/automataCI/release_unix-any.sh new file mode 100644 index 0000000..23becfe --- /dev/null +++ b/automataCI/release_unix-any.sh @@ -0,0 +1,200 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + +. "${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-homebrew_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-pypi_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-rpm_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-staticrepo_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-docsrepo_unix-any.sh" + + + + +# execute +RELEASE_Initiate_CHECKSUM +if [ $? -ne 0 ]; then + return 1 +fi + + +__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}" + . "$__recipe" + if [ $? -ne 0 ]; then + I18N_Parse_Failed + return 1 + fi +fi + + +OS_Is_Command_Available "RELEASE_Run_Pre_Processor" +if [ $? -eq 0 ]; then + RELEASE_Run_Pre_Processor + if [ $? -ne 0 ]; then + return 1 + fi +fi + + +RELEASE_Setup_STATIC_REPO +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Setup_HOMEBREW +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Setup_CHOCOLATEY +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 + if [ "${TARGET%.asc*}" != "$TARGET" ]; then + continue + fi + I18N_Processing "$TARGET" + + RELEASE_Run_DEB "$TARGET" "$STATIC_REPO" + if [ $? -ne 0 ]; then + return 1 + fi + + RELEASE_Run_RPM "$TARGET" "$STATIC_REPO" + if [ $? -ne 0 ]; then + return 1 + fi + + RELEASE_Run_DOCKER "$TARGET" + if [ $? -ne 0 ]; then + return 1 + fi + + RELEASE_Run_PYPI "$TARGET" + if [ $? -ne 0 ]; then + return 1 + fi + + RELEASE_Run_CARGO "$TARGET" + if [ $? -ne 0 ]; then + return 1 + fi + + RELEASE_Run_CITATION_CFF "$TARGET" + if [ $? -ne 0 ]; then + return 1 + fi + + RELEASE_Run_HOMEBREW "$TARGET" "$HOMEBREW_REPO" + if [ $? -ne 0 ]; then + return 1 + fi + + RELEASE_Run_CHOCOLATEY "$TARGET" "$CHOCOLATEY_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" + if [ $? -ne 0 ]; then + return 1 + fi + fi +done + + +RELEASE_Run_CHECKSUM "$STATIC_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + +OS_Is_Command_Available "RELEASE_Run_Post_Processor" +if [ $? -eq 0 ]; then + RELEASE_Run_Post_Processor + if [ $? -ne 0 ]; then + return 1 + fi +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 + + RELEASE_Conclude_CHANGELOG + if [ $? -ne 0 ]; then + return 1 + fi + + RELEASE_Conclude_DOCS + if [ $? -ne 0 ]; then + return 1 + fi +fi + + + + +# report status +I18N_Run_Successful +return 0 diff --git a/automataCI/release_windows-any.ps1 b/automataCI/release_windows-any.ps1 new file mode 100644 index 0000000..862d26b --- /dev/null +++ b/automataCI/release_windows-any.ps1 @@ -0,0 +1,204 @@ +# 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\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + +. "${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-docker_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-homebrew_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-pypi_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" + + + + +# execute +$___process = RELEASE-Initiate-CHECKSUM +if ($___process -ne 0) { + return 1 +} + + +$__recipe = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}" +$__recipe = "${__recipe}\release_windows-any.ps1" +$___process = FS-Is-File "${__recipe}" +if ($___process -eq 0) { + $null = I18N-Detected "${__recipe}" + $null = I18N-Parse "${__recipe}" + $___process = . "${__recipe}" + if ($___process -ne 0) { + $null = I18N-Parse-Failed + return 1 + } +} + + +$___process = OS-Is-Command-Available "RELEASE-Run-Pre-Processor" +if ($___process -eq 0) { + $___process = RELEASE-Run-Pre-Processor + if ($___process -ne 0) { + return 1 + } +} + + +$___process = RELEASE-Setup-STATIC-REPO +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Setup-HOMEBREW +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Setup-CHOCOLATEY +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-DEB "$TARGET" "$STATIC_REPO" + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Run-RPM "$TARGET" "$STATIC_REPO" ` + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Run-DOCKER "$TARGET" + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Run-PYPI "$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-HOMEBREW "$TARGET" "$HOMEBREW_REPO" + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Run-CHOCOLATEY "$TARGET" "$CHOCOLATEY_REPO" + if ($___process -ne 0) { + return 1 + } + + $___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-CHECKSUM "$STATIC_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 + } +} + + +if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Conclusion "STATIC REPO" + $null = I18N-Simulate-Conclusion "CHANGELOG" +} else { + $___process = RELEASE-Conclude-STATIC-REPO + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Conclude-HOMEBREW "$HOMEBREW_REPO" + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Conclude-CHOCOLATEY "$CHOCOLATEY_REPO" + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Conclude-CHANGELOG + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Conclude-DOCS + if ($___process -ne 0) { + return 1 + } +} + + + + +# report status +$null = I18N-Run-Successful +return 0 diff --git a/automataCI/services/ai/google.ps1 b/automataCI/services/ai/google.ps1 new file mode 100644 index 0000000..6c1a647 --- /dev/null +++ b/automataCI/services/ai/google.ps1 @@ -0,0 +1,88 @@ +# 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\strings.ps1" + + + + +function GOOGLEAI-Gemini-Query-Text-To-Text() { + param( + [string]$___query + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___query}") -eq 0) { + return 1 + } + + $___process = GOOGLEAI-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # configure + if ($(STRINGS-Is-Empty "${env:GOOGLEAI_BLOCK_HATE_SPEECH}") -eq 0) { + ${env:GOOGLEAI_BLOCK_HATE_SPEECH} = "BLOCK_NONE" + } + + if ($(STRINGS-Is-Empty "${GOOGLEAI_BLOCK_SEXUALLY_EXPLICIT}") -eq 0) { + ${GOOGLEAI_BLOCK_SEXUALLY_EXPLICIT} = "BLOCK_NONE" + } + + if ($(STRINGS-Is-Empty "${GOOGLEAI_BLOCK_DANGEROUS_CONTENT}") -eq 0) { + ${GOOGLEAI_BLOCK_DANGEROUS_CONTENT} = "BLOCK_NONE" + } + + if ($(STRINGS-Is-Empty "${env:GOOGLEAI_BLOCK_HARASSMENT}") -eq 0) { + ${env:GOOGLEAI_BLOCK_HARASSMENT} = "BLOCK_NONE" + } + + $___url = "${env:GOOGLEAI_API_URL}/${env:GOOGLEAI_API_VERSION}/${env:GOOGLEAI_MODEL}" + $___url = "${___url}:generateContent?key=${env:GOOGLEAI_API_TOKEN}" + + + # execute + return "$(curl.exe --progress-bar --header 'Content-Type: application/json' --data @" +{ + "contents" = [{ + "parts": [{ + "text": "${___query}" + }], + "role": "user" + }], + "safetySettings": [{ + "category": "HARM_CATEGORY_HATE_SPEECH", + "threshold": "${env:GOOGLEAI_BLOCK_HATE_SPEECH}" + }, { + "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", + "threshold": "${env:GOOGLEAI_BLOCK_SEXUALLY_EXPLICIT}" + }, { + "category": "HARM_CATEGORY_DANGEROUS_CONTENT", + "threshold": "${env:GOOGLEAI_BLOCK_DANGEROUS_CONTENT}" + }, { + "category": "HARM_CATEGORY_HARASSMENT", + "threshold": "${env:GOOGLEAI_BLOCK_HARASSMENT}" + }] +} +"@ ` + --request POST "$___url")" +} + + + + +function GOOGLEAI-Is-Available { + # report status + return 0 +} diff --git a/automataCI/services/ai/google.sh b/automataCI/services/ai/google.sh new file mode 100644 index 0000000..776fbaa --- /dev/null +++ b/automataCI/services/ai/google.sh @@ -0,0 +1,107 @@ +#!/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/strings.sh" +. "${LIBS_AUTOMATACI}/services/io/net/http.sh" + + + + +GOOGLEAI_Gemini_Query_Text_To_Text() { + #___query="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + GOOGLEAI_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # configure + if [ $(STRINGS_Is_Empty "$GOOGLEAI_BLOCK_HATE_SPEECH") -eq 0 ]; then + GOOGLEAI_BLOCK_HATE_SPEECH="BLOCK_NONE" + fi + + if [ $(STRINGS_Is_Empty "$GOOGLEAI_BLOCK_SEXUALLY_EXPLICIT") -eq 0 ]; then + GOOGLEAI_BLOCK_SEXUALLY_EXPLICIT="BLOCK_NONE" + fi + + if [ $(STRINGS_Is_Empty "$GOOGLEAI_BLOCK_DANGEROUS_CONTENT") -eq 0 ]; then + GOOGLEAI_BLOCK_DANGEROUS_CONTENT="BLOCK_NONE" + fi + + if [ $(STRINGS_Is_Empty "$GOOGLEAI_BLOCK_HARASSMENT") -eq 0 ]; then + GOOGLEAI_BLOCK_HARASSMENT="BLOCK_NONE" + fi + + ___url="${GOOGLEAI_API_URL}/${GOOGLEAI_API_VERSION}/${GOOGLEAI_MODEL}" + ___url="${___url}:generateContent?key=${GOOGLEAI_API_TOKEN}" + + + # execute + curl --progress-bar --header 'Content-Type: application/json' --data "{ + \"contents\": [{ + \"parts\":[{ + \"text\": \"${1}\" + }], + \"role\": \"user\" + }], + \"safetySettings\": [{ + \"category\": \"HARM_CATEGORY_HATE_SPEECH\", + \"threshold\": \"${GOOGLEAI_BLOCK_HATE_SPEECH}\" + }, { + \"category\": \"HARM_CATEGORY_SEXUALLY_EXPLICIT\", + \"threshold\": \"${GOOGLEAI_BLOCK_SEXUALLY_EXPLICIT}\" + }, { + \"category\": \"HARM_CATEGORY_DANGEROUS_CONTENT\", + \"threshold\": \"${GOOGLEAI_BLOCK_DANGEROUS_CONTENT}\" + }, { + \"category\": \"HARM_CATEGORY_HARASSMENT\", + \"threshold\": \"${GOOGLEAI_BLOCK_HARASSMENT}\" + }] +}" --request POST "$___url" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GOOGLEAI_Is_Available() { + # execute + HTTP_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$GOOGLEAI_API_URL") -eq 0 ] && + [ $(STRINGS_Is_Empty "$GOOGLEAI_API_VERSION") -eq 0 ] && + [ $(STRINGS_Is_Empty "$GOOGLEAI_MODEL") -eq 0 ] && + [ $(STRINGS_Is_Empty "$GOOGLEAI_API_TOKEN") -eq 0 ] && + [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/archive/ar.ps1 b/automataCI/services/archive/ar.ps1 new file mode 100644 index 0000000..e68f238 --- /dev/null +++ b/automataCI/services/archive/ar.ps1 @@ -0,0 +1,61 @@ +# 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" + + + + +function AR-Is-Available { + # execute + $___process = OS-Is-Command-Available "ar" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function AR-Create { + param ( + [string]$___name, + [string]$___list + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___name}") -eq 0) -or + ($(STRINGS-Is-Empty "${___list}") -eq 0)) { + return 1 + } + + $___process = AR-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "ar" "cr ${___name} ${___list}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/archive/ar.sh b/automataCI/services/archive/ar.sh new file mode 100644 index 0000000..70a1bf7 --- /dev/null +++ b/automataCI/services/archive/ar.sh @@ -0,0 +1,60 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +AR_Is_Available() { + # execute + OS_Is_Command_Available "ar" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +AR_Create() { + #___name="$1" + #___list="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || + [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + AR_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ar cr "$1" $2 + 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 new file mode 100644 index 0000000..bb0e0a8 --- /dev/null +++ b/automataCI/services/archive/tar.ps1 @@ -0,0 +1,186 @@ +# 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\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\compress\gz.ps1" +. "${env:LIBS_AUTOMATACI}\services\compress\xz.ps1" + + + + +function TAR-Is-Available { + # validate input + $___process = OS-Is-Command-Available "tar" + if ($___process -ne 0) { + return 1 + } + + + # execute + return 0 +} + + + + +function TAR-Create { + param ( + [string]$___destination, + [string]$___source, + [string]$___owner, + [string]$___group + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___destination}") -eq 0) -or + ($(STRINGS-Is-Empty "${___source}") -eq 0)) { + return 1 + } + + $___process = FS-Is-File "${___destination}" + if ($___process -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___destination}" + if ($___process -eq 0) { + return 1 + } + + $___process = TAR-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # create tar archive + $___supported = $false # windows' TAR system does not support UNIX UGID system + if (($___supported) -and + ($(STRINGS-Is-Empty "${___owner}") -ne 0) -and + ($(STRINGS-Is-Empty "${___group}") -ne 0)) { + $___arguments = "--numeric-owner --group=`"${___group}`" " ` + + "--owner=`"${___owner}`" " ` + + "-cvf `"${___destination}`" ${___source}" + $___process = OS-Exec "tar" "${___arguments}" + if ($___process -ne 0) { + return 1 + } + } else { + $___process = OS-Exec "tar" "-cvf `"${___destination}`" ${___source}" + if ($___process -ne 0) { + return 1 + } + } + + + # report status + return 0 +} + + + + +function TAR-Create-GZ { + param ( + [string]$___destination, + [string]$___source, + [string]$___owner, + [string]$___group + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___destination}") -eq 0) -or + ($(STRINGS-Is-Empty "${___source}") -eq 0)) { + return 1 + } + + $___process = FS-Is-File "${___destination}" + if ($___process -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___destination}" + if ($___process -eq 0) { + return 1 + } + + + # create tar archive + $___dest = $___destination -replace '\.gz.*$' + $___process = TAR-Create "${___dest}" "${___source}" "${___owner}" "${___group}" + if ($___process -ne 0) { + return 1 + } + + $___process = GZ-Create "${___dest}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function TAR-Create-XZ { + param ( + [string]$___destination, + [string]$___source, + [string]$___owner, + [string]$___group + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___destination}") -eq 0) -or + ($(STRINGS-Is-Empty "${___source}") -eq 0)) { + return 1 + } + + $___process = FS-Is-File "${___destination}" + if ($___process -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___destination}" + if ($___process -eq 0) { + return 1 + } + + $___process = XZ-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # create tar archive + $___destination = $___destination -replace '\.xz.*$' + $___process = TAR-Create "${___destination}" "${___source}" "${___owner}" "${___group}" + if ($___process -ne 0) { + return 1 + } + + $___process = XZ-Create "${___destination}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/archive/tar.sh b/automataCI/services/archive/tar.sh new file mode 100644 index 0000000..5a8ab13 --- /dev/null +++ b/automataCI/services/archive/tar.sh @@ -0,0 +1,174 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/compress/gz.sh" +. "${LIBS_AUTOMATACI}/services/compress/xz.sh" + + + + +TAR_Is_Available() { + # execute + OS_Is_Command_Available "tar" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +TAR_Create() { + #___destination="$1" + #___source="$2" + #___owner="$3" + #___group="$4" + + + # validate input + if [ $(STRINGS_Is_Empty "$2") -eq 0 ] || [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$1" + if [ $? -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -eq 0 ]; then + return 1 + fi + + TAR_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # create tar archive + if [ $(STRINGS_Is_Empty "$3") -ne 0 ] && [ $(STRINGS_Is_Empty "$4") -ne 0 ]; then + tar --numeric-owner --group="$4" --owner="$3" -cvf "$1" $2 + if [ $? -ne 0 ]; then + return 1 + fi + else + tar -cvf "$1" $2 + if [ $? -ne 0 ]; then + return 1 + fi + fi + + + # report status + return 0 +} + + + + +TAR_Create_GZ() { + #___destination="$1" + #___source="$2" + #___owner="$3" + #___group="$4" + + + # validate input + if [ $(STRINGS_Is_Empty "$2") -eq 0 ] || [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$1" + if [ $? -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -eq 0 ]; then + return 1 + fi + + + # create tar archive + TAR_Create "${1%.gz*}" "$2" "$3" "$4" + if [ $? -ne 0 ]; then + return 1 + fi + + + # compress archive + GZ_Create "${1%.gz*}" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +TAR_Create_XZ() { + #___destination="$1" + #___source="$2" + #___owner="$3" + #___group="$4" + + + # validate input + if [ $(STRINGS_Is_Empty "$2") -eq 0 ] || [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$1" + if [ $? -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -eq 0 ]; then + return 1 + fi + + XZ_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # create tar archive + TAR_Create "${1%.xz*}" "$2" "$3" "$4" + if [ $? -ne 0 ]; then + return 1 + fi + + + # compress archive + XZ_Create "${1%%.xz*}" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/archive/zip.ps1 b/automataCI/services/archive/zip.ps1 new file mode 100644 index 0000000..2dde8d6 --- /dev/null +++ b/automataCI/services/archive/zip.ps1 @@ -0,0 +1,83 @@ +# 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" + + + + +function ZIP-Create { + param ( + [string]$___destination, + [string]$___source + ) + + + # execute + try { + $null = Compress-Archive -Update ` + -DestinationPath $___destination ` + -Path $___source + $___process = FS-Is-File "${___destination}" + if ($___process -eq 0) { + return 0 + } + } catch { + return 1 + } + + + # report status + return 1 +} + + + + +function ZIP-Extract { + param ( + [string]$___destination, + [string]$___source + ) + + + # validate input + $___process = FS-Is-File "${___source}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___destination}" + if ($___process -eq 0) { + return 1 + } + + + # execute + try { + $null = FS-Make-Directory "${___destination}" + $null = Expand-Archive -Path $___source -DestinationPath $___destination + } catch { + return 1 + } + + + # report status + return 0 +} + + + + +function ZIP-Is-Available { + # report status + return 0 +} diff --git a/automataCI/services/archive/zip.sh b/automataCI/services/archive/zip.sh new file mode 100644 index 0000000..905a312 --- /dev/null +++ b/automataCI/services/archive/zip.sh @@ -0,0 +1,92 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" + + + + +ZIP_Create() { + #___destination="$1" + #___source="$2" + + + # validate input + ZIP_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + zip -9 -r "$1" $2 + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +ZIP_Extract() { + ___destination="$1" + ___source="$2" + + + # validate input + OS_Is_Command_Available "unzip" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "$___source" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "$___destination" + if [ $? -eq 0 ]; then + return 1 + fi + + + # extract + FS_Make_Directory "$___destination" + unzip "$___source" -d "$___destination" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +ZIP_Is_Available() { + # execute + OS_Is_Command_Available "zip" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} diff --git a/automataCI/services/checksum/md5.ps1 b/automataCI/services/checksum/md5.ps1 new file mode 100644 index 0000000..af80db2 --- /dev/null +++ b/automataCI/services/checksum/md5.ps1 @@ -0,0 +1,59 @@ +# 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" + + + + +function MD5-Checksum-From-File { + param ( + [string]$___target + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___hasher = [System.Security.Cryptography.MD5]::Create("MD5") + $___stream = [System.IO.File]::OpenRead($___target) + $___hash = [System.BitConverter]::ToString($___hasher.ComputeHash($___stream)) + $null = $___stream.Close() + + + # report status + return $___hash.Replace("-", "").ToLower() +} + + + + +function MD5-Is-Available { + # execute + $___md5 = [System.Security.Cryptography.MD5]::Create("MD5") + if ($___md5) { + return 0 + } + + + # report status + return 1 +} diff --git a/automataCI/services/checksum/md5.sh b/automataCI/services/checksum/md5.sh new file mode 100644 index 0000000..1f74263 --- /dev/null +++ b/automataCI/services/checksum/md5.sh @@ -0,0 +1,79 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +MD5_Checksum_From_File() { + #___target="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + OS_Is_Command_Available "md5sum" + if [ $? -eq 0 ]; then + md5sum "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + return 0 + fi + + OS_Is_Command_Available "md5" + if [ $? -eq 0 ]; then + md5 "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + return 0 + fi + + + # report status + return 1 +} + + + + +MD5_Is_Available() { + # execute + OS_Is_Command_Available "md5sum" + if [ $? -eq 0 ]; then + return 0 + fi + + OS_Is_Command_Available "md5" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} diff --git a/automataCI/services/checksum/shasum.ps1 b/automataCI/services/checksum/shasum.ps1 new file mode 100644 index 0000000..2b7f795 --- /dev/null +++ b/automataCI/services/checksum/shasum.ps1 @@ -0,0 +1,90 @@ +# 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" + + + + +function SHASUM-Checksum-From-File { + param ( + [string]$___target, + [string]$___algo + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___algo}") -eq 0)) { + return "" + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return "" + } + + + # execute + switch ($___algo) { + '1' { + $___hasher = New-Object System.Security.Cryptography.SHA1CryptoServiceProvider + } '224' { + return "" + } '256' { + $___hasher = New-Object System.Security.Cryptography.SHA256CryptoServiceProvider + } '384' { + $___hasher = New-Object System.Security.Cryptography.SHA384CryptoServiceProvider + } '512' { + $___hasher = New-Object System.Security.Cryptography.SHA512CryptoServiceProvider + } '512224' { + return "" + } '512256' { + return "" + } Default { + return "" + }} + + $___fileStream = [System.IO.File]::OpenRead($___target) + $___hash = $___hasher.ComputeHash($___fileStream) + return [System.BitConverter]::ToString($___hash).Replace("-", "").ToLower() +} + + + + +function SHASUM-Is-Available { + # execute + $___ret = [System.Security.Cryptography.SHA1]::Create("SHA1") + if (-not $___ret) { + return 1 + } + + $___ret = [System.Security.Cryptography.SHA256]::Create("SHA256") + if (-not $___ret) { + return 1 + } + + $___ret = [System.Security.Cryptography.SHA384]::Create("SHA384") + if (-not $___ret) { + return 1 + } + + $___ret = [System.Security.Cryptography.SHA512]::Create("SHA512") + if (-not $___ret) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/checksum/shasum.sh b/automataCI/services/checksum/shasum.sh new file mode 100644 index 0000000..b699f22 --- /dev/null +++ b/automataCI/services/checksum/shasum.sh @@ -0,0 +1,74 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +SHASUM_Create_From_File() { + #___target="$1" + #___algo="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + case "$2" in + 1|224|256|384|512|512224|512256) + ;; + *) + return 1 + ;; + esac + + + # execute + OS_Is_Command_Available "shasum" + if [ $? -eq 0 ]; then + ___ret="$(shasum -a "$2" "$1")" + if [ -z "$___ret" ]; then + return 1 + fi + + printf "${___ret%% *}" + unset ___ret + fi + + + # report status + return 0 +} + + + + +SHASUM_Is_Available() { + # execute + OS_Is_Command_Available "shasum" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} diff --git a/automataCI/services/compilers/angular.ps1 b/automataCI/services/compilers/angular.ps1 new file mode 100644 index 0000000..5f508e1 --- /dev/null +++ b/automataCI/services/compilers/angular.ps1 @@ -0,0 +1,114 @@ +# 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" + + + + +function ANGULAR-Build { + # validate input + $___process = ANGULAR-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $null = OS-Sync + # WARNING: DO NOT CHANGE - ng is not a win32 exe so OS-Exec will + # fail so bad. Leave this as it is. + $null = Invoke-Expression "ng build" + if ($?) { + return 0 + } + + + # return status + return 1 +} + + + + +function ANGULAR-Is-Available { + # execute + $null = OS-Sync + + $___process = OS-Is-Command-Available "npm" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Is-Command-Available "ng" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function ANGULAR-Setup { + # validate input + $null = OS-Sync + + $___process = ANGULAR-Is-Available + if ($___process -eq 0) { + return 0 + } + + $___process = OS-Is-Command-Available "npm" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "npm" "install -g @angular/cli" + if ($___process -ne 0) { + return 1 + } + $null = OS-Sync + + + # report status + return 0 +} + + + + +function ANGULAR-Test { + # validate input + $___process = ANGULAR-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $null = OS-Sync + # WARNING: DO NOT CHANGE - ng is not a win32 exe so OS-Exec will + # fail so bad. Leave this as it is. + $null = Invoke-Expression "ng test --no-watch --code-coverage" + if ($?) { + return 0 + } + + + # return status + return 1 +} diff --git a/automataCI/services/compilers/angular.sh b/automataCI/services/compilers/angular.sh new file mode 100644 index 0000000..6c10dee --- /dev/null +++ b/automataCI/services/compilers/angular.sh @@ -0,0 +1,104 @@ +#!/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/os.sh" + + + + +ANGULAR_Build() { + # validate input + ANGULAR_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ng build + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +ANGULAR_Is_Available() { + # execute + OS_Is_Command_Available "npm" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "ng" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +ANGULAR_Setup() { + # validate input + ANGULAR_Is_Available + if [ $? -eq 0 ]; then + return 0 + fi + + OS_Is_Command_Available "npm" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + npm install -g @angular/cli + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +ANGULAR_Test() { + # validate input + ANGULAR_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ng test --no-watch --code-coverage + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/appimage.ps1 b/automataCI/services/compilers/appimage.ps1 new file mode 100644 index 0000000..d202b23 --- /dev/null +++ b/automataCI/services/compilers/appimage.ps1 @@ -0,0 +1,114 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" + + + + +function APPIMAGE-Is-Available { + return 0 # Unsupported - requires linux kernel libfuse2 +} + + + + +function APPIMAGE-Setup { + return 0 # Unsupported - requires linux kernel libfuse2 +} + + + + +function APPIMAGE-Unpack { + param( + [string]$___dest, + [string]$___dir_install, + [string]$___image + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___dest}") -eq 0) -or + ($(STRINGS-Is-Empty "${___dir_install}") -eq 0) -or + ($(STRINGS-Is-Empty "${___image}") -eq 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_PATH_TEMP}") -eq 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_PATH_ROOT}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___dest}" + if ($___process -eq 0) { + return 1 + } + + $___process = FS-Is-File "${___dir_install}" + if ($___process -eq 0) { + return 1 + } + + $___process = FS-Is-File "${___image}" + if ($___process -ne 0) { + return 1 + } + + + # setup a temporary directory + $___mnt = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\mnt-appimage-$(FS-Get-File "${___dest}")" + $null = FS-Remake-Directory "${___mnt}" + + try { + $___diskImage = Mount-DiskImage -ImagePath $___image -PassThru + $___diskVolume = Get-Volume -DiskImage $___diskImage -ErrorAction Stop + Add-PartitionAccessPath -DiskNumber $___diskVolume.DiskNumber ` + -PartitionNumber $___diskVolume.PartitionNumber ` + -AccessPath "${___mnt}" ` + -ErrorAction Stop + } catch { + return 1 + } + + $___process = FS-Copy-All "${___mnt}\" "${___dir_install}" + if ($___process -ne 0) { + return 1 + } + + try { + $___partition = Get-Partition ` + | Where-Object { $_.AccessPaths -contains $___mnt } + if ($___partition -eq $null) { + return 1 + } + + Remove-PartitionAccessPath -DiskNumber $___partition.DiskNumber ` + -PartitionNumber $___partition.PartitionNumber ` + -AccessPath $___mnt -ErrorAction Stop + } catch { + return 1 + } + + $null = FS-Remove-Silently "${___mnt}" + + + # symlink to dest + try { + New-Item -ItemType SymbolicLink ` + -Path $___dest ` + -Target "${___dir_install}\AppRun" + } catch { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/appimage.sh b/automataCI/services/compilers/appimage.sh new file mode 100644 index 0000000..5a52717 --- /dev/null +++ b/automataCI/services/compilers/appimage.sh @@ -0,0 +1,132 @@ +#!/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" + + + + +APPIMAGE_Is_Available() { + # validate input + case "$(OS_Get)" in + darwin) + return 0 # not applicable - requires linux kernel libfuse2 + ;; + windows) + return 0 # not applicable - requires linux kernel libfuse2 + ;; + *) + # Other UNIX systems (e.g. Linux) + ;; + esac + + + # execute + OS_Is_Command_Available "fusermount" + if [ $? -eq 0 ]; then + fusermount -V &> /dev/null + if [ $? -eq 0 ]; then + return 0 + fi + fi + + + # report status + return 1 +} + + + + +APPIMAGE_Setup() { + # validate input + APPIMAGE_Is_Available + if [ $? -eq 0 ]; then + return 0 + fi + + + # execute + ## TODO: setup APPIMAGE packager + + + # report status + return 0 +} + + + + +APPIMAGE_Unpack() { + #___dest="$1" + #___dir_install="$2" + #___image="$3" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || + [ $(STRINGS_Is_Empty "$2") -eq 0 ] || + [ $(STRINGS_Is_Empty "$3") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_PATH_TEMP") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_PATH_ROOT") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -eq 0 ]; then + return 1 + fi + + FS_Is_File "$2" + if [ $? -eq 0 ]; then + return 1 + fi + + FS_Is_File "$3" + if [ $? -ne 0 ]; then + return 1 + fi + + + # setup a temporary directory + ___mnt="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/mnt-appimage-$(FS_Get_File "$1")" + FS_Remake_Directory "$___mnt" + su root --preserve-environment --command "mount -o loop '$3' '$___mnt'" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Copy_All "${___mnt}/" "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + su root --preserve-environment --command "umount '$___mnt'" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Remove_Silently "$___mnt" + + + # symlink to dest + ln -s "${2}/AppRun" "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/c.ps1 b/automataCI/services/compilers/c.ps1 new file mode 100644 index 0000000..5f8ce6a --- /dev/null +++ b/automataCI/services/compilers/c.ps1 @@ -0,0 +1,915 @@ +# 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\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\sync.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\ar.ps1" + + + + +function C-Build { + param( + [string]$___file_output, + [string]$___list_sources, + [string]$___output_type, + [string]$___target_os, + [string]$___target_arch, + [string]$___directory_workspace, + [string]$___directory_log, + [string]$___compiler, + [string]$___arguments + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___file_output}") -eq 0) -or + ($(STRINGS-Is-Empty "${___list_sources}") -eq 0) -or + ($(STRINGS-Is-Empty "${___output_type}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target_os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target_arch}") -eq 0) -or + ($(STRINGS-Is-Empty "${___directory_workspace}") -eq 0) -or + ($(STRINGS-Is-Empty "${___directory_log}") -eq 0) -or + ($(STRINGS-Is-Empty "${___compiler}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arguments}") -eq 0)) { + return 1 + } + + $___process = FS-Is-File "${___list_sources}" + if ($___process -ne 0) { + return 1 + } + + $___directory_source = "$(FS-Get-Directory "${___list_sources}")" + $___process = FS-Is-Directory "${___directory_source}" + if ($___process -ne 0) { + return 1 + } + + switch ("${___output_type}") { + { $_ -in "elf", "exe", "executable" } { + # accepted - build .elf|.exe file + } { $_ -in "lib", "dll", "library" } { + # accepted - build .a|.dll file + } "none" { + # accepted - build .o objects + } default { + return 1 + }} + + $___process = AR-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___build_list = "${___directory_workspace}\build-list.txt" + $___object_list = "${___directory_workspace}\object-list.txt" + $null = FS-Remake-Directory "${___directory_workspace}" + $null = FS-Remake-Directory "${___directory_log}" + $null = FS-Remove-Silently "${___build_list}" + $null = FS-Remove-Silently "${___object_list}" + + ## (1) Scan for all files + foreach ($__line in (Get-Content -Path "${___list_sources}")) { + $__line = $__line -replace '#.*$', '' + $__line = "$(STRINGS-Trim-Whitespace "${__line}")" + if ($(STRINGS-Is-Empty "${__line}") -eq 0) { + continue + } + $__line = $__line -replace '/', '\' + + $___platform = $__line -replace ' .*$', '' + $___file = $__line -replace '^.*\s', '' + $___file_src = "${___directory_source}\${___file}" + $___file_obj = "${___directory_workspace}\$(FS-Extension-Remove "${___file}" "*").o" + $___file_log = "${___directory_log}\$(FS-Extension-Remove "${___file}" "*")_build.log" + + + # check source code existence + $___process = FS-Is-File "${___file_src}" + if ($___process -ne 0) { + return 1 + } + + + # check source file compatibilities + $___os = $___platform -replace '-.*$', '' + $___arch = $___platform -replace '^.*-', '' + if ($(STRINGS-Is-Empty "${___platform}") -ne 0) { + # verify OS + if ($___os -ne "any") { + if ($___os -ne $___target_os) { + continue + } + } + + # verify ARCH + if ($___arch -ne "any") { + if ($___arch -ne $___target_arch) { + continue + } + } + } + $___os = "${___target_os}" + $___arch = "${___target_arch}" + + + # begin registrations + if ("$(FS-Extension-Remove "${___file_src}" ".c")" -ne "${___file_src}") { + # it's a .c file. Register for building and linking... + $___process = FS-Append-File "${___build_list}" @" +build|${___file_obj}|${___file_src}|${___file_log}|${___os}|${___arch}|${___compiler}|${___arguments} +"@ + if ($___process -ne 0) { + return 1 + } + + + $___process = FS-Append-File "${___object_list}" "${___file_obj}" + if ($___process -ne 0) { + return 1 + } + } elseif ("$(FS-Extension-Remove "${___file_src}" ".o")" -ne "${___file_src}") { + # it's a .o file. Register only for linking... + $null = FS-Make-Housing-Directory "${___file_obj}" + + $___process = FS-Copy-File "${___file_src}" "${___file_obj}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Append-File "${___object_list}" "${___file_obj}" + if ($___process -ne 0) { + return 1 + } + } else { + # it's an unknown file. Bail out... + return 1 + } + } + + ## (2) Bail early if object list is unavailable + $___process = FS-Is-File "${___object_list}" + if ($___process -ne 0) { + return 0 + } + + ## (3) Build all object files if found + $___process = FS-Is-File "${___build_list}" + if ($___process -eq 0) { + $___process = SYNC-Exec-Parallel ` + ${function:C-Run-Parallel}.ToString() ` + "${___build_list}" ` + "${___directory_workspace}" + if ($___process -ne 0) { + return 1 + } + } + + ## (4) Link all objects into the target + $null = FS-Remove-Silently "${___file_output}" + switch ("${___output_type}") { + { $_ -in "elf", "exe", "executable" } { + $___arguments = "" + foreach ($__line in (Get-Content -Path "${___object_list}")) { + $___arguments = "${___arguments} ${__line}" + } + + $___process = OS-Exec "${___compiler}" "-o ${___file_output} ${___arguments}" + if ($___process -ne 0) { + $null = FS-Remove-Silently "${___file_output}" + return 1 + } + } { $_ -in "lib", "dll", "library" } { + foreach ($__line in (Get-Content -Path "${___object_list}")) { + $___process = AR-Create "${___file_output}" "${__line}" + if ($___process -ne 0) { + $null = FS-Remove-Silently "${___file_output}" + return 1 + } + } + } default { + # assume to building only object file + }} + + + # report status + return 0 +} + + + +function C-Get-Compiler { + param( + [string]$___os, + [string]$___arch, + [string]$___base_os, + [string]$___base_arch, + [string]$___compiler + ) + + + # execute + $null = OS-Sync + + if ($(STRINGS-Is-Empty "${___compiler}") -ne 0) { + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return "${___compiler}" + } + } + + switch ("${___os}-${___arch}") { + { $_ -in "darwin-amd64", "darwin-arm64" } { + $___compiler = "clang-17" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + $___compiler = "clang-15" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + $___compiler = "clang-14" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "clang" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } "js-wasm" { + $___compiler = "emcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } "linux-amd64" { + $___compiler = "arm-linux-gnueabi-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } "linux-arm64" { + $___compiler = "aarch64-linux-gnu-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } { $_ -in "linux-arm", "linux-armel", "linux-armle" } { + $___compiler = "arm-linux-gnueabi-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + $___compiler = "arm-linux-eabi-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } "linux-armhf" { + $___compiler = "arm-linux-gnueabihf-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } "linux-i386" { + $___compiler = "i686-linux-gnu-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + $___compiler = "i686-elf-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } "linux-mips" { + $___compiler = "mips-linux-gnu-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } { $_ -in "linux-mipsle", "linux-mipsel" } { + $___compiler = "mipsel-linux-gnu-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } "linux-mips64" { + $___compiler = "mips64-linux-gnuabi64-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } { $_ -in "linux-mips64le", "linux-mips64el" } { + $___compiler = "mips64el-linux-gnuabi64-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } { $_ -in "linux-mips32r6", "linux-mipsisa32r6" } { + $___compiler = "mipsisa32r6-linux-gnu-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } { $_ -in "linux-mips64r6", "linux-mipsisa64r6" } { + $___compiler = "mipsisa64r6-linux-gnuabi64-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } { $_ -in "linux-mips32r6le", "linux-mipsisa32r6le", "linux-mipsisa32r6el" } { + $___compiler = "mipsisa32r6el-linux-gnu-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } { $_ -in "linux-mips64r6le", "linux-mipsisa64r6le", "linux-mipsisa64r6el" } { + $___compiler = "mipsisa64r6el-linux-gnuabi64-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } "linux-powerpc" { + $___compiler = "powerpc-linux-gnu-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } { $_ -in "linux-ppc64le", "linux-ppc64el" } { + $___compiler = "powerpc64le-linux-gnu-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } { "linux-riscv64" } { + $___compiler = "riscv64-linux-gnu-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + $___compiler = "riscv64-elf-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } { "linux-s390x" } { + $___compiler = "s390x-linux-gnu-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } { "none-avr" } { + $___compiler = "avr-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } "windows-amd64" { + $___compiler = "x86_64-w64-mingw32-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + $___compiler = "mingw64" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "cc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } "windows-i386" { + $___compiler = "i686-w64-mingw32-gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + $___compiler = "mingw32" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + + + if (("${___os}" -eq "${___base_os}") -and + ("${___arch}" -eq "${___base_arch}")) { + $___compiler = "gcc" + $___process = OS-Is-Command-Available "${___compiler}" + if ($___process -eq 0) { + return $___compiler + } + } + } "wasip1-wasm" { + # let it fail + } default { + # let it fail + }} + + + # report status + return "" +} + + + + +function C-Get-Strict-Settings { + return " -Wall" ` + + " -Wextra" ` + + " -std=gnu89" ` + + " -pedantic" ` + + " -Wstrict-prototypes" ` + + " -Wold-style-definition" ` + + " -Wundef" ` + + " -Wno-trigraphs" ` + + " -fno-strict-aliasing" ` + + " -fno-common" ` + + " -fshort-wchar" ` + + " -fstack-protector-all" ` + + " -Werror-implicit-function-declaration" ` + + " -Wno-format-security" ` + + " -Os" +} + + + + +function C-Is-Available { + # execute + $null = OS-Sync + $___process = C-Get-Compiler ` + "${env:PROJECT_OS}" ` + "${env:PROJECT_ARCH}" ` + "${env:PROJECT_OS}" ` + "${env:PROJECT_ARCH}" + if ($(STRINGS-Is-Empty "${___process}") -eq 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function C-Setup { + # validate input + $___process = C-Is-Available + if ($___process -eq 0) { + return 0 + } + + $___process = OS-Is-Command-Available "choco" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "choco" "install gcc-arm-embedded -y" + if ($___process -ne 0) { + return 1 + } + + if (($(STRINGS-Is-Empty "$(C-Get-Compiler "windows" "amd64")") -eq 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_ROBOT_RUN}") -ne 0)) { + $___process = OS-Exec "choco" "install mingw -y" + if ($___process -ne 0) { + return 1 + } + } + + if (($(STRINGS-Is-Empty "$(C-Get-Compiler "js" "wasm")") -eq 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_ROBOT_RUN}") -ne 0)) { + # BUG: choco fails to install emscripten's dependency properly (git.install) + # See: https://github.com/aminya/chocolatey-emscripten/issues/2 + #$___process = OS-Exec "choco" "install emscripten -y" + #if ($___process -ne 0) { + # return 1 + #} + } + + $null = OS-Sync + + + # report status + return 0 +} + + + + +function C-Run-Parallel { + param( + [string]$___line + ) + + + # initialize libraries from scratch + . "${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" + + + # parse input + $___list = $___line.Split("|") + $___mode = $___list[0] + $___file_object = $___list[1] + $___file_source = $___list[2] + $___file_log = $___list[3] + $___target_os = $___list[4] + $___target_arch = $___list[5] + $___compiler = $___list[6] + $___arguments = $___list[7] + + + # validate input + if (($(STRINGS-Is-Empty "${___mode}") -eq 0) -or + ($(STRINGS-Is-Empty "${___file_object}") -eq 0) -or + ($(STRINGS-Is-Empty "${___file_source}") -eq 0) -or + ($(STRINGS-Is-Empty "${___file_log}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target_os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target_arch}") -eq 0) -or + ($(STRINGS-Is-Empty "${___compiler}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arguments}") -eq 0)) { + return 1 + } + + $___mode = "$(STRINGS-To-Lowercase "${___mode}")" + switch ("${___mode}") { + { $_ -in "build", "build-obj", "build-object" } { + # accepted + } { $_ -in "build-exe", "build-elf", "build-executable" } { + # accepted + } "test" { + # accepted + } default { + return 1 + }} + + $null = FS-Make-Housing-Directory "${___file_object}" + $null = FS-Make-Housing-Directory "${___file_log}" + $null = FS-Remove-Silently "${___file_log}" + + if ("${___mode}" -eq "test") { + $null = I18N-Test "${___file_object}" *>> "${___file_log}" + if ("${___target_os}" -ne "${env:PROJECT_OS}") { + $null = I18N-Test-Skipped *>> "${___file_log}" + return 10 # skipped - cannot operate in host environment + } + + $($___process = FS-Is-File "${___file_object}") *> "${___file_log}" + if ($___process -ne 0) { + $null = I18N-Test-Failed *>> "${___file_log}" + return 1 # failed - build stage + } + + $___process = OS-Exec ` + "${___file_object}" ` + "" ` + "$(FS-Extension-Remove "${___file_log}" ".log")-stdout.log" ` + "$(FS-Extension-Remove "${___file_log}" ".log")-stderr.log" + if ($___process -ne 0) { + $null = I18N-Test-Failed *>> "${___file_log}" + return 1 # failed - test stage + } + + + # report status (test mode) + return 0 + } + + + # operate in build mode + if ($(STRINGS-Is-Empty "${___compiler}") -eq 0) { + $null = I18N-Build-Failed *>> "${___file_log}" + return 1 + } + + switch ("${___mode}") { + { $_ -in "build-exe", "build-elf", "build-executable" } { + $___arguments = @" +${___arguments} -o ${___file_object} ${___file_source} +"@ + + } default { + # assume to building object file + $___arguments = @" +${___arguments} -o ${___file_object} -c ${___file_source} +"@ + }} + + $($null = I18N-Build "${___file_object}") *>> "${___file_log}" + $___process = OS-Exec ` + "${___compiler}" ` + "${___arguments}" ` + "$(FS-Extension-Remove "${___file_log}" ".log")-stdout.log" ` + "$(FS-Extension-Remove "${___file_log}" ".log")-stderr.log" + if ($___process -ne 0) { + $null = I18N-Build-Failed *>> "${___file_log}" + return 1 + } + + + # report status (build mode) + return 0 +} + + + + +function C-Test { + param( + [string]$___directory, + [string]$___os, + [string]$___arch, + [string]$___arguments + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arguments}") -eq 0)) { + return 1 + } + + $___process = C-Is-Available + if ($___process -ne 0) { + return 1 + } + + $___compiler = "$(C-Get-Compiler ` + "${___os}" ` + "${___arch}" ` + "${env:PROJECT_OS}" ` + "${env:PROJET_ARCH}" ` + )" + if ($(STRINGS-Is-Empty "${___compiler}") -eq 0) { + return 1 + } + + + # execute + $___workspace = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\test-${env:PROJECT_C}" + $___log = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_LOG}\test-${env:PROJECT_C}" + $___build_list = "${___workspace}\build-list.txt" + $___test_list = "${___workspace}\test-list.txt" + $null = FS-Remake-Directory "${___workspace}" + $null = FS-Remake-Directory "${___log}" + + ## (1) Scan for all test files + foreach ($___file_src in (Get-ChildItem -Path "${___directory}" ` + -Recurse ` + -Filter "*_test.c").FullName) { + $___file_obj = "$(FS-Get-Path-Relative "${___file_src}" "${___directory}")" + $___file_obj = "$(FS-Extension-Remove "${___file_obj}" "*")" + $___file_log = "${___log}/${___file_obj}" + switch ("${___os}") { + "windows" { + $___file_obj = "${___workspace}\${___file_obj}.exe" + } default { + $___file_obj = "${___workspace}\${___file_obj}.elf" + }} + + + $___process = FS-Append-File "${___build_list}" @" +build-executable|${___file_obj}|${___file_src}|${___file_log}_build.log|${___os}|${___arch}|${___compiler}|${___arguments} +"@ + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Append-File "${___test_list}" @" +test|${___file_obj}|${___file_src}|${___file_log}_test.log|${___os}|${___arch}|${___compiler}|${___arguments} +"@ + if ($___process -ne 0) { + return 1 + } + } + + ## (2) Bail early if test is unavailable + $___process = FS-Is-File "${___test_list}" + if ($___process -ne 0) { + return 0 + } + + ## (3) Build all test artifacts + $___process = FS-Is-File "${___build_list}" + if ($___process -eq 0) { + $___process = SYNC-Exec-Parallel ` + ${function:C-Run-Parallel}.ToString() ` + "${___build_list}" ` + "${___workspace}" + if ($___process -ne 0) { + return 1 + } + } + + ## (4) Execute all test artifacts + $___process = SYNC-Exec-Parallel ` + ${function:C-Run-Parallel}.ToString() ` + "${___test_list}" ` + "${___workspace}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/c.sh b/automataCI/services/compilers/c.sh new file mode 100644 index 0000000..7aaa0ca --- /dev/null +++ b/automataCI/services/compilers/c.sh @@ -0,0 +1,1015 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/io/sync.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/archive/ar.sh" + + + + +C_Build() { + ___file_output="$1" + ___list_sources="$2" + ___output_type="$3" + ___target_os="$4" + ___target_arch="$5" + ___directory_workspace="$6" + ___directory_log="$7" + ___compiler="$8" + ___arguments="$9" + + + # validate input + if [ $(STRINGS_Is_Empty "$___file_output") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___list_sources") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___output_type") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___target_os") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___target_arch") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___directory_workspace") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___directory_log") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___compiler") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___arguments") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$___list_sources" + if [ $? -ne 0 ]; then + return 1 + fi + + ___directory_source="$(FS_Get_Directory "$___list_sources")" + FS_Is_Directory "$___directory_source" + if [ $? -ne 0 ]; then + return 1 + fi + + case "$___output_type" in + elf|exe|executable) + # accepted - build .elf|.exe file + ;; + lib|dll|library) + # accepted - build .a|.dll file + ;; + none) + # accepted - build .o objects + ;; + *) + return 1 + esac + + AR_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___build_list="${___directory_workspace}/build-list.txt" + ___object_list="${___directory_workspace}/object-list.txt" + FS_Remake_Directory "$___directory_workspace" + FS_Remake_Directory "$___directory_log" + FS_Remove_Silently "$___build_list" + FS_Remove_Silently "$___object_list" + + ## (1) Scan for all files + ___old_IFS="$IFS" + while IFS="" read -r __line || [ -n "$__line" ]; do + __line="${__line%%#*}" + __line="$(STRINGS_Trim_Whitespace "$__line")" + if [ $(STRINGS_Is_Empty "$__line") -eq 0 ]; then + continue + fi + + ___platform="${__line%% *}" + ___file="${__line##* }" + ___file_src="${___directory_source}/${___file}" + ___file_obj="${___directory_workspace}/$(FS_Extension_Remove "$___file" "*").o" + ___file_log="${___directory_log}/$(FS_Extension_Remove "$___file" "*")_build.log" + + + # check source file existence + FS_Is_File "$___file_src" + if [ $? -ne 0 ]; then + return 1 + fi + + + # check source file compatibilities + ___os="${___platform%%-*}" + ___arch="${___platform##*-}" + if [ $(STRINGS_Is_Empty "${___platform}") -ne 0 ]; then + # verify OS + if [ ! "$___os" = "any" ]; then + if [ ! "$___os" = "$___target_os" ]; then + continue + fi + fi + + # verify ARCH + if [ ! "$___arch" = "any" ]; then + if [ ! "$___arch" = "$___target_arch" ]; then + continue + fi + fi + fi + ___os="$___target_os" + ___arch="$___target_arch" + + + # begin registrations + if [ ! "$(FS_Extension_Remove "$___file_src" ".c")" = "$___file_src" ]; then + # it's a .c file. Register for building and linking... + FS_Append_File "$___build_list" "\ +build|${___file_obj}|${___file_src}|${___file_log}|${___os}|${___arch}|${___compiler}|${___arguments} +" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Append_File "$___object_list" "${___file_obj}\n" + if [ $? -ne 0 ]; then + return 1 + fi + elif [ ! "$(FS_Extension_Remove "$___file_src" ".o")" = "$___file_src" ]; then + # it's a .o file. Register only for linking... + FS_Make_Housing_Directory "$___file_obj" + + FS_Copy_File "$___file_src" "$___file_obj" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Append_File "$___object_list" "${___file_obj}\n" + if [ $? -ne 0 ]; then + return 1 + fi + else + # it's an unknown file. Bail out... + return 1 + fi + done < "$___list_sources" + IFS="$___old_IFS" && unset ___old_IFS + + ## (2) Bail early if object list is unavailable + FS_Is_File "$___object_list" + if [ $? -ne 0 ]; then + return 0 + fi + + ## (3) Build all object files if found + FS_Is_File "$___build_list" + if [ $? -eq 0 ]; then + SYNC_Exec_Parallel "C_Run_Parallel" "$___build_list" "$___directory_workspace" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + ## (4) Link all objects into the target + FS_Remove_Silently "$___file_output" + case "$___output_type" in + elf|exe|executable) + ___arguments="" + ___old_IFS="$IFS" + while IFS="" read -r __line || [ -n "$__line" ]; do + if [ $(STRINGS_Is_Empty "$__line") -eq 0 ]; then + continue + fi + ___arguments="${___arguments} ${__line}" + done < "$___object_list" + IFS="$___old_IFS" && unset ___old_IFS + + eval "${___compiler} -o ${___file_output} ${___arguments}" + if [ $? -ne 0 ]; then + FS_Remove_Silently "$___file_output" + return 1 + fi + ;; + lib|dll|library) + ___old_IFS="$IFS" + while IFS="" read -r __line || [ -n "$__line" ]; do + if [ $(STRINGS_Is_Empty "$__line") -eq 0 ]; then + continue + fi + + AR_Create "$___file_output" "$__line" + if [ $? -ne 0 ]; then + FS_Remove_Silently "$___file_output" + return 1 + fi + done < "$___object_list" + IFS="$___old_IFS" && unset ___old_IFS + ;; + *) + # assume to building only object file + ;; + esac + + + # report status + return 0 +} + + + + +C_Get_Compiler() { + #___os="$1" + #___arch="$2" + #___base_os="$3" + #___base_arch="$4" + #___compiler="$5" + + + # execute + if [ $(STRINGS_Is_Empty "$5") -ne 0 ]; then + OS_Is_Command_Available "$5" + if [ $? -eq 0 ]; then + printf -- "%b" "$5" + return 0 + else + printf -- "" + return 1 + fi + fi + + case "${1}-${2}" in + darwin-amd64|darwin-arm64) + ___compiler="clang-17" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + ___compiler="clang-15" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + ___compiler="clang-14" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="clang" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + js-wasm) + ___compiler="emcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + ;; + linux-amd64) + ___compiler="x86_64-linux-gnu-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + ___compiler="x86_64-elf-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-arm64) + ___compiler="aarch64-linux-gnu-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + ___compiler="aarch64-elf-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-arm|linux-armel|linux-armle) + ___compiler="arm-linux-gnueabi-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + ___compiler="arm-linux-eabi-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + ___compiler="arm-none-eabi-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-armhf) + ___compiler="arm-linux-gnueabihf-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-i386) + ___compiler="i686-linux-gnu-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + ___compiler="i686-elf-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-mips) + ___compiler="mips-linux-gnu-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-mipsle|linux-mipsel) + ___compiler="mipsel-linux-gnu-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-mips64) + ___compiler="mips64-linux-gnuabi64-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-mips64le|linux-mips64el) + ___compiler="mips64el-linux-gnuabi64-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-mips32r6|linux-mipsisa32r6) + ___compiler="mipsisa32r6-linux-gnu-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-mips64r6|linux-mipsisa64r6) + ___compiler="mipsisa64r6-linux-gnuabi64-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-mips32r6le|linux-mipsisa32r6le|linux-mipsisa32r6el) + ___compiler="mipsisa32r6el-linux-gnu-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-mips64r6le|linux-mipsisa64r6le|linux-mipsisa64r6el) + ___compiler="mipsisa64r6el-linux-gnuabi64-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-powerpc) + ___compiler="powerpc-linux-gnu-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-ppc64le|linux-ppc64el) + ___compiler="powerpc64le-linux-gnu-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-riscv64) + ___compiler="riscv64-linux-gnu-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + ___compiler="riscv64-elf-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + linux-s390x) + __compiler="s390x-linux-gnu-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + + if [ "$1" = "$3" ] || [ "$2" = "$4" ]; then + ___compiler="gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + fi + ;; + none-avr) + ___compiler="avr-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + ;; + windows-amd64) + ___compiler="x86_64-w64-mingw32-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + ;; + windows-i386) + ___compiler="i686-w64-mingw32-gcc" + OS_Is_Command_Available "$___compiler" + if [ $? -eq 0 ]; then + printf -- "%b" "$___compiler" + return 0 + fi + ;; + wasip1-wasm) + ;; + *) + ;; + esac + + + # report status + printf -- "" + return 1 +} + + + + +C_Get_Strict_Settings() { + # execute + printf -- "%b" "\ +-Wall \ +-Wextra \ +-std=gnu89 \ +-pedantic \ +-Wstrict-prototypes \ +-Wold-style-definition \ +-Wundef \ +-Wno-trigraphs \ +-fno-strict-aliasing \ +-fno-common \ +-fshort-wchar \ +-fstack-protector-all \ +-Werror-implicit-function-declaration \ +-Wno-format-security \ +-Os \ +" + + + # report status + return 0 +} + + + + +C_Is_Available() { + # execute + ___compiler="$(C_Get_Compiler \ + "$PROJECT_OS" \ + "$PROJECT_ARCH" \ + "$PROJECT_OS" \ + "$PROJECT_ARCH")" + if [ $(STRINGS_Is_Empty "$___compiler") -eq 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +C_Setup() { + # validate input + OS_Is_Command_Available "brew" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + if [ $(STRINGS_Is_Empty "$(C_Get_Compiler "linux" "arm64")") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_ROBOT_RUN") -ne 0 ]; then + brew install aarch64-elf-gcc + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$(C_Get_Compiler "linux" "riscv64")") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_ROBOT_RUN") -ne 0 ]; then + brew install riscv64-elf-gcc + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$(C_Get_Compiler "linux" "arm")") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_ROBOT_RUN") -ne 0 ]; then + brew install arm-none-eabi-gcc + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$(C_Get_Compiler "linux" "amd64")") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_ROBOT_RUN") -ne 0 ]; then + brew install x86_64-elf-gcc + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$(C_Get_Compiler "linux" "i386")") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_ROBOT_RUN") -ne 0 ]; then + brew install i686-elf-gcc + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$(C_Get_Compiler "windows" "amd64")") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_ROBOT_RUN") -ne 0 ]; then + brew install mingw-w64 + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$(C_Get_Compiler "js" "wasm")") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_ROBOT_RUN") -ne 0 ]; then + brew install emscripten + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$(C_Get_Compiler "$PROJECT_OS" "$PROJECT_ARCH")") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_ROBOT_RUN") -ne 0 ]; then + case "$PROJECT_OS" in + darwin) + brew install gcc + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + brew install llvm + if [ $? -ne 0 ]; then + return 1 + fi + ;; + esac + fi + + + # report status + return 0 +} + + + + +C_Run_Parallel() { + #___line="$1" + + + # parse input + ___mode="${1%%|*}" + ___arguments="${1#*|}" + + ___file_object="${___arguments%%|*}" + ___arguments="${___arguments#*|}" + + ___file_source="${___arguments%%|*}" + ___arguments="${___arguments#*|}" + + ___file_log="${___arguments%%|*}" + ___arguments="${___arguments#*|}" + + ___target_os="${___arguments%%|*}" + ___arguments="${___arguments#*|}" + + ___target_arch="${___arguments%%|*}" + ___arguments="${___arguments#*|}" + + ___compiler="${___arguments%%|*}" + ___arguments="${___arguments#*|}" + + + # validate input + if [ $(STRINGS_Is_Empty "$___mode") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___file_object") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___file_source") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___file_log") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___target_os") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___target_arch") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___compiler") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___arguments") -eq 0 ]; then + return 1 + fi + + ___mode="$(STRINGS_To_Lowercase "$___mode")" + case "$___mode" in + build|build-obj|build-object) + # accepted + ;; + build-exe|build-elf|build-executable) + # accepted + ;; + test) + # accepted + ;; + *) + return 1 + ;; + esac + + FS_Make_Housing_Directory "$___file_object" + FS_Make_Housing_Directory "$___file_log" + FS_Remove_Silently "$___file_log" + + if [ "$___mode" = "test" ]; then + I18N_Test "$___file_object" >> "$___file_log" 2>&1 + if [ ! "$___target_os" = "$PROJECT_OS" ]; then + I18N_Test_Skipped >> "$___file_log" 2>&1 + return 10 # skipped - cannot operate in host environment + fi + + FS_Is_File "$___file_object" + if [ $? -ne 0 ]; then + I18N_Test_Failed >> "$___file_log" 2>&1 + return 1 # failed - build stage + fi + + $___file_object >> "$___file_log" 2>&1 + if [ $? -ne 0 ]; then + I18N_Test_Failed >> "$___file_log" 2>&1 + return 1 # failed - test stage + fi + + + # report status (test mode) + return 0 + fi + + + # operate in build mode + if [ $(STRINGS_Is_Empty "$___compiler") -eq 0 ]; then + I18N_Build_Failed >> "$___file_log" 2>&1 + return 1 + fi + + case "$___mode" in + build-exe|build-elf|build-executable) + ___command="\ +${___compiler} ${___arguments} -o ${___file_object} ${___file_source} +" + ;; + *) + # assume to building object file + ___command="\ +${___compiler} ${___arguments} -o ${___file_object} -c ${___file_source} +" + ;; + esac + + I18N_Run "$___command" >> "$___file_log" 2>&1 + FS_Remove_Silently "$___file_object" + eval "$___command" >> "$___file_log" 2>&1 + if [ $? -ne 0 ]; then + I18N_Run_Failed >> "$___file_log" 2>&1 + return 1 + fi + + + # report status (build mode) + return 0 +} + + + + +C_Test() { + ___directory="$1" + ___os="$2" + ___arch="$3" + ___arguments="$4" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___os") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___arch") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___arguments") -eq 0 ]; then + return 1 + fi + + C_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + ___compiler="$(C_Get_Compiler \ + "$___os" \ + "$___arch" \ + "$PROJECT_OS" \ + "$PROJECT_ARCH" \ + )" + if [ $(STRINGS_Is_Empty "$___compiler") -eq 0 ]; then + return 1 + fi + + + # execute + ___workspace="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/test-${PROJECT_C}" + ___log="${PROJECT_PATH_ROOT}/${PROJECT_PATH_LOG}/test-${PROJECT_C}" + ___build_list="${___workspace}/build-list.txt" + ___test_list="${___workspace}/test-list.txt" + FS_Remake_Directory "$___workspace" + FS_Remake_Directory "$___log" + + ## (1) Scan for all test files + __old_IFS="$IFS" + find "$___directory" -name '*_test.c' -printf "%p\n" \ + | while IFS= read -r ___file_src || [ -n "$___file_src" ]; do + if [ $(STRINGS_Is_Empty "$___file_src") -eq 0 ]; then + continue + fi + + ___file_obj="$(FS_Get_Path_Relative "$___file_src" "$___directory")" + ___file_obj="$(FS_Extension_Remove "$___file_obj" "*")" + ___file_log="${___log}/${___file_obj}" + case "$___os" in + windows) + ___file_obj="${___workspace}/${___file_obj}.exe" + ;; + *) + ___file_obj="${___workspace}/${___file_obj}.elf" + ;; + esac + + FS_Append_File "$___build_list" "\ +build-executable|${___file_obj}|${___file_src}|${___file_log}_build.log|${___os}|${___arch}|${___compiler}|${___arguments} +" + if [ $? -ne 0 ]; then + return 1 + fi + FS_Append_File "$___test_list" "\ +test|${___file_obj}|${___file_src}|${___file_log}_test.log|${___os}|${___arch}|${___compiler}|${___arguments} +" + if [ $? -ne 0 ]; then + return 1 + fi + done + IFS="$__old_IFS" && unset __old_IFS + + ## (2) Bail early if test is unavailable + FS_Is_File "$___test_list" + if [ $? -ne 0 ]; then + return 0 + fi + + ## (3) Build all test artifacts + FS_Is_File "$___build_list" + if [ $? -eq 0 ]; then + SYNC_Exec_Parallel "C_Run_Parallel" "$___build_list" "$___workspace" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + ## (4) Execute all test artifacts + SYNC_Exec_Parallel "C_Run_Parallel" "$___test_list" "$___workspace" + if [ $? -ne 0 ]; then + return 1 + fi + + + # Report status + return 0 +} diff --git a/automataCI/services/compilers/changelog.ps1 b/automataCI/services/compilers/changelog.ps1 new file mode 100644 index 0000000..8dcce92 --- /dev/null +++ b/automataCI/services/compilers/changelog.ps1 @@ -0,0 +1,473 @@ +# 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\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\compress\gz.ps1" + + + + +function CHANGELOG-Assemble-DEB { + param ( + [string]$___directory, + [string]$___target, + [string]$___version + ) + + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___version}") -eq 0)) { + return 1 + } + + $___directory = "${___directory}\deb" + $___target = $___target -replace '\.gz.*$' + + + # assemble file + $null = FS-Remove-Silently "${___target}" + $null = FS-Remove-Silently "${___target}.gz" + $null = FS-Make-Housing-Directory "${___target}" + + $___initiated = "" + foreach ($___line in (Get-Content "${___directory}\latest")) { + $___process = FS-Append-File "${___target}" "${___line}" + if ($___process -ne 0) { + return 1 + } + + $___initiated = "true" + } + + foreach ($___tag in (Invoke-Expression "git tag --sort -version:refname")) { + $___process = FS-Is-File "${___directory}\$($___tag -replace ".*v")" + if ($___process -ne 0) { + continue + } + + if ($(STRINGS-Is-Empty "${___initiated}") -eq 0) { + $___process = FS-Append-File "${___target}" "`n" + if ($___process -ne 0) { + return 1 + } + } + + foreach ($___line in (Get-Content "${___directory}\$($___tag -replace ".*v")")) { + $___process = FS-Append-File "${___target}" "${___line}" + if ($___process -ne 0) { + return 1 + } + + $___initiated = "true" + } + } + + + # gunzip + $___process = GZ-Create "${___target}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function CHANGELOG-Assemble-MD { + param ( + [string]$___directory, + [string]$___target, + [string]$___version, + [string]$___title + ) + + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___version}") -eq 0) -or + ($(STRINGS-Is-Empty "${___title}") -eq 0)) { + return 1 + } + + $___directory = "${___directory}\data" + + + # assemble file + $null = FS-Remove-Silently "${___target}" + $null = FS-Make-Housing-Directory "${___target}" + $null = FS-Write-File "${___target}" "# ${___title}`n" + $null = FS-Append-File "${___target}" "`n## ${___version}`n" + foreach ($___line in (Get-Content "${___directory}\latest")) { + $___process = FS-Append-File "${___target}" "* ${___line}" + if ($___process -ne 0) { + return 1 + } + } + + foreach ($___tag in (Invoke-Expression "git tag --sort -version:refname")) { + $___process = FS-Is-File "${___directory}\$($___tag -replace ".*v")" + if ($___process -ne 0) { + continue + } + + $null = FS-Append-File "${___target}" "`n`n## ${___tag}`n" + foreach ($___line in (Get-Content "${___directory}\$($___tag -replace ".*v")")) { + $___process = FS-Append-File "${___target}" "* ${___line}" + if ($___process -ne 0) { + return 1 + } + } + } + + + # report status + return 0 +} + + + + +function CHANGELOG-Assemble-RPM { + param ( + [string]$___target, + [string]$___resources, + [string]$___date, + [string]$___name, + [string]$___email, + [string]$___version, + [string]$___cadence + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___resources}") -eq 0) -or + ($(STRINGS-Is-Empty "${___date}") -eq 0) -or + ($(STRINGS-Is-Empty "${___name}") -eq 0) -or + ($(STRINGS-Is-Empty "${___email}") -eq 0) -or + ($(STRINGS-Is-Empty "${___version}") -eq 0) -or + ($(STRINGS-Is-Empty "${___cadence}") -eq 0)) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Directory "${___resources}" + if ($___process -ne 0) { + return 1 + } + + + # emit stanza + $___process = FS-Write-File "${___target}" "%%changelog`n" + if ($___process -ne 0) { + return 1 + } + + + # emit latest changelog + $___process = FS-Is-File "${__resources}\changelog\data\latest" + if ($___process -eq 0) { + $___process = FS-Append-File "${___target}" ` + "* ${___date} ${___name} <${___email}> - ${___version}-${___cadence}`n" + if ($___process -ne 0) { + return 1 + } + + foreach ($___line in (Get-Content -Path "${___directory}\changelog\data\latest")) { + $___line = $___line -replace '#.*' + if ($(STRINGS-Is-Empty "${___line}") -eq 0) { + continue + } + + $___process = FS-Append-File "${___target}" " * ${___line}" + if ($___process -ne 0) { + return 1 + } + } + } else { + $___process = FS-Append-File "${___target}" "# unavailable`n" + if ($___process -ne 0) { + return 1 + } + } + + + # emit tailing newline + $___process = FS-Append-File "${___target}" "`n" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function CHANGELOG-Build-DATA-Entry { + param( + [string]$___directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___directory}") -eq 0) { + return 1 + } + + + # get last tag from git log + $___tag = Invoke-Expression "git rev-list --tags --max-count=1" + if ($(STRINGS-Is-Empty "${___tag}") -eq 0) { + $___tag = Invoke-Expression "git rev-list --max-parents=0 --abbrev-commit HEAD" + } + + + # generate log file from the latest to the last tag + $___directory = "${___directory}\data" + $null = FS-Make-Directory "${___directory}" + Invoke-Expression "git log --pretty=`"%s`" HEAD...${___tag}" ` + | Out-File -FilePath "${___directory}\.latest" -Encoding utf8 + $___process = FS-Is-File "${___directory}\.latest" + if ($___process -ne 0) { + return 1 + } + + + # good file, update the previous + $null = FS-Remove-Silently "${___directory}\latest" + $___process = FS-Move "${___directory}\.latest" "${___directory}\latest" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function CHANGELOG-Build-DEB-Entry { + param ( + [string]$___directory, + [string]$___version, + [string]$___sku, + [string]$___dist, + [string]$___urgency, + [string]$___name, + [string]$___email, + [string]$___date + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___version}") -eq 0) -or + ($(STRINGS-Is-Empty "${___sku}") -eq 0) -or + ($(STRINGS-Is-Empty "${___dist}") -eq 0) -or + ($(STRINGS-Is-Empty "${___urgency}") -eq 0) -or + ($(STRINGS-Is-Empty "${___name}") -eq 0) -or + ($(STRINGS-Is-Empty "${___email}") -eq 0) -or + ($(STRINGS-Is-Empty "${___date}") -eq 0)) { + return 1 + } + + $___process = FS-Is-File "${___directory}\data\latest" + if ($___process -ne 0) { + return 1 + } + + + switch ($___dist) { + stable { + break + } unstable { + break + } testing { + break + } experimental { + break + } default { + return 1 + }} + + + # all good. Generate the log fragment + $null = FS-Make-Directory "${___directory}\deb" + + + # create the entry header + $null = FS-Write-File "${___directory}\deb\.latest" @" +${___sku} (${___version}) ${___dist}; urgency=${___urgency} + +"@ + + + # generate body line-by-line + foreach ($___line in (Get-Content -Path "${___directory}\data\latest")) { + $___line = $___line.Substring(0, [Math]::Min($___line.Length, 80)) + $null = FS-Append-File "${___directory}\deb\.latest" " * ${___line}" + } + $null = FS-Append-File "${___directory}\deb\.latest" "" + + + # create the entry sign-off + $null = FS-Append-File "${___directory}\deb\.latest" ` + "-- ${___name} <${___email}> ${___date}" + + + # good file, update the previous + $___process = FS-Move "${___directory}\deb\.latest" "${___directory}\deb\latest" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function CHANGELOG-Compatible-DATA-Version { + param( + [string]$___directory, + [string]$___version + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___version}") -eq 0)) { + return 1 + } + + + # execute + $___process = FS-Is-File "${___directory}\data\${___version}" + if ($___process -ne 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function CHANGELOG-Compatible-DEB-Version { + param( + [string]$___directory, + [string]$___version + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___version}") -eq 0)) { + return 1 + } + + + # execute + $___process = FS-Is-File "${___directory}\deb\${___version}" + if ($___process -ne 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function CHANGELOG-Is-Available { + # execute + $___process = OS-Is-Command-Available "git" + if ($___process -ne 0) { + return 1 + } + + $___process = GZ-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function CHANGELOG-Seal { + param ( + [string]$___directory, + [string]$___version + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___version}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___directory}\data\latest" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___directory}\deb\latest" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = FS-Move "${___directory}\data\latest" "${___directory}\data\${___version}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Move "${___directory}\deb\latest" "${___directory}\deb\${___version}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/changelog.sh b/automataCI/services/compilers/changelog.sh new file mode 100644 index 0000000..7ba7fc8 --- /dev/null +++ b/automataCI/services/compilers/changelog.sh @@ -0,0 +1,464 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/compress/gz.sh" + + + + +CHANGELOG_Assemble_DEB() { + ___directory="$1" + ___target="$2" + ___version="$3" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___target") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___version") -eq 0 ]; then + return 1 + fi + + ___directory="${___directory}/deb" + ___target="${___target%.gz*}" + + + # assemble file + FS_Remove_Silently "$___target" + FS_Remove_Silently "${___target}.gz" + FS_Make_Housing_Directory "$___target" + + ___initiated="" + ___old_IFS="$IFS" + while IFS="" read -r ___line || [ -n "$___line" ]; do + FS_Append_File "$___target" "$___line\n" + if [ $? -ne 0 ]; then + return 1 + fi + + ___initiated="true" + done < "${___directory}/latest" + IFS="$___old_IFS" && unset ___old_IFS ___line + + for ___tag in $(git tag --sort -version:refname); do + FS_Is_File "${___directory}/${___tag##*v}" + if [ $? -ne 0 ]; then + continue + fi + + if [ $(STRINGS_Is_Empty "$___initiated") -ne 0 ]; then + FS_Append_File "$___target" "\n\n" + fi + + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + FS_Append_File "$___target" "$___line\n" + if [ $? -ne 0 ]; then + return 1 + fi + + ___initiated="true" + done < "${___directory}/${___tag##*v}" + IFS="$___old_IFS" && unset ___old_IFS ___line + done + unset ___tag + + + # gunzip + GZ_Create "$___target" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +CHANGELOG_Assemble_MD() { + ___directory="$1" + ___target="$2" + ___version="$3" + ___title="$4" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___target") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___version") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___title") -eq 0 ]; then + return 1 + fi + + ___directory="${___directory}/data" + + + # assemble file + FS_Remove_Silently "$___target" + FS_Make_Housing_Directory "$___target" + FS_Write_File "$___target" "# ${___title}\n\n" + FS_Append_File "$___target" "\n## ${___version}\n\n" + ___old_IFS="$IFS" + while IFS="" read -r ___line || [ -n "$___line" ]; do + FS_Append_File "$___target" "* ${___line}\n" + if [ $? -ne 0 ]; then + return 1 + fi + done < "${___directory}/latest" + + for ___tag in $(git tag --sort -version:refname); do + FS_Is_File "${___directory}/${___tag##*v}" + if [ $? -ne 0 ]; then + continue + fi + + FS_Append_File "$___target" "\n\n## ${___tag}\n\n" + while IFS= read -r ___line || [ -n "$___line" ]; do + FS_Append_File "$___target" "* ${___line}\n" + if [ $? -ne 0 ]; then + return 1 + fi + done < "${___directory}/${___tag##*v}" + done + IFS="$___old_IFS" + unset ___old_IFS ___line ___tag + + + # report status + return 0 +} + + + + +CHANGELOG_Assemble_RPM() { + ___target="$1" + ___resources="$2" + ___date="$3" + ___name="$4" + ___email="$5" + ___version="$6" + ___cadence="$7" + + + # validate input + if [ $(STRINGS_Is_Empty "$___target") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___resources") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___date") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___name") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___email") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___version") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___cadence") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$___target" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "$___resources" + if [ $? -ne 0 ]; then + return 1 + fi + + + # emit stanza + FS_Append_File "$___target" "%%changelog\n" + if [ $? -ne 0 ]; then + return 1 + fi + + + # emit latest changelog + FS_Is_File "${___resources}/changelog/data/latest" + if [ $? -eq 0 ]; then + FS_Append_File "$___target" \ + "* ${___date} ${___name} <${___email}> - ${___version}-${___cadence}\n" + if [ $? -ne 0 ]; then + return 1 + fi + + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + ___line="${___line%%#*}" + if [ $(STRINGS_Is_Empty "$___line") -eq 0 ]; then + continue + fi + + FS_Append_File "$___target" "- ${___line}\n" + if [ $? -ne 0 ]; then + return 1 + fi + done < "${___resources}/changelog/data/latest" + IFS="$___old_IFS" && unset ___old_IFS ___line + else + FS_Append_File "$___target" "# unavailable\n" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + + # emit tailing newline + FS_Append_File "$___target" "\n" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +CHANGELOG_Build_Data_Entry() { + ___directory="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ]; then + return 1 + fi + + + # get last tag from git log + ___tag="$(git rev-list --tags --max-count=1)" + if [ $(STRINGS_Is_Empty "$___tag") -eq 0 ]; then + ___tag="$(git rev-list --max-parents=0 --abbrev-commit HEAD)" + fi + + + # generate log file from the latest to the last tag + ___directory="${___directory}/data" + FS_Make_Directory "$___directory" + git log --pretty=format:"%s" HEAD..."$___tag" > "${___directory}/.latest" + FS_Is_File "${___directory}/.latest" + if [ $? -ne 0 ]; then + return 1 + fi + + + # good file, update the previous + FS_Remove_Silently "${___directory}/latest" &> /dev/null + FS_Move "${___directory}/.latest" "${___directory}/latest" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report verdict + return 0 +} + + + + +CHANGELOG_Build_DEB_Entry() { + ___directory="$1" + ___version="$2" + ___sku="$3" + ___dist="$4" + ___urgency="$5" + ___name="$6" + ___email="$7" + ___date="$8" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___version") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___sku") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___dist") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___urgency") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___name") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___email") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___date") -eq 0 ]; then + return 1 + fi + + FS_Is_File "${___directory}/data/latest" + if [ $? -ne 0 ]; then + return 1 + fi + + case "$___dist" in + stable|unstable|testing|experimental) + ;; + *) + return 1 + ;; + esac + + + # all good. Generate the log fragment + FS_Make_Directory "${___directory}/deb" + + + # create the entry header + FS_Append_File "${___directory}/deb/.latest" "\ +${___sku} (${___version}) ${___dist}; urgency=${___urgency} + +" + + + # generate body line-by-line + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + ___line="${___line::80}" + FS_Append_File "${___directory}/deb/.latest" " * ${___line}\n" + done < "${___directory}/data/latest" + IFS="$___old_IFS" && unset ___line ___old_IFS + FS_Append_File "${___directory}/deb/.latest" "\n" + + + # create the entry signed-off + FS_Append_File "${___directory}/deb/.latest" \ + "-- ${___name} <${___email}> ${___date}\n" + + + # good file, update the previous + FS_Move "${___directory}/deb/.latest" "${___directory}/deb/latest" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +CHANGELOG_Compatible_DATA_Version() { + ___directory="$1" + ___version="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___version") -eq 0 ]; then + return 1 + fi + + + # execute + FS_Is_File "${___directory}/data/${___version}" + if [ $? -eq 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +CHANGELOG_Compatible_DEB_Version() { + ___directory="$1" + ___version="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___version") -eq 0 ]; then + return 1 + fi + + + # execute + FS_Is_File "${___directory}/deb/${___version}" + if [ $? -eq 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +CHANGELOG_Is_Available() { + # execute + OS_Is_Command_Available "git" + if [ $? -ne 0 ]; then + return 1 + fi + + GZ_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +CHANGELOG_Seal() { + ___directory="$1" + ___version="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___version") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "${___directory}/data/latest" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "${___directory}/deb/latest" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + FS_Move "${___directory}/data/latest" "${___directory}/data/${___version}" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Move "${___directory}/deb/latest" "${___directory}/deb/${___version}" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/citation.ps1 b/automataCI/services/compilers/citation.ps1 new file mode 100644 index 0000000..f161f00 --- /dev/null +++ b/automataCI/services/compilers/citation.ps1 @@ -0,0 +1,222 @@ +# 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" + + + + +function CITATION-Build { + param( + [string]$___filepath, + [string]$___abstract_filepath, + [string]$___citation_filepath, + [string]$___cff_version, + [string]$___type, + [string]$___date, + [string]$___title, + [string]$___version, + [string]$___license, + [string]$___repo, + [string]$___repo_code, + [string]$___repo_artifact, + [string]$___contact_name, + [string]$___contact_website, + [string]$___contact_email + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___cff_version}") -eq 0) { + return 0 # requested to be disabled + } + + if (($(STRINGS-Is-Empty "${___filepath}") -eq 0) -or + ($(STRINGS-Is-Empty "${___title}") -eq 0) -or + ($(STRINGS-Is-Empty "${___type}") -eq 0)) { + return 1 + } + + if ($(STRINGS-Is-Empty "${___citation_filepath}") -eq 0) { + return 1 + } + + $___process = FS-Is-File "${___citation_filepath}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $null = FS-Remove-Silently "${___filepath}" + $null = FS-Make-Housing-Directory "${___filepath}" + $___process = FS-Write-File "${___filepath}" @" +# WARNING: auto-generated by AutomataCI + +cff-version: `"${___cff_version}`" +type: `"${___type}`" +"@ + if ($___process -ne 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${___date}") -ne 0) { + $___process = FS-Append-File "${___filepath}" @" +date-released: `"${___date}`" +"@ + if ($___process -ne 0) { + return 1 + } + } + + if ($(STRINGS-Is-Empty "${___title}") -ne 0) { + $___process = FS-Append-File "${___filepath}" @" +title: `"${___title}`" +"@ + if ($___process -ne 0) { + return 1 + } + } + + if ($(STRINGS-Is-Empty "${___version}") -ne 0) { + $___process = FS-Append-File "${___filepath}" @" +version: `"${___version}`" +"@ + if ($___process -ne 0) { + return 1 + } + } + + if ($(STRINGS-Is-Empty "${___license}") -ne 0) { + $___process = FS-Append-File "${___filepath}" @" +license: `"${___license}`" +"@ + if ($___process -ne 0) { + return 1 + } + } + + if ($(STRINGS-Is-Empty "${___repo}") -ne 0) { + $___process = FS-Append-File "${___filepath}" @" +repository: `"${___repo}`" +"@ + if ($___process -ne 0) { + return 1 + } + } + + if ($(STRINGS-Is-Empty "${___repo_code}") -ne 0) { + $___process = FS-Append-File "${___filepath}" @" +repository-code: `"${___repo_code}`" +"@ + if ($___process -ne 0) { + return 1 + } + } + + if ($(STRINGS-Is-Empty "${___repo_artifact}") -ne 0) { + $___process = FS-Append-File "${___filepath}" @" +repository-artifact: `"${___repo_artifact}`" +"@ + if ($___process -ne 0) { + return 1 + } + } + + if ($(STRINGS-Is-Empty "${___contact_website}") -ne 0) { + $___process = FS-Append-File "${___filepath}" @" +url: `"${___contact_website}`" +"@ + if ($___process -ne 0) { + return 1 + } + } + + if ($(STRINGS-Is-Empty "${___contact_name}") -ne 0) { + if (($(STRINGS-Is-Empty "${___contact_website}") -ne 0) -or + ($(STRINGS-Is-Empty "${___contact_email}") -ne 0)) { + $___process = FS-Append-File "${___filepath}" @" +contact: + - affiliation: `"${___contact_name}`" +"@ + if ($___process -ne 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${___contact_email}") -ne 0) { + $___process = FS-Append-File "${___filepath}" @" + email: `"${___contact_email}`" +"@ + if ($___process -ne 0) { + return 1 + } + } + + if ($(STRINGS-Is-Empty "${___contact_website}") -ne 0) { + $___process = FS-Append-File "${___filepath}" @" + website: `"${___contact_website}`" +"@ + if ($___process -ne 0) { + return 1 + } + } + } + } + + $___process = FS-Is-File "${___abstract_filepath}" + if ($___process -eq 0) { + $___process = FS-Append-File "${___filepath}" @" +abstract: |- +"@ + if ($___process -ne 0) { + return 1 + } + + foreach ($___line in (Get-Content "${___abstract_filepath}")) { + if (($(STRINGS-Is-Empty "${___line}") -ne 0) -and + ($(STRINGS-Is-Empty "$($___line -replace "#.*$")") -eq 0)) { + continue + } + + $___line = $___line -replace '#.*' + if ($(STRINGS-Is-Empty "${___line}") -ne 0) { + $___line = " ${___line}" + } + + $___process = FS-Append-File "${___filepath}" "${___line}" + if ($___process -ne 0) { + return 1 + } + } + } + + foreach ($___line in (Get-Content "${___citation_filepath}")) { + if (($(STRINGS-Is-Empty "${___line}") -ne 0) -and + ($(STRINGS-Is-Empty "$($___line -replace "#.*$")") -eq 0)) { + continue + } + + $___line = $___line -replace '#.*' + if ($(STRINGS-Is-Empty "${___line}") -eq 0) { + continue + } + + $___process = FS-Append-File "${___filepath}" "${___line}" + if ($___process -ne 0) { + return 1 + } + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/citation.sh b/automataCI/services/compilers/citation.sh new file mode 100644 index 0000000..25434d6 --- /dev/null +++ b/automataCI/services/compilers/citation.sh @@ -0,0 +1,225 @@ +#!/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" + + + + +CITATION_Build() { + ___filepath="$1" + ___abstract_filepath="$2" + ___citation_filepath="$3" + ___cff_version="$4" + ___type="$5" + ___date="$6" + ___title="$7" + ___version="$8" + ___license="$9" + ___repo="${10}" + ___repo_code="${11}" + ___repo_artifact="${12}" + ___contact_name="${13}" + ___contact_website="${14}" + ___contact_email="${15}" + + + # validate input + if [ $(STRINGS_Is_Empty "$___cff_version") -eq 0 ]; then + return 0 # requested to be disabled + fi + + if [ $(STRINGS_Is_Empty "$___filepath") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___title") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___type") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$___citation_filepath") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$___citation_filepath" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + FS_Remove_Silently "$___filepath" + FS_Make_Housing_Directory "$___filepath" + FS_Write_File "$___filepath" "\ +# WARNING: auto-generated by AutomataCI + +cff-version: \"${___cff_version}\" +type: \"${___type}\" +" + if [ $? -ne 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$___date") -ne 0 ]; then + FS_Append_File "$___filepath" "\ +date-released: \"${___date}\" +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$___title") -ne 0 ]; then + FS_Append_File "$___filepath" "\ +title: \"${___title}\" +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$___version") -ne 0 ]; then + FS_Append_File "$___filepath" "\ +version: \"${___version}\" +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$___license") -ne 0 ]; then + FS_Append_File "$___filepath" "\ +license: \"${___license}\" +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$___repo") -ne 0 ]; then + FS_Append_File "$___filepath" "\ +repository: \"${___repo}\" +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$___repo_code") -ne 0 ]; then + FS_Append_File "$___filepath" "\ +repository-code: \"${___repo_code}\" +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$___repo_artifact") -ne 0 ]; then + FS_Append_File "$___filepath" "\ +repository-artifact: \"${___repo_artifact}\" +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$___contact_website") -ne 0 ]; then + FS_Append_File "$___filepath" "\ +url: \"${___contact_website}\" +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$___contact_name") -ne 0 ]; then + if [ $(STRINGS_Is_Empty "$___contact_website") -ne 0 ] || + [ $(STRINGS_Is_Empty "$___contact_email") -ne 0 ]; then + FS_Append_File "$___filepath" "\ +contact: + - affiliation: \"${___contact_name}\" +" + if [ $? -ne 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$___contact_email") -ne 0 ]; then + FS_Append_File "$___filepath" "\ + email: \"${___contact_email}\" +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$___contact_website") -ne 0 ]; then + FS_Append_File "$___filepath" "\ + website: \"${___contact_website}\" +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + fi + fi + + FS_Is_File "$___abstract_filepath" + if [ $? -eq 0 ]; then + FS_Append_File "$___filepath" "\ +abstract: |- +" + if [ $? -ne 0 ]; then + return 1 + fi + + ___old_IFS="$IFS" + while IFS="" read -r ___line || [ -n "$___line" ]; do + if [ $(STRINGS_Is_Empty "$___line") -ne 0 ] && + [ $(STRINGS_Is_Empty "${___line%%#*}") -eq 0 ]; then + continue + fi + + ___line="${___line%%#*}" + if [ $(STRINGS_Is_Empty "$___line") -ne 0 ]; then + ___line=" ${___line}" + fi + + FS_Append_File "$___filepath" "${___line}\n" + if [ $? -ne 0 ]; then + return 1 + fi + done < "$___abstract_filepath" + IFS="$___old_IFS" && unset ___old_IFS + fi + + ___old_IFS="$IFS" + while IFS="" read -r ___line || [ -n "$___line" ]; do + if [ $(STRINGS_Is_Empty "$___line") -ne 0 ] && + [ $(STRINGS_Is_Empty "${___line%%#*}") -eq 0 ]; then + continue + fi + + ___line="${___line%%#*}" + if [ $(STRINGS_Is_Empty "$___line") -eq 0 ]; then + continue + fi + + FS_Append_File "$___filepath" "${___line}\n" + if [ $? -ne 0 ]; then + return 1 + fi + done < "$___citation_filepath" + IFS="$___old_IFS" && unset ___old_IFS + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/copyright.ps1 b/automataCI/services/compilers/copyright.ps1 new file mode 100644 index 0000000..85ee27c --- /dev/null +++ b/automataCI/services/compilers/copyright.ps1 @@ -0,0 +1,79 @@ +# 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" + + + + +function COPYRIGHT-Create { + param ( + [string]$___location, + [string]$___manual_file, + [string]$___sku, + [string]$___name, + [string]$___email, + [string]$___website + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___location}") -eq 0) -or + ($(STRINGS-Is-Empty "${___manual_file}") -eq 0) -or + ($(STRINGS-Is-Empty "${___sku}") -eq 0) -or + ($(STRINGS-Is-Empty "${___name}") -eq 0) -or + ($(STRINGS-Is-Empty "${___email}") -eq 0) -or + ($(STRINGS-Is-Empty "${___website}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___location}" + if ($___process -eq 0) { + return 1 + } + + $___process = FS-Is-File "${___manual_file}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___location}" + if ($___process -eq 0) { + return 0 + } + + # create housing directory path + $null = FS-Make-Housing-Directory "${___location}" + + + # create copyright stanza header + $___process = FS-Write-File "${___location}" @" +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: ${___sku} +Upstream-Contact: ${___name} <${___email}> +Source: ${___website} + +"@ + if ($___process -ne 0) { + return 1 + } + + + # append manually facilitated copyright contents + foreach ($___line in (Get-Content -Path $___manual_file)) { + $null = FS-Append-File "${___location}" "${___line}" + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/copyright.sh b/automataCI/services/compilers/copyright.sh new file mode 100644 index 0000000..8bccdaa --- /dev/null +++ b/automataCI/services/compilers/copyright.sh @@ -0,0 +1,81 @@ +#!/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" + + + + +COPYRIGHT_Create() { + ___location="$1" + ___manual_file="$2" + ___sku="$3" + ___name="$4" + ___email="$5" + ___website="$6" + + + # validate input + if [ $(STRINGS_Is_Empty "$___location") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___manual_file") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___sku") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___name") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___email") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___website") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "${___location}" + if [ $? -eq 0 ]; then + return 1 + fi + + FS_Is_File "${___manual_file}" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "${___location}" + if [ $? -eq 0 ]; then + return 0 + fi + + + # create housing directory path + FS_Make_Housing_Directory "$___location" + + + # create copyright stanza header + FS_Write_File "$___location" "\ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: ${___sku} +Upstream-Contact: ${___name} <${___email}> +Source: ${___website} + +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # append manually facilitated copyright contents + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + FS_Append_File "$___location" "$___line\n" + done < "$___manual_file" + IFS="$___old_IFS" && unset ___old_IFS ___line + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/deb.ps1 b/automataCI/services/compilers/deb.ps1 new file mode 100644 index 0000000..9b34545 --- /dev/null +++ b/automataCI/services/compilers/deb.ps1 @@ -0,0 +1,528 @@ +# 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\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\disk.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\ar.ps1" +. "${env:LIBS_AUTOMATACI}\services\crypto\gpg.ps1" +. "${env:LIBS_AUTOMATACI}\services\checksum\md5.ps1" + + + + +function DEB-Create-Archive { + param ( + [string]$___directory, + [string]$___destination + ) + + + # 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-Directory "${___directory}/control" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}/data" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___directory}/control/control" + if ($___process -ne 0) { + return 1 + } + + + # change directory into workspace + $___current_path = Get-Location + + + # package control + $null = Set-Location "${___directory}\control" + $___process = TAR-Create-XZ "..\control.tar.xz" "*" + if ($___process -ne 0) { + $null = Set-Location $___current_path + $null = Remove-Variable -Name ___current_path + return 1 + } + + + # package data + $null = Set-Location "${___directory}\data" + $___process = TAR-Create-XZ "..\data.tar.xz" "*" + if ($___process -ne 0) { + $null = Set-Location $___current_path + $null = Remove-Variable -Name ___current_path + return 1 + } + + + # generate debian-binary + $null = Set-Location "${___directory}" + $___process = FS-Write-File ".\debian-binary" "2.0`n" + if ($___process -ne 0) { + $null = Set-Location -Path $___current_path + $null = Remove-Variable -Name ___current_path + return 1 + } + + + # archive into deb + $___file = "package.deb" + $___process = AR-Create "${___file}" "debian-binary control.tar.xz data.tar.xz" + if ($___process -ne 0) { + $null = Set-Location -Path $___current_path + $null = Remove-Variable -Name ___current_path + return 1 + } + + + # move to destination + $null = FS-Remove-Silently "${___destination}" + $___process = FS-Move "${___file}" "${___destination}" + + + # return back to current path + $null = Set-Location -Path $___current_path + $null = Remove-Variable -Name ___current_path + + + # report status + if ($___process -ne 0) { + return 1 + } + + return 0 +} + + + + +function DEB-Create-Changelog { + param ( + [string]$___location, + [string]$___filepath, + [string]$___sku + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___location}") -eq 0) -or + ($(STRINGS-Is-Empty "${___filepath}") -eq 0) -or + ($(STRINGS-Is-Empty "${___sku}") -eq 0)) { + return 1 + } + + $___process = FS-Is-File "${___filepath}" + if ($___process -ne 0) { + return 1 + } + + + # create housing directory path + $null = FS-Make-Housing-Directory "${___location}" + $null = FS-Remove-Silently "${___location}" + + + # copy processed file to the target location + $___process = FS-Copy-File "${___filepath}" "${___location}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function DEB-Create-Checksum { + param ( + [string]$___directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___directory}") -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}" + if ($___process -ne 0) { + return 1 + } + + + # check if is the document already injected + $___location = "${___directory}\control\md5sums" + $null = FS-Remove-Silently "${___location}" + $null = FS-Make-Housing-Directory "${___location}" + + + # checksum each file + foreach ($___line in (Get-ChildItem -Path "${___directory}\data" -File -Recurse)) { + $___checksum = MD5-Checksum-From-File "${___line}" + $___path = "${___line}" -replace [regex]::Escape("${___directory}\data\"), "" + $___path = $___path -replace "\\", "/" + $___process = FS-Append-File "${___location}" "${___checksum} ${___path}" + if ($___process -ne 0) { + return 1 + } + } + + + # report status + return 0 +} + + + + +function DEB-Create-Control { + param ( + [string]$___directory, + [string]$___resources, + [string]$___sku, + [string]$___version, + [string]$___arch, + [string]$___os, + [string]$___name, + [string]$___email, + [string]$___website, + [string]$___pitch, + [string]$___priority, + [string]$___section, + [string]$___description_filepath + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___resources}") -eq 0) -or + ($(STRINGS-Is-Empty "${___sku}") -eq 0) -or + ($(STRINGS-Is-Empty "${___version}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch}") -eq 0) -or + ($(STRINGS-Is-Empty "${___os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___name}") -eq 0) -or + ($(STRINGS-Is-Empty "${___email}") -eq 0) -or + ($(STRINGS-Is-Empty "${___website}") -eq 0) -or + ($(STRINGS-Is-Empty "${___pitch}") -eq 0) -or + ($(STRINGS-Is-Empty "${___priority}") -eq 0) -or + ($(STRINGS-Is-Empty "${___section}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Directory "${___resources}" + if ($___process -ne 0) { + return 1 + } + + switch (${___priority}) { + { $_ -in "required", "important", "standard", "optional", "extra" } { + # accepted + } Default { + return 1 + }} + + + # check if is the document already injected + $___arch = DEB-Get-Architecture "${___os}" "${___arch}" + $___location = "${___directory}\control\control" + $null = FS-Make-Housing-Directory "${___location}" + $null = FS-Remove-Silently "${___location}" + + + # generate control file + $___size = DISK-Calculate-Size "${___directory}\data" + if ($(STRINGS-Is-Empty "${___size}") -eq 0) { + return 1 + } + + $null = FS-Write-File "${___location}" @" +Package: ${___sku} +Version: ${___version} +Architecture: ${___arch} +Maintainer: ${___name} <${___email}> +Installed-Size: ${___size} +Section: ${___section} +Priority: ${___priority} +Homepage: ${___website} +Description: ${___pitch} +"@ + + + # append description data file + $___process = FS-Is-File "${___description_filepath}" + if ($___process -ne 0) { + return 0 # report status early + } + + foreach ($___line in (Get-Content -Path "${___description_filepath}")) { + if (($(STRINGS-Is-Empty "${___line}") -ne 0) -and + ($(STRINGS-Is-Empty "$($___line -replace "#.*$")") -eq 0)) { + continue + } + + $___line = $___line -replace '#.*' + if ($(STRINGS-Is-Empty "${___line}") -eq 0) { + $___line = " ." + } else { + $___line = " ${___line}" + } + + $null = FS-Append-File $___location $___line + } + + + # report status + return 0 +} + + + + +function DEB-Create-Source-List { + param( + [string]$___directory, + [string]$___gpg_id, + [string]$___url, + [string]$___codename, + [string]$___distribution, + [string]$___keyring + ) + + + # 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 "${___distribution}") -eq 0) -or + ($(STRINGS-Is-Empty "${___keyring}") -eq 0)) { + return 1 + } + + if (($(STRINGS-Is-Empty "${___gpg_id}") -eq 0) -and ($(OS-Is-Run-Simulated) -ne 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}" + if ($___process -ne 0) { + return 1 + } + + + # 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" + + $___process = FS-Is-File "${___filename}" + if ($___process -eq 0) { + return 10 + } + + $___process = FS-Is-File "${___directory}\data\${___key}" + if ($___process -eq 0) { + return 1 + } + + $null = FS-Make-Housing-Directory "${___filename}" + $___process = FS-Write-File "${___filename}" @" +# WARNING: AUTO-GENERATED - DO NOT EDIT! +deb [signed-by=/${___key}] ${___url} ${___codename} ${___distribution} +"@ + if ($___process -ne 0) { + return 1 + } + + $null = FS-Make-Housing-Directory "${___directory}\data\${___key}" + if ($(OS-Is-Run-Simulated) -eq 0) { + $___process = FS-Write-File "${___directory}\data\${___key}" "" + } else { + $___process = GPG-Export-Public-Keyring ` + "${___directory}\data\${___key}" ` + "${___gpg_id}" + } + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function DEB-Get-Architecture { + param ( + [string]$___os, + [string]$___arch + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch}") -eq 0)) { + return "" + } + + + # process os + switch ($___os) { + 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}" + }} + + + # report status + return STRINGS-To-Lowercase "${___output}" +} + + + + +function DEB-Is-Available { + param( + [string]$___os, + [string]$___arch + ) + + if (($(STRINGS-Is-Empty "${___os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch}") -eq 0)) { + return 1 + } + + + # validate dependencies + $___process = MD5-Is-Available + if ($___process -ne 0) { + return 1 + } + + $___process = TAR-Is-Available + if ($___process -ne 0) { + return 1 + } + + $___process = AR-Is-Available + if ($___process -ne 0) { + return 1 + } + + $___process = DISK-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # check compatible target os + switch ($___os) { + { $_ -in 'windows', 'darwin' } { + return 2 + } Default { + # accepted + }} + + + # check compatible target cpu architecture + switch ($___arch) { + { $_ -in 'any' } { + return 3 + } Default { + # accepted + }} + + + # report status + return 0 +} + + + + +function DEB-Is-Valid { + param ( + [string]$___target + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + + # execute + if ($(${___target} -split '\.')[-1] -eq "deb") { + return 0 + } + + + # report status + return 1 +} diff --git a/automataCI/services/compilers/deb.sh b/automataCI/services/compilers/deb.sh new file mode 100644 index 0000000..62b088e --- /dev/null +++ b/automataCI/services/compilers/deb.sh @@ -0,0 +1,532 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/io/disk.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" + + + + +DEB_Create_Archive() { + ___directory="$1" + ___destination="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "${___directory}/control" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "${___directory}/data" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "${___directory}/control/control" + if [ $? -ne 0 ]; then + return 1 + fi + + + # capture current directory + ___current_path="$PWD" + + + # package control + cd "${___directory}/control" + TAR_Create_XZ "../control.tar.xz" "*" + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + + # package data + cd "${___directory}/data" + TAR_Create_XZ "../data.tar.xz" "*" + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + + # generate debian-binary + cd "${___directory}" + FS_Write_File "${___directory}/debian-binary" "2.0\n" + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + + # archive into deb + ___file="package.deb" + AR_Create "$___file" "debian-binary control.tar.xz data.tar.xz" + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + + # move to destination + FS_Remove_Silently "$___destination" + FS_Move "$___file" "$___destination" + ___process=$? + + + # return to current directory + cd "$___current_path" && unset ___current_path + + + # report status + if [ $___process -ne 0 ]; then + return 1 + fi + + return 0 +} + + + + +DEB_Create_Changelog() { + ___location="$1" + ___filepath="$2" + ___sku="$3" + + + # validate input + if [ $(STRINGS_Is_Empty "$___location") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___filepath") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___sku") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$___filepath" + if [ $? -ne 0 ]; then + return 1 + fi + + + # create housing directory path + FS_Make_Housing_Directory "$___location" + FS_Remove_Silently "$___location" + + + # copy processed file to target location + FS_Copy_File "$___filepath" "$___location" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +DEB_Create_Checksum() { + #___directory="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # prepare workspace + ___location="${1}/control/md5sums" + FS_Remove_Silently "$___location" + FS_Make_Housing_Directory "$___location" + + + # checksum every items + for ___line in $(find "${1}/data" -type f); do + ___checksum="$(MD5_Checksum_From_File "$___line")" + FS_Append_File "$___location" \ + "${___checksum%% *} ${___line##*${1}/data/}\n" + if [ $? -ne 0 ]; then + return 1 + fi + done + + + # report status + return 0 +} + + + + +DEB_Create_Control() { + ___directory="$1" + ___resources="$2" + ___sku="$3" + ___version="$4" + ___arch="$5" + ___os="$6" + ___name="$7" + ___email="$8" + ___website="$9" + ___pitch="${10}" + ___priority="${11}" + ___section="${12}" + ___description_filepath="${13}" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___resources") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___sku") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___version") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___arch") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___os") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___name") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___email") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___website") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___pitch") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___priority") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___section") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "$___resources" + if [ $? -ne 0 ]; then + return 1 + fi + + case "$___priority" in + required|important|standard|optional|extra) + ;; + *) + return 1 + ;; + esac + + + # prepare workspace + ___arch="$(DEB_Get_Architecture "$___os" "$___arch")" + ___location="${___directory}/control/control" + FS_Make_Housing_Directory "${___location}" + FS_Remove_Silently "${___location}" + + + # generate control file + ___size="$(DISK_Calculate_Size "${___directory}/data")" + if [ $(STRINGS_Is_Empty "$___size") -eq 0 ]; then + return 1 + fi + + FS_Write_File "$___location" "\ +Package: $___sku +Version: $___version +Architecture: $___arch +Maintainer: $___name <$___email> +Installed-Size: $___size +Section: $___section +Priority: $___priority +Homepage: $___website +Description: $___pitch +" + + + # append description data file + if [ ! "$(FS_Is_File "$___description_filepath")" = "0" ]; then + return 0 # report status early + fi + + ___old_IFS="$IFS" + while IFS="" read -r ___line || [ -n "$___line" ]; do + if [ $(STRINGS_Is_Empty "$___line") -ne 0 ] && + [ $(STRINGS_Is_Empty "${___line%%#*}") -eq 0 ]; then + continue + fi + + if [ $(STRINGS_Is_Empty "${___line}") -eq 0 ]; then + ___line=" ." + else + ___line=" ${___line}" + fi + + FS_Append_File "$___location" "${___line}\n" + done < "${___description_filepath}" + IFS="$___old_IFS" && unset ___old_IFS ___line + + + # report status + return 0 +} + + + + +DEB_Create_Source_List() { + ___directory="$1" + ___gpg_id="$2" + ___url="$3" + ___codename="$4" + ___distribution="$5" + ___keyring="$6" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___url") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___codename") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___distribution") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___keyring") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$___gpg_id") -eq 0 ] && [ $(OS_Is_Run_Simulated) -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "$___directory" + if [ $? -ne 0 ]; then + return 1 + fi + + + # 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" + + FS_Is_File "$___filename" + if [ $? -eq 0 ]; then + return 10 + fi + + FS_Is_File "${___directory}/data/${___key}" + if [ $? -eq 0 ]; then + return 1 + fi + + + FS_Make_Housing_Directory "$___filename" + FS_Write_File "$___filename" "\ +# WARNING: AUTO-GENERATED - DO NOT EDIT! +deb [signed-by=/${___key}] ${___url} ${___codename} ${___distribution} +" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Make_Housing_Directory "${___directory}/data/${___key}" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + FS_Write_File "${___directory}/data/${___key}" "" + else + GPG_Export_Public_Keyring "${___directory}/data/${___key}" "$___gpg_id" + fi + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +DEB_Get_Architecture() { + #___os="$1" + #___arch="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + printf -- "" + return 1 + fi + + + # process os + case "$1" in + linux) + ___output="" + ;; + dragonfly) + ___output="dragonflybsd-" + ;; + *) + ___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 + + + # report status + ___output="$(STRINGS_To_Lowercase "$___output")" + printf -- "%b" "$___output" + return 0 +} + + + + +DEB_Is_Available() { + #___os="$1" + #___arch="$2" + + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + + # validate dependencies + MD5_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + TAR_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + AR_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + DISK_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "find" + if [ $? -ne 0 ]; then + return 1 + fi + + + # check compatible target os + case "$1" in + windows|darwin) + return 2 + ;; + *) + # accepted + ;; + esac + + + + # check compatible target cpu architecture + case "$2" in + any) + return 3 + ;; + *) + # accepted + ;; + esac + + + # report status + return 0 +} + + + + +DEB_Is_Valid() { + #___target="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + if [ "${1##*.}" = "deb" ]; then + return 0 + fi + + + # return status + return 1 +} diff --git a/automataCI/services/compilers/docker.ps1 b/automataCI/services/compilers/docker.ps1 new file mode 100644 index 0000000..d0c378a --- /dev/null +++ b/automataCI/services/compilers/docker.ps1 @@ -0,0 +1,426 @@ +# 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\io\strings.ps1" + + + + +function DOCKER-Amend-Manifest { + param( + [string]$___tag, + [string]$___list + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___tag}" -eq 0) -or + ($(STRINGS-Is-Empty "${___list}") -eq 0)) { + return 1 + } + + + # execute + $env:BUILDX_NO_DEFAULT_ATTESTATIONS = 1 + $___process = OS-Exec "docker" "manifest create `"${___tag}`" ${___list}" + $env:BUILDX_NO_DEFAULT_ATTESTATIONS = $null + if ($___process -ne 0) { + return 1 + } + + $env:BUILDX_NO_DEFAULT_ATTESTATIONS = 1 + $___process = OS-Exec "docker" "manifest push `"${___tag}`"" + $env:BUILDX_NO_DEFAULT_ATTESTATIONS = $null + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function DOCKER-Check-Login { + # validate input + if (($(STRINGS-Is-Empty "${env:CONTAINER_USERNAME}") -eq 0) -or + ($(STRINGS-Is-Empty "${env:CONTAINER_PASSWORD}") -eq 0)) { + return 1 + } + + + # report status + return 0 +} + + + + +function DOCKER-Clean-Up { + # validate input + $___process = DOCKER-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "docker" "system prune --force" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function DOCKER-Create { + param( + [string]$___destination, + [string]$___os, + [string]$___arch, + [string]$___repo, + [string]$___sku, + [string]$___version + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___destination}") -eq 0) -or + ($(STRINGS-Is-Empty "${___os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch}") -eq 0) -or + ($(STRINGS-Is-Empty "${___repo}") -eq 0) -or + ($(STRINGS-Is-Empty "${___sku}") -eq 0) -or + ($(STRINGS-Is-Empty "${___version}") -eq 0)) { + return 1 + } + + $___process = DOCKER-Is-Available + if ($___process -ne 0) { + return 1 + } + + $___dockerfile = ".\Dockerfile" + $___tag = DOCKER-Get-ID "${___repo}" "${___sku}" "${___version}" "${___os}" "${___arch}" + + $___process = FS-Is-File "${___dockerfile}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = DOCKER-Login "${___repo}" + if ($___process -ne 0) { + $null = DOCKER-Logout + return 1 + } + + $___arguments = "buildx build " ` + + "--platform `"${___os}/${___arch}`" " ` + + "--file `"${___dockerfile}`" " ` + + "--tag `"${___tag}`" " ` + + "--provenance=false " ` + + "--sbom=false " ` + + "--label `"org.opencontainers.image.ref.name=${___tag}`" " ` + + "--push " ` + + "." + $env:BUILDX_NO_DEFAULT_ATTESTATIONS = 1 + $___process = OS-Exec "docker" $___arguments + $env:BUILDX_NO_DEFAULT_ATTESTATIONS = $null + if ($___process -ne 0) { + $null = DOCKER-Logout + return 1 + } + + $___process = DOCKER-logout + if ($___process -ne 0) { + $null = DOCKER-Logout + return 1 + } + + $___process = FS-Append-File "${___destination}" @" +${___os} ${___arch} ${___tag}`n +"@ + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function DOCKER-Get-Builder-ID { + return "multiarch" +} + + + + +function DOCKER-Get-ID { + param( + [string]$___repo, + [string]$___sku, + [string]$___version, + [string]$___os, + [string]$___arch + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___repo}") -eq 0) -or + ($(STRINGS-Is-Empty "${___sku}") -eq 0) -or + ($(STRINGS-Is-Empty "${___version}") -eq 0)) { + return 1 + } + + + # execute + if (($(STRINGS-Is-Empty "${___os}") -ne 0) -and + ($(STRINGS-Is-Empty "${___arch}") -ne 0)) { + return STRINGS-To-Lowercase ` + "${___repo}/${___sku}:${___os}-${___arch}_${___version}" + } elseif (($(STRINGS-Is-Empty "${___os}") -eq 0) -and + ($(STRINGS-Is-Empty "${___arch}") -ne 0)) { + return STRINGS-To-Lowercase ` + "${___repo}/${___sku}:${___arch}_${___version}" + } elseif (($(STRINGS-Is-Empty "${___os}") -ne 0) -and + ($(STRINGS-Is-Empty "${___arch}") -eq 0)) { + return STRINGS-To-Lowercase ` + "${___repo}/${___sku}:${___os}_${___version}" + } else { + return STRINGS-To-Lowercase "${___repo}/${___sku}:${___version}" + } +} + + + + +function DOCKER-Is-Available { + # execute + $___process = OS-Is-Command-Available "docker" + if ($___process -ne 0) { + return 1 + } + + $null = Invoke-Expression -Command "docker ps" -ErrorAction SilentlyContinue 2> $null + if ($LASTEXITCODE -ne 0) { + return 1 + } + + $null = Invoke-Expression ` + -Command "docker buildx inspect `"$(DOCKER-Get-Builder-ID)`"" ` + -ErrorAction SilentlyContinue ` + 2> $null + if ($LASTEXITCODE -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function DOCKER-Is-Valid { + param ( + [string]$___target + ) + + + # execute + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + if ((Split-Path -Leaf -Path "${___target}") -eq "docker.txt") { + return 0 + } + + + # report status + return 1 +} + + + + +function DOCKER-Login { + param( + [string]$___repo + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___repo}") -eq 0) { + return 1 + } + + $___process = DOCKER-Check-Login + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = Write-Output "${env:CONTAINER_PASSWORD}" ` + | Start-Process -NoNewWindow ` + -FilePath "docker" ` + -ArgumentList "login --username `"${env:CONTAINER_USERNAME}`" --password-stdin" ` + -PassThru + + + # report status + if ($___process.ExitCode -eq 0) { + return 0 + } + + return 1 +} + + + + +function DOCKER-Logout { + return OS-Exec "docker" "logout" +} + + + + +function DOCKER-Release { + param ( + [string]$___target, + [string]$___version + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___version}") -eq 0)) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___list = "" + $___repo = "" + $___sku = "" + Get-Content -Path "${___target}" | ForEach-Object { + if (($(STRINGS-Is-Empty "${_}") -eq 0) -or (${_} == "`n")) { + continue + } + + $___entry = ${_}.Substring(${_}.LastIndexOf(" ") + 1) + $___repo = ${___entry}.Substring(0, ${___entry}.IndexOf(":")) + $___sku = ${___repo}.Substring(${___repo}.LastIndexOf("/") + 1) + $___repo = ${___repo}.Substring(0, ${___repo}.LastIndexOf("/")) + + if ($(STRINGS-Is-Empty "${___list}") -ne 0) { + $___list = "${___list} " + } + + $___list = "${___list}--amend ${___entry}" + } + + if (($(STRINGS-Is-Empty "${___list}") -eq 0) -or + ($(STRINGS-Is-Empty "${___repo}") -eq 0) -or + ($(STRINGS-Is-Empty "${___sku}") -eq 0)) { + return 1 + } + + $___process = DOCKER-Login "${___repo}" + if ($___process -ne 0) { + $null = DOCKER-Logout + return 1 + } + + $___process = DOCKER-Amend-Manifest ` + (DOCKER-Get-ID "${___repo}" "${___sku}" "latest") ` + "${___list}" + if ($___process -ne 0) { + $null = DOCKER-Logout + return 1 + } + + $___process = DOCKER-Amend-Manifest ` + (DOCKER-Get-ID "${___repo}" "${___sku}" "${___version}") ` + "${___list}" + if ($___process -ne 0) { + $null = DOCKER-Logout + return 1 + } + + $___process = DOCKER-Logout + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function DOCKER-Setup { + # validate input + $___process = OS-Is-Command-Available "choco" + if ($___process -ne 0) { + return 1 + } + + $___process = DOCKER-Is-Available + if ($___process -ne 0) { + # NOTE: nothing else can be done since it's host-specific. + # DO NOT choco install Docker-Desktop autonomously. + return 0 + } + + + # execute + $___name = DOCKER-Get-Builder-ID + + $___process = OS-Exec "docker" "buildx inspect `"${___name}`"" + if ($___process -eq 0) { + return 0 + } + + $___process = OS-Exec "docker" "buildx create --use --name `"${___name}`"" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/docker.sh b/automataCI/services/compilers/docker.sh new file mode 100644 index 0000000..07ecf9e --- /dev/null +++ b/automataCI/services/compilers/docker.sh @@ -0,0 +1,403 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +DOCKER_Amend_Manifest() { + #___tag="$1" + #___list="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + + # execute + BUILDX_NO_DEFAULT_ATTESTATIONS=1 docker manifest create "$1" $2 + if [ $? -ne 0 ]; then + return 1 + fi + + BUILDX_NO_DEFAULT_ATTESTATIONS=1 docker manifest push "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +DOCKER_Check_Login() { + # validate input + if [ $(STRINGS_Is_Empty "$CONTAINER_USERNAME") -eq 0 ] || + [ $(STRINGS_Is_Empty "$CONTAINER_PASSWORD") -eq 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +DOCKER_Clean_Up() { + # validate input + DOCKER_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + docker system prune --force + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +DOCKER_Create() { + ___destination="$1" + ___os="$2" + ___arch="$3" + ___repo="$4" + ___sku="$5" + ___version="$6" + + + # validate input + if [ $(STRINGS_Is_Empty "${___destination}") -eq 0 ] || + [ $(STRINGS_Is_Empty "${___os}") -eq 0 ] || + [ $(STRINGS_Is_Empty "${___arch}") -eq 0 ] || + [ $(STRINGS_Is_Empty "${___repo}") -eq 0 ] || + [ $(STRINGS_Is_Empty "${___sku}") -eq 0 ] || + [ $(STRINGS_Is_Empty "${___version}") -eq 0 ]; then + return 1 + fi + + DOCKER_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + ___dockerfile="./Dockerfile" + ___tag="$(DOCKER_Get_ID "$___repo" "$___sku" "$___version" "$___os" "$___arch")" + + FS_Is_File "$___dockerfile" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + DOCKER_Login "$___repo" + if [ $? -ne 0 ]; then + DOCKER_Logout + return 1 + fi + + BUILDX_NO_DEFAULT_ATTESTATIONS=1 docker buildx build \ + --platform "${___os}/${___arch}" \ + --file "$___dockerfile" \ + --tag "$___tag" \ + --provenance=false \ + --sbom=false \ + --label "org.opencontainers.image.ref.name=${___tag}" \ + --push \ + . + if [ $? -ne 0 ]; then + DOCKER_Logout + return 1 + fi + + DOCKER_Logout + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Append_File "$___destination" "${___os} ${___arch} ${___tag}\n" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +DOCKER_Get_Builder_ID() { + printf "multiarch" +} + + + + +DOCKER_Get_ID() { + #___repo="$1" + #___sku="$2" + #___version="$3" + #___os="$4" + #___arch="$5" + + + # 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 + + + # execute + if [ $(STRINGS_Is_Empty "$4") -ne 0 ] && [ $(STRINGS_Is_Empty "$5") -ne 0 ]; then + printf "$(STRINGS_To_Lowercase "${1}/${2}:${4}-${5}_${3}")" + elif [ $(STRINGS_Is_Empty "$4") -eq 0 ] && [ $(STRINGS_Is_Empty "$5") -ne 0 ]; then + printf "$(STRINGS_To_Lowercase "${1}/${2}:${5}_${3}")" + elif [ $(STRINGS_Is_Empty "$4") -ne 0 ] && [ $(STRINGS_Is_Empty "$5") -eq 0 ]; then + printf "$(STRINGS_To_Lowercase "${1}/${2}:${4}_${3}")" + else + printf "$(STRINGS_To_Lowercase "${1}/${2}:${3}")" + fi + + + # report status + return 0 +} + + + + +DOCKER_Is_Available() { + # execute + OS_Is_Command_Available "docker" + if [ $? -ne 0 ]; then + return 1 + fi + + docker ps &> /dev/null + if [ $? -ne 0 ]; then + return 1 + fi + + docker buildx inspect "$(DOCKER_Get_Builder_ID)" &> /dev/null + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +DOCKER_Is_Valid() { + #___target="$1" + + + # execute + FS_Is_File "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + if [ "${1##*/}" = "docker.txt" ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +DOCKER_Login() { + #___repo="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + DOCKER_Check_Login + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + printf "$CONTAINER_PASSWORD" \ + | docker login "$1" \ + --username "$CONTAINER_USERNAME" \ + --password-stdin + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +DOCKER_Logout() { + # execute + docker logout && rm -f "${HOME}/.docker/config.json" &> /dev/null + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +DOCKER_Release() { + ___target="$1" + ___version="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$___target") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___version") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$___target" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___list="" + ___repo="" + ___sku="" + ___old_IFS="$IFS" + while IFS="" read -r ___line || [ -n "$___line" ]; do + if [ $(STRINGS_Is_Empty "$___line") -eq 0 ] || [ "$___line" == "\n" ]; then + continue + fi + + ___entry="${___line##* }" + ___repo="${___entry%%:*}" + ___sku="${___repo##*/}" + ___repo="${___repo%/*}" + + if [ $(STRINGS_Is_Empty "$___list") -ne 0 ]; then + ___list="${___list} " + fi + + ___list="${___list}--amend $___entry" + done < "$___target" + IFS="$___old_IFS" && unset ___old_IFS ___line + + if [ $(STRINGS_Is_Empty "$___list") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___repo") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___sku") -eq 0 ]; then + return 1 + fi + + DOCKER_Login "$___repo" + if [ $? -ne 0 ]; then + DOCKER_Logout + return 1 + fi + + DOCKER_Amend_Manifest "$(DOCKER_Get_ID "$___repo" "$___sku" "latest")" "$___list" + if [ $? -ne 0 ]; then + DOCKER_Logout + return 1 + fi + + DOCKER_Amend_Manifest "$(DOCKER_Get_ID "$___repo" "$___sku" "$___version")" "$___list" + if [ $? -ne 0 ]; then + DOCKER_Logout + return 1 + fi + + DOCKER_Logout + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +DOCKER_Setup() { + # validate input + OS_Is_Command_Available "brew" + if [ $? -ne 0 ]; then + return 1 + fi + + DOCKER_Is_Available + if [ $? -ne 0 ]; then + # NOTE: nothing else can be done since it's host-specific. + # DO NOT brew install Docker-Desktop autonomously. + return 0 + fi + + + # execute + ___name="$(DOCKER_Get_Builder_ID)" + + docker buildx inspect "${___name}" &> /dev/null + if [ $? -eq 0 ]; then + return 0 + fi + + docker buildx create --use --name "${___name}" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/flatpak.ps1 b/automataCI/services/compilers/flatpak.ps1 new file mode 100644 index 0000000..9475d06 --- /dev/null +++ b/automataCI/services/compilers/flatpak.ps1 @@ -0,0 +1,160 @@ +# 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\io\strings.ps1" + + + + +function FLATPAK-Create-Archive { + param ( + [string]$___directory, + [string]$___destination, + [string]$___repo, + [string]$___app_id, + [string]$___gpg_id + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___destination}") -eq 0) -or + ($(STRINGS-Is-Empty "${___repo}") -eq 0) -or + ($(STRINGS-Is-Empty "${___app_id}") -eq 0) -or + ($(STRINGS-Is-Empty "${___gpg_id}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}" + if ($___process -ne 0) { + return 1 + } + + $___path_build = ".\build" + $___path_export = ".\export" + $___path_package = ".\out.flatpak" + $___path_manifest = ".\manifest.yml" + $null = FS-Make-Directory "${___repo}" + + + # change location into the workspace + $___current_path = Get-Location + Set-Location -Path $___directory + + + # build archive + $___process = FS-Is-File "${___path_manifest}" + if ($___process -ne 0) { + return 1 + } + + $___arguments = "--user " + + "--force-clean " + + "--repo=`"${___repo}`" " + + "--gpg-sign=`"${___gpg_id}`" " + + "`"${___path_build}`" " + + "`"${___path_manifest}`" " + $___process = OS-Exec "flatpak-builder" "${___arguments}" + if ($___process -ne 0) { + Set-Location -Path $___current_path + Remove-Variable -Name ___current_path + return 1 + } + + $___process = OS-Exec "flatpak" ` + "build-export `"${___path_export}`" `"${___path_build}`"" + if ($___process -ne 0) { + Set-Location -Path $___current_path + Remove-Variable -Name ___current_path + return 1 + } + + $___arguments = "build-bundle " + + "`"${___path_export}`" " + + "`"${___path_package}`" " + + "`"${___app_id}`" " + $___process = OS-Exec "flatpak" "${___arguments}" + if ($___process -ne 0) { + Set-Location -Path $___current_path + Remove-Variable -Name ___current_path + return 1 + } + + + # export output + $___process = FS-Is-File "${___path_package}" + if ($___process -ne 0) { + Set-Location -Path $___current_path + Remove-Variable -Name ___current_path + return 1 + } + + $___process = FS-Move "${___path_build}" "${___destination}" + + + # head back to current directory + Set-Location -Path "${___current_path}" + Remove-Variable -Name ___current_path + + + # report status + if ($___process -ne 0) { + return 1 + } + + return 0 +} + + + + +function FLATPAK-Is-Available { + param( + [string]$___os, + [string]$___arch + ) + + if (($(STRINGS-Is-Empty "${___os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch}") -eq 0)) { + return 1 + } + + + # check compatible target os + switch ($___os) { + { $_ -in linux, any } { + # accepted + } Default { + return 2 + }} + + + # check compatible target cpu architecture + switch ($___arch) { + any { + return 3 + } Default { + Break + }} + + + # validate dependencies + $___process = OS-Is-Command-Available "flatpak-builder" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/flatpak.sh b/automataCI/services/compilers/flatpak.sh new file mode 100644 index 0000000..a017bed --- /dev/null +++ b/automataCI/services/compilers/flatpak.sh @@ -0,0 +1,153 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +FLATPAK_Create_Archive() { + ___directory="$1" + ___destination="$2" + ___repo="$3" + ___app_id="$4" + ___gpg_id="$5" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___destination") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___repo") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___app_id") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___gpg_id") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___directory" + if [ $? -ne 0 ]; then + return 1 + fi + + ___path_build="./build" + ___path_export="./export" + ___path_package="./out.flatpak" + ___path_manifest="./manifest.yml" + FS_Make_Directory "$___repo" + + + # change location into the workspace + ___current_path="$PWD" + cd "$___directory" + + + # build archive + FS_Is_File "$___path_manifest" + if [ $? -ne 0 ]; then + return 1 + fi + + flatpak-builder \ + --user \ + --force-clean \ + --repo="$___repo" \ + --gpg-sign="$___gpg_id" \ + "$___path_build" \ + "$___path_manifest" + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + flatpak build-export "$___path_export" "$___path_build" + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + flatpak build-bundle "$___path_export" "$___path_package" "$___app_id" + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + + # export output + FS_Is_File "$___path_package" + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + FS_Move "$___path_package" "$___destination" + ___process=$? + + + # head back to current directory + cd "${___current_path}" && unset ___current_path + + + # report status + if [ $___process -ne 0 ]; then + return 1 + fi + + return 0 +} + + + + +FLATPAK_Is_Available() { + ___os="$1" + ___arch="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$___os") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___arch") -eq 0 ]; then + return 1 + fi + + + # check compatible target os + case "$___os" in + linux|any) + # accepted + ;; + *) + return 2 + ;; + esac + + + # check compatible target cpu architecture + case "$___arch" in + any) + return 3 + ;; + *) + ;; + esac + + + # validate dependencies + OS_Is_Command_Available "flatpak-builder" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/go.ps1 b/automataCI/services/compilers/go.ps1 new file mode 100644 index 0000000..99556ce --- /dev/null +++ b/automataCI/services/compilers/go.ps1 @@ -0,0 +1,286 @@ +# 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\io\strings.ps1" + + + + +function GO-Activate-Local-Environment { + # validate input + $___process = GO-Is-Available + if ($___process -ne 0) { + return 1 + } + + $___process = GO-Is-Localized + if ($___process -eq 0) { + return 0 + } + + + # execute + $___location = "$(GO-Get-Activator-Path)" + if ($(FS-Is-File "${___location}") -ne 0) { + return 1 + } + + . "${___location}" + $___process = GO-Is-Localized + if ($___process -eq 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function GO-Get-Activator-Path { + return "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}\${env:PROJECT_PATH_GO_ENGINE}\Activate.ps1" +} + + + + +function Go-Get-Compiler-Optimization-Arguments() { + param( + [string]$___os, + [string]$___arch + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch}") -eq 0)) { + return "" + } + + + # execute + $___os = "$(STRINGS-To-Lowercase "${___os}")" + $___arch = "$(STRINGS-To-Lowercase "${___arch}")" + $___arguments = "" + + switch ("${___os}-${___arch}") { + "android-amd64" { + if ("${env:PROJECT_OS}" -ne "darwin") { + $___arguments = "${___argument} -buildmode=pie" + } + } { $_ -in "darwin-amd64", "darwin-arm64" } { + $___arguments = "${___argument} -buildmode=pie" + } { $_ -in "linux-amd64", "linux-arm64", "linux-ppc64le" } { + $___arguments = "${___argument} -buildmode=pie" + } { $_ -in "windows-amd64", "windows-arm64" } { + $___arguments = "${___argument} -buildmode=pie" + } default { + # do nothing + }} + + + # report status + return STRINGS-Trim-Whitespace "${___arguments}" +} + + + + +function Go-Get-Filename { + param( + [string]$___name, + [string]$___os, + [string]$___arch + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___name}") -eq 0) -or + ($(STRINGS-Is-Empty "${___os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch}") -eq 0)) { + return "" + } + + + # execute + $___os = "$(STRINGS-To-Lowercase "${___os}")" + $___arch = "$(STRINGS-To-Lowercase "${___arch}")" + $___filename = "${___name}_${___os}-${___arch}" + + switch -Regex ("${___os}-${___arch}") { + "^js-wasm$" { + $___filename = "${___filename}.wasm" + } "^wasip1-wasm$" { + $___filename = "${___filename}.wasi" + } "^windows-.*$" { + $___filename = "${___filename}.exe" + } default { + # do nothing + }} + + + # report status + return STRINGS-Trim-Whitespace "${___filename}" +} + + + +function GO-Is-Available { + # execute + $null = OS-Sync + + $___process = OS-Is-Command-Available "go" + if ($___process -eq 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function GO-Is-Localized { + # execute + if ($(STRINGS-Is-Empty "${env:PROJECT_GO_LOCALIZED}") -ne 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function GO-Setup { + # validate input + $___process = GO-Is-Available + if ($___process -eq 0) { + return 0 + } + + $___process = OS-Is-Command-Available "choco" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "choco" "install go -y" + if ($___process -ne 0) { + return 1 + } + $null = OS-Sync + + + # report status + return 0 +} + + + + +function GO-Setup-Local-Environment { + # validate input + $___process = GO-Is-Localized + if ($___process -eq 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_PATH_ROOT}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_PATH_TOOLS}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_PATH_GO_ENGINE}") -eq 0) { + return 1 + } + + $___process = GO-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___label = "($env:PROJECT_PATH_GO_ENGINE)" + $___location = "$(GO-Get-Activator-Path)" + + $null = FS-Make-Housing-Directory "${___location}" + $null = FS-Make-Directory "$(FS-Get-Directory "${___location}")\bin" + $null = FS-Make-Directory "$(FS-Get-Directory "${___location}")\cache" + $null = FS-Make-Directory "$(FS-Get-Directory "${___location}")\env" + $null = FS-Write-File "${___location}" @" +if (-not (Get-Command "go" -ErrorAction SilentlyContinue)) { + Write-Error "[ ERROR ] missing go compiler." + return +} + +function deactivate { + `${env:GOPATH} = "$(Invoke-Expression "go env GOPATH")" + `${env:GOBIN} = "$(Invoke-Expression "go env GOBIN")" + `${env:GOCACHE} = "$(Invoke-Expression "go env GOCACHE")" + `${env:GOENV} = "$(Invoke-Expression "go env GOENV")" + `${env:PROJECT_GO_LOCALIZED} = `$null + Copy-Item -Path Function:_OLD_PROMPT -Destination Function:prompt + Remove-Item -Path Function:_OLD_PROMPT +} + + +# check existing +if (-not [string]::IsNullOrEmpty(`${env:PROJECT_GO_LOCALIZED})) { + return +} + + +# activate +`$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") `` + + ";" `` + + [System.Environment]::GetEnvironmentVariable("Path","User") +`${env:GOPATH} = "$(FS-Get-Directory "${___location}")" +`${env:GOBIN} = "$(FS-Get-Directory "${___location}")\bin" +`${env:GOCACHE} = "$(FS-Get-Directory "${___location}")\cache" +`${env:GOENV} = "$(FS-Get-Directory "${___location}")\env" +`${env:PROJECT_GO_LOCALIZED} = "${___location}" +Copy-Item -Path function:prompt -Destination function:_OLD_PROMPT +function global:prompt { + Write-Host -NoNewline -ForegroundColor Green "(${___label}) " + _OLD_VIRTUAL_PROMPT +} +"@ + + $___process = FS-Is-File "${___location}" + if ($___process -ne 0) { + return 1 + } + + + # testing the activation + $___process = GO-Activate-Local-Environment + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/go.sh b/automataCI/services/compilers/go.sh new file mode 100644 index 0000000..b30a832 --- /dev/null +++ b/automataCI/services/compilers/go.sh @@ -0,0 +1,294 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +GO_Activate_Local_Environment() { + # validate input + GO_Is_Available + if [ $? -ne 0 ] ; then + return 1 + fi + + GO_Is_Localized + if [ $? -eq 0 ] ; then + return 0 + fi + + + # execute + ___location="$(GO_Get_Activator_Path)" + FS_Is_File "$___location" + if [ $? -ne 0 ]; then + return 1 + fi + + . "$___location" + GO_Is_Localized + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +GO_Get_Activator_Path() { + printf -- "%b" "${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/${PROJECT_PATH_GO_ENGINE}/activate.sh" +} + + + + +GO_Get_Compiler_Optimization_Arguments() { + #___os="$1" + #___arch="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + printf -- "" + return 1 + fi + + + # execute + ___os="$(STRINGS_To_Lowercase "$1")" + ___arch="$(STRINGS_To_Lowercase "$2")" + ___arguments="" + + case "${___os}-${___arch}" in + android-arm64) + if [ "$PROJECT_OS" != "darwin" ]; then + ___arguments="${___argument} -buildmode=pie" + fi + ;; + darwin-amd64|darwin-arm64) + ___arguments="${___argument} -buildmode=pie" + ;; + linux-amd64|linux-arm64|linux-ppc64le) + ___arguments="${___argument} -buildmode=pie" + ;; + windows-amd64|windows-arm64) + ___arguments="${___argument} -buildmode=pie" + ;; + *) + ;; + esac + + + # report status + printf -- "%b" "$(STRINGS_Trim_Whitespace "$___arguments")" + return 0 +} + + + + +GO_Get_Filename() { + #___name="$1" + #___os="$2" + #___arch="$3" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || + [ $(STRINGS_Is_Empty "$2") -eq 0 ] || + [ $(STRINGS_Is_Empty "$3") -eq 0 ]; then + printf -- "" + return 1 + fi + + + # execute + ___os="$(STRINGS_To_Lowercase "$2")" + ___arch="$(STRINGS_To_Lowercase "$3")" + ___filename="${1}_${___os}-${___arch}" + + case "${___os}-${___arch}" in + js-wasm) + ___filename="${___filename}.wasm" + ;; + wasip1-wasm) + ___filename="${___filename}.wasi" + ;; + windows*) + ___filename="${___filename}.exe" + ;; + *) + ;; + esac + + + # report status + printf -- "%b" "$(STRINGS_Trim_Whitespace "$___filename")" + return 0 +} + + + + +GO_Is_Available() { + # execute + OS_Is_Command_Available "go" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +GO_Is_Localized() { + # execute + if [ $(STRINGS_Is_Empty "$PROJECT_GO_LOCALIZED") -ne 0 ] ; then + return 0 + fi + + + # report status + return 1 +} + + + + +GO_Setup() { + # validate input + GO_Is_Available + if [ $? -eq 0 ]; then + return 0 + fi + + OS_Is_Command_Available "brew" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + brew install go + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GO_Setup_Local_Environment() { + # validate input + GO_Is_Localized + if [ $? -eq 0 ] ; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_PATH_ROOT") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_PATH_TOOLS") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_PATH_GO_ENGINE") -eq 0 ]; then + return 1 + fi + + GO_Is_Available + if [ $? -ne 0 ] ; then + return 1 + fi + + + # execute + ___label="($PROJECT_PATH_GO_ENGINE)" + ___location="$(GO_Get_Activator_Path)" + + if [ -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then + ___brew="eval \$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + elif [ -f "/usr/local/bin/brew" ]; then + ___brew="eval \$(/usr/local/bin/brew shellenv)" + else + ___brew="" + fi + + FS_Make_Housing_Directory "$___location" + FS_Make_Directory "$(FS_Get_Directory "$___location")/bin" + FS_Make_Directory "$(FS_Get_Directory "$___location")/cache" + FS_Make_Directory "$(FS_Get_Directory "$___location")/env" + FS_Write_File "$___location" "\ +#!/bin/sh +if [ -z \"\$(type -t 'go')\" ]; then + 1>&2 printf -- '[ ERROR ] missing go compiler.\\\\n' + return 1 +fi + +deactivate() { + export GOPATH='$(go env GOPATH)' + export GOBIN='$(go env GOBIN)' + export GOCACHE='$(go env GOCACHE)' + export GOENV='$(go env GOENV)' + export PS1=\"\${PS1##*${___label} }\" + unset PROJECT_GO_LOCALIZED + return 0 +} + +# check +if [ ! -z \"\$PROJECT_GO_LOCALIZED\" ]; then + return 0 +fi + +# activate +${___brew} +export GOPATH='$(FS_Get_Directory "$___location")' +export GOBIN='$(FS_Get_Directory "$___location")/bin' +export GOCACHE='$(FS_Get_Directory "$___location")/cache' +export GOENV='$(FS_Get_Directory "$___location")/env' +export PROJECT_GO_LOCALIZED='${___location}' +export PS1=\"${___label} \${PS1}\" +return 0 +" + + FS_Is_File "${___location}" + if [ $? -ne 0 ]; then + return 1 + fi + + + # testing the activation + GO_Activate_Local_Environment + if [ $? -ne 0 ] ; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/ipk.ps1 b/automataCI/services/compilers/ipk.ps1 new file mode 100644 index 0000000..89b9c77 --- /dev/null +++ b/automataCI/services/compilers/ipk.ps1 @@ -0,0 +1,251 @@ +# 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\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\disk.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\deb.ps1" + + + + +function IPK-Create-Archive { + param ( + [string]$___directory, + [string]$___destination + ) + + + # 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-Directory "${___directory}/control" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}/data" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___directory}/control/control" + if ($___process -ne 0) { + return 1 + } + + + # change directory into workspace + $___current_path = Get-Location + + + # package control + $null = Set-Location "${___directory}\control" + $___process = TAR-Create-GZ "..\control.tar.gz" "*" + if ($___process -ne 0) { + $null = Set-Location $___current_path + $null = Remove-Variable -Name ___current_path + return 1 + } + + + # package data + $null = Set-Location "${___directory}\data" + $___process = TAR-Create-GZ "..\data.tar.gz" "*" + if ($___process -ne 0) { + $null = Set-Location $___current_path + $null = Remove-Variable -Name ___current_path + return 1 + } + + + # generate debian-binary + $null = Set-Location "${___directory}" + $___process = FS-Write-File ".\debian-binary" "2.0`n" + if ($___process -ne 0) { + $null = Set-Location $___current_path + $null = Remove-Variable -Name ___current_path + return 1 + } + + + # archive into ipk + $___file = "package.ipk" + $___process = TAR-Create-GZ "${___file}" "debian-binary control.tar.gz data.tar.gz" + if ($___process -ne 0) { + $null = Set-Location $___current_path + $null = Remove-Variable -Name ___current_path + return 1 + } + + + # move to destination + $null = FS-Remove-Silently "${___destination}" + $___process = FS-Move "${___file}.gz" "${___destination}" + + + # return 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 +} + + + + +function IPK-Create-Control { + param ( + [string]$___directory, + [string]$___resources, + [string]$___sku, + [string]$___version, + [string]$___arch, + [string]$___os, + [string]$___name, + [string]$___email, + [string]$___website, + [string]$___pitch, + [string]$___priority, + [string]$___section, + [string]$___description_filepath + ) + + + # execute + $___process = DEB-Create-Control ` + "${___directory}" ` + "${___resources}" ` + "${___sku}" ` + "${___version}" ` + "${___arch}" ` + "${___os}" ` + "${___name}" ` + "${___email}" ` + "${___website}" ` + "${___pitch}" ` + "${___priority}" ` + "${___section}" ` + "${___description_filepath}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function IPK-Get-Architecture { + param ( + [string]$___os, + [string]$___arch + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch}") -eq 0)) { + return "" + } + + + # report status + return STRINGS-To-Lowercase "${___os}-${___arch}" +} + + + + +function IPK-Is-Available { + param( + [string]$___os, + [string]$___arch + ) + + if (($(STRINGS-Is-Empty "${___os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch}") -eq 0)) { + return 1 + } + + + # validate dependencies + $___process = TAR-Is-Available + if ($___process -ne 0) { + return 1 + } + + $___process = DISK-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # check compatible target cpu architecture + switch ($___arch) { + { $_ -in 'any' } { + return 3 + } Default { + # accepted + }} + + + # report status + return 0 +} + + + + +function IPK-Is-Valid { + param ( + [string]$___target + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + + # execute + if ($(${___target} -split '\.')[-1] -eq "ipk") { + return 0 + } + + + # report status + return 1 +} diff --git a/automataCI/services/compilers/ipk.sh b/automataCI/services/compilers/ipk.sh new file mode 100644 index 0000000..8e7c276 --- /dev/null +++ b/automataCI/services/compilers/ipk.sh @@ -0,0 +1,244 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/io/disk.sh" +. "${LIBS_AUTOMATACI}/services/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/compilers/deb.sh" + + + + +IPK_Create_Archive() { + ___directory="$1" + ___destination="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "${___directory}/control" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "${___directory}/data" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "${___directory}/control/control" + if [ $? -ne 0 ]; then + return 1 + fi + + + # capture current directory + ___current_path="$PWD" + + + # package control + cd "${___directory}/control" + TAR_Create_GZ "../control.tar.gz" "*" + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + + # package data + cd "${___directory}/data" + TAR_Create_GZ "../data.tar.gz" "*" + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + + # generate debian-binary + cd "${___directory}" + FS_Write_File "${___directory}/debian-binary" "2.0\n" + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + + # archive into ipk + ___file="package.ipk" + TAR_Create_GZ "$___file" "debian-binary control.tar.gz data.tar.gz" + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + + # move to destination + FS_Remove_Silently "$___destination" + FS_Move "${___file}.gz" "$___destination" + ___process=$? + + + # return to current directory + cd "$___current_path" && unset ___current_path + + + # report status + if [ $___process -ne 0 ]; then + return 1 + fi + + return 0 +} + + + + +IPK_Create_Control() { + #___directory="$1" + #___resources="$2" + #___sku="$3" + #___version="$4" + #___arch="$5" + #___os="$6" + #___name="$7" + #___email="$8" + #___website="$9" + #___pitch="${10}" + #___priority="${11}" + #___section="${12}" + #___description_filepath="${13}" + + + # execute + DEB_Create_Control "$1" \ + "$2" \ + "$3" \ + "$4" \ + "$5" \ + "$6" \ + "$7" \ + "$8" \ + "$9" \ + "${10}" \ + "${11}" \ + "${12}" \ + "${13}" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +IPK_Get_Architecture() { + #___os="$1" + #___arch="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + printf -- "" + return 1 + fi + + + # report status + printf -- "%b" "$(STRINGS_To_Lowercase "${1}-${2}")" + return 0 +} + + + + +IPK_Is_Available() { + ___os="$1" + ___arch="$2" + + if [ $(STRINGS_Is_Empty "$___os") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___arch") -eq 0 ]; then + return 1 + fi + + + # validate dependencies + TAR_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + DISK_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "find" + if [ $? -ne 0 ]; then + return 1 + fi + + + # check compatible target cpu architecture + case "$___arch" in + any) + return 3 + ;; + *) + ;; + esac + + + # report status + return 0 +} + + + + +IPK_Is_Valid() { + #___target="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + if [ "${1##*.}" = "ipk" ]; then + return 0 + fi + + + # return status + return 1 +} diff --git a/automataCI/services/compilers/libreoffice.ps1 b/automataCI/services/compilers/libreoffice.ps1 new file mode 100644 index 0000000..dc99977 --- /dev/null +++ b/automataCI/services/compilers/libreoffice.ps1 @@ -0,0 +1,231 @@ +# 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\net\http.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\msi.ps1" +. "${env:LIBS_AUTOMATACI}\services\publishers\apple.ps1" + + + + +function LIBREOFFICE-Get { + # execute + $null = OS-Sync + + $___source = "libreoffice" + $___process = OS-Is-Command-Available "${___source}" + if ($___process -eq 0) { + return "${___source}" + } + + $___source = "soffice" + $___process = OS-Is-Command-Available "${___source}" + if ($___process -eq 0) { + return "${___source}" + } + + $___source = "$(LIBREOFFICE-Get-Path)" + $___process = FS-Is-File "${___source}" + if ($___process -eq 0) { + return $___source + } + + + # report status + return "" +} + + + + +function LIBREOFFICE-Get-Path { + switch ("$(OS-Get)") { + "darwin" { + $___path = "/Applications/LibreOffice.app/Contents/MacOS/soffice" + } "windows" { + $___path = "C:\Program Files\LibreOffice\program\soffice.exe" + } default { + $___path = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}\libreoffice\bin\libreoffice" + }} + + + # report status + return $___path +} + + + + +function LIBREOFFICE-Is-Available { + # execute + $null = OS-Sync + + $___process = OS-Is-Command-Available "libreoffice" + if ($___process -eq 0) { + return 0 + } + + $___process = OS-Is-Command-Available "soffice" + if ($___process -eq 0) { + return 0 + } + + $___process = FS-Is-File "$(LIBREOFFICE-Get-Path)" + if ($___process -eq 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function LIBREOFFICE-Setup { + # validate input + $___process = LIBREOFFICE-Is-Available + if ($___process -eq 0) { + return 0 + } + + if (($(STRINGS-Is-Empty "${env:PROJECT_PATH_ROOT}") -eq 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_PATH_TEMP}") -eq 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_PATH_TOOLS}") -eq 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_LIBREOFFICE_MIRROR}") -eq 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_LIBREOFFICE_VERSION}") -eq 0)) { + return 1 + } + + + # execute + if ($(OS-Get) -eq "darwin") { + $___dest = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\libreoffice\instal.dmg" + $null = FS-Make-Housing-Directory "${___dest}" + $null = FS-Remove-Silently "${___dest}" + + + ## Download directly from provider + $___url = "${env:PROJECT_LIBREOFFICE_MIRROR}/stable/${env:PROJECT_LIBREOFFICE_VERSION}" + $___url = "${___url}/mac" + if ($(OS-Get-Arch) -eq "amd64") { + $___url = "${___url}/x86_64" + $___url = "${___url}/LibreOffice_${env:PROJECT_LIBREOFFICE_VERSION}_MacOS_x86-64.dmg" + } elseif ($(OS-Get-Arch) -eq "arm64") { + $___url = "${___url}/aarch64" + $___url = "${___url}/LibreOffice_${env:PROJECT_LIBREOFFICE_VERSION}_MacOS_aarch64.dmg" + } else { + return 1 + } + + + # download from provider + $___process = HTTP-Download "GET" "${___url}" "${___dest}" + if ($___process -ne 0) { + return 1 + } + + + ## silently install + $___process = Apple-Install-DMG "${___dest}" + if ($___process -ne 0) { + return 1 + } + + + ## clean up + $null = FS-Remove-Silently "${___dest}" + } elseif ($(OS-Get) -eq "windows") { + ## Attempt to use directly from the provider + $___dest = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\libreoffice\install.msi" + $null = FS-Make-Housing-Directory "${___dest}" + $null = FS-Remove-Silently "${___dest}" + + + $___url = "${env:PROJECT_LIBREOFFICE_MIRROR}/stable/${env:PROJECT_LIBREOFFICE_VERSION}" + $___url = "${___url}/win" + if ($(OS-Get-Arch) -eq "amd64") { + $___url = "${___url}/x86_64" + $___url = "${___url}/LibreOffice_${env:PROJECT_LIBREOFFICE_VERSION}_Win_x86-64.msi" + } elseif ($(OS-Get-Arch) -eq "arm64") { + $___url = "${___url}/aarch64" + $___url = "${___url}/LibreOffice_${env:PROJECT_LIBREOFFICE_VERSION}_Win_aarch64.msi" + } else { + ## fallback to choco as the last resort + $___process = OS-Is-Command-Available "choco" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Exec "choco" "install libreoffice-fresh -y" + if ($___process -ne 0) { + return 1 + } + + return 0 + } + + $___process = HTTP-Download "GET" "${___url}" "${___dest}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___dest}" + if ($___process -ne 0) { + return 1 + } + + $___process = MSI-Install-Silent "${___dest}" + $null = FS-Remove-Silently "${___dest}" + $null = OS-Sync + if ($___process -ne 0) { + ## fallback to choco as the last resort + $___process = OS-Is-Command-Available "choco" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Exec "choco" "install libreoffice-fresh -y" + if ($___process -ne 0) { + return 1 + } + + $null = OS-Sync + return 0 + } + } else { + ## check compatible platform version + $___url = "https://appimages.libreitalia.org" + switch ("$(OS-Get-Arch)") { + "amd64" { + $___url = "${___url}/LibreOffice-fresh.full-x86_64.AppImage" + } default { + return 1 + }} + + + ## download appimage portable version + $___dest = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}\libreoffice\bin\libreoffice" + $null = FS-Make-Housing-Directory "${___dest}" + $null = FS-Remove-Silently "${___dest}" + $___process = HTTP-Download "GET" "${___url}" "${___dest}" + if ($___process -ne 0) { + return 1 + } + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/libreoffice.sh b/automataCI/services/compilers/libreoffice.sh new file mode 100644 index 0000000..ca3dc8d --- /dev/null +++ b/automataCI/services/compilers/libreoffice.sh @@ -0,0 +1,250 @@ +#!/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/net/http.sh" +. "${LIBS_AUTOMATACI}/services/compilers/msi.sh" +. "${LIBS_AUTOMATACI}/services/publishers/apple.sh" + + + + +LIBREOFFICE_Get() { + # execute + ___source="libreoffice" + OS_Is_Command_Available "$___source" + if [ $? -eq 0 ]; then + printf -- "%b" "$___source" + return 0 + fi + + ___source="soffice" + OS_Is_Command_Available "$___source" + if [ $? -eq 0 ]; then + printf -- "%b" "$___source" + return 0 + fi + + OS_Is_Command_Available "flatpak" + if [ $? -eq 0 ]; then + flatpak info org.libreoffice.LibreOffice &> /dev/null + if [ $? -eq 0 ]; then + printf -- "%b" "flatpak run org.libreoffice.LibreOffice" + return 0 + fi + fi + + ___source="$(LIBREOFFICE_Get_Path)" + FS_Is_File "$___source" + if [ $? -eq 0 ]; then + printf -- "%b" "$___source" + return 0 + fi + + + # report status + return 1 +} + + + + +LIBREOFFICE_Get_Path() { + case "$(OS_Get)" in + darwin) + ___path="/Applications/LibreOffice.app/Contents/MacOS/soffice" + ;; + windows) + ___path="C:\\Program Files\\LibreOffice\\program\\soffice.exe" + ;; + *) + ___path="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/libreoffice/bin/libreoffice" + ;; + esac + + + # report status + printf -- "%b" "$___path" + return 0 +} + + + + +LIBREOFFICE_Is_Available() { + # execute + OS_Is_Command_Available "libreoffice" + if [ $? -eq 0 ]; then + return 0 + fi + + OS_Is_Command_Available "soffice" + if [ $? -eq 0 ]; then + return 0 + fi + + OS_Is_Command_Available "flatpak" + if [ $? -eq 0 ]; then + flatpak info org.libreoffice.LibreOffice &> /dev/null + if [ $? -eq 0 ]; then + return 0 + fi + fi + + FS_Is_File "$(LIBREOFFICE_Get_Path)" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +LIBREOFFICE_Setup() { + # validate input + LIBREOFFICE_Is_Available + if [ $? -eq 0 ]; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_PATH_ROOT") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_PATH_TEMP") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_PATH_TOOLS") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_LIBREOFFICE_MIRROR") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_LIBREOFFICE_VERSION") -eq 0 ]; then + return 1 + fi + + + # execute + if [ "$(OS_Get)" = "darwin" ]; then + ## apple OS + ___dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/libreoffice/install.dmg" + FS_Make_Housing_Directory "$___dest" + FS_Remove_Silently "$___dest" + + + ## Download directly from provider + ___url="${PROJECT_LIBREOFFICE_MIRROR}/stable/${PROJECT_LIBREOFFICE_VERSION}" + ___url="${___url}/mac" + if [ "$(OS_Get_Arch)" = "amd64" ]; then + ___url="${___url}/x86_64" + ___url="${___url}/LibreOffice_${PROJECT_LIBREOFFICE_VERSION}_MacOS_x86-64.dmg" + elif [ "$(OS_Get_Arch)" = "arm64" ]; then + ___url="${___url}/aarch64" + ___url="${___url}/LibreOffice_${PROJECT_LIBREOFFICE_VERSION}_MacOS_aarch64.dmg" + else + return 1 + fi + + + # download from provider + HTTP_Download "GET" "$___url" "$___dest" + if [ $? -ne 0 ]; then + return 1 + fi + + + ## silently install + APPLE_Install_DMG "$___dest" + if [ $? -ne 0 ]; then + return 1 + fi + + + ## clean up + FS_Remove_Silently "$___dest" + elif [ "$(OS_Get)" = "windows" ]; then + ## Attempt to use directly from the provider + ___dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/libreoffice/install.msi" + FS_Make_Housing_Directory "$___dest" + FS_Remove_Silently "$___dest" + + + ## Download directly from provider + ___url="${PROJECT_LIBREOFFICE_MIRROR}/stable/${PROJECT_LIBREOFFICE_VERSION}" + ___url="${___url}/win" + if [ "$(OS_Get_Arch)" = "amd64" ]; then + ___url="${___url}/x86_64" + ___url="${___url}/LibreOffice_${PROJECT_LIBREOFFICE_VERSION}_Win_x86-64.msi" + elif [ "$(OS_Get_Arch)" = "arm64" ]; then + ___url="${___url}/aarch64" + ___url="${___url}/LibreOffice_${PROJECT_LIBREOFFICE_VERSION}_Win_aarch64.msi" + else + return 1 + fi + + HTTP_Download "GET" "$___url" "$___dest" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "$___dest" + if [ $? -ne 0 ]; then + return 1 + fi + + MSI_Install_Silent "$___dest" + ___process=$? + FS_Remove_Silently "$___dest" + if [ $___process -ne 0 ]; then + return 1 + fi + else + # other UNIX OS (including Linux) + OS_Is_Command_Available "flatpak" + if [ $? -eq 0 ]; then + flatpak --user install org.libreoffice.LibreOffice + if [ $? -ne 0 ]; then + return 1 + fi + + return 0 + fi + + + # check compatible platform version + ___url="https://appimages.libreitalia.org" + case "$(OS_Get_Arch)" in + amd64) + ___url="${___url}/LibreOffice-fresh.full-x86_64.AppImage" + ;; + *) + return 1 + ;; + esac + + + # download appimage portable version + ___dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/libreoffice/bin/libreoffice" + FS_Make_Housing_Directory "$___dest" + FS_Remove_Silently "$___dest" + HTTP_Download "GET" "$___url" "$___dest" + if [ $? -ne 0 ]; then + return 1 + fi + + chmod +x "$___dest" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/manual.ps1 b/automataCI/services/compilers/manual.ps1 new file mode 100644 index 0000000..2fde03c --- /dev/null +++ b/automataCI/services/compilers/manual.ps1 @@ -0,0 +1,101 @@ +# 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\compress\gz.ps1" + + + + +function MANUAL-Create { + param( + [string]$___location, + [string]$___sku, + [string]$___name, + [string]$___email, + [string]$___website + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___location}") -eq 0) -or + ($(STRINGS-Is-Empty "${___sku}") -eq 0) -or + ($(STRINGS-Is-Empty "${___name}") -eq 0) -or + ($(STRINGS-Is-Empty "${___email}") -eq 0) -or + ($(STRINGS-Is-Empty "${___website}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___location}" + if ($___process -eq 0) { + return 1 + } + + + # create housing directory path + $null = FS-Make-Housing-Directory "${___location}" + $null = FS-Remove-Silently "${___location}" + $null = FS-Remove-Silently "${___location}.gz" + + + # create basic level 1 man page that instruct users to seek --help + $___process = FS-Write-File "${___location}" @" +.`" ${___sku} - Lv1 Manpage +.TH man 1 `"${___sku} man page`" + +.SH NAME +${___sku} - Getting help + +.SH SYNOPSIS +command: $ ./${___sku} help + +.SH DESCRIPTION +This is a backward-compatible auto-generated system-level manual page. To make +sure you get the required and proper assistances from the software, please make +sure you call the command above. + +.SH SEE ALSO +Please visit ${___website} for more info. + +.SH AUTHORS +Contact: ${___name} <${___email}> +"@ + if ($___process -ne 0) { + return 0 + } + + + # gunzip the manual + $___process = GZ-Create "${___location}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function MANUAL-Is-Available { + # execute + $___process = GZ-Is-Available + if ($___process -eq 0) { + return 0 + } + + + # report status + return 1 +} diff --git a/automataCI/services/compilers/manual.sh b/automataCI/services/compilers/manual.sh new file mode 100644 index 0000000..b975aaa --- /dev/null +++ b/automataCI/services/compilers/manual.sh @@ -0,0 +1,100 @@ +#!/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/compress/gz.sh" + + + + +MANUAL_Create() { + ___location="$1" + ___sku="$2" + ___name="$3" + ___email="$4" + ___website="$5" + + + # validate input + if [ $(STRINGS_Is_Empty "$___location") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___sku") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___name") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___email") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___website") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___location" + if [ $? -eq 0 ]; then + return 1 + fi + + + # prepare workspace + FS_Make_Housing_Directory "$___location" + FS_Remove_Silently "$___location" + FS_Remove_Silently "${___location}.gz" + + + # create basic level 1 man page that instruct users to seek --help + FS_Write_File "${___location}" "\ +.\" ${___sku} - Lv1 Manpage +.TH man 1 \"${___sku} man page\" + +.SH NAME +${___sku} - Getting help + +.SH SYNOPSIS +command: $ ./${___sku} help + +.SH DESCRIPTION +This is a backward-compatible auto-generated system-level manual page. To make +sure you get the required and proper assistances from the software, please make +sure you call the command above. + +.SH SEE ALSO +Please visit ${___website} for more info. + +.SH AUTHORS +Contact: ${___name} <${___email}> +" + if [ $? -ne 0 ]; then + return 0 + fi + + + # gunzip the manual + GZ_Create "$___location" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +MANUAL_Is_Available() { + # execute + GZ_Is_Available + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} diff --git a/automataCI/services/compilers/msi.ps1 b/automataCI/services/compilers/msi.ps1 new file mode 100644 index 0000000..4b032a3 --- /dev/null +++ b/automataCI/services/compilers/msi.ps1 @@ -0,0 +1,157 @@ +# 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\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\publishers\dotnet.ps1" +. "${env:LIBS_AUTOMATACI}\services\publishers\microsoft.ps1" + + + + +function MSI-Compile { + param ( + [string]$___target, + [string]$___arch, + [string]$___lang + ) + + + # validate input + $___process = MSI-Is-Available + if ($___process -ne 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + $___arch = MICROSOFT-Get-Arch "${___arch}" + if ($(STRINGS-Is-Empty "${___arch}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${___lang}") -eq 0) { + return 1 + } + + + # execute + $___arguments = "build " ` + + "-arch ${___arch} " ` + + "-culture ${___lang} " ` + + "-out `"" + $(FS-Extension-Replace "${___target}" ".wxs" ".msi") + "`" " + + $___extensions = $(Split-Path -Parent -Path "${___target}") + "\ext" + $___process = FS-Is-Directory "${___extensions}" + if ($___process -eq 0) { + foreach ($___ext in (Get-ChildItem "${___extensions}" -Filter "*.dll")) { + $___arguments += "-ext ${___ext} " + } + } + $___arguments += "`"${___target}`" " + + $___process = OS-Exec "wix" "${___arguments}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function MSI-Install-Silent() { + param( + [string]$___installer + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___installer}") -eq 0) { + return 1 + } + + if ($(FS-Is-File "${___installer}") -ne 0) { + return 1 + } + + if ($(FS-Is-Target-A-MSI "${___installer}") -ne 0) { + return 1 + } + + + # execute + try { + $null = Start-Process -FilePath "${___installer}" ` + -ArgumentList "/qn /norestart" ` + -Wait + } catch { + return 1 + } + + + # report status + return 0 +} + + + + +function MSI-Is-Available { + # execute + $___process = DOTNET-Activate-Environment + if ($___process -ne 0) { + return 1 + } + + + $___process = OS-Is-Command-Available "wix" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function MSI-Setup { + # validate input + $___process = MSI-Is-Available + if ($___process -eq 0) { + return 0 + } + + + # execute + $___process = DOTNET-Install "wix" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/msi.sh b/automataCI/services/compilers/msi.sh new file mode 100644 index 0000000..b361a8d --- /dev/null +++ b/automataCI/services/compilers/msi.sh @@ -0,0 +1,135 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/publishers/microsoft.sh" + + + + +MSI_Compile() { + #___target="$1" + #___arch="$2" + + + # validate input + MSI_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + ___arch="$(MICROSOFT_Get_Arch "$2")" + if [ -z "$___arch" ]; then + return 1 + fi + + + # execute + wixl --verbose --arch "${___arch}" --output "${1%.wxs*}.msi" "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +MSI_Install_Silent() { + #___installer="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + if [ $(FS_Is_File "$1") -ne 0 ]; then + return 1 + fi + + if [ $(FS_Is_Target_A_MSI "$1") -ne 0 ]; then + return 1 + fi + + + # execute + $1 /qn /norestart + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +MSI_Is_Available() { + # execute + OS_Is_Command_Available "wixl" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "wixl-heat" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +MSI_Setup() { + # validate input + OS_Is_Command_Available "brew" + if [ $? -ne 0 ]; then + return 1 + fi + + MSI_Is_Available + if [ $? -eq 0 ]; then + return 0 + fi + + + # execute + brew install msitools + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/nim.ps1 b/automataCI/services/compilers/nim.ps1 new file mode 100644 index 0000000..03d2668 --- /dev/null +++ b/automataCI/services/compilers/nim.ps1 @@ -0,0 +1,457 @@ +# 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\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\sync.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + + + + +function NIM-Activate-Local-Environment { + # validate input + $___process = NIM-Is-Available + if ($___process -ne 0) { + return 1 + } + + $___process = NIM-Is-Localized + if ($___process -eq 0) { + return 0 + } + + + # execute + $___location = "$(NIM-Get-Activator-Path)" + if ($(FS-Is-File "${___location}") -ne 0) { + return 1 + } + + . $___location + + $___process = NIM-Is-Localized + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function NIM-Check-Package { + param( + [string]$___directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___directory}") -eq 0) { + return 1 + } + + + # execute + $___current_path = Get-Location + $null = Set-Location "${___directory}" + $___process = OS-Exec "nimble" "check" + $null = Set-Location "${___current_path}" + $null = Remove-Variable ___current_path + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function NIM-Get-Activator-Path { + return "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}\${env:PROJECT_PATH_NIM_ENGINE}\Activate.ps1" +} + + + + +function NIM-Is-Available { + # execute + $null = OS-Sync + + $___process = OS-Is-Command-Available "nim" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Is-Command-Available "nimble" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function NIM-Is-Localized { + # execute + if ($(STRINGS-Is-Empty "${env:PROJECT_NIM_LOCALIZED}") -ne 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function NIM-Run-Parallel { + param( + [string]$___line + ) + + + # initialize libraries from scratch + . "${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" + + + # parse input + $___list = $___line.Split("|") + $___mode = $___list[0] + $___directory_source = $___list[1] + $___directory_workspace = $___list[2] + $___directory_log = $___list[3] + $___target = $___list[4] + $___target_os = $___list[5] + $___target_arch = $___list[6] + $___arguments = $___list[7] + + + # validate input + if (($(STRINGS-Is-Empty "${___mode}") -eq 0) -or + ($(STRINGS-Is-Empty "${___directory_source}") -eq 0) -or + ($(STRINGS-Is-Empty "${___directory_workspace}") -eq 0) -or + ($(STRINGS-Is-Empty "${___directory_log}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target_os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target_arch}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arguments}") -eq 0)) { + return 1 + } + + $___mode = "$(STRINGS-To-Lowercase "${___mode}")" + switch ("${___mode}") { + { $_ -in "build", "test" } { + # accepted + } default { + return 1 + }} + + $___target = FS-Get-Path-Relative "${___target}" "${___directory_source}" + $___directory_target = "$(FS-Get-Directory "${___target}")" + $___file_target = "$(FS-Get-File "${___target}")" + + $___file_log = "${___directory_log}" + $___file_output = "${___directory_workspace}" + if ("${___directory_target}" -ne "${___file_target}") { + # there are sub-directories + $___file_log = "${___file_log}\${___directory_target}" + $___file_output = "${___file_output}\${___directory_target}" + } + + $___file_target = "$(FS-Extension-Remove "${___file_target}" "*")" + if ("${___mode}" -eq "test") { + $___file_log = "${___file_log}\${___file_target}_test.log" + } else { + $___file_log = "${___file_log}\${___file_target}_build.log" + } + $null = FS-Make-Housing-Directory "${___file_log}" + + $___file_output = "${___file_output}\${___file_target}" + switch ("${___target_os}") { + "windows" { + $___file_output = "${___file_output}.exe" + } default { + $___file_output = "${___file_output}.elf" + }} + $null = FS-Make-Housing-Directory "${___file_output}" + + if ("${___mode}" -eq "test") { + $null = I18N-Test "${___file_output}" *>> "${___file_log}" + if ("${___target_os}" -ne "${env:PROJECT_OS}") { + $null = I18N-Test-Skipped *>> "${___file_log}" + return 10 # skipped - cannot operate in host environment + } + + $($___process = FS-Is-File "${___file_output}") *> "${___file_log}" + if ($___process -ne 0) { + $null = I18N-Test-Failed *>> "${___file_log}" + return 1 # failed - build stage + } + + $___process = OS-Exec ` + "${___file_output}" ` + "" ` + "$(FS-Extension-Remove "${___file_log}" ".log")-stdout.log" ` + "$(FS-Extension-Remove "${___file_log}" ".log")-stderr.log" + if ($___process -ne 0) { + $null = I18N-Test-Failed *>> "${___file_log}" + return 1 # failed - test stage + } + + + # report status (test mode) + return 0 + } + + + # operate in build mode + $___arguments = @" +${___arguments} --out:${___file_output} ${___directory_source}\${___target} +"@ + $___process = OS-Exec ` + "nim" ` + "${___arguments}" ` + "$(FS-Extension-Remove "${___file_log}" ".log")-stdout.log" ` + "$(FS-Extension-Remove "${___file_log}" ".log")-stderr.log" + if ($___process -ne 0) { + $null = I18N-Build-Failed *>> "${___file_log}" + return 1 + } + + + # report status (build mode) + return 0 +} + + + + +function NIM-Run-Test { + param( + [string]$___directory, + [string]$___os, + [string]$___arch, + [string]$___arguments + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arguments}") -eq 0)) { + return 1 + } + + $___process = NIM-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___workspace = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\test-${env:PROJECT_NIM}" + $___log = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_LOG}\test-${env:PROJECT_NIM}" + $___build_list = "${___workspace}\build-list.txt" + $___test_list = "${___workspace}\test-list.txt" + $null = FS-Remake-Directory "${___workspace}" + $null = FS-Remake-Directory "${___log}" + + ## (1) Scan for all test files + foreach ($__line in (Get-ChildItem -Path "${___directory}" ` + -Recurse ` + -Filter "*_test.nim").FullName) { + $___process = FS-Append-File "${___build_list}" @" +build|${___directory}|${___workspace}|${___log}|${__line}|${___os}|${___arch}|${___arguments} +"@ + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Append-File "${___test_list}" @" +test|${___directory}|${___workspace}|${___log}|${__line}|${___os}|${___arch}|${___arguments} +"@ + if ($___process -ne 0) { + return 1 + } + } + + ## (2) Bail early if test is unavailable + $___process = FS-Is-File "${___build_list}" + if ($___process -ne 0) { + return 0 + } + + $___process = FS-Is-File "${___test_list}" + if ($___process -ne 0) { + return 0 + } + + ## (3) Build all test artifacts + $___process = SYNC-Exec-Parallel ` + ${function:NIM-Run-Parallel}.ToString() ` + "${___build_list}" ` + "${___workspace}" + if ($___process -ne 0) { + return 1 + } + + ## (4) Execute all test artifacts + $___process = SYNC-Exec-Parallel ` + ${function:NIM-Run-Parallel}.ToString() ` + "${___test_list}" ` + "${___workspace}" + if ($___process -ne 0) { + return 1 + } + + # report status + return 0 +} + + + + +function NIM-Setup { + # validate input + $___process = NIM-Is-Available + if ($___process -eq 0) { + return 0 + } + + $___process = OS-Is-Command-Available "choco" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "choco" "install nim -y" + if ($___process -ne 0) { + return 1 + } + $null = OS-Sync + + + # report status + return 0 +} + + + + +function NIM-Setup-Local-Environment { + # validate input + $___process = NIM-Is-Localized + if ($___process -eq 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_PATH_ROOT}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_PATH_TOOLS}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_PATH_NIM_ENGINE}") -eq 0) { + return 1 + } + + $null = OS-Exec + $___process = NIM-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___label = "($env:PROJECT_PATH_NIM_ENGINE)" + $___location = "$(NIM-Get-Activator-Path)" + + $null = FS-Make-Housing-Directory "${___location}" + $null = FS-Write-File "${___location}" @" +if (-not (Get-Command "nim" -ErrorAction SilentlyContinue)) { + Write-Error "[ ERROR ] missing nim compiler." + return +} + +if (-not (Get-Command "nimble" -ErrorAction SilentlyContinue)) { + Write-Error "[ ERROR ] missing nimble package manager." + return +} + +function deactivate { + if ([string]::IsNullOrEmpty(`$env:old_NIMBLE_DIR)) { + `${env:NIMBLE_DIR} = `$null + `${env:old_NIMBLE_DIR} = `$null + } else { + `${env:NIMBLE_DIR} = "`${env:old_NIMBLE_DIR}" + `${env:old_NIMBLE_DIR} = `$null + } + `${env:PROJECT_NIM_LOCALIZED} = `$null + Copy-Item -Path Function:_OLD_PROMPT -Destination Function:prompt + Remove-Item -Path Function:_OLD_PROMPT +} + + +# check existing +if (-not [string]::IsNullOrEmpty(`${env:PROJECT_NIM_LOCALIZED})) { + return +} + + +# activate +`$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") `` + + ";" `` + + [System.Environment]::GetEnvironmentVariable("Path","User") +`${env:old_NIMBLE_DIR} = "`${NIMBLE_DIR}" +`${env:NIMBLE_DIR} = "$(FS-Get-Directory "${___location}")" +`${env:PROJECT_NIM_LOCALIZED} = "${___location}" +Copy-Item -Path function:prompt -Destination function:_OLD_PROMPT +function global:prompt { + Write-Host -NoNewline -ForegroundColor Green "(${___label}) " + _OLD_VIRTUAL_PROMPT +} +"@ + $___process = FS-Is-File "${___location}" + if ($___process -ne 0) { + return 1 + } + + + # testing the activation + $___process = NIM-Activate-Local-Environment + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/nim.sh b/automataCI/services/compilers/nim.sh new file mode 100644 index 0000000..5d6fab0 --- /dev/null +++ b/automataCI/services/compilers/nim.sh @@ -0,0 +1,450 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/io/sync.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + + + + +NIM_Activate_Local_Environment() { + # validate input + NIM_Is_Available + if [ $? -ne 0 ] ; then + return 1 + fi + + NIM_Is_Localized + if [ $? -eq 0 ] ; then + return 0 + fi + + + # execute + ___location="$(NIM_Get_Activator_Path)" + FS_Is_File "$___location" + if [ $? -ne 0 ]; then + return 1 + fi + + . "$___location" + + NIM_Is_Localized + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NIM_Check_Package() { + #___directory="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + + # execute + ___current_path="$PWD" && cd "$1" + nimble check + ___process=$? + cd "$___current_path" && unset ___current_path + if [ $___process -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NIM_Get_Activator_Path() { + printf -- "%b" "${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/${PROJECT_PATH_NIM_ENGINE}/activate.sh" +} + + + + +NIM_Is_Available() { + # execute + OS_Sync + + OS_Is_Command_Available "nim" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "nimble" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NIM_Is_Localized() { + # execute + if [ $(STRINGS_Is_Empty "$PROJECT_NIM_LOCALIZED") -ne 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +NIM_Run_Parallel() { + #___line="$1" + + + # parse input + ___mode="${1%%|*}" + ___arguments="${1#*|}" + + ___directory_source="${___arguments%%|*}" + ___arguments="${___arguments#*|}" + + ___directory_workspace="${___arguments%%|*}" + ___arguments="${___arguments#*|}" + + ___directory_log="${___arguments%%|*}" + ___arguments="${___arguments#*|}" + + ___target="${___arguments%%|*}" + ___arguments="${___arguments#*|}" + + ___target_os="${___arguments%%|*}" + ___arguments="${___arguments#*|}" + + ___target_arch="${___arguments%%|*}" + ___arguments="${___arguments#*|}" + + + # validate input + if [ $(STRINGS_Is_Empty "$___mode") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___directory_source") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___directory_workspace") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___directory_log") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___target") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___target_os") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___target_arch") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___arguments") -eq 0 ]; then + return 1 + fi + + ___mode="$(STRINGS_To_Lowercase "$___mode")" + case "$___mode" in + build|test) + # accepted + ;; + *) + return 1 + ;; + esac + + ___target="$(FS_Get_Path_Relative "$___target" "$___directory_source")" + ___directory_target="$(FS_Get_Directory "$___target")" + ___file_target="$(FS_Get_File "$___target")" + + ___file_log="$___directory_log" + ___file_output="$___directory_workspace" + if [ ! "$___directory_target" = "$___file_target" ]; then + # there are sub-directories + ___file_log="${___file_log}/${___directory_target}" + ___file_output="${___file_output}/${___directory_target}" + fi + + ___file_target="$(FS_Extension_Remove "$___file_target" "*")" + if [ "$___mode" = "test" ]; then + ___file_log="${___file_log}/${___file_target}_test.log" + else + ___file_log="${___file_log}/${___file_target}_build.log" + fi + FS_Make_Housing_Directory "$___file_log" + + ___file_output="${___file_output}/${___file_target}" + case "$___target_os" in + windows) + ___file_output="${___file_output}.exe" + ;; + *) + ___file_output="${___file_output}.elf" + ;; + esac + FS_Make_Housing_Directory "$___file_output" + + if [ "$___mode" = "test" ]; then + I18N_Test "$___file_output" >> "$___file_log" 2>&1 + if [ ! "$___target_os" = "$PROJECT_OS" ]; then + I18N_Test_Skipped >> "$___file_log" 2>&1 + return 10 # skipped - cannot operate in host environment + fi + + FS_Is_File "$___file_output" + if [ $? -ne 0 ]; then + I18N_Test_Failed >> "$___file_log" 2>&1 + return 1 # failed - build stage + fi + + $___file_output >> "$___file_log" 2>&1 + if [ $? -ne 0 ]; then + I18N_Test_Failed >> "$___file_log" 2>&1 + return 1 # failed - test stage + fi + + + # report status (test mode) + return 0 + fi + + + # operate in build mode + ___command="\ +nim ${___arguments} --out:${___file_output} ${___directory_source}/${___target} +" + + + # execute + I18N_Build "$___command" >> "$___file_log" 2>&1 + $___command >> "$___file_log" 2>&1 + if [ $? -ne 0 ]; then + I18N_Build_Failed >> "$___file_log" 2>&1 + return 1 + fi + + + # report status (build mode) + return 0 +} + + + + +NIM_Run_Test() { + ___directory="$1" + ___os="$2" + ___arch="$3" + ___arguments="$4" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___os") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___arch") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___arguments") -eq 0 ]; then + return 1 + fi + + NIM_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___workspace="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/test-${PROJECT_NIM}" + ___log="${PROJECT_PATH_ROOT}/${PROJECT_PATH_LOG}/test-${PROJECT_NIM}" + ___build_list="${___workspace}/build-list.txt" + ___test_list="${___workspace}/test-list.txt" + FS_Remake_Directory "$___workspace" + FS_Remake_Directory "$___log" + + ## (1) Scan for all test files + __old_IFS="$IFS" + find "$___directory" -name '*_test.nim' -printf "%p\n" \ + | while IFS= read -r __line || [ -n "$__line" ]; do + FS_Append_File "$___build_list" "\ +build|${___directory}|${___workspace}|${___log}|${__line}|${___os}|${___arch}|${___arguments} +" + if [ $? -ne 0 ]; then + return 1 + fi + FS_Append_File "$___test_list" "\ +test|${___directory}|${___workspace}|${___log}|${__line}|${___os}|${___arch}|${___arguments} +" + if [ $? -ne 0 ]; then + return 1 + fi + done + IFS="$__old_IFS" && unset __old_IFS + + ## (2) Bail early if test is unavailable + FS_Is_File "$___build_list" + if [ $? -ne 0 ]; then + return 0 + fi + + FS_Is_File "$___test_list" + if [ $? -ne 0 ]; then + return 0 + fi + + ## (3) Build all test artifacts + SYNC_Exec_Parallel "NIM_Run_Parallel" "$___build_list" "$___workspace" + if [ $? -ne 0 ]; then + return 1 + fi + + ## (4) Execute all test artifacts + SYNC_Exec_Parallel "NIM_Run_Parallel" "$___test_list" "$___workspace" + if [ $? -ne 0 ]; then + return 1 + fi + + + # Report status + return 0 +} + + + + +NIM_Setup() { + # validate input + NIM_Is_Available + if [ $? -eq 0 ]; then + return 0 + fi + + OS_Is_Command_Available "brew" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + brew install nim + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NIM_Setup_Local_Environment() { + # validate input + NIM_Is_Localized + if [ $? -eq 0 ] ; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_PATH_ROOT") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_PATH_TOOLS") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_PATH_NIM_ENGINE") -eq 0 ]; then + return 1 + fi + + NIM_Is_Available + if [ $? -ne 0 ] ; then + return 1 + fi + + + # execute + ___label="($PROJECT_PATH_NIM_ENGINE)" + ___location="$(NIM_Get_Activator_Path)" + + if [ -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then + ___brew="eval \$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + elif [ -f "/usr/local/bin/brew" ]; then + ___brew="eval \$(/usr/local/bin/brew shellenv)" + else + ___brew="" + fi + + FS_Make_Housing_Directory "$___location" + FS_Write_File "$___location" "\ +#!/bin/sh +if [ -z \"\$(type -t 'nim')\" ]; then + 1>&2 printf -- '[ ERROR ] missing nim compiler.\\\\n' + return 1 +fi + +if [ -z \"\$(type -t 'nimble')\" ]; then + 1>&2 printf -- '[ ERROR ] missing nimble package manager.\\\\n' + return 1 +fi + +deactivate() { + if [ -z \"\$old_NIMBLE_DIR\" ]; then + unset old_NIMBLE_DIR NIMBLE_DIR + else + NIMBLE_DIR=\"\$old_NIMBLE_DIR\" + unset old_NIMBLE_DIR + fi + export PS1=\"\${PS1##*${___label} }\" + unset PROJECT_NIM_LOCALIZED + return 0 +} + +# check +if [ ! -z \"\$PROJECT_NIM_LOCALIZED\" ]; then + return 0 +fi + +# activate +${___brew} +export old_NIMBLE_DIR=\"\$NIMBLE_DIR\" +export NIMBLE_DIR=\"$(FS_Get_Directory "${___location}")\" +export PROJECT_NIM_LOCALIZED='${___location}' +export PS1=\"${___label} \${PS1}\" +return 0 +" + FS_Is_File "${___location}" + if [ $? -ne 0 ]; then + return 1 + fi + + + # testing the activation + NIM_Activate_Local_Environment + if [ $? -ne 0 ] ; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/node.ps1 b/automataCI/services/compilers/node.ps1 new file mode 100644 index 0000000..8de6601 --- /dev/null +++ b/automataCI/services/compilers/node.ps1 @@ -0,0 +1,43 @@ +# 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" + + + + +function NODE-Setup { + # validate input + $null = OS-Sync + + $___process = OS-Is-Command-Available "npm" + if ($___process -eq 0) { + return 0 + } + + $___process = OS-Is-Command-Available "choco" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "choco" "install node -y" + if ($___process -ne 0) { + return 1 + } + + $null = OS-Sync + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/node.sh b/automataCI/services/compilers/node.sh new file mode 100644 index 0000000..349ed6f --- /dev/null +++ b/automataCI/services/compilers/node.sh @@ -0,0 +1,40 @@ +#!/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" + + + + +NODE_Setup() { + # validate input + OS_Is_Command_Available "npm" + if [ $? -eq 0 ]; then + return 0 + fi + + OS_Is_Command_Available "brew" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + brew install node + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/python.ps1 b/automataCI/services/compilers/python.ps1 new file mode 100644 index 0000000..8d36b8d --- /dev/null +++ b/automataCI/services/compilers/python.ps1 @@ -0,0 +1,500 @@ +# 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\io\strings.ps1" + + + + +function PYTHON-Activate-VENV { + # validate input + $___process = PYTHON-Is-VENV-Activated + if ($___process -eq 0) { + return 0 + } + + + # execute + $___location = "$(PYTHON-Get-Activator-Path)" + $___process = FS-Is-File "${___location}" + if ($___process -ne 0) { + return 1 + } + + . $___location + $___process = PYTHON-Is-VENV-Activated + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function PYTHON-Check-PYPI-Login { + # execute + if (($(STRINGS-Is-Empty "${env:TWINE_USERNAME}") -eq 0) -or + ($(STRINGS-Is-Empty "${env:TWINE_PASSWORD}") -eq 0)) { + return 1 + } + + + # report status + return 0 +} + + + + +function PYTHON-Clean-Artifact { + param ( + [string]$___target + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___target}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $null = Get-ChildItem -Path "${___target}" -Recurse ` + | Where-Object {$_.Name -match "__pycache__|\.pyc$" } ` + | Remove-Item -Force -Recurse + + + # report status + return 0 +} + + + + +function PYTHON-Create-PYPI-Archive { + param ( + [string]$___directory, + [string]$___destination + ) + + + # valdiate input + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___destination}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___directory}\pyproject.toml" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Directory "${___destination}" + if ($___process -ne 0) { + return 1 + } + + $___process = PYTHON-PYPI-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # construct archive + $___current_path = Get-Location + Set-Location -Path $___directory + + $___process = OS-Exec "python" "-m build --sdist --wheel ${___directory}\." + if ($___process -ne 0) { + Set-Location -Path $___current_path + Remove-Variable -Name ___current_path + return 1 + } + + $___process = OS-Exec "twine" "check `"${___directory}\dist\*`"" + if ($___process -ne 0) { + Set-Location -Path $___current_path + Remove-Variable -Name ___current_path + return 1 + } + Set-Location -Path $___current_path + Remove-Variable -Name ___current_path + + + # export to destination + foreach ($___file in (Get-ChildItem -Path "${___directory}\dist")) { + $___process = FS-Move "${___file}" "${___destination}" + if ($___process -ne 0) { + return 1 + } + } + + + # report status + return 0 +} + + + + +function PYTHON-Create-PYPI-Config { + param( + [string]$___directory, + [string]$___project_name, + [string]$___version, + [string]$___name, + [string]$___email, + [string]$___website, + [string]$___pitch, + [string]$___readme_path, + [string]$___readme_type, + [string]$___license + ) + + + # validate input + if ( + ($(STRINGS-Is-Empty "${___directory}") -eq 0 ) -or + ($(STRINGS-Is-Empty "${___project_name}") -eq 0 ) -or + ($(STRINGS-Is-Empty "${___version}") -eq 0 ) -or + ($(STRINGS-Is-Empty "${___name}") -eq 0 ) -or + ($(STRINGS-Is-Empty "${___email}") -eq 0 ) -or + ($(STRINGS-Is-Empty "${___website}") -eq 0 ) -or + ($(STRINGS-Is-Empty "${___pitch}") -eq 0 ) -or + ($(STRINGS-Is-Empty "${___readme_path}") -eq 0 ) -or + ($(STRINGS-Is-Empty "${___readme_type}") -eq 0 ) -or + ($(STRINGS-Is-Empty "${___license}") -eq 0 )) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___directory}\${___readme_path}" + if ($___process -ne 0) { + return 1 + } + + + # check existing overriding file + $___process = FS-Is-File "${___directory}\pyproject.toml" + if ($___process -eq 0) { + return 2 + } + + + # create default file + $___process = FS-Write-File "${___directory}\pyproject.toml" @" +[build-system] +requires = [ 'setuptools' ] +build-backend = 'setuptools.build_meta' + +[project] +name = '${___project_name}' +version = '${___version}' +description = '${___pitch}' + +[project.license] +text = '${___license}' + +[project.readme] +file = '${___readme_path}' +'content-type' = '${___readme_type}' + +[[project.authors]] +name = '${___name}' +email = '${___email}' + +[[project.maintainers]] +name = '${___name}' +email = '${___email}' + +[project.urls] +Homepage = '${___website}' +"@ + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function PYTHON-Get-Activator-Path { + return "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}\${env:PROJECT_PATH_PYTHON_ENGINE}\Scripts\Activate.ps1" +} + + + + +function PYTHON-Has-PIP { + return OS-Is-Command-Available "pip" +} + + + + +function PYTHON-Is-Available { + # execute + $null = OS-Sync + + $___process = OS-Is-Command-Available "python3" + if ($___process -eq 0) { + return 0 + } + + $___process = OS-Is-Command-Available "python" + if ($___process -eq 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function PYTHON-Is-Valid-PYPI { + param( + [string]$___target + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___target}" + if ($___process -ne 0) { + return 1 + } + + $___process = STRINGS-Has-Prefix "pypi" (Split-Path -Leaf -Path "${___target}") + if ($___process -ne 0) { + return 1 + } + + + # execute + $___hasWHL = $false + $___hasTAR = $false + foreach ($___file in (Get-ChildItem -Path ${___target})) { + if ($___file.Extension -eq ".whl") { + $___hasWHL = $true + } elseif ($___file.Extension -like ".tar.*") { + $___hasTAR = $true + } + } + if ($___hasWHL -and $___hasTAR) { + return 0 + } + + + # report status + return 1 +} + + + + +function PYTHON-Is-VENV-Activated { + # execute + if ($(STRINGS-Is-Empty "${env:VIRTUAL_ENV}") -ne 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function PYTHON-PYPI-Is-Available { + # validate input + if ($(STRINGS-Is-Empty "${env:PROJECT_PYTHON}") -eq 0) { + return 1 + } + + + # execute + if ($(PYTHON-Is-VENV-Activated) -ne 0) { + return 1 + } + + if ($(OS-Is-Command-Available "twine") -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function PYTHON-Release-PYPI { + param( + [string]$___target, + [string]$___gpg, + [string]$___url + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___gpg}") -eq 0) -or + ($(STRINGS-Is-Empty "${___url}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___target}" + if ($___process -ne 0) { + return 1 + } + + $___process = PYTHON-PYPI-Is-Available + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Exec "twine" "check ${___target}\*" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___arguments = "upload " ` + + "--sign " ` + + "--identity `"${___gpg}`" " ` + + "--repository-url `"${___url}`" " ` + + "--non-interactive" + $___process = OS-Exec "twine" "${___arguments}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function PYTHON-Setup { + # validate input + $___process = OS-Is-Command-Available "choco" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Is-Command-Available "python" + if ($___process -eq 0) { + return 0 + } + + $___process = OS-Is-Command-Available "python3" + if ($___process -eq 0) { + return 0 + } + + + # execute + $___process = OS-Exec "choco" "install python -y" + if ($___process -ne 0) { + return 1 + } + $null = OS-Sync + + $___process = PYTHON-Setup-VENV + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function PYTHON-Setup-VENV { + # validate input + if (($(STRINGS-Is-Empty "${env:PROJECT_PATH_ROOT}") -eq 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_PATH_TOOLS}") -eq 0) -or + ($(STRINGS-Is-Empty "${env:PROJECT_PATH_PYTHON_ENGINE}") -eq 0)) { + return 1 + } + + $___process = PYTHON-Activate-VENV + if ($___process -eq 0) { + # already available + return 0 + } + + + # execute + $___program = "" + if ($(OS-Is-Command-Available "python3") -eq 0) { + $___program = "python3" + } elseif ($(OS-Is-Command-Available "python") -eq 0) { + $___program = "python" + } else { + return 1 + } + + $___location = "${env:PROJECT_PATH_ROOT}" ` + + "\${env:PROJECT_PATH_TOOLS}" ` + + "\${env:PROJECT_PATH_PYTHON_ENGINE}" + $___process = OS-Exec "${___program}" "-m venv `"${___location}`"" + if ($___process -ne 0) { + return 1 + } + + $___process = PYTHON-Activate-VENV + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/python.sh b/automataCI/services/compilers/python.sh new file mode 100644 index 0000000..22bbf3d --- /dev/null +++ b/automataCI/services/compilers/python.sh @@ -0,0 +1,491 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +PYTHON_Activate_VENV() { + # validate input + PYTHON_Is_VENV_Activated + if [ $? -eq 0 ] ; then + return 0 + fi + + + # execute + ___location="$(PYTHON_Get_Activator_Path)" + FS_Is_File "$___location" + if [ $? -ne 0 ]; then + return 1 + fi + + . "$___location" + PYTHON_Is_VENV_Activated + if [ $? -ne 0 ] ; then + return 1 + fi + + + # report status + return 0 +} + + + + +PYTHON_Check_PYPI_Login() { + # execute + if [ $(STRINGS_Is_Empty "$TWINE_USERNAME") -eq 0 ] || + [ $(STRINGS_Is_Empty "$TWINE_PASSWORD") -eq 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +PYTHON_Clean_Artifact() { + #___target="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "find" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + find "$1" | grep -E "(__pycache__|\.pyc$)" | xargs rm -rf &> /dev/null + + + # report status + return 0 +} + + + + +PYTHON_Create_PYPI_Archive() { + ___directory="$1" + ___destination="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___destination") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "${___directory}/pyproject.toml" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "$___destination" + if [ $? -ne 0 ]; then + return 1 + fi + + PYTHON_PYPI_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # construct archive + ___current_path="$PWD" && cd "$___directory" + python -m build --sdist --wheel . + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + twine check "${___directory}/dist/"* + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + cd "$___current_path" && unset ___current_path + + + # export to destination + for ___file in "${___directory}/dist/"*; do + FS_Move "$___file" "$___destination" + if [ $? -ne 0 ]; then + return 1 + fi + done + + + # report status + return 0 +} + + + + +PYTHON_Create_PYPI_Config() { + ___directory="$1" + ___project_name="$2" + ___version="$3" + ___name="$4" + ___email="$5" + ___website="$6" + ___pitch="$7" + ___readme_path="$8" + ___readme_type="$9" + ___license="${10}" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___project_name") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___version") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___name") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___email") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___website") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___pitch") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___readme_path") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___readme_type") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___license") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "${___directory}/${___readme_path}" + if [ $? -ne 0 ]; then + return 1 + fi + + + # check existing overriding file + FS_Is_File "${___directory}/pyproject.toml" + if [ $? -eq 0 ]; then + return 2 + fi + + + # create default file + FS_Write_File "${___directory}/pyproject.toml" "\ +[build-system] +requires = [ 'setuptools' ] +build-backend = 'setuptools.build_meta' + +[project] +name = '${___project_name}' +version = '${___version}' +description = '${___pitch}' + +[project.license] +text = '${___license}' + +[project.readme] +file = '${___readme_path}' +'content-type' = '${___readme_type}' + +[[project.authors]] +name = '${___name}' +email = '${___email}' + +[[project.maintainers]] +name = '${___name}' +email = '${___email}' + +[project.urls] +Homepage = '${___website}' +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +PYTHON_Get_Activator_Path() { + ___location="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/${PROJECT_PATH_PYTHON_ENGINE}/bin/activate" + printf -- "$___location" + + + # report status + return 0 +} + + + + +PYTHON_Has_PIP() { + OS_Is_Command_Available "pip" + return $? +} + + + + +PYTHON_Is_Available() { + # execute + OS_Is_Command_Available "python3" + if [ $? -eq 0 ]; then + return 0 + fi + + OS_Is_Command_Available "python" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +PYTHON_Is_Valid_PYPI() { + #___target="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + STRINGS_Has_Prefix "pypi" "${1##*/}" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___hasWHL=false + ___hasTAR=false + for ___file in "${1}/"*; do + if [ ! "${___file%%.whl*}" = "${___file}" ]; then + ___hasWHL=true + elif [ ! "${___file%%.tar*}" = "${___file}" ]; then + ___hasTAR=true + fi + done + + if [ "$___hasWHL" = "true" ] && [ "$___hasTAR" = "true" ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +PYTHON_Is_VENV_Activated() { + # execute + if [ $(STRINGS_Is_Empty "$VIRTUAL_ENV") -ne 0 ] ; then + return 0 + fi + + + # report status + return 1 +} + + + + +PYTHON_PYPI_Is_Available() { + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_PYTHON") -eq 0 ]; then + return 1 + fi + + + # execute + PYTHON_Is_VENV_Activated + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "twine" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +PYTHON_Release_PYPI() { + ___target="$1" + ___gpg="$2" + ___url="$3" + + + # validate input + if [ $(STRINGS_Is_Empty "$___target") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___gpg") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___url") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___target" + if [ $? -ne 0 ]; then + return 1 + fi + + PYTHON_PYPI_Is_available + if [ $? -ne 0 ]; then + return 1 + fi + + twine check "${___target}/"* + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + twine upload "${___target}/"* \ + --sign \ + --identity "$___gpg" \ + --repository-url "$___url" \ + --non-interactive + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +PYTHON_Setup() { + # validate input + OS_Is_Command_Available "brew" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "python" + if [ $? -eq 0 ]; then + return 0 + fi + + OS_Is_Command_Available "python3" + if [ $? -eq 0 ]; then + return 0 + fi + + + # execute + brew install python + if [ $? -ne 0 ]; then + return 1 + fi + + PYTHON_Setup_VENV + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 1 +} + + + + +PYTHON_Setup_VENV() { + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_PATH_ROOT") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_PATH_TOOLS") -eq 0 ] || + [ $(STRINGS_Is_Empty "$PROJECT_PATH_PYTHON_ENGINE") -eq 0 ]; then + return 1 + fi + + PYTHON_Activate_VENV + if [ $? -eq 0 ]; then + # already available + return 0 + fi + + + # execute + ___program="" + if [ ! -z "$(type -t python3)" ]; then + ___program="python3" + elif [ ! -z "$(type -t python)" ]; then + ___program="python" + else + return 1 + fi + + ___location="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/${PROJECT_PATH_PYTHON_ENGINE}" + $___program -m venv "$___location" + if [ $? -ne 0 ]; then + return 1 + fi + + PYTHON_Activate_VENV + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/rpm.ps1 b/automataCI/services/compilers/rpm.ps1 new file mode 100644 index 0000000..b987e3d --- /dev/null +++ b/automataCI/services/compilers/rpm.ps1 @@ -0,0 +1,515 @@ +# 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\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\changelog.ps1" + + + + +function RPM-Create-Archive { + param ( + [string]$___directory, + [string]$___destination, + [string]$___arch + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___destination}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Directory "${___destination}" + if ($___process -ne 0) { + return 1 + } + + + # scan for spec file + $___spec = "" + foreach($___file in (Get-ChildItem -File -Path "${___directory}\SPECS")) { + $___spec = $___file.FullName + break + } + + $___process = FS-Is-File "${___spec}" + if ($___process -ne 0) { + return 1 + } + + + # archive into rpm + $___current_path = Get-Location + Set-Location -Path $___directory + $null = FS-Make-Directory ".\BUILD" + $null = FS-Make-Directory ".\BUILDROOT" + $null = FS-Make-Directory ".\RPMS" + $null = FS-Make-Directory ".\SOURCES" + $null = FS-Make-Directory ".\SPECS" + $null = FS-Make-Directory ".\SRPMCS" + $null = FS-Make-Directory ".\tmp" + $___arguments = "--define `"_topdir ${___directory}`" " + + "--define `"debug_package %{nil}`" " + + "--define `"__strip /bin/true`" " + + "--target `"${___arch}`" " + + "-ba `"${___spec}`"" + $___process = OS-Exec "rpmbuild" "${___arguments}" + Set-Location -Path $___current_path + Remove-Variable -Name ___current_path + + if ($___process -ne 0) { + return 1 + } + + + # move to destination + foreach($___package in (Get-ChildItem -Path "${___directory}/RPMS/${___arch}")) { + $null = FS-Remove-Silently "${___destination}\$($___package.Name)" + $null = FS-Move "${___package}" "${___destination}" + } + + + # report status + return 0 +} + + + + +function RPM-Create-Source-Repo { + param( + [string]$___is_simulated, + [string]$___directory, + [string]$___gpg_id, + [string]$___url, + [string]$___name, + [string]$___sku + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___is_simulated}") -ne 0) { + return 0 + } + + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(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 "${___sku}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___directory}\SPEC_INSTALL" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___directory}\SPEC_FILES" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___url = "${___url}/rpm" + $___url = $___url -replace "//rpm", "/rpm" + $___key = "usr\local\share\keyrings\${___sku}-keyring.gpg" + $___filename = "etc\yum.repos.d\${___sku}.repo" + + $___process = FS-Is-File ` + "${___directory}\BUILD\$(Split-Path -Leaf -Path "${___filename}")" + if ($___process -eq 0) { + return 10 + } + + $___process = FS-Is-File ` + "${___directory}\BUILD\$(Split-Path -Leaf -Path "${___key}")" + if ($___process -eq 0) { + return 1 + } + + $null = FS-Make-Directory "${___directory}\BUILD" + $___process = FS-Write-File ` + "${___directory}\BUILD\$(Split-Path -Leaf -Path "${___filename}")" @" +# WARNING: AUTO-GENERATED - DO NOT EDIT! +[${___sku}] +name=${___name} +baseurl=${___url} +gpgcheck=1 +gpgkey=file:///${___key} +"@ + if ($___process -ne 0) { + return 1 + } + + $___process = GPG-Export-Public-Keyring ` + "${___directory}\BUILD\$(Split-Path -Leaf -Path "${___key}")" ` + "${___gpg_id}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Append-File "${___directory}\SPEC_INSTALL" @" +install --directory %{buildroot}/$(Split-Path -Parent -Path "${___filename}") +install -m 0644 $(Split-Path -Leaf -Path "${___filename}") %{buildroot}/$(Split-Path -Parent -Path "${___filename}") + +install --directory %{buildroot}/$(Split-Path -Parent -Path "${___key}") +install -m 0644 $(Split-Path -Leaf -Path "${___key}") %{buildroot}/$(Split-Path -Parent -Path "${___key}") +"@ + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Append-File "${___directory}\SPEC_FILES" @" +/${___filename} +/${___key} +"@ + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function RPM-Create-Spec { + param( + [string]$___directory, + [string]$___resources, + [string]$___sku, + [string]$___version, + [string]$___cadence, + [string]$___pitch, + [string]$___name, + [string]$___email, + [string]$___website, + [string]$___license, + [string]$___description_filepath + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___resources}") -eq 0) -or + ($(STRINGS-Is-Empty "${___sku}") -eq 0) -or + ($(STRINGS-Is-Empty "${___version}") -eq 0) -or + ($(STRINGS-Is-Empty "${___cadence}") -eq 0) -or + ($(STRINGS-Is-Empty "${___pitch}") -eq 0) -or + ($(STRINGS-Is-Empty "${___name}") -eq 0) -or + ($(STRINGS-Is-Empty "${___email}") -eq 0) -or + ($(STRINGS-Is-Empty "${___website}") -eq 0) -or + ($(STRINGS-Is-Empty "${___license}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Directory "${___resources}" + if ($___process -ne 0) { + return 1 + } + + + # check if is the document already injected + $___location = "${__directory}\SPECS\${__sku}.spec" + $___process = FS-Is-File "${___location}" + if ($___process -eq 0) { + return 2 + } + + + # create housing directory path + $null = FS-Make-Housing-Directory "${___location}" + + + # generate spec file's header + $null = FS-Write-File "${___location}" @" +Name: ${___sku} +Version: ${___version} +Summary: ${___pitch} +Release: ${___cadence} + +License: ${___license} +URL: ${___website} +"@ + + + # generate spec file's description field + $null = FS-Append-File "${___location}" "%%description`n" + + $___written = 1 + $___process = FS-Is-File "${___directory}\SPEC_DESCRIPTION" + if ($___process -eq 0) { + foreach($___line in Get-Content "${___directory}\SPEC_DESCRIPTION") { + if (($(STRINGS-Is-Empty "${___line}") -ne 0) -and + ($(STRINGS-Is-Empty "$($___line -replace "#.*$")") -eq 0)) { + continue + } + + $___line = $___line -replace '#.*' + $null = FS-Append-File $___location "${___line}`n" + } + + $null = FS-Remove-Silently "${___directory}\SPEC_DESCRIPTION" + $___written = 0 + } + + $___process = FS-Is-File "${___description_filepath}" + if (($___process -eq 0) -and ($___written -ne 0)) { + foreach($___line in Get-Content "${___description_filepath}") { + if (($(STRINGS-Is-Empty "${___line}") -ne 0) -and + ($(STRINGS-Is-Empty "$($___line -replace "#.*$")") -eq 0)) { + continue + } + + $___line = $___line -replace '#.*' + $null = FS-Append-File "${___location}" "${___line}`n" + } + } + + if ($___written -ne 0) { + $null = FS-Append-File "${___location}" "`n" + } + + $null = FS-Append-File "${___location}" "`n" + + + # generate spec file's prep field + $null = FS-Append-File "${___location}" "%%prep`n" + $___process = FS-Is-File "${___directory}\SPEC_PREPARE" + if ($___process -eq 0) { + foreach($___line in Get-Content "${___directory}\SPEC_PREPARE") { + $___line = $_ -replace '#.*' + if ($(STRINGS-Is-Empty "${___line}") -eq 0) { + continue + } + + $null = FS-Append-File "${___location}" "${___line}`n" + } + + $null = FS-Remove-Silently "${___directory}\SPEC_PREPARE" + } else { + $null = FS-Append-File "${___location}" "`n" + } + $null = FS-Append-File "${___location}" "`n" + + + # generate spec file's build field + $null = FS-Append-File "${___location}" "%%build`n" + $___process = FS-Is-File "${___directory}\SPEC_BUILD" + if ($___process -eq 0) { + foreach($___line in Get-Content "${___directory}\SPEC_BUILD") { + $___line = $_ -replace '#.*' + if ($(STRINGS-Is-Empty "${___line}") -eq 0) { + continue + } + + $null = FS-Append-File "${___location}" "${___line}`n" + } + + $null = FS-Remove-Silently "${___directory}\SPEC_BUILD" + } else { + $null = FS-Append-File "${___location}" "`n" + } + $null = FS-Append-File "${___location}" "`n" + + + # generate spec file's install field + $null = FS-Append-File "${___location}" "%%install`n" + $___process = FS-Is-File "${___directory}\SPEC_INSTALL" + if ($___process -eq 0) { + foreach ($___line in Get-Content "${___directory}\SPEC_INSTALL") { + $___line = $_ -replace '#.*' + if ($(STRINGS-Is-Empty "${___line}") -eq 0) { + continue + } + + $null = FS-Append-File "${___location}" "${___line}`n" + } + + $null = FS-Remove-Silently "${___directory}\SPEC_INSTALL" + } else { + $null = FS-Append-File "${___location}" "`n" + } + $null = FS-Append-File "${___location}" "`n" + + + # generate spec file's clean field + $null = FS-Append-File "${___location}" "%%clean`n" + $___process = FS-Is-File "${___directory}\SPEC_CLEAN" + if ($___process -eq 0) { + foreach($___line in Get-Content "${___directory}\SPEC_CLEAN") { + $___line = $_ -replace '#.*' + if ($(STRINGS-Is-Empty "${___line}") -eq 0) { + continue + } + + $null = FS-Append-File "${___location}" "${___line}`n" + } + + $null = FS-Remove-Silently "${___directory}\SPEC_CLEAN" + } else { + $null = FS-Append-File "${___location}" "`n" + } + $null = FS-Append-File "${___location}" "`n" + + + # generate spec file's files field + $null = FS-Append-File $___location "%%files`n" + $___process = FS-Is-File "${___directory}\SPEC_FILES" + if ($___process -eq 0) { + foreach($___line in Get-Content "${___directory}\SPEC_FILES") { + $___line = $_ -replace '#.*' + if ($(STRINGS-Is-Empty "${___line}") -eq 0) { + continue + } + + $null = FS-Append-File "${___location}" "${___line}`n" + } + + $null = FS-Remove-Silently "${__directory}\SPEC_CLEAN" + } else { + $null = FS-Append-File "${___location}" "`n" + } + $null = FS-Append-File "${___location}" "`n" + + + # generate spec file's changelog field + $___process = FS-Is-File "${___directory}\SPEC_CHANGELOG" + if ($___process -eq 0) { + $null = FS-Append-File "${___location}" "%%changelog`n" + + foreach($___line in Get-Content "${__directory}\SPEC_CHANGELOG") { + $___line = $_ -replace '#.*' + if ($(STRINGS-Is-Empty "${___line}") -eq 0) { + continue + } + + $null = FS-Append-File "${___location}" "${___line}`n" + } + + $null = FS-Remove-Silently "${___directory}\SPEC_CHANGELOG" + } else { + $___date = Get-Date -Format "ddd MMM dd yyyy" + $___process = CHANGELOG-Assemble-RPM ` + "${___location}" ` + "${___resources}" ` + "${___date}" ` + "${___name}" ` + "${___email}" ` + "${___version}" ` + 1 + if ($___process -ne 0) { + return 1 + } + } + + + # report status + return 0 +} + + + + +function RPM-Is-Available { + param( + [string]$___os, + [string]$___arch + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___os}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch}") -eq 0)) { + return 1 + } + + $___process = OS-Is-Command-Available "rpmbuild" + if ($___process -ne 0) { + return 1 + } + + + # check compatible target os + switch ($___os) { + { $_ -in "linux", "any" } { + break + } default { + return 2 + }} + + + # check compatible target cpu architecture + switch ($___arch) { + any { + return 3 + } default { + Break + }} + + + # report status + return 0 +} + + + + +function RPM-Is-Valid { + param ( + [string]$___target + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { + return 1 + } + + $___process = FS-Is-File "$1" + if ($___process -ne 0) { + return 1 + } + + + # execute + if ($(${__target} -split '\.')[-1] -eq "rpm") { + return 0 + } + + + # report status + return 1 +} diff --git a/automataCI/services/compilers/rpm.sh b/automataCI/services/compilers/rpm.sh new file mode 100644 index 0000000..ea7e947 --- /dev/null +++ b/automataCI/services/compilers/rpm.sh @@ -0,0 +1,526 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/compilers/changelog.sh" + + + + +RPM_Create_Archive() { + ___directory="$1" + ___destination="$2" + ___arch="$3" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___destination") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___arch") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "$___destination" + if [ $? -ne 0 ]; then + return 1 + fi + + + # scan for spec file + ___spec="" + for ___file in "${___directory}/SPECS/"*; do + FS_Is_File "$___file" + if [ $? -ne 0 ]; then + continue + fi + + ___spec="$___file" + break + done + + FS_Is_File "$___spec" + if [ $? -ne 0 ]; then + return 1 + fi + + + # archive into rpm + ___current_path="$PWD" && cd "${___directory}" + FS_Make_Directory "./BUILD" + FS_Make_Directory "./BUILDROOT" + FS_Make_Directory "./RPMS" + FS_Make_Directory "./SOURCES" + FS_Make_Directory "./SPECS" + FS_Make_Directory "./SRPMCS" + FS_Make_Directory "./tmp" + rpmbuild --define "_topdir ${___directory}" \ + --define "debug_package %{nil}" \ + --define "__strip /bin/true" \ + --target "$___arch" \ + -ba "$___spec" + ___process=$? + cd "$___current_path" && unset ___current_path + + if [ $___process -ne 0 ]; then + return 1 + fi + + + # move to destination + for ___package in "${___directory}/RPMS/${___arch}/"*; do + FS_Is_File "$___package" + if [ $? -ne 0 ]; then + continue + fi + + FS_Remove_Silently "${___destination}/${___package##*/}" + FS_Move "$___package" "$___destination" + done + + + # report status + return 0 +} + + + + +RPM_Create_Source_Repo() { + ___is_simulated="$1" + ___directory="$2" + ___gpg_id="$3" + ___url="$4" + ___name="$5" + ___sku="$6" + + + # validate input + if [ $(STRINGS_Is_Empty "$___is_simulated") -ne 0 ]; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___gpg_id") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___url") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___name") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___sku") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "${___directory}/SPEC_INSTALL" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "${___directory}/SPEC_FILES" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___url="${___url}/rpm" + ___url="${___url%//rpm*}/rpm" + ___key="usr/local/share/keyrings/${___sku}-keyring.gpg" + ___filename="etc/yum.repos.d/${___sku}.repo" + + FS_Is_File "${___directory}/BUILD/${___filename##*/}" + if [ $? -eq 0 ]; then + return 10 + fi + + FS_Is_File "${___directory}/BUILD/${___key##*/}" + if [ $? -eq 0 ]; then + return 1 + fi + + FS_Make_Directory "${___directory}/BUILD" + FS_Write_File "${___directory}/BUILD/${___filename##*/}" "\ +# WARNING: AUTO-GENERATED - DO NOT EDIT! +[${___sku}] +name=${___name} +baseurl=${___url} +gpgcheck=1 +gpgkey=file:///${___key} +" + if [ $? -ne 0 ]; then + return 1 + fi + + GPG_Export_Public_Keyring "${___directory}/BUILD/${___key##*/}" "$___gpg_id" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Append_File "${___directory}/SPEC_INSTALL" " +install --directory %{buildroot}/${___filename%/*} +install -m 0644 ${___filename##*/} %{buildroot}/${___filename%/*} + +install --directory %{buildroot}/${___key%/*} +install -m 0644 ${___key##*/} %{buildroot}/${___key%/*} +" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Append_File "${___directory}/SPEC_FILES" "\ +/${___filename} +/${___key} +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +RPM_Create_Spec() { + ___directory="$1" + ___resources="$2" + ___sku="$3" + ___version="$4" + ___cadence="$5" + ___pitch="$6" + ___name="$7" + ___email="$8" + ___website="$9" + ___license="${10}" + ___description_filepath="${11}" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___resources") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___sku") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___version") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___cadence") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___pitch") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___name") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___email") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___website") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___license") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "$___resources" + if [ $? -ne 0 ]; then + return 1 + fi + + + # check if is the document already injected + ___location="${___directory}/SPECS/${___sku}.spec" + FS_Is_File "$___location" + if [ $? -eq 0 ]; then + return 2 + fi + + + # create housing directory path + FS_Make_Housing_Directory "$___location" + + + # generate spec file's header + FS_Write_File "$___location" "\ +Name: ${___sku} +Version: ${___version} +Summary: ${___pitch} +Release: ${___cadence} +License: ${___license} +URL: ${___website} + +" + + + # generate spec file's description field + FS_Append_File "$___location" "%%description\n" + + ___written=1 + FS_Is_File "${___directory}/SPEC_DESCRIPTION" + if [ $? -eq 0 ]; then + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + if [ $(STRINGS_Is_Empty "$___line") -ne 0 ] && + [ $(STRINGS_Is_Empty "${___line%%#*}") -eq 0 ]; then + continue + fi + + FS_Append_File "$___location" "${___line%%#*}\n" + done < "${___directory}/SPEC_DESCRIPTION" + IFS="$___old_IFS" && unset ___old_IFS ___line + + FS_Remove_Silently "${___directory}/SPEC_DESCRIPTION" + ___written=0 + fi + + FS_Is_File "$___description_filepath" + if [ $? -eq 0 ] && [ $___written -ne 0 ]; then + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + if [ $(STRINGS_Is_Empty "$___line") -ne 0 ] && + [ $(STRINGS_Is_Empty "${___line%%#*}") -eq 0 ]; then + continue + fi + + FS_Append_File "$___location" "${___line%%#*}\n" + done < "$___description_filepath" + IFS="$___old_IFS" && unset ___old_IFS ___line + ___written=0 + fi + + if [ $___written -ne 0 ]; then + FS_Append_File "$___location" "\n" + fi + + FS_Append_File "$___location" "\n" + + + # generate spec file's prep field + FS_Append_File "$___location" "%%prep\n" + FS_Is_File "${___directory}/SPEC_PREPARE" + if [ $? -eq 0 ]; then + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + ___line="${___line%%#*}" + if [ $(STRINGS_Is_Empty "$___line") -eq 0 ]; then + continue + fi + + FS_Append_File "$___location" "${___line}\n" + done < "${___directory}/SPEC_PREPARE" + IFS="$___old_IFS" && unset ___old_IFS ___line + + FS_Remove_Silently "${___directory}/SPEC_PREPARE" + else + FS_Append_File "$___location" "\n" + fi + FS_Append_File "$___location" "\n" + + + # generate spec file's build field + FS_Append_File "$___location" "%%build\n" + FS_Is_File "${___directory}/SPEC_BUILD" + if [ $? -eq 0 ]; then + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + ___line="${___line%%#*}" + if [ $(STRINGS_Is_Empty "$___line") -eq 0 ]; then + continue + fi + + FS_Append_File "$___location" "${___line}\n" + done < "${___directory}/SPEC_BUILD" + IFS="$___old_IFS" && unset ___old_IFS ___line + + FS_Remove_Silently "${___directory}/SPEC_BUILD" + else + FS_Append_File "$___location" "\n" + fi + FS_Append_File "$___location" "\n" + + + # generate spec file's install field + FS_Append_File "$___location" "%%install\n" + FS_Is_File "${___directory}/SPEC_INSTALL" + if [ $? -eq 0 ]; then + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + ___line="${___line%%#*}" + if [ $(STRINGS_Is_Empty "$___line") -eq 0 ]; then + continue + fi + + FS_Append_File "$___location" "${___line}\n" + done < "${___directory}/SPEC_INSTALL" + IFS="$___old_IFS" && unset ___old_IFS ___line + + FS_Remove_Silently "${___directory}/SPEC_INSTALL" + else + FS_Append_File "$___location" "\n" + fi + FS_Append_File "$___location" "\n" + + + # generate spec file's clean field + FS_Append_File "$___location" "%%clean\n" + FS_Is_File "${___directory}/SPEC_CLEAN" + if [ $? -eq 0 ]; then + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + ___line="${___line%%#*}" + if [ $(STRINGS_Is_Empty "$___line") -eq 0 ]; then + continue + fi + + FS_Append_File "$___location" "${___line}\n" + done < "${___directory}/SPEC_CLEAN" + IFS="$___old_IFS" && unset ___old_IFS ___line + + FS_Remove_Silently "${___directory}/SPEC_CLEAN" + else + FS_Append_File "$___location" "\n" + fi + FS_Append_File "$___location" "\n" + + + # generate spec file's files field + FS_Append_File "$___location" "%%files\n" + FS_Is_File "${___directory}/SPEC_FILES" + if [ $? -eq 0 ]; then + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + ___line="${___line%%#*}" + if [ $(STRINGS_Is_Empty "$___line") -eq 0 ]; then + continue + fi + + FS_Append_File "$___location" "${___line}\n" + done < "${___directory}/SPEC_FILES" + IFS="$___old_IFS" && unset ___old_IFS ___line + + FS_Remove_Silently "${___directory}/SPEC_FILES" + else + FS_Append_File "$___location" "\n" + fi + FS_Append_File "$___location" "\n" + + + # generate spec file's changelog field + FS_Is_File "${___directory}/SPEC_CHANGELOG" + if [ $? -eq 0 ]; then + FS_Append_File "$___location" "%%changelog\n" + + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + ___line="${___line%%#*}" + if [ $(STRINGS_Is_Empty "$___line") -eq 0 ]; then + continue + fi + + FS_Append_File "$___location" "${___line}\n" + done < "${___directory}/SPEC_CHANGELOG" + IFS="$___old_IFS" && unset ___old_IFS ___line + + FS_Remove_Silently "${___directory}/SPEC_CHANGELOG" + else + ___date="$(date "+%a %b %d %Y")" + CHANGELOG_Assemble_RPM \ + "$___location" \ + "$___resources" \ + "$___date" \ + "$___name" \ + "$___email" \ + "$___version" \ + "1" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + + # report status + return 0 +} + + + + +RPM_Is_Available() { + ___os="$1" + ___arch="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$___os") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___arch") -eq 0 ]; then + return 1 + fi + + OS_Is_Command_Available "rpmbuild" + if [ $? -ne 0 ]; then + return 1 + fi + + + # check compatible target cpu architecture + case "$___os" in + linux|any) + ;; + *) + return 2 + ;; + esac + + + # check compatible target cpu architecture + case "$___arch" in + any) + return 3 + ;; + *) + ;; + esac + + + # report status + return 0 +} + + + + +RPM_Is_Valid() { + #___target="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + if [ "${1##*.}" = "rpm" ]; then + return 0 + fi + + + # return status + return 1 +} diff --git a/automataCI/services/compilers/rust-rustup.ps1 b/automataCI/services/compilers/rust-rustup.ps1 new file mode 100644 index 0000000..076d5c5 --- /dev/null +++ b/automataCI/services/compilers/rust-rustup.ps1 @@ -0,0 +1,50 @@ +# 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. + + + + +# define configurations +$url = "https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-gnu/rustup-init.exe" +$dir = ".\.tmp" +$dest = "${dir}\rustup-init.exe" + + + + +# download and setup rust +Write-Host "info: downloading rustup-init.exe..." +if (-not (Test-Path "${dir}")) { + New-Item -ItemType directory -Path "${dir}" +} + + +$null = Start-BitsTransfer -Source $url -Destination $dest +if (-not (Test-Path "$dest")) { + Write-Error "info: download failed." + $null = Remove-Item -Path "${dir}" -Recurse -Force -ErrorAction SilentlyContinue + return 1 +} + + + + +# execute installation +Write-Host "info: executing rustup-init.exe..." +$null = Invoke-Expression "$dest -y" +$null = Remove-Item -Path "${dir}" -Recurse -Force -ErrorAction SilentlyContinue + + + + +# report status +return 0 diff --git a/automataCI/services/compilers/rust-rustup.sh b/automataCI/services/compilers/rust-rustup.sh new file mode 100644 index 0000000..ddc99f2 --- /dev/null +++ b/automataCI/services/compilers/rust-rustup.sh @@ -0,0 +1,731 @@ +#!/bin/sh +# shellcheck shell=dash + +# This is just a little script that can be downloaded from the internet to +# install rustup. It just does platform detection, downloads the installer +# and runs it. + +# It runs on Unix shells like {a,ba,da,k,z}sh. It uses the common `local` +# extension. Note: Most shells limit `local` to 1 var per line, contra bash. + +if [ "$KSH_VERSION" = 'Version JM 93t+ 2010-03-05' ]; then + # The version of ksh93 that ships with many illumos systems does not + # support the "local" extension. Print a message rather than fail in + # subtle ways later on: + echo 'rustup does not work with this ksh93 version; please try bash!' >&2 + exit 1 +fi + + +set -u + +# If RUSTUP_UPDATE_ROOT is unset or empty, default it. +RUSTUP_UPDATE_ROOT="${RUSTUP_UPDATE_ROOT:-https://static.rust-lang.org/rustup}" + +# NOTICE: If you change anything here, please make the same changes in setup_mode.rs +usage() { + cat < + Choose a default host triple + + --default-toolchain + Choose a default toolchain to install. Use 'none' to not install any toolchains at all + + --profile + [default: default] [possible values: minimal, default, complete] + + -c, --component ... + Component name to also install + + -t, --target ... + Target name to also install + + --no-update-default-toolchain + Don't update any existing default toolchain after install + + --no-modify-path + Don't configure the PATH environment variable + + -h, --help + Print help information + + -V, --version + Print version information +EOF +} + +main() { + downloader --check + need_cmd uname + need_cmd mktemp + need_cmd chmod + need_cmd mkdir + need_cmd rm + need_cmd rmdir + + get_architecture || return 1 + local _arch="$RETVAL" + assert_nz "$_arch" "arch" + + local _ext="" + case "$_arch" in + *windows*) + _ext=".exe" + ;; + esac + + local _url="${RUSTUP_UPDATE_ROOT}/dist/${_arch}/rustup-init${_ext}" + + local _dir + if ! _dir="$(ensure mktemp -d)"; then + # Because the previous command ran in a subshell, we must manually + # propagate exit status. + exit 1 + fi + local _file="${_dir}/rustup-init${_ext}" + + local _ansi_escapes_are_valid=false + if [ -t 2 ]; then + if [ "${TERM+set}" = 'set' ]; then + case "$TERM" in + xterm*|rxvt*|urxvt*|linux*|vt*) + _ansi_escapes_are_valid=true + ;; + esac + fi + fi + + # check if we have to use /dev/tty to prompt the user + local need_tty=yes + for arg in "$@"; do + case "$arg" in + --help) + usage + exit 0 + ;; + *) + OPTIND=1 + if [ "${arg%%--*}" = "" ]; then + # Long option (other than --help); + # don't attempt to interpret it. + continue + fi + while getopts :hy sub_arg "$arg"; do + case "$sub_arg" in + h) + usage + exit 0 + ;; + y) + # user wants to skip the prompt -- + # we don't need /dev/tty + need_tty=no + ;; + *) + ;; + esac + done + ;; + esac + done + + if $_ansi_escapes_are_valid; then + printf "\33[1minfo:\33[0m downloading installer\n" 1>&2 + else + printf '%s\n' 'info: downloading installer' 1>&2 + fi + + ensure mkdir -p "$_dir" + ensure downloader "$_url" "$_file" "$_arch" + ensure chmod u+x "$_file" + if [ ! -x "$_file" ]; then + printf '%s\n' "Cannot execute $_file (likely because of mounting /tmp as noexec)." 1>&2 + printf '%s\n' "Please copy the file to a location where you can execute binaries and run ./rustup-init${_ext}." 1>&2 + exit 1 + fi + + if [ "$need_tty" = "yes" ] && [ ! -t 0 ]; then + # The installer is going to want to ask for confirmation by + # reading stdin. This script was piped into `sh` though and + # doesn't have stdin to pass to its children. Instead we're going + # to explicitly connect /dev/tty to the installer's stdin. + if [ ! -t 1 ]; then + err "Unable to run interactively. Run with -y to accept defaults, --help for additional options" + fi + + ignore "$_file" "$@" < /dev/tty + else + ignore "$_file" "$@" + fi + + local _retval=$? + + ignore rm "$_file" + ignore rmdir "$_dir" + + return "$_retval" +} + +check_proc() { + # Check for /proc by looking for the /proc/self/exe link + # This is only run on Linux + if ! test -L /proc/self/exe ; then + err "fatal: Unable to find /proc/self/exe. Is /proc mounted? Installation cannot proceed without /proc." + fi +} + +get_bitness() { + need_cmd head + # Architecture detection without dependencies beyond coreutils. + # ELF files start out "\x7fELF", and the following byte is + # 0x01 for 32-bit and + # 0x02 for 64-bit. + # The printf builtin on some shells like dash only supports octal + # escape sequences, so we use those. + local _current_exe_head + _current_exe_head=$(head -c 5 /proc/self/exe ) + if [ "$_current_exe_head" = "$(printf '\177ELF\001')" ]; then + echo 32 + elif [ "$_current_exe_head" = "$(printf '\177ELF\002')" ]; then + echo 64 + else + err "unknown platform bitness" + fi +} + +is_host_amd64_elf() { + need_cmd head + need_cmd tail + # ELF e_machine detection without dependencies beyond coreutils. + # Two-byte field at offset 0x12 indicates the CPU, + # but we're interested in it being 0x3E to indicate amd64, or not that. + local _current_exe_machine + _current_exe_machine=$(head -c 19 /proc/self/exe | tail -c 1) + [ "$_current_exe_machine" = "$(printf '\076')" ] +} + +get_endianness() { + local cputype=$1 + local suffix_eb=$2 + local suffix_el=$3 + + # detect endianness without od/hexdump, like get_bitness() does. + need_cmd head + need_cmd tail + + local _current_exe_endianness + _current_exe_endianness="$(head -c 6 /proc/self/exe | tail -c 1)" + if [ "$_current_exe_endianness" = "$(printf '\001')" ]; then + echo "${cputype}${suffix_el}" + elif [ "$_current_exe_endianness" = "$(printf '\002')" ]; then + echo "${cputype}${suffix_eb}" + else + err "unknown platform endianness" + fi +} + +get_architecture() { + local _ostype _cputype _bitness _arch _clibtype + _ostype="$(uname -s)" + _cputype="$(uname -m)" + _clibtype="gnu" + + if [ "$_ostype" = Linux ]; then + if [ "$(uname -o)" = Android ]; then + _ostype=Android + fi + if ldd --version 2>&1 | grep -q 'musl'; then + _clibtype="musl" + fi + fi + + if [ "$_ostype" = Darwin ] && [ "$_cputype" = i386 ]; then + # Darwin `uname -m` lies + if sysctl hw.optional.x86_64 | grep -q ': 1'; then + _cputype=x86_64 + fi + fi + + if [ "$_ostype" = SunOS ]; then + # Both Solaris and illumos presently announce as "SunOS" in "uname -s" + # so use "uname -o" to disambiguate. We use the full path to the + # system uname in case the user has coreutils uname first in PATH, + # which has historically sometimes printed the wrong value here. + if [ "$(/usr/bin/uname -o)" = illumos ]; then + _ostype=illumos + fi + + # illumos systems have multi-arch userlands, and "uname -m" reports the + # machine hardware name; e.g., "i86pc" on both 32- and 64-bit x86 + # systems. Check for the native (widest) instruction set on the + # running kernel: + if [ "$_cputype" = i86pc ]; then + _cputype="$(isainfo -n)" + fi + fi + + case "$_ostype" in + + Android) + _ostype=linux-android + ;; + + Linux) + check_proc + _ostype=unknown-linux-$_clibtype + _bitness=$(get_bitness) + ;; + + FreeBSD) + _ostype=unknown-freebsd + ;; + + NetBSD) + _ostype=unknown-netbsd + ;; + + DragonFly) + _ostype=unknown-dragonfly + ;; + + Darwin) + _ostype=apple-darwin + ;; + + illumos) + _ostype=unknown-illumos + ;; + + MINGW* | MSYS* | CYGWIN* | Windows_NT) + _ostype=pc-windows-gnu + ;; + + *) + err "unrecognized OS type: $_ostype" + ;; + + esac + + case "$_cputype" in + + i386 | i486 | i686 | i786 | x86) + _cputype=i686 + ;; + + xscale | arm) + _cputype=arm + if [ "$_ostype" = "linux-android" ]; then + _ostype=linux-androideabi + fi + ;; + + armv6l) + _cputype=arm + if [ "$_ostype" = "linux-android" ]; then + _ostype=linux-androideabi + else + _ostype="${_ostype}eabihf" + fi + ;; + + armv7l | armv8l) + _cputype=armv7 + if [ "$_ostype" = "linux-android" ]; then + _ostype=linux-androideabi + else + _ostype="${_ostype}eabihf" + fi + ;; + + aarch64 | arm64) + _cputype=aarch64 + ;; + + x86_64 | x86-64 | x64 | amd64) + _cputype=x86_64 + ;; + + mips) + _cputype=$(get_endianness mips '' el) + ;; + + mips64) + if [ "$_bitness" -eq 64 ]; then + # only n64 ABI is supported for now + _ostype="${_ostype}abi64" + _cputype=$(get_endianness mips64 '' el) + fi + ;; + + ppc) + _cputype=powerpc + ;; + + ppc64) + _cputype=powerpc64 + ;; + + ppc64le) + _cputype=powerpc64le + ;; + + s390x) + _cputype=s390x + ;; + riscv64) + _cputype=riscv64gc + ;; + loongarch64) + _cputype=loongarch64 + ;; + *) + err "unknown CPU type: $_cputype" + + esac + + # Detect 64-bit linux with 32-bit userland + if [ "${_ostype}" = unknown-linux-gnu ] && [ "${_bitness}" -eq 32 ]; then + case $_cputype in + x86_64) + if [ -n "${RUSTUP_CPUTYPE:-}" ]; then + _cputype="$RUSTUP_CPUTYPE" + else { + # 32-bit executable for amd64 = x32 + if is_host_amd64_elf; then { + echo "This host is running an x32 userland; as it stands, x32 support is poor," 1>&2 + echo "and there isn't a native toolchain -- you will have to install" 1>&2 + echo "multiarch compatibility with i686 and/or amd64, then select one" 1>&2 + echo "by re-running this script with the RUSTUP_CPUTYPE environment variable" 1>&2 + echo "set to i686 or x86_64, respectively." 1>&2 + echo 1>&2 + echo "You will be able to add an x32 target after installation by running" 1>&2 + echo " rustup target add x86_64-unknown-linux-gnux32" 1>&2 + exit 1 + }; else + _cputype=i686 + fi + }; fi + ;; + mips64) + _cputype=$(get_endianness mips '' el) + ;; + powerpc64) + _cputype=powerpc + ;; + aarch64) + _cputype=armv7 + if [ "$_ostype" = "linux-android" ]; then + _ostype=linux-androideabi + else + _ostype="${_ostype}eabihf" + fi + ;; + riscv64gc) + err "riscv64 with 32-bit userland unsupported" + ;; + esac + fi + + # Detect armv7 but without the CPU features Rust needs in that build, + # and fall back to arm. + # See https://github.com/rust-lang/rustup.rs/issues/587. + if [ "$_ostype" = "unknown-linux-gnueabihf" ] && [ "$_cputype" = armv7 ]; then + if ensure grep '^Features' /proc/cpuinfo | grep -q -v neon; then + # At least one processor does not have NEON. + _cputype=arm + fi + fi + + _arch="${_cputype}-${_ostype}" + + RETVAL="$_arch" +} + +say() { + printf 'rustup: %s\n' "$1" +} + +err() { + say "$1" >&2 + exit 1 +} + +need_cmd() { + if ! check_cmd "$1"; then + err "need '$1' (command not found)" + fi +} + +check_cmd() { + command -v "$1" > /dev/null 2>&1 +} + +assert_nz() { + if [ -z "$1" ]; then err "assert_nz $2"; fi +} + +# Run a command that should never fail. If the command fails execution +# will immediately terminate with an error showing the failing +# command. +ensure() { + if ! "$@"; then err "command failed: $*"; fi +} + +# This is just for indicating that commands' results are being +# intentionally ignored. Usually, because it's being executed +# as part of error handling. +ignore() { + "$@" +} + +# This wraps curl or wget. Try curl first, if not installed, +# use wget instead. +downloader() { + local _dld + local _ciphersuites + local _err + local _status + local _retry + if check_cmd curl; then + _dld=curl + elif check_cmd wget; then + _dld=wget + else + _dld='curl or wget' # to be used in error message of need_cmd + fi + + if [ "$1" = --check ]; then + need_cmd "$_dld" + elif [ "$_dld" = curl ]; then + check_curl_for_retry_support + _retry="$RETVAL" + get_ciphersuites_for_curl + _ciphersuites="$RETVAL" + if [ -n "$_ciphersuites" ]; then + _err=$(curl $_retry --proto '=https' --tlsv1.2 --ciphers "$_ciphersuites" --silent --show-error --fail --location "$1" --output "$2" 2>&1) + _status=$? + else + echo "Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure" + if ! check_help_for "$3" curl --proto --tlsv1.2; then + echo "Warning: Not enforcing TLS v1.2, this is potentially less secure" + _err=$(curl $_retry --silent --show-error --fail --location "$1" --output "$2" 2>&1) + _status=$? + else + _err=$(curl $_retry --proto '=https' --tlsv1.2 --silent --show-error --fail --location "$1" --output "$2" 2>&1) + _status=$? + fi + fi + if [ -n "$_err" ]; then + echo "$_err" >&2 + if echo "$_err" | grep -q 404$; then + err "installer for platform '$3' not found, this may be unsupported" + fi + fi + return $_status + elif [ "$_dld" = wget ]; then + if [ "$(wget -V 2>&1|head -2|tail -1|cut -f1 -d" ")" = "BusyBox" ]; then + echo "Warning: using the BusyBox version of wget. Not enforcing strong cipher suites for TLS or TLS v1.2, this is potentially less secure" + _err=$(wget "$1" -O "$2" 2>&1) + _status=$? + else + get_ciphersuites_for_wget + _ciphersuites="$RETVAL" + if [ -n "$_ciphersuites" ]; then + _err=$(wget --https-only --secure-protocol=TLSv1_2 --ciphers "$_ciphersuites" "$1" -O "$2" 2>&1) + _status=$? + else + echo "Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure" + if ! check_help_for "$3" wget --https-only --secure-protocol; then + echo "Warning: Not enforcing TLS v1.2, this is potentially less secure" + _err=$(wget "$1" -O "$2" 2>&1) + _status=$? + else + _err=$(wget --https-only --secure-protocol=TLSv1_2 "$1" -O "$2" 2>&1) + _status=$? + fi + fi + fi + if [ -n "$_err" ]; then + echo "$_err" >&2 + if echo "$_err" | grep -q ' 404 Not Found$'; then + err "installer for platform '$3' not found, this may be unsupported" + fi + fi + return $_status + else + err "Unknown downloader" # should not reach here + fi +} + +check_help_for() { + local _arch + local _cmd + local _arg + _arch="$1" + shift + _cmd="$1" + shift + + local _category + if "$_cmd" --help | grep -q 'For all options use the manual or "--help all".'; then + _category="all" + else + _category="" + fi + + case "$_arch" in + + *darwin*) + if check_cmd sw_vers; then + case $(sw_vers -productVersion) in + 10.*) + # If we're running on macOS, older than 10.13, then we always + # fail to find these options to force fallback + if [ "$(sw_vers -productVersion | cut -d. -f2)" -lt 13 ]; then + # Older than 10.13 + echo "Warning: Detected macOS platform older than 10.13" + return 1 + fi + ;; + 11.*) + # We assume Big Sur will be OK for now + ;; + *) + # Unknown product version, warn and continue + echo "Warning: Detected unknown macOS major version: $(sw_vers -productVersion)" + echo "Warning TLS capabilities detection may fail" + ;; + esac + fi + ;; + + esac + + for _arg in "$@"; do + if ! "$_cmd" --help "$_category" | grep -q -- "$_arg"; then + return 1 + fi + done + + true # not strictly needed +} + +# Check if curl supports the --retry flag, then pass it to the curl invocation. +check_curl_for_retry_support() { + local _retry_supported="" + # "unspecified" is for arch, allows for possibility old OS using macports, homebrew, etc. + if check_help_for "notspecified" "curl" "--retry"; then + _retry_supported="--retry 3" + if check_help_for "notspecified" "curl" "--continue-at"; then + # "-C -" tells curl to automatically find where to resume the download when retrying. + _retry_supported="--retry 3 -C -" + fi + fi + + RETVAL="$_retry_supported" +} + +# Return cipher suite string specified by user, otherwise return strong TLS 1.2-1.3 cipher suites +# if support by local tools is detected. Detection currently supports these curl backends: +# GnuTLS and OpenSSL (possibly also LibreSSL and BoringSSL). Return value can be empty. +get_ciphersuites_for_curl() { + if [ -n "${RUSTUP_TLS_CIPHERSUITES-}" ]; then + # user specified custom cipher suites, assume they know what they're doing + RETVAL="$RUSTUP_TLS_CIPHERSUITES" + return + fi + + local _openssl_syntax="no" + local _gnutls_syntax="no" + local _backend_supported="yes" + if curl -V | grep -q ' OpenSSL/'; then + _openssl_syntax="yes" + elif curl -V | grep -iq ' LibreSSL/'; then + _openssl_syntax="yes" + elif curl -V | grep -iq ' BoringSSL/'; then + _openssl_syntax="yes" + elif curl -V | grep -iq ' GnuTLS/'; then + _gnutls_syntax="yes" + else + _backend_supported="no" + fi + + local _args_supported="no" + if [ "$_backend_supported" = "yes" ]; then + # "unspecified" is for arch, allows for possibility old OS using macports, homebrew, etc. + if check_help_for "notspecified" "curl" "--tlsv1.2" "--ciphers" "--proto"; then + _args_supported="yes" + fi + fi + + local _cs="" + if [ "$_args_supported" = "yes" ]; then + if [ "$_openssl_syntax" = "yes" ]; then + _cs=$(get_strong_ciphersuites_for "openssl") + elif [ "$_gnutls_syntax" = "yes" ]; then + _cs=$(get_strong_ciphersuites_for "gnutls") + fi + fi + + RETVAL="$_cs" +} + +# Return cipher suite string specified by user, otherwise return strong TLS 1.2-1.3 cipher suites +# if support by local tools is detected. Detection currently supports these wget backends: +# GnuTLS and OpenSSL (possibly also LibreSSL and BoringSSL). Return value can be empty. +get_ciphersuites_for_wget() { + if [ -n "${RUSTUP_TLS_CIPHERSUITES-}" ]; then + # user specified custom cipher suites, assume they know what they're doing + RETVAL="$RUSTUP_TLS_CIPHERSUITES" + return + fi + + local _cs="" + if wget -V | grep -q '\-DHAVE_LIBSSL'; then + # "unspecified" is for arch, allows for possibility old OS using macports, homebrew, etc. + if check_help_for "notspecified" "wget" "TLSv1_2" "--ciphers" "--https-only" "--secure-protocol"; then + _cs=$(get_strong_ciphersuites_for "openssl") + fi + elif wget -V | grep -q '\-DHAVE_LIBGNUTLS'; then + # "unspecified" is for arch, allows for possibility old OS using macports, homebrew, etc. + if check_help_for "notspecified" "wget" "TLSv1_2" "--ciphers" "--https-only" "--secure-protocol"; then + _cs=$(get_strong_ciphersuites_for "gnutls") + fi + fi + + RETVAL="$_cs" +} + +# Return strong TLS 1.2-1.3 cipher suites in OpenSSL or GnuTLS syntax. TLS 1.2 +# excludes non-ECDHE and non-AEAD cipher suites. DHE is excluded due to bad +# DH params often found on servers (see RFC 7919). Sequence matches or is +# similar to Firefox 68 ESR with weak cipher suites disabled via about:config. +# $1 must be openssl or gnutls. +get_strong_ciphersuites_for() { + if [ "$1" = "openssl" ]; then + # OpenSSL is forgiving of unknown values, no problems with TLS 1.3 values on versions that don't support it yet. + echo "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384" + elif [ "$1" = "gnutls" ]; then + # GnuTLS isn't forgiving of unknown values, so this may require a GnuTLS version that supports TLS 1.3 even if wget doesn't. + # Begin with SECURE128 (and higher) then remove/add to build cipher suites. Produces same 9 cipher suites as OpenSSL but in slightly different order. + echo "SECURE128:-VERS-SSL3.0:-VERS-TLS1.0:-VERS-TLS1.1:-VERS-DTLS-ALL:-CIPHER-ALL:-MAC-ALL:-KX-ALL:+AEAD:+ECDHE-ECDSA:+ECDHE-RSA:+AES-128-GCM:+CHACHA20-POLY1305:+AES-256-GCM" + fi +} + +main "$@" || exit 1 diff --git a/automataCI/services/compilers/rust.ps1 b/automataCI/services/compilers/rust.ps1 new file mode 100644 index 0000000..95e180d --- /dev/null +++ b/automataCI/services/compilers/rust.ps1 @@ -0,0 +1,610 @@ +# 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\io\strings.ps1" + + + + +function RUST-Activate-Local-Environment { + # validate input + $___process = RUST-Is-Localized + if ($___process -eq 0) { + return 0 + } + + + # execute + $___location = "$(RUST-Get-Activator-Path)" + $___process = FS-Is-File "${___location}" + if ($___process -ne 0) { + return 1 + } + + . $___location + $___process = RUST-Is-Localized + if ($___process -eq 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function RUST-Cargo-Login { + # validate input + if (($(STRINGS-Is-Empty "${env:CARGO_REGISTRY}") -eq 0) -or + ($(STRINGS-Is-Empty "${env:CARGO_PASSWORD}") -eq 0)) { + return 1 + } + + + # execute + $___arguments = "login " ` + + "--registry `"${env:CARGO_REGISTRY}`" " ` + + "`"${env:CARGO_PASSWORD}`" " + $___process = OS-Exec "cargo" "${___arguments}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function RUST-Cargo-Logout { + # execute + $___process = OS-Exec "cargo" "logout" + if ($___process -ne 0) { + return 1 + } + + $null = FS-Remove-Silently "\.cargo\credentials.toml" + + + # report status + return 0 +} + + + + +function RUST-Cargo-Release-Crate { + param( + [string]$___source_directory + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___source_directory}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___source_directory}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___current_path = Get-Location + $null = Set-Location "${___source_directory}" + $___process = OS-Exec "cargo" "publish" + $null = Set-Location "${___current_path}" + $null = Remove-Variable ___current_path + + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function RUST-Crate-Is-Valid { + param( + [string]$___target + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___target}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___target}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = STRINGS-Has-Prefix "cargo" (Split-Path -Leaf -Path "${___target}") + if ($___process -ne 0) { + return 1 + } + + $___hasCARGO = "false" + foreach ($___file in (Get-ChildItem -Path ${___target})) { + if ($___file.Name -eq "Cargo.toml") { + $___hasCARGO = "true" + } + } + if ($___hasCARGO -eq "true") { + return 0 + } + + + # report status + return 1 +} + + + + +function RUST-Create-Archive { + param( + [string]$___source_directory, + [string]$___target_directory + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___source_directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target_directory}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___source_directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Directory "${___target_directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = RUST-Activate-Local-Environment + if ($___process -ne 0) { + return 1 + } + + + # execute + $null = FS-Remove-Silently "${___source_directory}\Cargo.lock" + + $___current_path = Get-Location + $null = Set-Location "${___source_directory}" + + $___process = OS-Exec "cargo" "build" + if ($___process -ne 0) { + $null = Set-Location "${___current_path}" + $null = Remove-Variable ___current_path + return 1 + } + + $___process = OS-Exec "cargo" "publish --dry-run" + if ($___process -ne 0) { + $null = Set-Location "${___current_path}" + $null = Remove-Variable ___current_path + return 1 + } + + $null = Set-Location "${___current_path}" + $null = Remove-Variable ___current_path + + $null = FS-Remove-Silently "${___source_directory}\target" + $null = FS-Remake-Directory "${___target_directory}" + $___process = FS-Copy-All "${___source_directory}\" "${___target_directory}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function RUST-Create-CARGO-TOML { + param( + [string]$___filepath, + [string]$___template, + [string]$___sku, + [string]$___version, + [string]$___pitch, + [string]$___edition, + [string]$___license, + [string]$___docs, + [string]$___website, + [string]$___repo, + [string]$___readme, + [string]$___contact_name, + [string]$___contact_email + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___filepath}") -eq 0) -or + ($(STRINGS-Is-Empty "${___template}") -eq 0) -or + ($(STRINGS-Is-Empty "${___sku}") -eq 0) -or + ($(STRINGS-Is-Empty "${___version}") -eq 0) -or + ($(STRINGS-Is-Empty "${___pitch}") -eq 0) -or + ($(STRINGS-Is-Empty "${___edition}") -eq 0) -or + ($(STRINGS-Is-Empty "${___license}") -eq 0) -or + ($(STRINGS-Is-Empty "${___docs}") -eq 0) -or + ($(STRINGS-Is-Empty "${___website}") -eq 0) -or + ($(STRINGS-Is-Empty "${___repo}") -eq 0) -or + ($(STRINGS-Is-Empty "${___readme}") -eq 0) -or + ($(STRINGS-Is-Empty "${___contact_name}") -eq 0) -or + ($(STRINGS-Is-Empty "${___contact_email}") -eq 0)) { + return 1 + } + + $___process = FS-Is-File "${___template}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $null = FS-Remove-Silently "${___filepath}" + $___process = FS-Write-File "${___filepath}" @" +[package] +name = '${___sku}' +version = '${___version}' +description = '${___pitch}' +edition = '${___edition}' +license = '${___license}' +documentation = '${___docs}' +homepage = '${___website}' +repository = '${___repo}' +readme = '${___readme}' +authors = [ '${___contact_name} <${___contact_email}>' ] + + + + +"@ + if ($___process -ne 0) { + return 1 + } + + + $___begin_append = 1 + foreach ($___line in (Get-Content "${___template}")) { + if (($___begin_append -ne 0) -and + ($("${___line}" -replace '\[AUTOMATACI BEGIN\]') -ne "${___line}")) { + $___begin_append = 0 + continue + } + + if ($___begin_append -ne 0) { + continue + } + + $___process = FS-Append-File "${___filepath}" "${___line}" + if ($___process -ne 0) { + return 1 + } + } + + + # update Cargo.lock + $___process = RUST-Activate-Local-Environment + if ($___process -ne 0) { + return 1 + } + + $___current_path = Get-Location + $null = Set-Location (Split-Path -Parent -Path "${___filepath}") + $___process = OS-Exec "cargo" "update" + if ($___process -ne 0) { + $null = Set-Location "${___current_path}" + $null = Remove-Variable ___current_path + return 1 + } + + $___process = OS-Exec "cargo" "clean" + $null = Set-Location "${___current_path}" + $null = Remove-Variable ___current_path + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function RUST-Get-Activator-Path { + # execute + return "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}" ` + + "\${env:PROJECT_PATH_RUST_ENGINE}\Activate.ps1" +} + + + + +function RUST-Get-Build-Target { + param( + [string]$___os, + [string]$___arch + ) + + + # execute + switch ("${___os}-${___arch}") { + aix-ppc64 { + return "powerpc64-ibm-aix" + } android-amd64 { + return "x86_64-linux-android" + } android-arm64 { + return "aarch64-linux-android" + } darwin-amd64 { + return "x86_64-apple-darwin" + } darwin-arm64 { + return "aarch64-apple-darwin" + } dragonfly-amd64 { + return "x86_64-unknown-dragonfly" + } freebsd-amd64 { + return "x86_64-unknown-freebsd" + } fuchsia-amd64 { + return "x86_64-unknown-fuchsia" + } fuchsia-arm64 { + return "aarch64-unknown-fuchsia" + } haiku-amd64 { + return "x86_64-unknown-haiku" + } illumos-amd64 { + return "x86_64-unknown-illumos" + } ios-amd64 { + return "x86_64-apple-ios" + } ios-arm64 { + return "aarch64-apple-ios" + } js-wasm { + return "wasm32-unknown-emscripten" + } { $_ -in "linux-armel", "linux-armle" } { + return "arm-unknown-linux-musleabi" + } linux-armhf { + return "arm-unknown-linux-musleabihf" + } linux-armv7 { + return "armv7-unknown-linux-musleabihf" + } linux-amd64 { + return "x86_64-unknown-linux-musl" + } linux-arm64 { + return "aarch64-unknown-linux-musl" + } linux-loongarch64 { + return "loongarch64-unknown-linux-gnu" + } linux-mips { + return "mips-unknown-linux-musl" + } { $_ -in "linux-mipsle", "linux-mipsel" } { + return "mipsel-unknown-linux-musl" + } linux-mips64 { + return "mips64-unknown-linux-muslabi64" + } { $_ -in "linux-mips64el", "linux-mips64le" } { + return "mips64el-unknown-linux-muslabi64" + } linux-ppc64 { + return "powerpc64-unknown-linux-gnu" + } linux-ppc64le { + return "powerpc64le-unknown-linux-gnu" + } linux-riscv64 { + return "riscv64gc-unknown-linux-gnu" + } linux-s390x { + return "s390x-unknown-linux-gnu" + } linux-sparc { + return "sparc-unknown-linux-gnu" + } netbsd-amd64 { + return "x86_64-unknown-netbsd" + } netbsd-arm64 { + return "aarch64-unknown-netbsd" + } netbsd-riscv64 { + return "riscv64gc-unknown-netbsd" + } netbsd-sparc { + return "sparc64-unknown-netbsd" + } openbsd-amd64 { + return "x86_64-unknown-openbsd" + } openbsd-arm64 { + return "aarch64-unknown-openbsd" + } openbsd-ppc64 { + return "powerpc64-unknown-openbsd" + } openbsd-riscv64 { + return "riscv64gc-unknown-openbsd" + } openbsd-sparc { + return "sparc64-unknown-openbsd" + } redox-amd64 { + return "x86_64-unknown-redox" + } solaris-amd64 { + return "x86_64-pc-solaris" + } wasip1-wasm { + return "wasm32-wasi" + } windows-amd64 { + return "x86_64-pc-windows-msvc" + } windows-arm64 { + return "aarch64-pc-windows-msvc" + } default { + return "" + }} +} + + + + +function RUST-Is-Available { + # execute + $___process = OS-Is-Command-Available "rustup" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Is-Command-Available "rustc" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Is-Command-Available "cargo" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function RUST-Is-Localized { + # execute + if ($(STRINGS-Is-Empty "${env:PROJECT_RUST_LOCALIZED}") -ne 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function RUST-Setup-Local-Environment { + # validate input + if ($(STRINGS-Is-Empty "${env:PROJECT_PATH_ROOT}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_PATH_TOOLS}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_PATH_AUTOMATA}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_PATH_RUST_ENGINE}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_OS}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_ARCH}") -eq 0) { + return 1 + } + + $___process = RUST-Is-Localized + if ($___process -eq 0) { + return 0 + } + + + # execute + $___label = "($env:PROJECT_PATH_RUST_ENGINE)" + $___location = "$(RUST-Get-Activator-Path)" + $env:CARGO_HOME = Split-Path -Parent -Path "${___location}" + $env:RUSTUP_HOME = Split-Path -Parent -Path "${___location}" + + ## download installer from official portal + $null = Invoke-Expression "${env:LIBS_AUTOMATACI}\services\compilers\rust-rustup.ps1" + + ## it's a clean repo. Start setting up localized environment... + $null = FS-Make-Housing-Directory "${___location}" + $null = FS-Write-File "${___location}" @" +function deactivate { + `$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") `` + + ";" `` + + [System.Environment]::GetEnvironmentVariable("Path","User") + `${env:PROJECT_RUST_LOCALIZED} = `$null + `${env:CARGO_HOME} = `$null + `${env:RUSTUP_HOME} = `$null + Copy-Item -Path Function:_OLD_PROMPT -Destination Function:prompt + Remove-Item -Path Function:_OLD_PROMPT +} + + +# check existing +if (-not [string]::IsNullOrEmpty(`${env:PROJECT_RUST_LOCALIZED})) { + return +} + + +# activate +`${env:CARGO_HOME} = "${CARGO_HOME}" +`${env:RUSTUP_HOME} = "${RUSTUP_HOME}" +`${env:PROJECT_RUST_LOCALIZED} = "${___location}" +`$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") `` + + ";" `` + + [System.Environment]::GetEnvironmentVariable("Path","User") `` + + ";" `` + + "${CARGO_HOME}\bin" +Copy-Item -Path function:prompt -Destination function:_OLD_PROMPT +function global:prompt { + Write-Host -NoNewline -ForegroundColor Green "(${___label}) " + _OLD_VIRTUAL_PROMPT +} +"@ + + $___process = FS-Is-File "${___location}" + if ($___process -ne 0) { + return 1 + } + + + # testing the activation + $___process = RUST-Activate-Local-Environment + if ($___process -ne 0) { + return 1 + } + + + # setup localized compiler + $___target = RUST-Get-Build-Target "${env:PROJECT_OS}" "${env:PROJECT_ARCH}" + $___process = OS-Exec "rustup" "target add ${___target}" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Exec "rustup" "component add llvm-tools-preview" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Exec "cargo" "install grcov" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/rust.sh b/automataCI/services/compilers/rust.sh new file mode 100644 index 0000000..94b8cf6 --- /dev/null +++ b/automataCI/services/compilers/rust.sh @@ -0,0 +1,651 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +RUST_Activate_Local_Environment() { + # validate input + RUST_Is_Localized + if [ $? -eq 0 ] ; then + return 0 + fi + + + # execute + ___location="$(RUST_Get_Activator_Path)" + FS_Is_File "$___location" + if [ $? -ne 0 ]; then + return 1 + fi + + . "$___location" + RUST_Is_Localized + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +RUST_Cargo_Login() { + # validate input + if [ $(STRINGS_Is_Empty "$CARGO_REGISTRY") -eq 0 ] || + [ $(STRINGS_Is_Empty "$CARGO_PASSWORD") -eq 0 ]; then + return 1 + fi + + + # execute + cargo login --registry "$CARGO_REGISTRY" "$CARGO_PASSWORD" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +RUST_Cargo_Logout() { + # execute + cargo logout + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Remove_Silently "~/.cargo/credentials.toml" + + + # report status + return 0 +} + + + + +RUST_Cargo_Release_Crate() { + #___source_directory="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___current_path="$PWD" && cd "$1" + cargo publish + ___process=$? + cd "$___current_path" && unset ___current_path + + if [ $___process -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +RUST_Crate_Is_Valid() { + #___target="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + STRINGS_Has_Prefix "cargo" "${1##*/}" + if [ $? -ne 0 ]; then + return 1 + fi + + + ___hasCARGO="false" + for ___file in "${1}/"*; do + if [ ! -e "$___file" ]; then + continue + fi + + if [ ! "${___file%%Cargo.toml*}" = "${___file}" ]; then + ___hasCARGO="true" + fi + done + + if [ "$___hasCARGO" = "true" ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +RUST_Create_Archive() { + ___source_directory="$1" + ___target_directory="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$___source_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___target_directory") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___source_directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "$___target_directory" + if [ $? -ne 0 ]; then + return 1 + fi + + RUST_Activate_Local_Environment + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + FS_Remove_Silently "${___source_directory}/Cargo.lock" + + ___current_path="$PWD" && cd "$___source_directory" + + cargo build + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + cargo publish --dry-run + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + cd "$___current_path" && unset ___current_path + + FS_Remove_Silently "${___source_directory}/target" + FS_Remake_Directory "${___target_directory}" + FS_Copy_All "${___source_directory}/" "${___target_directory}" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +RUST_Create_CARGO_TOML() { + ___filepath="$1" + ___template="$2" + ___sku="$3" + ___version="$4" + ___pitch="$5" + ___edition="$6" + ___license="$7" + ___docs="$8" + ___website="$9" + ___repo="${10}" + ___readme="${11}" + ___contact_name="${12}" + ___contact_email="${13}" + + + # validate input + if [ $(STRINGS_Is_Empty "$___filepath") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___template") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___sku") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___version") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___pitch") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___edition") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___license") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___docs") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___website") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___repo") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___readme") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___contact_name") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___contact_email") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$___template" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + FS_Remove_Silently "$___filepath" + FS_Write_File "$___filepath" "\ +[package] +name = '$___sku' +version = '$___version' +description = '$___pitch' +edition = '$___edition' +license = '$___license' +documentation = '$___docs' +homepage = '$___website' +repository = '$___repo' +readme = '$___readme' +authors = [ '$___contact_name <$___contact_email>' ] + + + + +" + if [ $? -ne 0 ]; then + return 1 + fi + + ___begin_append=1 + ___old_IFS="$IFS" + while IFS="" read -r ___line || [ -n "$___line" ]; do + if [ $___begin_append -ne 0 ] && + [ ! "${___line%%\[AUTOMATACI BEGIN\]*}" = "${___line}" ]; then + ___begin_append=0 + continue + fi + + if [ $___begin_append -ne 0 ]; then + continue + fi + + FS_Append_File "$___filepath" "$___line\n" + if [ $? -ne 0 ]; then + return 1 + fi + done < "$___template" + IFS="$___old_IFS" && unset ___old_IFS + + + # update Cargo.lock + RUST_Activate_Local_Environment + if [ $? -ne 0 ]; then + return 1 + fi + + ___current_path="$PWD" && cd "${___filepath%/*}" + cargo update + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + cargo clean + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + cd "$___current_path" && unset ___current_path + + + # report status + return 0 +} + + + + +RUST_Get_Activator_Path() { + # execute + ___location="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/${PROJECT_PATH_RUST_ENGINE}" + ___location="${___location}/activate.sh" + printf -- "%b" "$___location" +} + + + + +RUST_Get_Build_Target() { + #___os="$1" + #___arch="$2" + + + # execute + case "${1}-${2}" in + aix-ppc64) + ___target='powerpc64-ibm-aix' + ;; + android-amd64) + ___target='x86_64-linux-android' + ;; + android-arm64) + ___target='aarch64-linux-android' + ;; + darwin-amd64) + ___target='x86_64-apple-darwin' + ;; + darwin-arm64) + ___target='aarch64-apple-darwin' + ;; + dragonfly-amd64) + ___target='x86_64-unknown-dragonfly' + ;; + freebsd-amd64) + ___target='x86_64-unknown-freebsd' + ;; + fuchsia-amd64) + ___target='x86_64-unknown-fuchsia' + ;; + fuchsia-arm64) + ___target='aarch64-unknown-fuchsia' + ;; + haiku-amd64) + ___target='x86_64-unknown-haiku' + ;; + illumos-amd64) + ___target='x86_64-unknown-illumos' + ;; + ios-amd64) + ___target='x86_64-apple-ios' + ;; + ios-arm64) + ___target='aarch64-apple-ios' + ;; + js-wasm) + ___target='wasm32-unknown-emscripten' + ;; + linux-armel|linux-armle) + ___target='arm-unknown-linux-musleabi' + ;; + linux-armhf) + ___target='arm-unknown-linux-musleabihf' + ;; + linux-armv7) + ___target='armv7-unknown-linux-musleabihf' + ;; + linux-amd64) + ___target='x86_64-unknown-linux-musl' + ;; + linux-arm64) + ___target='aarch64-unknown-linux-musl' + ;; + linux-loongarch64) + ___target='loongarch64-unknown-linux-gnu' + ;; + linux-mips) + ___target='mips-unknown-linux-musl' + ;; + linux-mipsle|linux-mipsel) + ___target='mipsel-unknown-linux-musl' + ;; + linux-mips64) + ___target='mips64-unknown-linux-muslabi64' + ;; + linux-mips64el|linux-mips64le) + ___target='mips64el-unknown-linux-muslabi64' + ;; + linux-ppc64) + ___target='powerpc64-unknown-linux-gnu' + ;; + linux-ppc64le) + ___target='powerpc64le-unknown-linux-gnu' + ;; + linux-riscv64) + ___target='riscv64gc-unknown-linux-gnu' + ;; + linux-s390x) + ___target='s390x-unknown-linux-gnu' + ;; + linux-sparc) + ___target='sparc-unknown-linux-gnu' + ;; + netbsd-amd64) + ___target='x86_64-unknown-netbsd' + ;; + netbsd-arm64) + ___target='aarch64-unknown-netbsd' + ;; + netbsd-riscv64) + ___target='riscv64gc-unknown-netbsd' + ;; + netbsd-sparc) + ___target='sparc64-unknown-netbsd' + ;; + openbsd-amd64) + ___target='x86_64-unknown-openbsd' + ;; + openbsd-arm64) + ___target='aarch64-unknown-openbsd' + ;; + openbsd-ppc64) + ___target='powerpc64-unknown-openbsd' + ;; + openbsd-riscv64) + ___target='riscv64gc-unknown-openbsd' + ;; + openbsd-sparc) + ___target='sparc64-unknown-openbsd' + ;; + redox-amd64) + ___target='x86_64-unknown-redox' + ;; + solaris-amd64) + ___target='x86_64-pc-solaris' + ;; + wasip1-wasm) + ___target='wasm32-wasi' + ;; + windows-amd64) + ___target='x86_64-pc-windows-gnu' + ;; + windows-arm64) + ___target='aarch64-pc-windows-msvc' + ;; + *) + ___target='' + ;; + esac + printf -- "%b" "${___target}" + if [ $(STRINGS_Is_Empty "$___target") -ne 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +RUST_Is_Available() { + # execute + OS_Is_Command_Available "rustup" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "rustc" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "cargo" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +RUST_Is_Localized() { + # execute + if [ $(STRINGS_Is_Empty "$PROJECT_RUST_LOCALIZED") -ne 0 ] ; then + return 0 + fi + + + # report status + return 1 +} + + + + +RUST_Setup_Local_Environment() { + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_PATH_ROOT") -eq 0 ] ; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_PATH_TOOLS") -eq 0 ] ; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_PATH_AUTOMATA") -eq 0 ] ; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_PATH_RUST_ENGINE") -eq 0 ] ; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_OS") -eq 0 ] ; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_ARCH") -eq 0 ] ; then + return 1 + fi + + RUST_Is_Localized + if [ $? -eq 0 ] ; then + return 0 + fi + + + # execute + ___label="($PROJECT_PATH_RUST_ENGINE)" + ___location="$(RUST_Get_Activator_Path)" + export CARGO_HOME="${___location%/*}" + export RUSTUP_HOME="${___location%/*}" + + ## download installer from official portal + sh "${LIBS_AUTOMATACI}/services/compilers/rust-rustup.sh" -y --no-modify-path + + ## it's a clean repo. Start setting up localized environment... + FS_Make_Housing_Directory "$___location" + FS_Write_File "${___location}" "\ +#!/bin/sh +deactivate() { + PATH=:\${PATH}: + PATH=\${PATH//:\$CARGO_HOME/bin:/:} + PATH=\${PATH%:} + export PS1=\"\${PS1##*${___label} }\" + unset PROJECT_RUST_LOCALIZED + unset CARGO_HOME RUSTUP_HOME + return 0 +} + + +# check existing +if [ ! -z \"\$PROJECT_RUST_LOCALIZED\" ]; then + return 0 +fi + + +# activate +export CARGO_HOME='${CARGO_HOME}' +export RUSTUP_HOME='${RUSTUP_HOME}' +export PROJECT_RUST_LOCALIZED='${___location}' +export PATH=\$PATH:\${CARGO_HOME}/bin +export PS1=\"${___label} \${PS1}\" + +if [ -z \"\$(type -t 'rustup')\" ] || + [ -z \"\$(type -t 'rustc')\" ] || + [ -z \"\$(type -t 'cargo')\" ]; then + 1>&2 printf -- '[ ERROR ] missing rust compiler.\\\\n' + deactivate && unset deactivate + return 1 +fi + +return 0 +" + FS_Is_File "$___location" + if [ $? -ne 0 ]; then + return 1 + fi + + + # testing the activation + RUST_Activate_Local_Environment + if [ $? -ne 0 ] ; then + return 1 + fi + + + # setup localized compiler + rustup target add "$(RUST_Get_Build_Target "$PROJECT_OS" "$PROJECT_ARCH")" + if [ $? -ne 0 ]; then + return 1 + fi + + rustup component add llvm-tools-preview + if [ $? -ne 0 ]; then + return 1 + fi + + cargo install grcov + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/compress/gz.ps1 b/automataCI/services/compress/gz.ps1 new file mode 100644 index 0000000..48a5f0f --- /dev/null +++ b/automataCI/services/compress/gz.ps1 @@ -0,0 +1,87 @@ +# 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\io\strings.ps1" + + + + +function GZ-Create { + param ( + [string]$___source + ) + + + # validate input + $___process = GZ-Is-Available + if ($___process -ne 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${___source}") -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___source}" + if ($___process -eq 0) { + return 1 + } + + + # create .gz compressed target + $___source = $___source -replace "\.gz$" + + $___process = OS-Is-Command-Available "gzip" + if ($___process -eq 0) { + $___process = OS-Exec "gzip" "-9 `"${___source}`"" + if ($___process -ne 0) { + return 1 + } + + return 0 + } + + $___process = OS-Is-Command-Available "gunzip" + if ($___process -eq 0) { + $___process = OS-Exec "gunzip" "-9 `"${___source}`"" + if ($___process -ne 0) { + return 1 + } + + return 0 + } + + + # report status + return 1 +} + + + + +function GZ-Is-Available { + # execute + $___process = OS-Is-Command-Available "gzip" + if ($___process -eq 0) { + return 0 + } + + $___process = OS-Is-Command-Available "gunzip" + if ($___process -eq 0) { + return 0 + } + + + # report status + return 1 +} diff --git a/automataCI/services/compress/gz.sh b/automataCI/services/compress/gz.sh new file mode 100644 index 0000000..aec327a --- /dev/null +++ b/automataCI/services/compress/gz.sh @@ -0,0 +1,86 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +GZ_Create() { + ___source="$1" + + + # validate input + GZ_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$___source") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___source" + if [ $? -eq 0 ]; then + return 1 + fi + + + # create .gz compressed target + ___source="${___source%.gz}" + + OS_Is_Command_Available "gzip" + if [ $? -eq 0 ]; then + gzip -9 "$___source" + if [ $? -ne 0 ]; then + return 1 + fi + + return 0 + fi + + OS_Is_Command_Available "gunzip" + if [ $? -eq 0 ]; then + gunzip -9 "$___source" + if [ $? -ne 0 ]; then + return 1 + fi + + return 0 + fi + + + # report status + return 1 +} + + + + +GZ_Is_Available() { + # execute + OS_Is_Command_Available "gzip" + if [ $? -eq 0 ]; then + return 0 + fi + + OS_Is_Command_Available "gunzip" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} diff --git a/automataCI/services/compress/xz.ps1 b/automataCI/services/compress/xz.ps1 new file mode 100644 index 0000000..08763e1 --- /dev/null +++ b/automataCI/services/compress/xz.ps1 @@ -0,0 +1,66 @@ +# 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\io\strings.ps1" + + + + +function XZ-Create { + param ( + [string]$___source + ) + + + # validate input + $___process = XZ-Is-Available + if ($___process -ne 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${___source}") -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___source}" + if ($___process -eq 0) { + return 1 + } + + + # create .gz compressed target + $___source = $___source -replace "\.xz$" + $___process = OS-Exec "xz" "-9 --compress `"${___source}`"" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function XZ-Is-Available { + # execute + $___process = OS-Is-Command-Available "xz" + if ($___process -eq 0) { + return 0 + } + + + # report status + return 1 +} diff --git a/automataCI/services/compress/xz.sh b/automataCI/services/compress/xz.sh new file mode 100644 index 0000000..bee0a93 --- /dev/null +++ b/automataCI/services/compress/xz.sh @@ -0,0 +1,66 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +XZ_Create() { + ___source="$1" + + + # validate input + XZ_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$___source") -eq 0 ]; then + unset ___source + return 1 + fi + + FS_Is_Directory "$___source" + if [ $? -eq 0 ]; then + return 1 + fi + + + # create .gz compressed target + ___source="${___source%.xz}" + xz -9 --compress "$___source" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +XZ_Is_Available() { + # execute + OS_Is_Command_Available "xz" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} diff --git a/automataCI/services/crypto/gpg.ps1 b/automataCI/services/crypto/gpg.ps1 new file mode 100644 index 0000000..40543e8 --- /dev/null +++ b/automataCI/services/crypto/gpg.ps1 @@ -0,0 +1,146 @@ +# 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\io\strings.ps1" + + + + +function GPG-Detach-Sign-File { + param ( + [string]$___target, + [string]$___id + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___id}") -eq 0)) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -eq 0) { + return 1 + } + + $___process = GPG-Is-Available "${___id}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec ` + "gpg" "--armor --detach-sign --local-user `"${__id}`" `"${__target}`"" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function GPG-Export-Public-Key { + param( + [string]$___destination, + [string]$___id + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___destination}") -eq 0) -or + ($(STRINGS-Is-Empty "${___id}") -eq 0)) { + return 1 + } + + $___process = GPG-Is-Available "${___id}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $null = FS-Remove-Silently "${___destination}" + $___process = OS-Exec "gpg" "--armor --export `"${___id}`" > `"${___destination}`"" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function GPG-Export-Public-Keyring { + param( + [string]$___destination, + [string]$___id + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___destination}") -eq 0) -or + ($(STRINGS-Is-Empty "${___id}") -eq 0)) { + return 1 + } + + $___process = GPG-Is-Available "${___id}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $null = FS-Remove-Silently "${___destination}" + $___process = OS-Exec "gpg" "--export `"${___id}`" > `"${___destination}`"" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function GPG-Is-Available { + param ( + [string]$___id + ) + + + # execute + $___process = OS-Is-Command-Available "gpg" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Exec "gpg" "--list-key `"${___id}`"" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/crypto/gpg.sh b/automataCI/services/crypto/gpg.sh new file mode 100644 index 0000000..c8d96e9 --- /dev/null +++ b/automataCI/services/crypto/gpg.sh @@ -0,0 +1,135 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +GPG_Detach_Sign_File() { + #___target="$1" + #___id="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + GPG_Is_Available "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + gpg --armor --detach-sign --local-user "$2" "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GPG_Export_Public_Key() { + #___destination="$1" + #___id="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + GPG_Is_Available "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + FS_Remove_Silently "$1" + gpg --armor --export "$2" > "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GPG_Export_Public_Keyring() { + #___destination="$1" + #___id="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + GPG_Is_Available "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + FS_Remove_Silently "$1" + gpg --export "$2" > "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GPG_Is_Available() { + #___id="$1" + + + # execute + OS_Is_Command_Available "gpg" + if [ $? -ne 0 ]; then + return 1 + fi + + gpg --list-key "$1" &> /dev/null + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/crypto/notary.ps1 b/automataCI/services/crypto/notary.ps1 new file mode 100644 index 0000000..c3066fa --- /dev/null +++ b/automataCI/services/crypto/notary.ps1 @@ -0,0 +1,219 @@ +# 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\io\strings.ps1" + + + + +function NOTARY-Apple-Is-Available { + # execute + $___process = OS-Is-Command-Available "codesign" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Is-Command-Available "ditto" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Is-Command-Available "xcrun" + if ($___process -ne 0) { + return 1 + } + + if ($(STRINGS-IS-Empty "${env:APPLE_DEVELOPER_ID}") -eq 0) { + return 1 + } + + if ($(STRINGS-IS-Empty "${env:APPLE_KEYCHAIN_PROFILE}") -eq 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function NOTARY-Microsoft-Is-Available { + # execute + $___process = OS-Is-Command-Available "signtool" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${env:MICROSOFT_CERT}" + if ($___process -ne 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:MICROSOFT_CERT_TYPE}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:MICROSOFT_CERT_TIMESTAMP}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:MICROSOFT_CERT_HASH}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:MICROSOFT_CERT_PASSWORD}") -eq 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function NOTARY-Setup-Microsoft { + # report status + return 0 # not applicable +} + + + + +function NOTARY-Sign-Apple { + param ( + [string]$___file, + [string]$___destination + ) + + + # validate input + $___process = NOTARY-Apple-Is-Available + if ($___process -ne 0) { + return 1 + } + + if (($(STRINGS-Is-Empty "${___file}") -eq 0) -or + ($(STRINGS-Is-Empty "${___destination}") -eq 0)) { + return 1 + } + + $___process = FS-Is-File "${___file}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___arguments = "--force " ` + + "--options " ` + + "runtime " ` + + "--deep " ` + + "--sign " ` + + "${env:APPLE_DEVELOPER_ID} " ` + + "${___file}" + $___process = OS-Exec "codesign" "${___arguments}" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Exec "ditto" "-c -k --keepParent ${___file} ${___file}.zip" + if ($___process -ne 0) { + return 1 + } + + $___arguments = "notarytool " ` + + "submit " ` + + "${___file}.zip " ` + + "--keychain-profile `"${env:APPLE_KEYCHAIN_PROFILE}`" " ` + + "--wait" + $___process = OS-Exec "xcrun" "${___arguments}" + if ($___process -ne 0) { + return 1 + } + + $null = FS-Remove-Silently "${___file}.zip" + + $___process = OS-Exec "xcrun" "stapler staple `"${___file}`"" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Move "${___file}" "${___destination}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function NOTARY-Sign-Microsoft { + param ( + [string]$___file, + [string]$___destination, + [string]$___name, + [string]$___website + ) + + + # validate input + $___process = NOTARY-Microsoft-Is-Available + if ($___process -ne 0) { + return 1 + } + + if (($(STRINGS-Is-Empty "${___name}") -eq 0) -or + ($(STRINGS-Is-Empty "${___website}") -eq 0)) { + return 1 + } + + $___process = FS-Is-File "${___file}" + if ($___process -ne 0) { + return 1 + } + + + # execute + switch (${env:MICROSOFT_CERT_TYPE}) { + PKCS12 { + $___arguments = "sign " ` + + "/f ${env:MICROSOFT_CERT} " ` + + "/fd ${env:MICROSOFT_CERT_HASH} " ` + + "/p ${env:MICROSOFT_CERT_PASSWORD} " ` + + "/n ${___name} " ` + + "/du ${___website} " ` + + "/t ${env:MICROSOFT_CERT_TIMESTAMP} " ` + + "${___file}" + } default { + return 1 + }} + + $___process = OS-Exec "signtool" "${___arguments}" + if ($___process -ne 0) { + return 1 + } + + $null = FS-Move "${___file}" "${___destination}" + + + # report status + return 0 +} diff --git a/automataCI/services/crypto/notary.sh b/automataCI/services/crypto/notary.sh new file mode 100644 index 0000000..6de541c --- /dev/null +++ b/automataCI/services/crypto/notary.sh @@ -0,0 +1,270 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +NOTARY_Apple_Is_Available() { + # execute + OS_Is_Command_Available "codesign" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "ditto" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "xcrun" + if [ $? -ne 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$APPLE_DEVELOPER_ID") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$APPLE_KEYCHAIN_PROFILE") -eq 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NOTARY_Microsoft_Is_Available() { + # execute + OS_Is_Command_Available "osslsigncode" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "$MICROSOFT_CERT" + if [ $? -ne 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$MICROSOFT_CERT_TYPE") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$MICROSOFT_CERT_TIMESTAMP") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$MICROSOFT_CERT_HASH") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$MICROSOFT_CERT_PASSWORD") -eq 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NOTARY_Setup_Microsoft() { + # validate input + OS_Is_Command_Available "brew" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "osslsigncode" + if [ $? -eq 0 ]; then + return 0 + fi + + + # execute + brew install osslsigncode + + + # report status + if [ $? -eq 0 ]; then + return 0 + fi + + return 1 +} + + + + +NOTARY_Sign_Apple() { + #___destination="$1" + #___file="$2" + + + # validate input + NOTARY_Apple_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + codesign --force --options runtime --deep --sign "$APPLE_DEVELOPER_ID" "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + ditto -c -k --keepParent "$2" "${2}.zip" + if [ $? -ne 0 ]; then + return 1 + fi + + xcrun notarytool \ + submit \ + "${2}.zip" \ + --keychain-profile "$APPLE_KEYCHAIN_PROFILE" \ + --wait + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Remove_Silently "${2}.zip" + + xcrun stapler staple "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Move "$2" "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NOTARY_Sign_Microsoft() { + ___destination="$1" + ___file="$2" + ___name="$3" + ___website="$4" + + + # validate input + NOTARY_Microsoft_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$___name") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___website") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___destination") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$___file" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + case "$MICROSOFT_CERT_TYPE" in + CERT) + FS_Is_File "$MICROSOFT_CERT_KEYFILE" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Remove_Silently "$___destination" + osslsigncode sign \ + -certs "$MICROSOFT_CERT" \ + -h "$MICROSOFT_CERT_HASH" \ + -key "$MICROSOFT_CERT_KEYFILE" \ + -pass "$MICROSOFT_CERT_PASSWORD" \ + -n "$___name" \ + -i "$___website" \ + -t "$MICROSOFT_CERT_TIMESTAMP" \ + -in "$___file" \ + -out "$___destination" + if [ $? -ne 0 ]; then + return 1 + fi + ;; + SPC) + FS_Is_File "$MICROSOFT_CERT_KEYFILE" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Remove_Silently "$___destination" + osslsigncode sign \ + -spc "$MICROSOFT_CERT" \ + -h "$MICROSOFT_CERT_HASH" \ + -key "$MICROSOFT_CERT_KEYFILE" \ + -pass "$MICROSOFT_CERT_PASSWORD" \ + -n "$___name" \ + -i "$___website" \ + -t "$MICROSOFT_CERT_TIMESTAMP" \ + -in "$___file" \ + -out "$___destination" + if [ $? -ne 0 ]; then + return 1 + fi + ;; + PKCS12) + FS_Remove_Silently "$___destination" + osslsigncode sign \ + -pkcs12 "$MICROSOFT_CERT" \ + -h "$MICROSOFT_CERT_HASH" \ + -pass "$MICROSOFT_CERT_PASSWORD" \ + -n "$___name" \ + -i "$___website" \ + -t "$MICROSOFT_CERT_TIMESTAMP" \ + -in "$___file" \ + -out "$___destination" + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + return 1 + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/crypto/random.ps1 b/automataCI/services/crypto/random.ps1 new file mode 100644 index 0000000..427f42e --- /dev/null +++ b/automataCI/services/crypto/random.ps1 @@ -0,0 +1,163 @@ +#!/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. +. "${env:LIBS_AUTOMATACI}\services\io\time.ps1" + + + + +function RANDOM-Create-BINARY { + param( + [long]$___length + ) + + + # execute + return RANDOM-Create-Data "${___length}" "01" +} + + + + +function RANDOM-Create-Data { + param( + [long]$___length, + [string]$___charset + ) + + + # validate input + if ($___length -le 0) { + $___length = 33 + } + + $__process = STRINGS-Is-Empty "${___charset}" + if ($__process -eq 0) { + return "" + } + + + # execute + $___outcome = [char[]]@(0) * $___length + $___bytes = [byte[]]@(0) * $___length + $___crypter = [System.Security.Cryptography.RandomNumberGenerator]::Create() + $null = $___crypter.GetBytes($___bytes) + $null = $___crypter.Dispose() + + for ($___i = 0; $___i -lt $___length; $___i++) { + $___index = [int] ($___bytes[$___i] % $___charset.Length) + $___outcome[$___i] = [char] $___charset[$___index] + } + + + # report status + return $___outcome -join ""; +} + + + + +function RANDOM-Create-DECIMAL { + param( + [long]$___length + ) + + + # execute + return RANDOM-Create-Data "${___length}" "0123456789" +} + + + + +function RANDOM-Create-HEX { + param( + [long]$___length + ) + + + # execute + return RANDOM-Create-Data "${___length}" "0123456789ABCDEF" +} + + + + +function RANDOM-Create-STRING { + param( + [long]$___length, + [string]$___charset + ) + + + # validate input + $__process = STRINGS-Is-Empty "${___charset}" + if ($__process -eq 0) { + $___charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + $___charset += "abcdefghijklmnopqrstuvwxyz" + $___charset += "0123456789" + } + + + # execute + return RANDOM-Create-Data "${___length}" "${___charset}" +} + + + + +function RANDOM-Create-UUID { + # execute + $___length_data = 24 + $___length_epoch = 8 + + $___data = "$(RANDOM-Create-HEX $___length_data)" + $___epoch = '{0:X}' -f ([int] $(Time-Now)) + + $___output = "" + $___length_data -= 1 + $___length_epoch -= 1 + for ($___count = 0; $___count -lt 32; $___count++) { + switch ($___count) { + { $_ -in 8, 12, 16, 20 } { + # add uuid dashes at correct index + $___output += "-" + } default { + # do nothing + }} + + if (($(RANDOM-Create-BINARY 1) -eq "1") -and ($___length_epoch -ge 0)) { + # gamble and add 1 character from epoch if won + $___output += $___epoch.Substring(0,1) + $___epoch = $___epoch.Substring(1) + $___length_epoch -= 1 + } elseif ($___length_data -ge 0) { + # add random character otherwise + $___output += $___data.Substring(0,1) + $___data = $___data.Substring(1) + $___length_data -= 1 + } elseif ($___length_epoch -ge 0) { + # only epoch left + $___output += $___epoch.Substring(0,1) + $___epoch = $___epoch.Substring(1) + $___length_epoch -= 1 + } else { + # impossible error edge cases - return nothing and fail + # is better than faulty. + return "" + } + } + + + # report status + return $___output +} diff --git a/automataCI/services/crypto/random.sh b/automataCI/services/crypto/random.sh new file mode 100644 index 0000000..ad8b820 --- /dev/null +++ b/automataCI/services/crypto/random.sh @@ -0,0 +1,195 @@ +#!/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/time.sh" + + + + +RANDOM_Create_BINARY() { + #___length="$1" + + + # execute + printf -- "%s" "$(RANDOM_Create_Data "$1" '0-1')" + return $? +} + + + + +RANDOM_Create_Data() { + #___length="$1" + #___charset="$2" + + + # validate input + if [ -n "$1" -a $1 -eq $1 2> /dev/null -a $1 -gt 0 ]; then + ___length=$1 + else + ___length=33 + fi + + if [ "$(STRINGS_Is_Empty "$2")" = "0" ]; then + printf -- "" + return 1 + fi + + if [ -z "$(type -t dd)" ]; then + printf -- "" + return 1 + fi + + if [ -z "$(type -t tr)" ]; then + printf -- "" + return 1 + fi + + if [ ! -e "/dev/urandom" ]; then + printf -- "" + return 1 + fi + + + # execute + ___output="" + ___count=0 + + # NOTE: + # (1) MacOS's 'tr' won't break itself when reading directly from + # /dev/urandom. + # (2) Using 'dd' directly against /dev/urandom cannot warrant the + # output length we wanted. + # (3) So, we do not have a choice but to perform loop capturing until + # we get exactly what we wanted. + # (4) If you have better idea without compromising crypto-randomness + # while improving the performance, please inform the maintainers. + # (5) For now, this is what we have. Blame note (1) for behaving + # funny especially coming from an organ-selling priced hardware. + while [ $___count -ne $___length ]; do + ___char="$(dd bs=1 if=/dev/urandom count=1 2> /dev/null \ + | LC_ALL=C tr -dc "$2" 2> /dev/null)" + if [ -z "$___char" ]; then + continue + fi + + ___output="${___output}${___char}" + + # increase counter for successful capture + ___count=$(($___count + ${#___char})) + done + + + # report status + printf -- "%b" "$___output" + return 0 +} + + + + +RANDOM_Create_DECIMAL() { + #___length="$1" + + + # execute + printf -- "%s" "$(RANDOM_Create_Data "$1" '0-9')" + return $? +} + + + + +RANDOM_Create_HEX() { + #___length="$1" + + + # execute + printf -- "%s" "$(RANDOM_Create_Data "$1" 'A-F0-9')" + return $? +} + + + + +RANDOM_Create_STRING() { + #___length="$1" + #___charset="$2" + + + # execute + printf -- "%s" "$(RANDOM_Create_Data "$1" "${2:-a-zA-Z0-9}")" + return $? +} + + + + +RANDOM_Create_UUID() { + # execute + ___length_data=24 + ___length_epoch=8 + + ___data="$(RANDOM_Create_HEX "$___length_data")" + ___epoch="$(printf -- "%X" "$(TIME_Now)")" + + ___output="" + ___length_epoch=$(($___length_epoch - 1)) + ___length_data=$(($___length_data - 1)) + ___count=0 + while [ $___count -lt 32 ]; do + case "$___count" in + 8|12|16|20) + # add uuid dashes at correct index + ___output="${___output}-" + ;; + *) + # do nothing + ;; + esac + + if [ "$(RANDOM_Create_BINARY 1)" = "1" ] && [ $___length_epoch -ge 0 ]; then + # gamble and add 1 character from epoch if won + ___remainder="${___epoch#?}" + ___output="${___output}${___epoch%"$___remainder"}" + ___epoch="$___remainder" + ___length_epoch=$(($___length_epoch - 1)) + elif [ $___length_data -ge 0 ]; then + # add random character otherwise + ___remainder="${___data#?}" + ___output="${___output}${___data%"$___remainder"}" + ___data="$___remainder" + ___length_data=$(($___length_data - 1)) + elif [ $___length_epoch -ge 0 ]; then + # only epoch left + ___remainder="${___epoch#?}" + ___output="${___output}${___epoch%"$___remainder"}" + ___epoch="$___remainder" + ___length_epoch=$(($___length_epoch - 1)) + else + # impossible error edge cases - return nothing and fail + # is better than faulty. + 1>&2 printf -- "bail: %s \n" "$___output" + printf -- "" + return 1 + fi + + + # increase counter since POSIX does not have C like for loop. + ___count=$(($___count + 1)) + done + + + # report status + printf -- "%s" "$___output" + return 0 +} diff --git a/automataCI/services/i18n/__param.ps1 b/automataCI/services/i18n/__param.ps1 new file mode 100644 index 0000000..2104d3f --- /dev/null +++ b/automataCI/services/i18n/__param.ps1 @@ -0,0 +1,37 @@ +# 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\strings.ps1" + + + + +function I18N-Param-Process { + param( + [string]$___subject + ) + + + # execute + if ($(STRINGS-Is-Empty "${___subject}") -ne 0) { + return $___subject + } + + switch ("${env:AUTOMATACI_LANG}") { + default { + # fallback to default english + return "⸨⸨ DEV! MISSING PARAM! ⸩⸩" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/__param.sh b/automataCI/services/i18n/__param.sh new file mode 100644 index 0000000..0ab158b --- /dev/null +++ b/automataCI/services/i18n/__param.sh @@ -0,0 +1,34 @@ +# 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/strings.sh" + + + + +I18N_Param_Process() { + #___subject="$1" + + + # execute + if [ $(STRINGS_Is_Empty "${1}") -ne 0 ]; then + printf -- "%b" "$1" + return 0 + fi + + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + printf -- "%b" "⸨⸨ DEV! MISSING PARAM! ⸩⸩" + return 0 + ;; + esac +} diff --git a/automataCI/services/i18n/__printer.ps1 b/automataCI/services/i18n/__printer.ps1 new file mode 100644 index 0000000..8f4548e --- /dev/null +++ b/automataCI/services/i18n/__printer.ps1 @@ -0,0 +1,141 @@ +# 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. +function I18N-Status-Print { + param( + [string]$___mode, + [string]$___message + ) + + + # execute + $___tag = I18N-Status-Tag-Get-Type "${___mode}" + $___color = "" + $___foreground_color = "Gray" + switch ($___mode) { + error { + $___color = "31" + $___foreground_color = "Red" + } warning { + $___color = "33" + $___foreground_color = "Yellow" + } info { + $___color = "36" + $___foreground_color = "Cyan" + } note { + $___color = "35" + $___foreground_color = "Magenta" + } success { + $___color = "32" + $___foreground_color = "Green" + } ok { + $___color = "36" + $___foreground_color = "Cyan" + } done { + $___color = "36" + $___foreground_color = "Cyan" + } default { + # do nothing + }} + + if (($Host.UI.RawUI.ForegroundColor -ge "DarkGray") -or + ("$env:TERM" -eq "xterm-256color") -or + ("$env:COLORTERM" -eq "truecolor", "24bit")) { + # terminal supports color mode + if ((-not ([string]::IsNullOrEmpty($___color))) -and + (-not ([string]::IsNullOrEmpty($___foreground_color)))) { + $null = Write-Host ` + -NoNewLine ` + -ForegroundColor $___foreground_color ` + "$([char]0x1b)[1;${___color}m${___tag}$([char]0x1b)[0;${___color}m${___message}$([char]0x1b)[0m" + } else { + $null = Write-Host -NoNewLine "${___tag}${___message}" + } + } else { + $null = Write-Host -NoNewLine "${___tag}${___message}" + } + + $null = Remove-Variable -Name ___mode -ErrorAction SilentlyContinue + $null = Remove-Variable -Name ___tag -ErrorAction SilentlyContinue + $null = Remove-Variable -Name ___message -ErrorAction SilentlyContinue + $null = Remove-Variable -Name ___color -ErrorAction SilentlyContinue + $null = Remove-Variable -Name ___foreground_color -ErrorAction SilentlyContinue + + + # report status + return 0 +} + + + + +function I18N-Status-Tag-Create { + param( + [string]$___content, + [string]$___spacing + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___content}") -eq 0) { + return "" + } + + + # execute + return "⦗${___content}⦘${___spacing}" +} + + + + +function I18N-Status-Tag-Get-Type { + param( + [string]$___mode + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + return I18N-Status-Tag-Get-Type-EN "${___mode}" + }} +} + + + + +function I18N-Status-Tag-Get-Type-EN { + param( + [string]$___mode + ) + + + # execute (REMEMBER: make sure the text and spacing are having the same length) + switch ($___mode) { + error { + return I18N-Status-Tag-Create " ERROR " " " + } warning { + return I18N-Status-Tag-Create " WARNING " " " + } info { + return I18N-Status-Tag-Create " INFO " " " + } note { + return I18N-Status-Tag-Create " NOTE " " " + } success { + return I18N-Status-Tag-Create " SUCCESS " " " + } ok { + return I18N-Status-Tag-Create " OK " " " + } done { + return I18N-Status-Tag-Create " DONE " " " + } default { + return "" + }} +} diff --git a/automataCI/services/i18n/__printer.sh b/automataCI/services/i18n/__printer.sh new file mode 100644 index 0000000..7e0d350 --- /dev/null +++ b/automataCI/services/i18n/__printer.sh @@ -0,0 +1,132 @@ +# 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. +I18N_Status_Print() { + #___mode="$1" + #___message="$2" + + + # execute + ___tag="$(I18N_Status_Tag_Get_Type "$1")" + ___color="" + case "$1" in + error) + ___color="31" + ;; + warning) + ___color="33" + ;; + info) + ___color="36" + ;; + note) + ___color="35" + ;; + success) + ___color="32" + ;; + ok) + ___color="36" + ;; + done) + ___color="36" + ;; + *) + # do nothing + ;; + esac + + if [ ! -z "$COLORTERM" ] || [ "$TERM" = "xterm-256color" ]; then + # terminal supports color mode + if [ ! -z "$___color" ]; then + 1>&2 printf -- "%b" \ + "\033[1;${___color}m${___tag}\033[0;${___color}m${2}\033[0m" + else + 1>&2 printf -- "%b" "${___tag}${2}" + fi + else + 1>&2 printf -- "%b" "${___tag}${2}" + fi + + unset ___color ___tag +} + + + + +I18N_Status_Tag_Create() { + #___content="$1" + #___spacing="$2" + + + # validate input + if [ "$(STRINGS_Is_Empty "$1")" -eq 0 ]; then + printf -- "" + return 0 + fi + + + # execute + printf -- "%b" "⦗$1⦘$2" + return 0 +} + + + + +I18N_Status_Tag_Get_Type() { + #___mode="$1" + + + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + printf -- "%b" "$(I18N_Status_Tag_Get_Type_EN "$1")" + ;; + esac +} + + + + +I18N_Status_Tag_Get_Type_EN() { + #___mode="$1" + + + # execute (REMEMBER: make sure the text and spacing are having the same length) + case "$1" in + error) + printf -- "%b" "$(I18N_Status_Tag_Create " ERROR " " ")" + ;; + warning) + printf -- "%b" "$(I18N_Status_Tag_Create " WARNING " " ")" + ;; + info) + printf -- "%b" "$(I18N_Status_Tag_Create " INFO " " ")" + ;; + note) + printf -- "%b" "$(I18N_Status_Tag_Create " NOTE " " ")" + ;; + success) + printf -- "%b" "$(I18N_Status_Tag_Create " SUCCESS " " ")" + ;; + ok) + printf -- "%b" "$(I18N_Status_Tag_Create " OK " " ")" + ;; + done) + printf -- "%b" "$(I18N_Status_Tag_Create " DONE " " ")" + ;; + *) + printf -- "" + ;; + esac +} diff --git a/automataCI/services/i18n/_activate-environment.ps1 b/automataCI/services/i18n/_activate-environment.ps1 new file mode 100644 index 0000000..0a235d0 --- /dev/null +++ b/automataCI/services/i18n/_activate-environment.ps1 @@ -0,0 +1,28 @@ +# 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-Activate-Environment { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print info "activating local environment...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_activate-environment.sh b/automataCI/services/i18n/_activate-environment.sh new file mode 100644 index 0000000..4bf8efc --- /dev/null +++ b/automataCI/services/i18n/_activate-environment.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_Activate_Environment() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print info "activating local environment...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_activate-failed.ps1 b/automataCI/services/i18n/_activate-failed.ps1 new file mode 100644 index 0000000..cbbc463 --- /dev/null +++ b/automataCI/services/i18n/_activate-failed.ps1 @@ -0,0 +1,28 @@ +# 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-Activate-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "activate failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_activate-failed.sh b/automataCI/services/i18n/_activate-failed.sh new file mode 100644 index 0000000..c4ced03 --- /dev/null +++ b/automataCI/services/i18n/_activate-failed.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_Activate_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "activate failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_archive-failed.ps1 b/automataCI/services/i18n/_archive-failed.ps1 new file mode 100644 index 0000000..7573d50 --- /dev/null +++ b/automataCI/services/i18n/_archive-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Archive-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "archive failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_archive-failed.sh b/automataCI/services/i18n/_archive-failed.sh new file mode 100644 index 0000000..249c46d --- /dev/null +++ b/automataCI/services/i18n/_archive-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Archive_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "archive failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_archive.ps1 b/automataCI/services/i18n/_archive.ps1 new file mode 100644 index 0000000..7bf6415 --- /dev/null +++ b/automataCI/services/i18n/_archive.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Archive { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "archiving '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_archive.sh b/automataCI/services/i18n/_archive.sh new file mode 100644 index 0000000..a7da6c9 --- /dev/null +++ b/automataCI/services/i18n/_archive.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Archive() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "archiving '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_assemble-failed.ps1 b/automataCI/services/i18n/_assemble-failed.ps1 new file mode 100644 index 0000000..59159d0 --- /dev/null +++ b/automataCI/services/i18n/_assemble-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Assemble-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "assembly failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_assemble-failed.sh b/automataCI/services/i18n/_assemble-failed.sh new file mode 100644 index 0000000..3427e0f --- /dev/null +++ b/automataCI/services/i18n/_assemble-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Assemble_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "assembly failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_assemble-package.ps1 b/automataCI/services/i18n/_assemble-package.ps1 new file mode 100644 index 0000000..2224d40 --- /dev/null +++ b/automataCI/services/i18n/_assemble-package.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Assemble-Package { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print info "assembling package files...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_assemble-package.sh b/automataCI/services/i18n/_assemble-package.sh new file mode 100644 index 0000000..cc72621 --- /dev/null +++ b/automataCI/services/i18n/_assemble-package.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Assemble_Package() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print info "assembling package file...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_assemble-skipped.ps1 b/automataCI/services/i18n/_assemble-skipped.ps1 new file mode 100644 index 0000000..6c5ed21 --- /dev/null +++ b/automataCI/services/i18n/_assemble-skipped.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Assemble-Skipped { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning "assembly not required. Skipping...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_assemble-skipped.sh b/automataCI/services/i18n/_assemble-skipped.sh new file mode 100644 index 0000000..8b65403 --- /dev/null +++ b/automataCI/services/i18n/_assemble-skipped.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Assemble_Skipped() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "assembly not required. Skipping...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_assemble.ps1 b/automataCI/services/i18n/_assemble.ps1 new file mode 100644 index 0000000..5357c19 --- /dev/null +++ b/automataCI/services/i18n/_assemble.ps1 @@ -0,0 +1,38 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Assemble { + param( + [string]$___subject, + [string]$___target + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $___target = I18N-Param-Process "${___target}" + $null = I18N-Status-Print info ` + "assembling '${___subject}' as/into '${___target}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_assemble.sh b/automataCI/services/i18n/_assemble.sh new file mode 100644 index 0000000..296d232 --- /dev/null +++ b/automataCI/services/i18n/_assemble.sh @@ -0,0 +1,36 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Assemble() { + ___subject="$1" + ___target="$2" + + + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "${___subject}")" + ___target="$(I18N_Param_Process "${___target}")" + I18N_Status_Print info "assembling '${___subject}' as/into '${___target}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_build-failed-parallel.ps1 b/automataCI/services/i18n/_build-failed-parallel.ps1 new file mode 100644 index 0000000..1e6769a --- /dev/null +++ b/automataCI/services/i18n/_build-failed-parallel.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Build-Failed-Parallel { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print error "build failed (${___subject}).`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_build-failed-parallel.sh b/automataCI/services/i18n/_build-failed-parallel.sh new file mode 100644 index 0000000..f14b890 --- /dev/null +++ b/automataCI/services/i18n/_build-failed-parallel.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Build_Failed_Parallel() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print error "build failed (${___subject}).\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_build-failed.ps1 b/automataCI/services/i18n/_build-failed.ps1 new file mode 100644 index 0000000..9aa814e --- /dev/null +++ b/automataCI/services/i18n/_build-failed.ps1 @@ -0,0 +1,28 @@ +# 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-Build-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "build failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_build-failed.sh b/automataCI/services/i18n/_build-failed.sh new file mode 100644 index 0000000..b0de110 --- /dev/null +++ b/automataCI/services/i18n/_build-failed.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_Build_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "build failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_build-parallel.ps1 b/automataCI/services/i18n/_build-parallel.ps1 new file mode 100644 index 0000000..e8a6569 --- /dev/null +++ b/automataCI/services/i18n/_build-parallel.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Build-Parallel { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "building '${___subject}' in parallel...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_build-parallel.sh b/automataCI/services/i18n/_build-parallel.sh new file mode 100644 index 0000000..6667588 --- /dev/null +++ b/automataCI/services/i18n/_build-parallel.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Build_Parallel() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "building '${___subject}' in parallel...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_build.ps1 b/automataCI/services/i18n/_build.ps1 new file mode 100644 index 0000000..024fa10 --- /dev/null +++ b/automataCI/services/i18n/_build.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-Build { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "building '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_build.sh b/automataCI/services/i18n/_build.sh new file mode 100644 index 0000000..2438302 --- /dev/null +++ b/automataCI/services/i18n/_build.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_Build() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "building '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-availability.ps1 b/automataCI/services/i18n/_check-availability.ps1 new file mode 100644 index 0000000..2749381 --- /dev/null +++ b/automataCI/services/i18n/_check-availability.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Check-Availability { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "checking '${___subject}' availability...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-availability.sh b/automataCI/services/i18n/_check-availability.sh new file mode 100644 index 0000000..e0a8de9 --- /dev/null +++ b/automataCI/services/i18n/_check-availability.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Check_Availability() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "checking '${___subject}' availability...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-failed-skipped.ps1 b/automataCI/services/i18n/_check-failed-skipped.ps1 new file mode 100644 index 0000000..754d676 --- /dev/null +++ b/automataCI/services/i18n/_check-failed-skipped.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Check-Failed-Skipped { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning "check failed. Skipping...`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-failed-skipped.sh b/automataCI/services/i18n/_check-failed-skipped.sh new file mode 100644 index 0000000..ba5953d --- /dev/null +++ b/automataCI/services/i18n/_check-failed-skipped.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Check_Failed_Skipped() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "check failed. Skipping...\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-failed.ps1 b/automataCI/services/i18n/_check-failed.ps1 new file mode 100644 index 0000000..858ef20 --- /dev/null +++ b/automataCI/services/i18n/_check-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Check-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "check failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-failed.sh b/automataCI/services/i18n/_check-failed.sh new file mode 100644 index 0000000..14453f5 --- /dev/null +++ b/automataCI/services/i18n/_check-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Check_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "check failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-function.ps1 b/automataCI/services/i18n/_check-function.ps1 new file mode 100644 index 0000000..d7a6429 --- /dev/null +++ b/automataCI/services/i18n/_check-function.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Check-Function { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "checking '${___subject}' function...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-function.sh b/automataCI/services/i18n/_check-function.sh new file mode 100644 index 0000000..268a386 --- /dev/null +++ b/automataCI/services/i18n/_check-function.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Check_Function() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "checking '${___subject}' function...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-incompatible-skipped.ps1 b/automataCI/services/i18n/_check-incompatible-skipped.ps1 new file mode 100644 index 0000000..db2fa76 --- /dev/null +++ b/automataCI/services/i18n/_check-incompatible-skipped.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Check-Incompatible-Skipped { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning "incompatible check. Skipping...`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-incompatible-skipped.sh b/automataCI/services/i18n/_check-incompatible-skipped.sh new file mode 100644 index 0000000..aa9d59f --- /dev/null +++ b/automataCI/services/i18n/_check-incompatible-skipped.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Check_Incompatible_Skipped() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "incompatible check. Skipping...\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-login.ps1 b/automataCI/services/i18n/_check-login.ps1 new file mode 100644 index 0000000..a1185c8 --- /dev/null +++ b/automataCI/services/i18n/_check-login.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Check-Login { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "checking '${___subject}' login status...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-login.sh b/automataCI/services/i18n/_check-login.sh new file mode 100644 index 0000000..0952eb3 --- /dev/null +++ b/automataCI/services/i18n/_check-login.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Check_Login() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "checking '${___subject}' login status...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check.ps1 b/automataCI/services/i18n/_check.ps1 new file mode 100644 index 0000000..5c0b801 --- /dev/null +++ b/automataCI/services/i18n/_check.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Check { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "checking '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check.sh b/automataCI/services/i18n/_check.sh new file mode 100644 index 0000000..2fc339f --- /dev/null +++ b/automataCI/services/i18n/_check.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Check() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "checking '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_checksum-failed.ps1 b/automataCI/services/i18n/_checksum-failed.ps1 new file mode 100644 index 0000000..e8d2b60 --- /dev/null +++ b/automataCI/services/i18n/_checksum-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Status-Print-Checksum-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "checksum failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_checksum-failed.sh b/automataCI/services/i18n/_checksum-failed.sh new file mode 100644 index 0000000..a2c05d0 --- /dev/null +++ b/automataCI/services/i18n/_checksum-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Checksum_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "checksum failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_checksum.ps1 b/automataCI/services/i18n/_checksum.ps1 new file mode 100644 index 0000000..0fbe9e3 --- /dev/null +++ b/automataCI/services/i18n/_checksum.ps1 @@ -0,0 +1,43 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Checksum { + param( + [string]$___subject, + [string]$___algo + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + + if ($(STRINGS-Is-Empty "${___algo}") -ne 0) { + $null = I18N-Status-Print info ` + "${___algo} checksum-ing '${___subject}'...`n" + } else { + $null = I18N-Status-Print info ` + "checksum-ing '${___subject}'...`n" + } + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_checksum.sh b/automataCI/services/i18n/_checksum.sh new file mode 100644 index 0000000..85e7f10 --- /dev/null +++ b/automataCI/services/i18n/_checksum.sh @@ -0,0 +1,40 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Checksum() { + ___subject="$1" + ___algo="$2" + + + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + + if [ $(STRINGS_Is_Empty "${___algo}") -ne 0 ]; then + I18N_Status_Print info "${___algo} checksum-ing '${___subject}'...\n" + else + I18N_Status_Print info "checksum-ing '${___subject}'...\n" + fi + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_clean-failed.ps1 b/automataCI/services/i18n/_clean-failed.ps1 new file mode 100644 index 0000000..f766c97 --- /dev/null +++ b/automataCI/services/i18n/_clean-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Clean-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "clean failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_clean-failed.sh b/automataCI/services/i18n/_clean-failed.sh new file mode 100644 index 0000000..ff2b9b8 --- /dev/null +++ b/automataCI/services/i18n/_clean-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Clean_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "clean failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_clean.ps1 b/automataCI/services/i18n/_clean.ps1 new file mode 100644 index 0000000..65273b9 --- /dev/null +++ b/automataCI/services/i18n/_clean.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Clean { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "cleaning up '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_clean.sh b/automataCI/services/i18n/_clean.sh new file mode 100644 index 0000000..d47642d --- /dev/null +++ b/automataCI/services/i18n/_clean.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Clean() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "cleaning up '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_commit-failed.ps1 b/automataCI/services/i18n/_commit-failed.ps1 new file mode 100644 index 0000000..ff157b1 --- /dev/null +++ b/automataCI/services/i18n/_commit-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Commit-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "commit failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_commit-failed.sh b/automataCI/services/i18n/_commit-failed.sh new file mode 100644 index 0000000..075d7b1 --- /dev/null +++ b/automataCI/services/i18n/_commit-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Commit_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "commit failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_commit.ps1 b/automataCI/services/i18n/_commit.ps1 new file mode 100644 index 0000000..ce000a5 --- /dev/null +++ b/automataCI/services/i18n/_commit.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Commit { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "committing '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_commit.sh b/automataCI/services/i18n/_commit.sh new file mode 100644 index 0000000..5c3fd53 --- /dev/null +++ b/automataCI/services/i18n/_commit.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Commit() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "committing '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_configure-build-settings.ps1 b/automataCI/services/i18n/_configure-build-settings.ps1 new file mode 100644 index 0000000..3e82c65 --- /dev/null +++ b/automataCI/services/i18n/_configure-build-settings.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Configure-Build-Settings { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print info "configuring build settings...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_configure-build-settings.sh b/automataCI/services/i18n/_configure-build-settings.sh new file mode 100644 index 0000000..95a5055 --- /dev/null +++ b/automataCI/services/i18n/_configure-build-settings.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Configure_Build_Settings() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print info "configuring build settings...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_configure-failed.ps1 b/automataCI/services/i18n/_configure-failed.ps1 new file mode 100644 index 0000000..9970e50 --- /dev/null +++ b/automataCI/services/i18n/_configure-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Configure-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "configure failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_configure-failed.sh b/automataCI/services/i18n/_configure-failed.sh new file mode 100644 index 0000000..60e2f32 --- /dev/null +++ b/automataCI/services/i18n/_configure-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Configure_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "configure failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_copy-failed.ps1 b/automataCI/services/i18n/_copy-failed.ps1 new file mode 100644 index 0000000..f0c61c4 --- /dev/null +++ b/automataCI/services/i18n/_copy-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Copy-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "copy failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_copy-failed.sh b/automataCI/services/i18n/_copy-failed.sh new file mode 100644 index 0000000..f791188 --- /dev/null +++ b/automataCI/services/i18n/_copy-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Copy_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "copy failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_copy.ps1 b/automataCI/services/i18n/_copy.ps1 new file mode 100644 index 0000000..24edabc --- /dev/null +++ b/automataCI/services/i18n/_copy.ps1 @@ -0,0 +1,38 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Copy { + param( + [string]$___subject, + [string]$___target + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $___target = I18N-Param-Process "${___target}" + $null = I18N-Status-Print info ` + "copying '${___subject}' into/as '${___target}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_copy.sh b/automataCI/services/i18n/_copy.sh new file mode 100644 index 0000000..f52b3b3 --- /dev/null +++ b/automataCI/services/i18n/_copy.sh @@ -0,0 +1,32 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Copy() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + ___target="$(I18N_Param_Process "$2")" + I18N_Status_Print info "copy '${___subject}' into/as '${___target}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_create-failed.ps1 b/automataCI/services/i18n/_create-failed.ps1 new file mode 100644 index 0000000..d8d6755 --- /dev/null +++ b/automataCI/services/i18n/_create-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Create-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "create failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_create-failed.sh b/automataCI/services/i18n/_create-failed.sh new file mode 100644 index 0000000..7fd3f72 --- /dev/null +++ b/automataCI/services/i18n/_create-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Create_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "create failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_create-package.ps1 b/automataCI/services/i18n/_create-package.ps1 new file mode 100644 index 0000000..bc600f9 --- /dev/null +++ b/automataCI/services/i18n/_create-package.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Create-Package { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "creating '${___subject}' package...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_create-package.sh b/automataCI/services/i18n/_create-package.sh new file mode 100644 index 0000000..7909947 --- /dev/null +++ b/automataCI/services/i18n/_create-package.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Create_Package() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "creating '${___subject}' package...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_create.ps1 b/automataCI/services/i18n/_create.ps1 new file mode 100644 index 0000000..b6e9ea8 --- /dev/null +++ b/automataCI/services/i18n/_create.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Create { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "creating '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_create.sh b/automataCI/services/i18n/_create.sh new file mode 100644 index 0000000..8e1325f --- /dev/null +++ b/automataCI/services/i18n/_create.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Create() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "creating '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_detected.ps1 b/automataCI/services/i18n/_detected.ps1 new file mode 100644 index 0000000..82a9e01 --- /dev/null +++ b/automataCI/services/i18n/_detected.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Detected { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "detected '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_detected.sh b/automataCI/services/i18n/_detected.sh new file mode 100644 index 0000000..f067089 --- /dev/null +++ b/automataCI/services/i18n/_detected.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Detected() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "detected '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_export-failed.ps1 b/automataCI/services/i18n/_export-failed.ps1 new file mode 100644 index 0000000..d4b261a --- /dev/null +++ b/automataCI/services/i18n/_export-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Export-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "export failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_export-failed.sh b/automataCI/services/i18n/_export-failed.sh new file mode 100644 index 0000000..c580ce3 --- /dev/null +++ b/automataCI/services/i18n/_export-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Export_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "export failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_export-missing.ps1 b/automataCI/services/i18n/_export-missing.ps1 new file mode 100644 index 0000000..d4da183 --- /dev/null +++ b/automataCI/services/i18n/_export-missing.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Export-Missing { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print error "missing '${___subject}' export.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_export-missing.sh b/automataCI/services/i18n/_export-missing.sh new file mode 100644 index 0000000..8fb827e --- /dev/null +++ b/automataCI/services/i18n/_export-missing.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Export_Missing() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print error "missing '${___subject}' export.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_export.ps1 b/automataCI/services/i18n/_export.ps1 new file mode 100644 index 0000000..b1d7724 --- /dev/null +++ b/automataCI/services/i18n/_export.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Export { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "exporting ${___subject}...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_export.sh b/automataCI/services/i18n/_export.sh new file mode 100644 index 0000000..a3483d5 --- /dev/null +++ b/automataCI/services/i18n/_export.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Export() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "exporting '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_file-bad-stat-skipped.ps1 b/automataCI/services/i18n/_file-bad-stat-skipped.ps1 new file mode 100644 index 0000000..d054f36 --- /dev/null +++ b/automataCI/services/i18n/_file-bad-stat-skipped.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-File-Has-Bad-Stat-Skipped { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning "file has bad stats. Skipping...`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_file-bad-stat-skipped.sh b/automataCI/services/i18n/_file-bad-stat-skipped.sh new file mode 100644 index 0000000..910618b --- /dev/null +++ b/automataCI/services/i18n/_file-bad-stat-skipped.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_File_Has_Bad_Stat_Skipped() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "file has bad stats. Skipping...\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_guide-start-activate.ps1 b/automataCI/services/i18n/_guide-start-activate.ps1 new file mode 100644 index 0000000..732dc76 --- /dev/null +++ b/automataCI/services/i18n/_guide-start-activate.ps1 @@ -0,0 +1,43 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Guide-Start-Source { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print note @" + + +IMPORTANT NOTICE +please perfrom the following command at your terminal manually: + $ . ${___subject} + + +"@ + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_guide-start-activate.sh b/automataCI/services/i18n/_guide-start-activate.sh new file mode 100644 index 0000000..ea4f5a1 --- /dev/null +++ b/automataCI/services/i18n/_guide-start-activate.sh @@ -0,0 +1,39 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Guide_Start_Source() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print note " + + +IMPORTANT NOTICE +please perfrom the following command at your terminal manually: + $ . ${___subject} + + +" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_guide-stop-deactivate.ps1 b/automataCI/services/i18n/_guide-stop-deactivate.ps1 new file mode 100644 index 0000000..57c7ba4 --- /dev/null +++ b/automataCI/services/i18n/_guide-stop-deactivate.ps1 @@ -0,0 +1,36 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Guide-Stop-Deactivate { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print note @" + + +IMPORTANT NOTICE +please perfrom the following command at your terminal manually: + $ deactivate + + +"@ + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_guide-stop-deactivate.sh b/automataCI/services/i18n/_guide-stop-deactivate.sh new file mode 100644 index 0000000..18dd8bf --- /dev/null +++ b/automataCI/services/i18n/_guide-stop-deactivate.sh @@ -0,0 +1,37 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Guide_Stop_Deactivate() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print note " + + +IMPORTANT NOTICE +please perfrom the following command at your terminal manually: + $ deactivate + + +" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_help.ps1 b/automataCI/services/i18n/_help.ps1 new file mode 100644 index 0000000..1f60729 --- /dev/null +++ b/automataCI/services/i18n/_help.ps1 @@ -0,0 +1,70 @@ +# 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\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__printer.ps1" + + + + +function I18N-Help { + param ( + [string]$___mode, + [string]$___executable + ) + + + # validate input + $__process = STRINGS-Is-Empty "${___mode}" + if ($__process -eq 0) { + $___mode = "info" + } + + $__process = STRINGS-Is-Empty "${___executable}" + if ($__process -eq 0) { + $___executable = ".\automataCI\ci.sh.ps1" + } + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print "${___mode}" @" + +Please try any of the following: + To seek commands' help 🠚 $ ${___executable} help + To initialize environment 🠚 $ ${___executable} env + To setup the repo for work 🠚 $ ${___executable} setup + To prepare the repo 🠚 $ ${___executable} prepare + To start a development 🠚 $ ${___executable} start + To test the repo 🠚 $ ${___executable} test + To build but for host system only 🠚 $ ${___executable} materialize + To build the repo 🠚 $ ${___executable} build + To notarize the builds 🠚 $ ${___executable} notarize + To package the repo product 🠚 $ ${___executable} package + To release the repo product 🠚 $ ${___executable} release + To stop a development 🠚 $ ${___executable} stop + To deploy the new release 🠚 $ ${___executable} deploy + To archive the workspace 🠚 $ ${___executable} archive + To clean the workspace 🠚 $ ${___executable} clean + To purge everything 🠚 $ ${___executable} purge + +"@ + }} + + $null = Remove-Variable ___mode + $null = Remove-Variable ___executable + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_help.sh b/automataCI/services/i18n/_help.sh new file mode 100644 index 0000000..f05a039 --- /dev/null +++ b/automataCI/services/i18n/_help.sh @@ -0,0 +1,65 @@ +# 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/strings.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__printer.sh" + + + + +I18N_Help() { + ___mode="$1" + ___executable="$2" + + + # validate input + if [ "$(STRINGS_Is_Empty "$___mode")" -eq 0 ]; then + ___mode="info" + fi + + if [ "$(STRINGS_Is_Empty "$___executable")" -eq 0 ]; then + ___executable="./automataCI/ci.sh.ps1" + fi + + + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print "$___mode" "\ + +Please try any of the following: + To seek commands' help 🠚 $ ${___executable} help + To initialize environment 🠚 $ ${___executable} env + To setup the repo for work 🠚 $ ${___executable} setup + To prepare the repo 🠚 $ ${___executable} prepare + To start a development 🠚 $ ${___executable} start + To test the repo 🠚 $ ${___executable} test + To build but for host system only 🠚 $ ${___executable} materialize + To build the repo 🠚 $ ${___executable} build + To notarize the builds 🠚 $ ${___executable} notarize + To package the repo product 🠚 $ ${___executable} package + To release the repo product 🠚 $ ${___executable} release + To stop a development 🠚 $ ${___executable} stop + To archive the workspace 🠚 $ ${___executable} archive + To deploy the new release 🠚 $ ${___executable} deploy + To clean the workspace 🠚 $ ${___executable} clean + To purge everything 🠚 $ ${___executable} purge + +" + ;; + esac + unset ___mode ___executable + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_import-compiler.ps1 b/automataCI/services/i18n/_import-compiler.ps1 new file mode 100644 index 0000000..c805369 --- /dev/null +++ b/automataCI/services/i18n/_import-compiler.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-Import-Compiler { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "importing '${___subject}' compiler...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_import-compiler.sh b/automataCI/services/i18n/_import-compiler.sh new file mode 100644 index 0000000..fe00b20 --- /dev/null +++ b/automataCI/services/i18n/_import-compiler.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_Import_Compiler() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "importing '${___subject}' compiler...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_import-dependencies.ps1 b/automataCI/services/i18n/_import-dependencies.ps1 new file mode 100644 index 0000000..ef8d239 --- /dev/null +++ b/automataCI/services/i18n/_import-dependencies.ps1 @@ -0,0 +1,28 @@ +# 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-Import-Dependencies { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print info "importing all dependencies...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_import-dependencies.sh b/automataCI/services/i18n/_import-dependencies.sh new file mode 100644 index 0000000..0afdfcd --- /dev/null +++ b/automataCI/services/i18n/_import-dependencies.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_Import_Dependencies() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print info "importing all dependencies...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_import-failed.ps1 b/automataCI/services/i18n/_import-failed.ps1 new file mode 100644 index 0000000..b3efece --- /dev/null +++ b/automataCI/services/i18n/_import-failed.ps1 @@ -0,0 +1,28 @@ +# 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-Import-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "import failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_import-failed.sh b/automataCI/services/i18n/_import-failed.sh new file mode 100644 index 0000000..27bf068 --- /dev/null +++ b/automataCI/services/i18n/_import-failed.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_Import_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "import failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_injection-manual-detected.ps1 b/automataCI/services/i18n/_injection-manual-detected.ps1 new file mode 100644 index 0000000..b1a006c --- /dev/null +++ b/automataCI/services/i18n/_injection-manual-detected.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Injection-Manual-Detected { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning "manual injection detected.`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_injection-manual-detected.sh b/automataCI/services/i18n/_injection-manual-detected.sh new file mode 100644 index 0000000..ea32498 --- /dev/null +++ b/automataCI/services/i18n/_injection-manual-detected.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Injection_Manual_Detected() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "manual injection detected.\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_install-failed.ps1 b/automataCI/services/i18n/_install-failed.ps1 new file mode 100644 index 0000000..e2b5e45 --- /dev/null +++ b/automataCI/services/i18n/_install-failed.ps1 @@ -0,0 +1,33 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Install-Failed { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "install failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_install-failed.sh b/automataCI/services/i18n/_install-failed.sh new file mode 100644 index 0000000..9710d07 --- /dev/null +++ b/automataCI/services/i18n/_install-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Install_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "install failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_install.ps1 b/automataCI/services/i18n/_install.ps1 new file mode 100644 index 0000000..c091a54 --- /dev/null +++ b/automataCI/services/i18n/_install.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Install { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "installing '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_install.sh b/automataCI/services/i18n/_install.sh new file mode 100644 index 0000000..f82a3e1 --- /dev/null +++ b/automataCI/services/i18n/_install.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Install() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "installing '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_is-directory-skipped.ps1 b/automataCI/services/i18n/_is-directory-skipped.ps1 new file mode 100644 index 0000000..b92d1c9 --- /dev/null +++ b/automataCI/services/i18n/_is-directory-skipped.ps1 @@ -0,0 +1,36 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Is-Directory-Skipped { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print warning ` + "'${___subject}' is a directory. Skipping...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_is-directory-skipped.sh b/automataCI/services/i18n/_is-directory-skipped.sh new file mode 100644 index 0000000..d85dc3f --- /dev/null +++ b/automataCI/services/i18n/_is-directory-skipped.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Is_Directory_Skipped() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "'${___subject}' is a directory. Skipping...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_is-incompatible-skipped.ps1 b/automataCI/services/i18n/_is-incompatible-skipped.ps1 new file mode 100644 index 0000000..c677d63 --- /dev/null +++ b/automataCI/services/i18n/_is-incompatible-skipped.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Is-Incompatible-Skipped { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print warning "${___subject} is incompatible. Skipping...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_is-incompatible-skipped.sh b/automataCI/services/i18n/_is-incompatible-skipped.sh new file mode 100644 index 0000000..919a767 --- /dev/null +++ b/automataCI/services/i18n/_is-incompatible-skipped.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Is_Incompatible_Skipped() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "${___subject} is incompatible. Skipping...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_logout-failed.ps1 b/automataCI/services/i18n/_logout-failed.ps1 new file mode 100644 index 0000000..014a956 --- /dev/null +++ b/automataCI/services/i18n/_logout-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Logout-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "logout failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_logout-failed.sh b/automataCI/services/i18n/_logout-failed.sh new file mode 100644 index 0000000..5c2fd26 --- /dev/null +++ b/automataCI/services/i18n/_logout-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Logout_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "logout failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_logout.ps1 b/automataCI/services/i18n/_logout.ps1 new file mode 100644 index 0000000..db2de7b --- /dev/null +++ b/automataCI/services/i18n/_logout.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Logout { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "logging out '${___subject}' account...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_logout.sh b/automataCI/services/i18n/_logout.sh new file mode 100644 index 0000000..2a79cc1 --- /dev/null +++ b/automataCI/services/i18n/_logout.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Logout() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "logging out '${___subject}' account...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_missing.ps1 b/automataCI/services/i18n/_missing.ps1 new file mode 100644 index 0000000..64a4951 --- /dev/null +++ b/automataCI/services/i18n/_missing.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Missing { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "missing '${___subject}'.`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_missing.sh b/automataCI/services/i18n/_missing.sh new file mode 100644 index 0000000..5bf349b --- /dev/null +++ b/automataCI/services/i18n/_missing.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Missing() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "missing '${___subject}'.\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_newline.ps1 b/automataCI/services/i18n/_newline.ps1 new file mode 100644 index 0000000..dc022a5 --- /dev/null +++ b/automataCI/services/i18n/_newline.ps1 @@ -0,0 +1,24 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Newline { + # execute + I18N-Status-Print plain "`n" + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_newline.sh b/automataCI/services/i18n/_newline.sh new file mode 100644 index 0000000..2afcedc --- /dev/null +++ b/automataCI/services/i18n/_newline.sh @@ -0,0 +1,24 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Newline() { + # execute + I18N_Status_Print plain "\n" + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_notarize-failed.ps1 b/automataCI/services/i18n/_notarize-failed.ps1 new file mode 100644 index 0000000..22b333c --- /dev/null +++ b/automataCI/services/i18n/_notarize-failed.ps1 @@ -0,0 +1,33 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Notarize-Failed { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "notarization failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_notarize-failed.sh b/automataCI/services/i18n/_notarize-failed.sh new file mode 100644 index 0000000..a37b183 --- /dev/null +++ b/automataCI/services/i18n/_notarize-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Notarize_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "notarization failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_notarize-not-applicable.ps1 b/automataCI/services/i18n/_notarize-not-applicable.ps1 new file mode 100644 index 0000000..79e46b1 --- /dev/null +++ b/automataCI/services/i18n/_notarize-not-applicable.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Notarize-Not-Applicable { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning "notarization not applicable. Skipping...`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_notarize-not-applicable.sh b/automataCI/services/i18n/_notarize-not-applicable.sh new file mode 100644 index 0000000..3d3b09f --- /dev/null +++ b/automataCI/services/i18n/_notarize-not-applicable.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Notarize_Not_Applicable() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "notarization not applicable. Skipping...\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_notarize-unavailable.ps1 b/automataCI/services/i18n/_notarize-unavailable.ps1 new file mode 100644 index 0000000..345d3dd --- /dev/null +++ b/automataCI/services/i18n/_notarize-unavailable.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Notarize-Unavailable { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning "notarization is unavailable. Skipping...`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_notarize-unavailable.sh b/automataCI/services/i18n/_notarize-unavailable.sh new file mode 100644 index 0000000..f50c497 --- /dev/null +++ b/automataCI/services/i18n/_notarize-unavailable.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Notarize_Unavailable() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "notarization is unavailable. Skipping...\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_package-failed.ps1 b/automataCI/services/i18n/_package-failed.ps1 new file mode 100644 index 0000000..b3822ad --- /dev/null +++ b/automataCI/services/i18n/_package-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Package-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "package failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_package-failed.sh b/automataCI/services/i18n/_package-failed.sh new file mode 100644 index 0000000..8c73131 --- /dev/null +++ b/automataCI/services/i18n/_package-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Package_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "package failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_package.ps1 b/automataCI/services/i18n/_package.ps1 new file mode 100644 index 0000000..e4f7590 --- /dev/null +++ b/automataCI/services/i18n/_package.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Package { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "packaging '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_package.sh b/automataCI/services/i18n/_package.sh new file mode 100644 index 0000000..bdb2010 --- /dev/null +++ b/automataCI/services/i18n/_package.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Package() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "packaging '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_parse-failed.ps1 b/automataCI/services/i18n/_parse-failed.ps1 new file mode 100644 index 0000000..a1faaf8 --- /dev/null +++ b/automataCI/services/i18n/_parse-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Parse-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "parse failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_parse-failed.sh b/automataCI/services/i18n/_parse-failed.sh new file mode 100644 index 0000000..7a2858f --- /dev/null +++ b/automataCI/services/i18n/_parse-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Parse_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "parse failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_parse.ps1 b/automataCI/services/i18n/_parse.ps1 new file mode 100644 index 0000000..4cd97b2 --- /dev/null +++ b/automataCI/services/i18n/_parse.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Parse { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "parsing '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_parse.sh b/automataCI/services/i18n/_parse.sh new file mode 100644 index 0000000..75c6493 --- /dev/null +++ b/automataCI/services/i18n/_parse.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Parse() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "parsing '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_prepare-failed.ps1 b/automataCI/services/i18n/_prepare-failed.ps1 new file mode 100644 index 0000000..05befe6 --- /dev/null +++ b/automataCI/services/i18n/_prepare-failed.ps1 @@ -0,0 +1,28 @@ +# 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-Prepare-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "prepare failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_prepare-failed.sh b/automataCI/services/i18n/_prepare-failed.sh new file mode 100644 index 0000000..53fe694 --- /dev/null +++ b/automataCI/services/i18n/_prepare-failed.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_Prepare_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "prepare failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_prepare.ps1 b/automataCI/services/i18n/_prepare.ps1 new file mode 100644 index 0000000..15051e3 --- /dev/null +++ b/automataCI/services/i18n/_prepare.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-Prepare { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "preparing '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_prepare.sh b/automataCI/services/i18n/_prepare.sh new file mode 100644 index 0000000..d0bfa3f --- /dev/null +++ b/automataCI/services/i18n/_prepare.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_Prepare() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "preparing '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_processing-failed.ps1 b/automataCI/services/i18n/_processing-failed.ps1 new file mode 100644 index 0000000..fd95732 --- /dev/null +++ b/automataCI/services/i18n/_processing-failed.ps1 @@ -0,0 +1,28 @@ +# 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-Processing-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "processing failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_processing-failed.sh b/automataCI/services/i18n/_processing-failed.sh new file mode 100644 index 0000000..b7e84c7 --- /dev/null +++ b/automataCI/services/i18n/_processing-failed.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_Processing_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "processing failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_processing-test-coverage.ps1 b/automataCI/services/i18n/_processing-test-coverage.ps1 new file mode 100644 index 0000000..153f9c8 --- /dev/null +++ b/automataCI/services/i18n/_processing-test-coverage.ps1 @@ -0,0 +1,28 @@ +# 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-Processing-Test-Coverage { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print info "processing test coverage data...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_processing-test-coverage.sh b/automataCI/services/i18n/_processing-test-coverage.sh new file mode 100644 index 0000000..f43fcdb --- /dev/null +++ b/automataCI/services/i18n/_processing-test-coverage.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_Processing_Test_Coverage() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print info "processing test coverage data...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_processing.ps1 b/automataCI/services/i18n/_processing.ps1 new file mode 100644 index 0000000..6927bc3 --- /dev/null +++ b/automataCI/services/i18n/_processing.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Processing { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "processing '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_processing.sh b/automataCI/services/i18n/_processing.sh new file mode 100644 index 0000000..df1371a --- /dev/null +++ b/automataCI/services/i18n/_processing.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Processing() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "processing '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_publish-failed.ps1 b/automataCI/services/i18n/_publish-failed.ps1 new file mode 100644 index 0000000..7799425 --- /dev/null +++ b/automataCI/services/i18n/_publish-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Publish-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "publish failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_publish-failed.sh b/automataCI/services/i18n/_publish-failed.sh new file mode 100644 index 0000000..f6524c3 --- /dev/null +++ b/automataCI/services/i18n/_publish-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Publish_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "publish failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_publish.ps1 b/automataCI/services/i18n/_publish.ps1 new file mode 100644 index 0000000..d077ab6 --- /dev/null +++ b/automataCI/services/i18n/_publish.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Publish { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "publishing ${___subject}...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_publish.sh b/automataCI/services/i18n/_publish.sh new file mode 100644 index 0000000..e95b471 --- /dev/null +++ b/automataCI/services/i18n/_publish.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Publish() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "publishing ${___subject}...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_purge.ps1 b/automataCI/services/i18n/_purge.ps1 new file mode 100644 index 0000000..63f67f0 --- /dev/null +++ b/automataCI/services/i18n/_purge.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Purge { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "nuking '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_purge.sh b/automataCI/services/i18n/_purge.sh new file mode 100644 index 0000000..536e548 --- /dev/null +++ b/automataCI/services/i18n/_purge.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Purge() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "nuking '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_remake-failed.ps1 b/automataCI/services/i18n/_remake-failed.ps1 new file mode 100644 index 0000000..713d379 --- /dev/null +++ b/automataCI/services/i18n/_remake-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Remake-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "remake failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_remake-failed.sh b/automataCI/services/i18n/_remake-failed.sh new file mode 100644 index 0000000..81161ca --- /dev/null +++ b/automataCI/services/i18n/_remake-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Remake_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "remaking failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_remake.ps1 b/automataCI/services/i18n/_remake.ps1 new file mode 100644 index 0000000..5287f69 --- /dev/null +++ b/automataCI/services/i18n/_remake.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Remake { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "remaking '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_remake.sh b/automataCI/services/i18n/_remake.sh new file mode 100644 index 0000000..af802c0 --- /dev/null +++ b/automataCI/services/i18n/_remake.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Remake() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "remaking '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_run-failed.ps1 b/automataCI/services/i18n/_run-failed.ps1 new file mode 100644 index 0000000..1d9da0e --- /dev/null +++ b/automataCI/services/i18n/_run-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Run-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "CI job - run failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_run-failed.sh b/automataCI/services/i18n/_run-failed.sh new file mode 100644 index 0000000..fa7c571 --- /dev/null +++ b/automataCI/services/i18n/_run-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Run_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "CI job - run failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_run-successful.ps1 b/automataCI/services/i18n/_run-successful.ps1 new file mode 100644 index 0000000..e37541d --- /dev/null +++ b/automataCI/services/i18n/_run-successful.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Run-Successful { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print success "`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_run-successful.sh b/automataCI/services/i18n/_run-successful.sh new file mode 100644 index 0000000..7807b68 --- /dev/null +++ b/automataCI/services/i18n/_run-successful.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Run_Successful() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print success "\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_run-test-coverage.ps1 b/automataCI/services/i18n/_run-test-coverage.ps1 new file mode 100644 index 0000000..6a392ed --- /dev/null +++ b/automataCI/services/i18n/_run-test-coverage.ps1 @@ -0,0 +1,28 @@ +# 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-Run-Test-Coverage { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print info "running all tests with coverage...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_run-test-coverage.sh b/automataCI/services/i18n/_run-test-coverage.sh new file mode 100644 index 0000000..64b191d --- /dev/null +++ b/automataCI/services/i18n/_run-test-coverage.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_Run_Test_Coverage() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print info "running all tests with coverage...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_run-test.ps1 b/automataCI/services/i18n/_run-test.ps1 new file mode 100644 index 0000000..1e88294 --- /dev/null +++ b/automataCI/services/i18n/_run-test.ps1 @@ -0,0 +1,28 @@ +# 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-Run-Test { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print info "running all tests...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_run-test.sh b/automataCI/services/i18n/_run-test.sh new file mode 100644 index 0000000..0367800 --- /dev/null +++ b/automataCI/services/i18n/_run-test.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_Run_Test() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print info "running all tests...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_run.ps1 b/automataCI/services/i18n/_run.ps1 new file mode 100644 index 0000000..fc788fb --- /dev/null +++ b/automataCI/services/i18n/_run.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Run { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "running '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_run.sh b/automataCI/services/i18n/_run.sh new file mode 100644 index 0000000..cd9ae8d --- /dev/null +++ b/automataCI/services/i18n/_run.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Run() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "running '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_setup-environment.ps1 b/automataCI/services/i18n/_setup-environment.ps1 new file mode 100644 index 0000000..a8856ce --- /dev/null +++ b/automataCI/services/i18n/_setup-environment.ps1 @@ -0,0 +1,33 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Setup-Environment { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print info "setting up localized environment...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_setup-environment.sh b/automataCI/services/i18n/_setup-environment.sh new file mode 100644 index 0000000..d568510 --- /dev/null +++ b/automataCI/services/i18n/_setup-environment.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Setup_Environment() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print info "setting up localized environment...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_setup-failed.ps1 b/automataCI/services/i18n/_setup-failed.ps1 new file mode 100644 index 0000000..80525da --- /dev/null +++ b/automataCI/services/i18n/_setup-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Setup-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "setup failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_setup-failed.sh b/automataCI/services/i18n/_setup-failed.sh new file mode 100644 index 0000000..f9cc3ee --- /dev/null +++ b/automataCI/services/i18n/_setup-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Setup_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "setup failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_setup.ps1 b/automataCI/services/i18n/_setup.ps1 new file mode 100644 index 0000000..808ba1c --- /dev/null +++ b/automataCI/services/i18n/_setup.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Setup { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "setting up '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_setup.sh b/automataCI/services/i18n/_setup.sh new file mode 100644 index 0000000..0e2a853 --- /dev/null +++ b/automataCI/services/i18n/_setup.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Setup() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "setting up '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_shasum-failed.ps1 b/automataCI/services/i18n/_shasum-failed.ps1 new file mode 100644 index 0000000..5bfcb95 --- /dev/null +++ b/automataCI/services/i18n/_shasum-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Shasum-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "shasum failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_shasum-failed.sh b/automataCI/services/i18n/_shasum-failed.sh new file mode 100644 index 0000000..e66e59f --- /dev/null +++ b/automataCI/services/i18n/_shasum-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Shasum_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "shasum failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_shasum.ps1 b/automataCI/services/i18n/_shasum.ps1 new file mode 100644 index 0000000..38e5f9c --- /dev/null +++ b/automataCI/services/i18n/_shasum.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Shasum { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "shasum with '${___subject}' algorithm...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_shasum.sh b/automataCI/services/i18n/_shasum.sh new file mode 100644 index 0000000..7d84a35 --- /dev/null +++ b/automataCI/services/i18n/_shasum.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Shasum() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "shasum with '${___subject}' algorithm...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sign-failed.ps1 b/automataCI/services/i18n/_sign-failed.ps1 new file mode 100644 index 0000000..3bc6b10 --- /dev/null +++ b/automataCI/services/i18n/_sign-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Sign-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "sign failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sign-failed.sh b/automataCI/services/i18n/_sign-failed.sh new file mode 100644 index 0000000..6db7306 --- /dev/null +++ b/automataCI/services/i18n/_sign-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Sign_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "sign failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sign.ps1 b/automataCI/services/i18n/_sign.ps1 new file mode 100644 index 0000000..4dae785 --- /dev/null +++ b/automataCI/services/i18n/_sign.ps1 @@ -0,0 +1,41 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Sign { + param( + [string]$___subject, + [string]$___signer + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + + if ($(STRINGS-Is-Empty "${___signer}") -ne 0) { + $null = I18N-Status-Print info "'${___signer}' signing '${___subject}'...`n" + } else { + $null = I18N-Status-Print info "signing '${___subject}'...`n" + } + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sign.sh b/automataCI/services/i18n/_sign.sh new file mode 100644 index 0000000..14c75a7 --- /dev/null +++ b/automataCI/services/i18n/_sign.sh @@ -0,0 +1,40 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Sign() { + ___subject="$1" + ___signer="$2" + + + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "${___subject}")" + + if [ $(STRINGS_Is_Empty "${___signer}") -ne 0 ]; then + I18N_Status_Print info "'${___signer}' signing '${___subject}'...\n" + else + I18N_Status_Print info "signing '${___subject}'...\n" + fi + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_simulate-available.ps1 b/automataCI/services/i18n/_simulate-available.ps1 new file mode 100644 index 0000000..9fc5335 --- /dev/null +++ b/automataCI/services/i18n/_simulate-available.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Simulate-Available { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print warning "simulating '${___subject}' is available...`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_simulate-available.sh b/automataCI/services/i18n/_simulate-available.sh new file mode 100644 index 0000000..319dc74 --- /dev/null +++ b/automataCI/services/i18n/_simulate-available.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Simulate_Available() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print warning "simulating '${___subject}' is available...\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_simulate-conclusion.ps1 b/automataCI/services/i18n/_simulate-conclusion.ps1 new file mode 100644 index 0000000..916705e --- /dev/null +++ b/automataCI/services/i18n/_simulate-conclusion.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Simulate-Conclusion { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print warning "simulating '${___subject}' conclusion...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_simulate-conclusion.sh b/automataCI/services/i18n/_simulate-conclusion.sh new file mode 100644 index 0000000..bb8af05 --- /dev/null +++ b/automataCI/services/i18n/_simulate-conclusion.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Simulate_Conclude() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print warning "simulating '${___subject}' conclusion...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_simulate-notarize.ps1 b/automataCI/services/i18n/_simulate-notarize.ps1 new file mode 100644 index 0000000..0e4de75 --- /dev/null +++ b/automataCI/services/i18n/_simulate-notarize.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Simulate-Notarize { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning "simulating successful notarization...`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_simulate-notarize.sh b/automataCI/services/i18n/_simulate-notarize.sh new file mode 100644 index 0000000..98e71db --- /dev/null +++ b/automataCI/services/i18n/_simulate-notarize.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Simulate_Notarize() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "simulating successful notarization...\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_simulate-publish.ps1 b/automataCI/services/i18n/_simulate-publish.ps1 new file mode 100644 index 0000000..aff03e7 --- /dev/null +++ b/automataCI/services/i18n/_simulate-publish.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Simulate-Publish { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print warning "simulating '${___subject}' publication...`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_simulate-publish.sh b/automataCI/services/i18n/_simulate-publish.sh new file mode 100644 index 0000000..2eafd6d --- /dev/null +++ b/automataCI/services/i18n/_simulate-publish.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Simulate_Publish() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print warning "simulating '${___subject}' publication...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_simulate-testing.ps1 b/automataCI/services/i18n/_simulate-testing.ps1 new file mode 100644 index 0000000..dedd647 --- /dev/null +++ b/automataCI/services/i18n/_simulate-testing.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Simulate-Testing { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning "simulating test run...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_simulate-testing.sh b/automataCI/services/i18n/_simulate-testing.sh new file mode 100644 index 0000000..0a265b0 --- /dev/null +++ b/automataCI/services/i18n/_simulate-testing.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Simulate_Testing() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "simulating test run...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_source-failed.ps1 b/automataCI/services/i18n/_source-failed.ps1 new file mode 100644 index 0000000..f9a1e83 --- /dev/null +++ b/automataCI/services/i18n/_source-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Source-Skipped { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning "source skipped.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_source-failed.sh b/automataCI/services/i18n/_source-failed.sh new file mode 100644 index 0000000..ed63779 --- /dev/null +++ b/automataCI/services/i18n/_source-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Source_Skipped() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "source skipped.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_source-skipped.ps1 b/automataCI/services/i18n/_source-skipped.ps1 new file mode 100644 index 0000000..f9a1e83 --- /dev/null +++ b/automataCI/services/i18n/_source-skipped.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Source-Skipped { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning "source skipped.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_source-skipped.sh b/automataCI/services/i18n/_source-skipped.sh new file mode 100644 index 0000000..ed63779 --- /dev/null +++ b/automataCI/services/i18n/_source-skipped.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Source_Skipped() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "source skipped.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_source.ps1 b/automataCI/services/i18n/_source.ps1 new file mode 100644 index 0000000..c7ef3df --- /dev/null +++ b/automataCI/services/i18n/_source.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Source { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "sourcing '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_source.sh b/automataCI/services/i18n/_source.sh new file mode 100644 index 0000000..c303437 --- /dev/null +++ b/automataCI/services/i18n/_source.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Source() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "sourcing '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-failed.ps1 b/automataCI/services/i18n/_sync-failed.ps1 new file mode 100644 index 0000000..6aae269 --- /dev/null +++ b/automataCI/services/i18n/_sync-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Sync-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "sync failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-failed.sh b/automataCI/services/i18n/_sync-failed.sh new file mode 100644 index 0000000..5a86ca3 --- /dev/null +++ b/automataCI/services/i18n/_sync-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Sync_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "sync failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-register-skipped-missing-compiler.ps1 b/automataCI/services/i18n/_sync-register-skipped-missing-compiler.ps1 new file mode 100644 index 0000000..a92302c --- /dev/null +++ b/automataCI/services/i18n/_sync-register-skipped-missing-compiler.ps1 @@ -0,0 +1,29 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Sync-Register-Skipped-Missing-Compiler { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning ` + "registration aborted: Missing compiler. Skipping...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-register-skipped-missing-compiler.sh b/automataCI/services/i18n/_sync-register-skipped-missing-compiler.sh new file mode 100644 index 0000000..9100952 --- /dev/null +++ b/automataCI/services/i18n/_sync-register-skipped-missing-compiler.sh @@ -0,0 +1,30 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Sync_Register_Skipped_Missing_Compiler() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning \ + "registration aborted: Missing compiler. Skipping...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-register-skipped-missing-linker.ps1 b/automataCI/services/i18n/_sync-register-skipped-missing-linker.ps1 new file mode 100644 index 0000000..61731a1 --- /dev/null +++ b/automataCI/services/i18n/_sync-register-skipped-missing-linker.ps1 @@ -0,0 +1,29 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Sync-Register-Skipped-Missing-Linker { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning ` + "registration aborted: Missing linker. Skipping...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-register-skipped-missing-linker.sh b/automataCI/services/i18n/_sync-register-skipped-missing-linker.sh new file mode 100644 index 0000000..979af93 --- /dev/null +++ b/automataCI/services/i18n/_sync-register-skipped-missing-linker.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Sync_Register_Skipped_Missing_Linker() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "registration aborted: Missing linker. Skipping...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-register-skipped-missing-target.ps1 b/automataCI/services/i18n/_sync-register-skipped-missing-target.ps1 new file mode 100644 index 0000000..c770238 --- /dev/null +++ b/automataCI/services/i18n/_sync-register-skipped-missing-target.ps1 @@ -0,0 +1,29 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Sync-Register-Skipped-Missing-Target { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning ` + "registration aborted: Missing target. Skipping...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-register-skipped-missing-target.sh b/automataCI/services/i18n/_sync-register-skipped-missing-target.sh new file mode 100644 index 0000000..39a000f --- /dev/null +++ b/automataCI/services/i18n/_sync-register-skipped-missing-target.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Sync_Register_Skipped_Missing_Target() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "registration aborted: Missing target. Skipping...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-register-skipped-unsupported.ps1 b/automataCI/services/i18n/_sync-register-skipped-unsupported.ps1 new file mode 100644 index 0000000..d074a86 --- /dev/null +++ b/automataCI/services/i18n/_sync-register-skipped-unsupported.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-Sync-Register-Skipped-Unsupported { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning ` + "registration aborted: Unsupported target. Skipping...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-register-skipped-unsupported.sh b/automataCI/services/i18n/_sync-register-skipped-unsupported.sh new file mode 100644 index 0000000..71442e8 --- /dev/null +++ b/automataCI/services/i18n/_sync-register-skipped-unsupported.sh @@ -0,0 +1,30 @@ +# 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_Sync_Register_Skipped_Unsupported() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning \ + "registration aborted: Unsupported target. Skipping...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-register.ps1 b/automataCI/services/i18n/_sync-register.ps1 new file mode 100644 index 0000000..db40856 --- /dev/null +++ b/automataCI/services/i18n/_sync-register.ps1 @@ -0,0 +1,36 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Sync-Register { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info ` + "registering '${___subject}' for parallel exec...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-register.sh b/automataCI/services/i18n/_sync-register.sh new file mode 100644 index 0000000..baae207 --- /dev/null +++ b/automataCI/services/i18n/_sync-register.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Sync_Register() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "registering '${___subject}' for parallel exec...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-report-log.ps1 b/automataCI/services/i18n/_sync-report-log.ps1 new file mode 100644 index 0000000..18ce759 --- /dev/null +++ b/automataCI/services/i18n/_sync-report-log.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Sync-Report-Log { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "reporting '${___subject}' log...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-report-log.sh b/automataCI/services/i18n/_sync-report-log.sh new file mode 100644 index 0000000..465800d --- /dev/null +++ b/automataCI/services/i18n/_sync-report-log.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Sync_Report_Log() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "reporting '${___subject}' log...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-run-series.ps1 b/automataCI/services/i18n/_sync-run-series.ps1 new file mode 100644 index 0000000..9afec34 --- /dev/null +++ b/automataCI/services/i18n/_sync-run-series.ps1 @@ -0,0 +1,29 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Sync-Run-Series { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print plain "`n`n" + $null = I18N-Status-Print info "executing series run...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-run-series.sh b/automataCI/services/i18n/_sync-run-series.sh new file mode 100644 index 0000000..a46af79 --- /dev/null +++ b/automataCI/services/i18n/_sync-run-series.sh @@ -0,0 +1,30 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Sync_Run_Series() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print plain "\n\n" + I18N_Status_Print info "executing series run...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-run-skipped.ps1 b/automataCI/services/i18n/_sync-run-skipped.ps1 new file mode 100644 index 0000000..245027b --- /dev/null +++ b/automataCI/services/i18n/_sync-run-skipped.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Sync-Run-Skipped { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning "no instruction found. Skipping...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-run-skipped.sh b/automataCI/services/i18n/_sync-run-skipped.sh new file mode 100644 index 0000000..da877f9 --- /dev/null +++ b/automataCI/services/i18n/_sync-run-skipped.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Sync_Run_Skipped() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "no instruction found. Skipping...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-run.ps1 b/automataCI/services/i18n/_sync-run.ps1 new file mode 100644 index 0000000..3dee768 --- /dev/null +++ b/automataCI/services/i18n/_sync-run.ps1 @@ -0,0 +1,29 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Sync-Run { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print plain "`n`n" + $null = I18N-Status-Print info "executing parallel run...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_sync-run.sh b/automataCI/services/i18n/_sync-run.sh new file mode 100644 index 0000000..eb2bbe2 --- /dev/null +++ b/automataCI/services/i18n/_sync-run.sh @@ -0,0 +1,30 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Sync_Run() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print plain "\n\n" + I18N_Status_Print info "executing parallel run...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_test-failed.ps1 b/automataCI/services/i18n/_test-failed.ps1 new file mode 100644 index 0000000..074960f --- /dev/null +++ b/automataCI/services/i18n/_test-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Test-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "test failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_test-failed.sh b/automataCI/services/i18n/_test-failed.sh new file mode 100644 index 0000000..2f200dd --- /dev/null +++ b/automataCI/services/i18n/_test-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Test_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "test failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_test-skipped.ps1 b/automataCI/services/i18n/_test-skipped.ps1 new file mode 100644 index 0000000..579fcb7 --- /dev/null +++ b/automataCI/services/i18n/_test-skipped.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Test-Skipped { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print skipped "test skipped.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_test-skipped.sh b/automataCI/services/i18n/_test-skipped.sh new file mode 100644 index 0000000..f1892d1 --- /dev/null +++ b/automataCI/services/i18n/_test-skipped.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Test_Skipped() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "test skipped.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_test.ps1 b/automataCI/services/i18n/_test.ps1 new file mode 100644 index 0000000..5c477ec --- /dev/null +++ b/automataCI/services/i18n/_test.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Test { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "testing '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_test.sh b/automataCI/services/i18n/_test.sh new file mode 100644 index 0000000..dd4c6e7 --- /dev/null +++ b/automataCI/services/i18n/_test.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Test() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "testing '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_unknown-action.ps1 b/automataCI/services/i18n/_unknown-action.ps1 new file mode 100644 index 0000000..ff22517 --- /dev/null +++ b/automataCI/services/i18n/_unknown-action.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Unknown-Action { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "unknown ACTION.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_unknown-action.sh b/automataCI/services/i18n/_unknown-action.sh new file mode 100644 index 0000000..ea59532 --- /dev/null +++ b/automataCI/services/i18n/_unknown-action.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Unknown_Action() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "unknown ACTION.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_unsupported-arch.ps1 b/automataCI/services/i18n/_unsupported-arch.ps1 new file mode 100644 index 0000000..9208cf5 --- /dev/null +++ b/automataCI/services/i18n/_unsupported-arch.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Unsupported-ARCH { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "unsupported ARCH.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_unsupported-arch.sh b/automataCI/services/i18n/_unsupported-arch.sh new file mode 100644 index 0000000..7a70957 --- /dev/null +++ b/automataCI/services/i18n/_unsupported-arch.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Unsupported_ARCH() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "unsupported ARCH.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_unsupported-os.ps1 b/automataCI/services/i18n/_unsupported-os.ps1 new file mode 100644 index 0000000..4a86aa2 --- /dev/null +++ b/automataCI/services/i18n/_unsupported-os.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Unsupported-OS { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "unsupported OS.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_unsupported-os.sh b/automataCI/services/i18n/_unsupported-os.sh new file mode 100644 index 0000000..1016ff6 --- /dev/null +++ b/automataCI/services/i18n/_unsupported-os.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Unsupported_OS() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "unsupported OS.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_update-failed.ps1 b/automataCI/services/i18n/_update-failed.ps1 new file mode 100644 index 0000000..06e587c --- /dev/null +++ b/automataCI/services/i18n/_update-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Update-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "updated failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_update-failed.sh b/automataCI/services/i18n/_update-failed.sh new file mode 100644 index 0000000..9b9b761 --- /dev/null +++ b/automataCI/services/i18n/_update-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Update_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "update failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_update.ps1 b/automataCI/services/i18n/_update.ps1 new file mode 100644 index 0000000..976ed75 --- /dev/null +++ b/automataCI/services/i18n/_update.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Update { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "updating '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_update.sh b/automataCI/services/i18n/_update.sh new file mode 100644 index 0000000..06c74a3 --- /dev/null +++ b/automataCI/services/i18n/_update.sh @@ -0,0 +1,31 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Subject_Update() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "updating '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_validate-failed.ps1 b/automataCI/services/i18n/_validate-failed.ps1 new file mode 100644 index 0000000..95c7012 --- /dev/null +++ b/automataCI/services/i18n/_validate-failed.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Validate-Failed { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print error "validation failed.`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_validate-failed.sh b/automataCI/services/i18n/_validate-failed.sh new file mode 100644 index 0000000..5ca9545 --- /dev/null +++ b/automataCI/services/i18n/_validate-failed.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Validate_Failed() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print error "validation failed.\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_validate-job.ps1 b/automataCI/services/i18n/_validate-job.ps1 new file mode 100644 index 0000000..1fc3512 --- /dev/null +++ b/automataCI/services/i18n/_validate-job.ps1 @@ -0,0 +1,28 @@ +# 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\i18n\__printer.ps1" + + + + +function I18N-Validate-Job { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print info "validating CI job...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_validate-job.sh b/automataCI/services/i18n/_validate-job.sh new file mode 100644 index 0000000..84389e2 --- /dev/null +++ b/automataCI/services/i18n/_validate-job.sh @@ -0,0 +1,29 @@ +# 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/i18n/__printer.sh" + + + + +I18N_Validate_Job() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print info "validating CI job...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_validate.ps1 b/automataCI/services/i18n/_validate.ps1 new file mode 100644 index 0000000..6353bd0 --- /dev/null +++ b/automataCI/services/i18n/_validate.ps1 @@ -0,0 +1,35 @@ +# 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\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Validate { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "validating '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_validate.sh b/automataCI/services/i18n/_validate.sh new file mode 100644 index 0000000..57e9997 --- /dev/null +++ b/automataCI/services/i18n/_validate.sh @@ -0,0 +1,34 @@ +# 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/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Validate() { + ___subject="$1" + + + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "${___subject}")" + I18N_Status_Print info "validating '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/translations.ps1 b/automataCI/services/i18n/translations.ps1 new file mode 100644 index 0000000..230275b --- /dev/null +++ b/automataCI/services/i18n/translations.ps1 @@ -0,0 +1,122 @@ +# 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\i18n\__param.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_activate-environment.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_activate-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_archive.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_archive-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_assemble.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_assemble-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_assemble-package.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_assemble-skipped.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_build.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_build-parallel.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_build-failed.ps1" +. "${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-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_check-failed-skipped.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_check-function.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_check-incompatible-skipped.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_check-login.ps1" +. "${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\_configure-build-settings.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_configure-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_copy.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_copy-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_create.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_create-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_create-package.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_detected.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_export.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_export-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_export-missing.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_file-bad-stat-skipped.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_guide-start-activate.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_guide-stop-deactivate.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_help.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_import-compiler.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_import-dependencies.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_import-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_injection-manual-detected.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_install.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_install-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_is-directory-skipped.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_is-incompatible-skipped.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_logout.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_logout-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_missing.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_newline.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_notarize-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_notarize-not-applicable.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_notarize-unavailable.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_package.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_package-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_parse.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_parse-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_prepare.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_prepare-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_processing.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_processing-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_processing-test-coverage.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_publish.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_publish-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_purge.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_remake.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_remake-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_run.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_run-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_run-successful.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_run-test.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_run-test-coverage.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_setup.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_setup-environment.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_setup-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_shasum.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_shasum-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_sign.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_sign-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_simulate-available.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_simulate-conclusion.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_simulate-notarize.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_simulate-publish.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_simulate-testing.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_source.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_source-skipped.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_sync-register.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_sync-register-skipped-missing-compiler.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_sync-register-skipped-missing-linker.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_sync-register-skipped-missing-target.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_sync-register-skipped-unsupported.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_sync-report-log.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_sync-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_sync-run.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_sync-run-series.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_sync-run-skipped.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_test.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_test-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_test-skipped.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_unknown-action.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_unsupported-arch.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_unsupported-os.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_update.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_update-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_validate.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_validate-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_validate-job.ps1" diff --git a/automataCI/services/i18n/translations.sh b/automataCI/services/i18n/translations.sh new file mode 100644 index 0000000..ce29c3b --- /dev/null +++ b/automataCI/services/i18n/translations.sh @@ -0,0 +1,122 @@ +# 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/i18n/__param.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_activate-environment.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_activate-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_archive.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_archive-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_assemble.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_assemble-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_assemble-package.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_assemble-skipped.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_build.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_build-parallel.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_build-failed.sh" +. "${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-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_check-failed-skipped.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_check-function.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_check-incompatible-skipped.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_check-login.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_checksum.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_checksum-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_clean.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_clean-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_commit.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_commit-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_configure-build-settings.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_configure-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_copy.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_copy-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_create.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_create-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_create-package.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_detected.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_export.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_export-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_export-missing.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_file-bad-stat-skipped.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_guide-start-activate.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_guide-stop-deactivate.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_help.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_import-compiler.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_import-dependencies.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_import-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_injection-manual-detected.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_install.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_install-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_is-directory-skipped.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_is-incompatible-skipped.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_logout.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_logout-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_missing.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_newline.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_notarize-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_notarize-not-applicable.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_notarize-unavailable.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_package.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_package-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_parse.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_parse-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_prepare.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_prepare-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_processing.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_processing-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_processing-test-coverage.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_publish.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_publish-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_purge.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_remake.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_remake-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_run.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_run-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_run-successful.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_run-test.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_run-test-coverage.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_setup.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_setup-environment.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_setup-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_shasum.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_shasum-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_sign.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_sign-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_simulate-available.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_simulate-conclusion.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_simulate-notarize.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_simulate-publish.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_simulate-testing.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_source.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_source-skipped.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_sync-register.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_sync-register-skipped-missing-compiler.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_sync-register-skipped-missing-linker.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_sync-register-skipped-missing-target.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_sync-register-skipped-unsupported.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_sync-report-log.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_sync-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_sync-run.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_sync-run-series.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_sync-run-skipped.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_test.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_test-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_test-skipped.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_unknown-action.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_unsupported-arch.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_unsupported-os.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_update.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_update-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_validate.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_validate-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_validate-job.sh" diff --git a/automataCI/services/io/disk.ps1 b/automataCI/services/io/disk.ps1 new file mode 100644 index 0000000..8a5f5f9 --- /dev/null +++ b/automataCI/services/io/disk.ps1 @@ -0,0 +1,44 @@ +# 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. +function DISK-Calculate-Size { + param ( + [string]$___location + ) + + + # validate input + if ([string]::IsNullOrEmpty($___location) -or + (-not (Test-Path -Path "${___location}"))) { + return 1 + } + + $___process = DISK-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___value = Get-ChildItem "${___location}" -Recurse -Force ` + -ErrorAction SilentlyContinue -Include * ` + | Where-Object {$_.psiscontainer -eq $false} ` + | Measure-Object -Property length -sum ` + | Select-Object sum + return [math]::Round($___value.sum / 1000,0) +} + + + + +function DISK-Is-Available { + return 0 +} diff --git a/automataCI/services/io/disk.sh b/automataCI/services/io/disk.sh new file mode 100644 index 0000000..7bbe2a0 --- /dev/null +++ b/automataCI/services/io/disk.sh @@ -0,0 +1,53 @@ +#!/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. +DISK_Calculate_Size() { + #___location="$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 -ks "$1")" + if [ $? -ne 0 ]; then + return 1 + fi + + printf "${___size%%[!0-9]*}" + + + # report status + return 0 +} + + + + +DISK_Is_Available() { + # execute + if [ ! -z "$(type -t du)" ]; then + return 0 + fi + + + # report status + return 1 +} diff --git a/automataCI/services/io/fs.ps1 b/automataCI/services/io/fs.ps1 new file mode 100644 index 0000000..b1dfd0d --- /dev/null +++ b/automataCI/services/io/fs.ps1 @@ -0,0 +1,890 @@ +# 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. +function FS-Append-File { + param ( + [string]$___target, + [string]$___content + ) + + + # validate target + if ([string]::IsNullOrEmpty($___target)) { + return 1 + } + + + # perform file write + $null = Add-Content -Path $___target -Value $___content + if ($?) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Copy-All { + param ( + [string]$___source, + [string]$___destination + ) + + + # validate input + if ([string]::IsNullOrEmpty($___source) -or [string]::IsNullOrEmpty($___destination)) { + return 1 + } + + + # execute + $null = Copy-Item -Path "${___source}\*" -Destination "${___destination}" -Recurse + if ($?) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Copy-File { + param ( + [string]$___source, + [string]$___destination + ) + + + # validate input + if ([string]::IsNullOrEmpty($___source) -or [string]::IsNullOrEmpty($___destination)) { + return 1 + } + + + # execute + $null = Copy-Item -Path "${___source}" -Destination "${___destination}" + if ($?) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Extension-Remove { + param ( + [string]$___target, + [string]$___extension + ) + + + # execute + return FS-Extension-Replace "${___target}" "${___extension}" "" +} + + + + +function FS-Extension-Replace { + param ( + [string]$__target, + [string]$___extension, + [string]$___candidate + ) + + + # validate input + if ([string]::IsNullOrEmpty($__target)) { + return "" + } + + + # execute + if ($___extension -eq "*") { + $___target = Split-Path -Leaf "${__target}" + $___target = $___target -replace '(\.\w+)+$' + + if (-not [string]::IsNullOrEmpty($(Split-Path -Parent "${__target}"))) { + $___target = $(Split-Path -Parent "${__target}") + "\" + "${___target}" + } + } elseif (-not [string]::IsNullOrEmpty($___extension)) { + if ($___extension.Substring(0,1) -eq ".") { + $___extension = $___extension.Substring(1) + } + + $___target = Split-Path -Leaf "${__target}" + $___target = $___target -replace "\.${___extension}$" + + if (-not [string]::IsNullOrEmpty($___candidate)) { + if ($___candidate.Substring(0,1) -eq ".") { + $___target += "." + $___candidate.Substring(1) + } else { + $___target += "." + $___candidate + } + } + + if (-not [string]::IsNullOrEmpty($(Split-Path -Parent "${__target}"))) { + $___target = $(Split-Path -Parent "${__target}") + "\" + "${___target}" + } + } else { + $___target = $__target + } + + + # report status + return $___target +} + + + + +function FS-Get-Directory { + param ( + [string]$___target + ) + + + # validate input + if ([string]::IsNullOrEmpty($___target)) { + return "" + } + + + # execute + return "$(Split-Path -Parent -Path "${___target}")" +} + + + + +function FS-Get-File { + param ( + [string]$___target + ) + + + # validate input + if ([string]::IsNullOrEmpty($___target)) { + return "" + } + + + # execute + return "$(Split-Path -Leaf -Path "${___target}")" +} + + + + +function FS-Get-MIME { + param( + [string]$___target + ) + + + # validate input + if ((FS-Is-Target-Exist $___target) -ne 0) { + return "" + } + + + # execute + $___process = FS-Is-Directory "${___target}" + if ($___process -eq 0) { + return "inode/directory" + } + + + switch ((Get-ChildItem $___target).Extension.ToLower()) { + ".avif" { + return "image/avif" + } ".gif" { + return "image/gif" + } ".gzip" { + return "application/x-gzip" + } { $_ -in ".jpg", ".jpeg" } { + return "image/jpeg" + } ".json" { + return "application/json" + } ".mkv" { + return "video/mkv" + } ".mp4" { + return "video/mp4" + } ".png" { + return "image/png" + } ".rar" { + return "application/x-rar-compressed" + } ".tiff" { + return "image/tiff" + } ".webp" { + return "image/webp" + } ".xml" { + return "application/xml" + } ".zip" { + return "application/zip" + } default { + return "" + }} +} + + + + +function FS-Get-Path-Relative { + param ( + [string]$___target, + [string]$___base + ) + + + # validate input + if ([string]::IsNullOrEmpty($___target) -or [string]::IsNullOrEmpty($___base)) { + return "" + } + + + # execute + $___output = Resolve-Path -Relative -Path "${___target}" -RelativeBasePath "${___base}" + if ($___output.StartsWith(".\")) { + $___output = $___output.Substring(2) + } + + + # report status + return $___output +} + + + + +function FS-Is-Directory { + param ( + [string]$___target + ) + + + # validate input + if ([string]::IsNullOrEmpty($___target)) { + return 1 + } + + + # execute + if (Test-Path -Path "${___target}" -PathType Container -ErrorAction SilentlyContinue) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-File { + param ( + [string]$___target + ) + + + # validate input + if ([string]::IsNullOrEmpty($___target)) { + return 1 + } + + + # execute + $___process = FS-Is-Directory "${___target}" + if ($___process -eq 0) { + return 1 + } + + if (Test-Path -Path "${___target}" -ErrorAction SilentlyContinue) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Cargo { + param ( + [string]$___target + ) + + + # execute + if (($("${___target}" -replace '^.*-cargo') -ne "${___target}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Chocolatey { + param ( + [string]$___target + ) + + + # execute + if (($("${___target}" -replace '^.*-chocolatey') -ne "${___target}") -or + ($("${___target}" -replace '^.*-choco') -ne "${___target}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Citation-CFF { + param ( + [string]$___target + ) + + + # execute + if ($("${___target}" -replace '^.*.cff') -ne "${___target}") { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Docs { + param ( + [string]$___target + ) + + + # execute + if (($("${___target}" -replace '^.*-doc') -ne "${___target}") -or + ($("${___target}" -replace '^.*-docs') -ne "${___target}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Homebrew { + param ( + [string]$___target + ) + + + # execute + if (($("${___target}" -replace '^.*-homebrew') -ne "${___target}") -or + ($("${___target}" -replace '^.*-brew') -ne "${___target}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Library { + param ( + [string]$___subject + ) + + + # 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}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-MSI { + param ( + [string]$___target + ) + + + # execute + if (($("${___target}" -replace '^.*-msi') -ne "${___target}") -or + ($("${___target}" -replace '^.*.msi') -ne "${___target}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Nupkg { + param ( + [string]$___target + ) + + + # execute + if ($("${___target}" -replace '^.*.nupkg') -ne "${___target}") { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-PDF { + param ( + [string]$___target + ) + + + # execute + if (($("${___target}" -replace '^.*.pdf') -ne "${___target}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-PYPI { + param ( + [string]$___target + ) + + + # execute + if (($("${___target}" -replace '^.*-pypi') -ne "${___target}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Source { + param ( + [string]$___target + ) + + + # execute + if (($("${___target}" -replace '^.*-src') -ne "${___target}") -or + ($("${___target}" -replace '^.*-source') -ne "${___target}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-WASM { + param ( + [string]$___target + ) + + + # execute + if ($("${___target}" -replace '^.*-wasm') -ne "${___target}") { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-WASM-JS { + param ( + [string]$___target + ) + + + # execute + if ($("${___target}" -replace '^.*-wasm') -eq "${___target}") { + return 1 + } + + if ($("${___target}" -replace '^.*.js') -eq "${___target}") { + return 1 + } + + + # report status + return 0 +} + + + + +function FS-Is-Target-Exist { + param ( + [string]$___target + ) + + + # validate input + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + + # perform checking + $___process = Test-Path -Path "${___target}" -PathType Any -ErrorAction SilentlyContinue + if ($___process) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-List-All { + param ( + [string]$___target + ) + + + # validate input + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + + # execute + if ((FS-Is-Directory "${___target}") -ne 0) { + return 1 + } + + try { + foreach ($___item in (Get-ChildItem -Path "${___target}" -Recurse)) { + Write-Host $___item.FullName + } + + return 0 + } catch { + return 1 + } +} + + + + +function FS-Make-Directory { + param ( + [string]$___target + ) + + + # validate input + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___process = FS-Is-Directory "${___target}" + if ($___process -eq 0) { + return 0 + } + + $___process = FS-Is-Target-Exist "${___target}" + if ($___process -eq 0) { + return 1 + } + + + # execute + $___process = New-Item -ItemType Directory -Force -Path "${___target}" + if ($___process) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Make-Housing-Directory { + param ( + [string]$___target + ) + + + # validate input + if ([string]::IsNullOrEmpty($___target)) { + return 1 + } + + $___process = FS-Is-Directory $___target + if ($___process -eq 0) { + return 0 + } + + + # perform create + $___process = FS-Make-Directory (Split-Path -Parent -Path $___target) + + + # report status + return $__process +} + + + + +function FS-Move { + param ( + [string]$___source, + [string]$___destination + ) + + + # validate input + if ([string]::IsNullOrEmpty($___source) -or [string]::IsNullOrEmpty($___destination)) { + return 1 + } + + + # execute + try { + Move-Item -Path $___source -Destination $___destination -Force + if (!$?) { + return 1 + } + } catch { + return 1 + } + + + # report status + return 0 +} + + + + +function FS-Remake-Directory { + param ( + [string]$___target + ) + + + # execute + $null = FS-Remove-Silently "${___target}" + $___process = FS-Make-Directory "${___target}" + if ($___process -eq 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Remove { + param ( + [string]$___target + ) + + + # validate input + if ([string]::IsNullOrEmpty($___target)) { + return 1 + } + + + # execute + $___process = Remove-Item $___target -Force -Recurse + if ($___process -eq $null) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Remove-Silently { + param ( + [string]$___target + ) + + + # validate input + if ([string]::IsNullOrEmpty($___target)) { + return 0 + } + + + # execute + $null = Remove-Item $___target -Force -Recurse -ErrorAction SilentlyContinue + + + # report status + return 0 +} + + + + +function FS-Rename { + param ( + [string]$___source, + [string]$___target + ) + + + # execute + return FS-Move "${___source}" "${___target}" +} + + + + +function FS-Touch-File { + param( + [string]$___target + ) + + + # validate input + if ([string]::IsNullOrEmpty($___target)) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -eq 0) { + return 0 + } + + + # execute + $___process = New-Item -Path "${___target}" + if ($___process) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Write-File { + param ( + [string]$___target, + [string]$___content + ) + + + # validate input + if ([string]::IsNullOrEmpty($___target)) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -eq 0) { + return 1 + } + + + # perform file write + $null = Set-Content -Path $___target -Value $___content + if ($?) { + return 0 + } + + + # report status + return 1 +} diff --git a/automataCI/services/io/fs.sh b/automataCI/services/io/fs.sh new file mode 100644 index 0000000..aacfa07 --- /dev/null +++ b/automataCI/services/io/fs.sh @@ -0,0 +1,832 @@ +#!/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. +FS_Append_File() { + #___target="$1" + #___content="$2" + + + # validate target + if [ ! -z "$1" -a -z "$2" ] || [ -z "$1" ]; then + return 1 + fi + + + # perform file write + printf -- "%b" "$2" >> "$1" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +FS_Copy_All() { + #___source="$1" + #___destination="$2" + + + # validate input + if [ -z "$1" ] || [ -z "$2" ]; then + return 1 + fi + + + # execute + cp -r "${1}"* "${2}/." + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +FS_Copy_File() { + #___source="$1" + #___destination="$2" + + + # validate input + if [ -z "$1" ] || [ -z "$2" ]; then + return 1 + fi + + + # execute + cp "$1" "$2" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +FS_Extension_Remove() { + printf -- "%s" "$(FS_Extension_Replace "$1" "$2" "")" + return $? +} + + + + +FS_Extension_Replace() { + #___target="$1" + #___extension="$2" + #___candidate="$3" + + + # validate input + if [ -z "$1" ]; then + printf -- "" + return 0 + fi + + + # execute + if [ "$2" = "*" ]; then + ___target="${1##*/}" + ___target="${___target%%.*}" + + if [ ! -z "${1%/*}" ] && [ ! "${1%/*}" = "$1" ]; then + ___target="${1%/*}/${___target}" + fi + elif [ ! -z "$2" ]; then + if [ "$(printf -- "%.1s" "$2")" = "." ]; then + ___extension="${2#*.}" + else + ___extension="$2" + fi + + ___target="${1##*/}" + while true; do + if [ "${___target#*.}" = "${___extension}" ]; then + ___target="${___target%.${___extension}*}" + continue + fi + + if [ ! "${___target##*.}" = "${___extension}" ]; then + break + fi + + ___target="${___target%.${___extension}*}" + done + + if [ ! "${___target}" = "${1##*/}" ]; then + if [ ! -z "$3" ]; then + if [ "$(printf -- "%.1s" "$3")" = "." ]; then + ___target="${___target}.${3#*.}" + else + ___target="${___target}.${3}" + fi + fi + fi + + if [ ! -z "${1%/*}" ] && [ ! "${1%/*}" = "$1" ]; then + ___target="${1%/*}/${___target}" + fi + else + ___target="$1" + fi + + printf -- "%s" "$___target" + + + # report status + return 0 +} + + + + +FS_Get_Directory() { + #___target="$1" + + + # validate input + if [ -z "$1" ]; then + printf -- "" + return 1 + fi + + + # execute + printf -- "%b" "${1%/*}" + + + # report status + return 0 +} + + + + +FS_Get_File() { + #___target="$1" + + + # validate input + if [ -z "$1" ]; then + printf -- "" + return 1 + fi + + + # execute + printf -- "%b" "${1##*/}" + + + # report status + return 0 +} + + + + +FS_Get_MIME() { + #___target="$1" + + + # validate input + if [ -z "$1" ]; then + return 1 + fi + + + # execute + ___output="$(file --mime-type "$1")" + if [ $? -eq 0 ]; then + printf -- "%b" "${___output##* }" + return 0 + fi + + + # report status + printf -- "" + return 1 +} + + + + +FS_Get_Path_Relative() { + #___target="$1" + #___base="$2" + + + # validate input + if [ -z "$1" ] || [ -z "$2" ]; then + printf -- "" + return 1 + fi + + + # execute + printf -- "%b" "${1#*${2}/}" + + + # report status + return 0 +} + + + + +FS_Is_Directory() { + #___target="$1" + + + # validate input + if [ -z "$1" ]; then + return 1 + fi + + + # execute + if [ -d "$1" ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +FS_Is_File() { + #___target="$1" + + + # validate input + if [ -z "$1" ]; then + return 1 + fi + + + # execute + FS_Is_Directory "$1" + if [ $? -eq 0 ]; then + return 1 + fi + + if [ -f "$1" ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +FS_Is_Target_A_Cargo() { + #___target="$1" + + + # execute + if [ "${1#*-cargo}" != "$1" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Chocolatey() { + #___target="$1" + + + # execute + if [ "${1#*-chocolatey}" != "$1" ] || [ "${1#*-choco}" != "$1" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Citation_CFF() { + #___target="$1" + + + # execute + if [ "${1#*.cff}" != "$1" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Docs() { + #___target="$1" + + + # execute + if [ "${1#*-doc}" != "$1" ] || [ "${1#*-docs}" != "$1" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Homebrew() { + #___target="$1" + + + # execute + if [ "${1#*-homebrew}" != "$1" ] || [ "${1#*-brew}" != "$1" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Library() { + #___target="$1" + + + # execute + if [ "${1%%lib*}" != "$1" ] || + [ "${1##*.a}" != "$1" ] || + [ "${1##*.dll}" != "$1" ] || + [ "${1#*-lib}" != "$1" ] || + [ "${1#*-libs}" != "$1" ] || + [ "${1#*-library}" != "$1" ] || + [ "${1#*-libraries}" != "$1" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_MSI() { + #___target="$1" + + + # execute + if [ "${1#*-msi}" != "$1" ] || [ "${1#*.msi}" != "$1" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Nupkg() { + #___target="$1" + + + # execute + if [ "${1#*.nupkg}" != "$1" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_PDF() { + #___target="$1" + + + # execute + if [ "${1#*.pdf}" != "$1" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_PYPI() { + #___target="$1" + + + # execute + if [ "${1#*-pypi}" != "$1" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Source() { + #___target="$1" + + + # execute + if [ "${1#*-src}" != "$1" ] || [ "${1#*-source}" != "$1" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_WASM() { + #___target="$1" + + + # execute + if [ "${1#*-wasm}" != "$1" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_WASM_JS() { + #___subject="$1" + + + # execute + if [ "${1#*-wasm}" == "$1" ]; then + printf -- "1" + return 1 + fi + + if [ "${1#*.js}" == "$1" ]; then + printf -- "1" + return 1 + fi + + + # report status + printf -- "0" + return 0 +} + + + + +FS_Is_Target_Exist() { + #___target="$1" + + + # validate input + if [ -z "$1" ]; then + return 1 + fi + + + # perform checking + if [ -e "$1" ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +FS_List_All() { + #___target="$1" + + + # validate input + if [ -z "$1" ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ls -la "$1" + if [ $? -eq 0 ]; then + return 0 + fi + return 1 +} + + + + +FS_Make_Directory() { + #___target="$1" + + + # validate input + if [ -z "$1" ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -eq 0 ]; then + return 0 + fi + + FS_Is_Target_Exist "$1" + if [ $? -eq 0 ]; then + return 1 + fi + + + # execute + mkdir -p "$1" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +FS_Make_Housing_Directory() { + #___target="$1" + + + # validate input + if [ -z "$1" ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -eq 0 ]; then + return 0 + fi + + + # perform create + FS_Make_Directory "${1%/*}" + + + # report status + return $? +} + + + + +FS_Move() { + #___source="$1" + #___destination="$2" + + + # validate input + if [ -z "$1" ] || [ -z "$2" ]; then + return 1 + fi + + + # execute + mv "$1" "$2" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +FS_Remake_Directory() { + #___target="$1" + + + # execute + FS_Remove_Silently "$1" + FS_Make_Directory "$1" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +FS_Remove() { + #___target="$1" + + + # validate input + if [ -z "$1" ]; then + return 1 + fi + + + # execute + rm -rf "$1" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +FS_Remove_Silently() { + #___target="$1" + + + # validate input + if [ -z "$1" ]; then + return 0 + fi + + + # execute + rm -rf "$1" &> /dev/null + + + # report status + return 0 +} + + + + +FS_Rename() { + #___source="$1" + #___target="$2" + + + # execute + FS_Move "$1" "$2" + return $? +} + + + + +FS_Touch_File() { + #___target="$1" + + + # validate input + if [ -z "$1" ]; then + return 1 + fi + + FS_Is_File "$1" + if [ $? -eq 0 ]; then + return 0 + fi + + + # execute + touch "$1" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +FS_Write_File() { + #___target="$1" + #___content="$2" + + + # validate input + if [ -z "$1" ]; then + return 1 + fi + + FS_Is_File "$1" + if [ $? -eq 0 ]; then + return 1 + fi + + + # perform file write + printf -- "%b" "$2" >> "$1" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} diff --git a/automataCI/services/io/net/http.ps1 b/automataCI/services/io/net/http.ps1 new file mode 100644 index 0000000..83cf655 --- /dev/null +++ b/automataCI/services/io/net/http.ps1 @@ -0,0 +1,174 @@ +# 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. +function HTTP-Download { + param ( + [string]$___method, + [string]$___url, + [string]$___filepath, + [string]$___shasum_type, + [string]$___shasum_value, + [string]$___auth_header + ) + + + # validate input + if ([string]::IsNullOrEmpty($___url) -or [string]::IsNullOrEmpty($___filepath)) { + return 1 + } + + if ((-not (Get-Command curl -ErrorAction SilentlyContinue)) -and + (-not (Get-Command wget -ErrorAction SilentlyContinue))) { + return 1 + } + + if ([string]::IsNullOrEmpty($___method)) { + $___method = "GET" + } + + + # execute + ## clean up workspace + $null = Remove-Item $___filepath -Force -Recurse -ErrorAction SilentlyContinue + $null = FS-Make-Directory (Split-Path -Path $___filepath) -ErrorAction SilentlyContinue + $___user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15" + + + ## download payload + if (-not [string]::IsNullOrEmpty($___auth_header)) { + if (Get-Command curl -ErrorAction SilentlyContinue) { + curl --location ` + --header $___user_agent ` + --header $___auth_header ` + --output $___filepath ` + --request $___method ` + $___url + if ($LASTEXITCODE -ne 0) { + return 1 + } + } elseif (Get-Command wget -ErrorAction SilentlyContinue) { + wget --max-redirect 16 ` + --header $___user_agent ` + --header=$___auth_header ` + --output-file=$___filepath ` + --method=$___method ` + $___url + if ($LASTEXITCODE -ne 0) { + return 1 + } + } else { + return 1 + } + } else { + if (Get-Command curl -ErrorAction SilentlyContinue) { + curl --location ` + --header $___user_agent ` + --output $___filepath ` + --request $___method ` + $___url + if ($LASTEXITCODE -ne 0) { + return 1 + } + } elseif (Get-Command wget -ErrorAction SilentlyContinue) { + wget --max-redirect 16 ` + --header $___user_agent ` + --output-file=$___filepath ` + --method=$___method ` + $___url + if ($LASTEXITCODE -ne 0) { + return 1 + } + } else { + return 1 + } + } + + if (-not (Test-Path -Path $___filepath)) { + return 1 + } + + ## checksum payload + if ([string]::IsNullOrEmpty($___shasum_type) -or + [string]::IsNullOrEmpty($___shasum_value)) { + return 0 + } + + switch ($___shasum_type) { + '1' { + $___hasher = New-Object ` + System.Security.Cryptography.SHA1CryptoServiceProvider + } '224' { + return 1 + } '256' { + $___hasher = New-Object ` + System.Security.Cryptography.SHA256CryptoServiceProvider + } '384' { + $___hasher = New-Object ` + System.Security.Cryptography.SHA384CryptoServiceProvider + } '512' { + $___hasher = New-Object ` + System.Security.Cryptography.SHA512CryptoServiceProvider + } '512224' { + return 1 + } '512256' { + return 1 + } Default { + return 1 + }} + + $___fileStream = [System.IO.File]::OpenRead($___filepath) + $___hash = $___hasher.ComputeHash($___fileStream) + $___hash = [System.BitConverter]::ToString($___hash).Replace("-", "").ToLower() + if ($___hash -ne $___shasum_value) { + return 1 + } + + + # report status + return 0 +} + + + + +function HTTP-Is-Available { + # execute + if (Get-Command curl -ErrorAction SilentlyContinue) { + return 0 + } + + + # report status + return 1 +} + + + + +function HTTP-Setup { + # validate input + if (-not (Get-Command choco -ErrorAction SilentlyContinue)) { + return 1 + } + + if (Get-Command curl -ErrorAction SilentlyContinue) { + return 0 + } + + choco install curl + if ($LASTEXITCODE -ne 0) { + return 1 + } + + + # report status + return 1 +} diff --git a/automataCI/services/io/net/http.sh b/automataCI/services/io/net/http.sh new file mode 100644 index 0000000..9179c48 --- /dev/null +++ b/automataCI/services/io/net/http.sh @@ -0,0 +1,148 @@ +#!/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. +HTTP_Download() { + ___method="$1" + ___url="$2" + ___filepath="$3" + ___shasum_type="$4" + ___shasum_value="$5" + ___auth_header="$6" + + + # validate input + if [ -z "$___url" ] || [ -z "$___filepath" ]; then + return 1 + fi + + if [ -z "$(type -t curl)" ] && [ -z "$(type -t wget)" ]; then + return 1 + fi + + if [ -z "$___method" ]; then + ___method="GET" + fi + + + # execute + ## clean up workspace + rm -rf "$___filepath" &> /dev/null + mkdir -p "${___filepath%/*}" &> /dev/null + ___user_agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15" + + ## download payload + if [ ! -z "$___auth_header" ]; then + if [ ! -z "$(type -t curl)" ]; then + curl --location \ + --header "$___user_agent" \ + --header "$___auth_header" \ + --output "$___filepath" \ + --request "$___method" \ + "$___url" + elif [ ! -z "$(type -t wget)" ]; then + wget --max-redirect 16 \ + --header "$___user_agent" \ + --header="$___auth_header" \ + --output-file"$___filepath" \ + --method="$___method" \ + "$___url" + else + return 1 + fi + else + if [ ! -z "$(type -t curl)" ]; then + curl --location \ + --header "$___user_agent" \ + --output "$___filepath" \ + --request "$___method" \ + "$___url" + elif [ ! -z "$(type -t wget)" ]; then + wget --max-redirect 16 \ + --header "$___user_agent" \ + --output-file"$___filepath" \ + --method="$___method" \ + "$___url" + else + return 1 + fi + fi + + if [ ! -f "$___filepath" ]; then + return 1 + fi + + ## checksum payload + if [ -z "$___shasum_type" ] || [ -z "$___shasum_value" ]; then + return 0 + fi + + if [ -z "$(type -t shasum)" ]; then + return 1 + fi + + case "$___shasum_type" in + 1|224|256|384|512|512224|512256) + ;; + *) + return 1 + ;; + esac + + ___target_shasum="$(shasum -a "$___shasum_type" "$___filepath")" + ___target_shasum="${___target_shasum%% *}" + if [ ! "$___target_shasum" = "$___shasum_value" ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +HTTP_Is_Available() { + # execute + if [ ! -z "$(type -t "curl")" ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +HTTP_Setup() { + # validate input + if [ -z "$(type -t "brew")" ]; then + return 1 + fi + + if [ ! -z "$(type -t "curl")" ]; then + return 0 + fi + + + # execute + brew install curl + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/io/os.ps1 b/automataCI/services/io/os.ps1 new file mode 100644 index 0000000..e95420a --- /dev/null +++ b/automataCI/services/io/os.ps1 @@ -0,0 +1,219 @@ +# 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. +function OS-Get-Arch { + # execute + switch ((Get-ComputerInfo).CsProcessors.Architecture) { + "Alpha" { + return "alpha" + } "ARM" { + return "arm" + } "ARM64" { + return "arm64" + } "ia64" { + return "ia64" + } "MIPs" { + return "mips" + } "PowerPC" { + return "powerpc" + } "x86" { + return "i386" + } "x64" { + return "amd64" + } Default { + return "" + }} +} + + + + +function OS-Get-CPU { + $___output = [System.Environment]::ProcessorCount + if (([string]::IsNullOrEmpty($___output)) -or (${___output} -eq 0)) { + $___output = 1 + } + + + # report status + return $___output +} + + + + +function OS-Get { + $___output = (Get-ComputerInfo).OsName.ToLower() + if (-not ($___output -match "microsoft" -or $___output -match "windows")) { + return "" + } + + return "windows" +} + + + + +function OS-Get-Lang { + $___lang = Get-WinSystemLocale + $fullLanguageCode = $___lang.Name + $___lang = $___lang -replace '[_-][A-Z]*$', '' + $___lang = $___lang -replace '_', '-' + + return $___lang +} + + + + +function OS-Is-Command-Available { + param ( + [string]$___command + ) + + + # validate input + if ([string]::IsNullOrEmpty($___command)) { + return 1 + } + + + # execute + $__program = Get-Command $___command -ErrorAction SilentlyContinue + if ($__program) { + return 0 + } + + + # report status + return 1 +} + + + + +function OS-Exec { + param ( + [string]$___command, + [string]$___arguments, + [string]$___log_stdout, + [string]$___log_stderr + ) + + + # validate input + if ([string]::IsNullOrEmpty($___command)) { + return 1 + } + + + # get program fullpath + if (Test-Path -Path "${___command}" -ErrorAction SilentlyContinue) { + $___program = "${___command}" + } else { + $___program = Get-Command $___command -ErrorAction SilentlyContinue + if (-not ($___program)) { + return 1 + } + } + + + # execute command + if ([string]::IsNullOrEmpty($___arguments)) { + if ((-not [string]::IsNullOrEmpty($___log_stdout)) -and + (-not [string]::IsNullOrEmpty($___log_stderr))) { + $___process = Start-Process -Wait ` + -FilePath "${___program}" ` + -NoNewWindow ` + -PassThru ` + -RedirectStandardOutput "${___log_stdout}" ` + -RedirectStandardError "${___log_stderr}" + } elseif (-not [string]::IsNullOrEmpty($___log_stdout)) { + $___process = Start-Process -Wait ` + -FilePath "${___program}" ` + -NoNewWindow ` + -PassThru ` + -RedirectStandardOutput "${___log_stdout}" + } elseif (-not [string]::IsNullOrEmpty($___log_stderr)) { + $___process = Start-Process -Wait ` + -FilePath "${___program}" ` + -NoNewWindow ` + -PassThru ` + -RedirectStandardError "${___log_stderr}" + } else { + $___process = Start-Process -Wait ` + -FilePath "${___program}" ` + -NoNewWindow ` + -PassThru + } + } else { + if ((-not [string]::IsNullOrEmpty($___log_stdout)) -and + (-not [string]::IsNullOrEmpty($___log_stderr))) { + $___process = Start-Process -Wait ` + -FilePath "${___program}" ` + -NoNewWindow ` + -PassThru ` + -ArgumentList "${___arguments}" ` + -RedirectStandardOutput "${___log_stdout}" ` + -RedirectStandardError "${___log_stderr}" + } elseif (-not [string]::IsNullOrEmpty($___log_stdout)) { + $___process = Start-Process -Wait ` + -FilePath "${___program}" ` + -NoNewWindow ` + -PassThru ` + -ArgumentList "${___arguments}" ` + -RedirectStandardOutput "${___log_stdout}" + } elseif (-not [string]::IsNullOrEmpty($___log_stderr)) { + $___process = Start-Process -Wait ` + -FilePath "${___program}" ` + -NoNewWindow ` + -PassThru ` + -ArgumentList "${___arguments}" ` + -RedirectStandardError "${___log_stderr}" + } else { + $___process = Start-Process -Wait ` + -FilePath "${___program}" ` + -NoNewWindow ` + -PassThru ` + -ArgumentList "${___arguments}" + } + } + if ($___process.ExitCode -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function OS-Is-Run-Simulated { + # execute + if (-not ([string]::IsNullOrEmpty("${env:PROJECT_SIMULATE_RELEASE_REPO}"))) { + return 0 + } + + + # report status + return 1 +} + + + + +function OS-Sync { + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") ` + + ";" ` + + [System.Environment]::GetEnvironmentVariable("Path","User") +} diff --git a/automataCI/services/io/os.sh b/automataCI/services/io/os.sh new file mode 100644 index 0000000..edcaad1 --- /dev/null +++ b/automataCI/services/io/os.sh @@ -0,0 +1,157 @@ +#!/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. +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_CPU() { + # execute + ___output=$(getconf _NPROCESSORS_ONLN) + if [ -z "$___output" ] || [ "$___output" -eq 0 ]; then + ___output="1" + fi + + + # 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 +} + + + + +OS_Get_Lang() { + ___lang="${LC_ALL:-$LANG}" + ___lang="${___lang%.*}" + ___lang="${___lang%_[A-Z]*}" + ___lang="$(printf -- "%b" "$___lang" | tr '_' '-')" + if [ "$___lang" = "C" ]; then + ___lang="en" + fi + + printf -- "%b" "$___lang" + return 0 +} + + + + +OS_Is_Command_Available() { + #___command="$1" + + + # validate input + if [ -z "$1" ]; then + return 1 + fi + + + # execute + 2>/dev/null 1>/dev/null type "$1" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +OS_Is_Run_Simulated() { + # execute + if [ ! -z "$PROJECT_SIMULATE_RELEASE_REPO" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +OS_Sync() { + # execute + sync + + + # report status + return 0 +} diff --git a/automataCI/services/io/strings.ps1 b/automataCI/services/io/strings.ps1 new file mode 100644 index 0000000..a31f62e --- /dev/null +++ b/automataCI/services/io/strings.ps1 @@ -0,0 +1,248 @@ +# 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. +function STRINGS-Has-Prefix { + param( + [string]$___prefix, + [string]$___content + ) + + + # validate input + $___process = STRINGS-Is-Empty "${___prefix}" + if ($___process -eq 0) { + return 1 + } + + + # execute + if ($___content.StartsWith($___prefix)) { + return 0 + } + + + # report status + return 1 +} + + + + +function STRINGS-Has-Suffix { + param( + [string]$___suffix, + [string]$___content + ) + + + # validate input + $___process = STRINGS-Is-Empty "${___suffix}" + if ($___process -eq 0) { + return 1 + } + + + # execute + if ($___content.EndsWith($___suffix)) { + return 0 + } + + + # report status + return 1 +} + + + + +function STRINGS-Is-Empty { + param( + $___target + ) + + + # execute + if ([string]::IsNullOrEmpty($___target)) { + return 0 + } + + + # report status + return 1 +} + + + + +function STRINGS-Replace-All { + param( + [string]$___content, + [string]$___subject, + [string]$___replacement + ) + + + # validate input + $___process = STRINGS-Is-Empty "${___content}" + if ($___process -eq 0) { + return "" + } + + $___process = STRINGS-Is-Empty "${___subject}" + if ($___process -eq 0) { + return $___content + } + + $___process = STRINGS-Is-Empty "${___replacement}" + if ($___process -eq 0) { + return $___content + } + + + # execute + $___right = $___content + $___register = "" + while ($___right) { + $___left = $___right -replace "$($___subject).*", "" + + if ($___left -eq $___right) { + return "${___register}${___right}" + } + + # replace this occurence + $___register += "${___left}${___replacement}" + $___right = $___right -replace "^.*?${___subject}", "" + } + + + # report status + return $___register +} + + + + +function STRINGS-To-Lowercase { + param( + [string]$___content + ) + + + # execute + return $___content.ToLower() +} + + + + +function STRINGS-To-Titlecase { + param( + [string]$___content + ) + + + # validate input + $___process = STRINGS-Is-Empty "${___content}" + if ($___process -eq 0) { + return "" + } + + + # execute + $___buffer = "" + $___resevoir = "${___content}" + $___trigger = $true + while ($___resevoir -ne "") { + ## extract character + $___char = $___resevoir.Substring(0, 1) + if ($___char -eq "``") { + $___char = $___resevoir.Substring(0, 2) + } + $___resevoir = $___resevoir -replace "^${___char}", "" + + ## process character + if ($___trigger ) { + $___char = $___char.ToUpper() + } else { + $___char = $___char.ToLower() + } + $___buffer += $___char + + ## set next character action + switch ("${___char}") { + { $_ -in " ", "`r", "`n" } { + $___trigger = $true + } default { + $___trigger = $false + }} + } + + + # report status + return $___buffer +} + + + + +function STRINGS-To-Uppercase { + param( + [string]$___content + ) + + + # execute + return $___content.ToUpper() +} + + + + +function STRINGS-Trim-Whitespace-Left { + param( + [string]$___content + ) + + + # execute + return $___content.TrimStart() +} + + + + +function STRINGS-Trim-Whitespace-Right { + param( + [string]$___content + ) + + + # execute + return $___content.TrimEnd() +} + + + + +function STRINGS-Trim-Whitespace { + param( + [string]$___content + ) + + + # execute + $___content = STRINGS-Trim-Whitespace-Left $___content + $___content = STRINGS-Trim-Whitespace-Right $___content + + + # report status + return $___content +} diff --git a/automataCI/services/io/strings.sh b/automataCI/services/io/strings.sh new file mode 100644 index 0000000..f99a2bd --- /dev/null +++ b/automataCI/services/io/strings.sh @@ -0,0 +1,253 @@ +#!/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. +STRINGS_Has_Prefix() { + #___prefix="$1" + #___content="$2" + + + # validate input + if [ "$(STRINGS_Is_Empty "$1")" -eq 0 ]; then + return 1 + fi + + + # execute + if [ "${2%"${2#"${1}"*}"}" = "$1" ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +STRINGS_Has_Suffix() { + #___suffix="$1" + #___content="$2" + + + # validate input + if [ "$(STRINGS_Is_Empty "$1")" -eq 0 ]; then + return 1 + fi + + + # execute + case "$2" in + *"$1") + return 0 + ;; + *) + return 1 + ;; + esac +} + + + + +STRINGS_Is_Empty() { + #___target="$1" + + + # execute + if [ -z "$1" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +STRINGS_Replace_All() { + #___content="$1" + #___subject="$2" + #___replacement="$3" + + + # validate input + if [ "$(STRINGS_Is_Empty "$1")" -eq 0 ]; then + printf -- "" + return 1 + fi + + if [ "$(STRINGS_Is_Empty "$2")" -eq 0 ]; then + printf -- "" + return 1 + fi + + if [ "$(STRINGS_Is_Empty "$3")" -eq 0 ]; then + printf -- "" + return 1 + fi + + + # execute + ___right="$1" + ___register="" + while [ -n "$___right" ]; do + ___left=${___right%%${2}*} + + if [ "$___left" = "$___right" ]; then + printf -- "%b" "${___register}${___right}" + return 0 + fi + + # replace this occurence + ___register="${___register}${___left}${3}" + ___right="${___right#*${2}}" + done + + + # report status + printf -- "%b" "${___register}" + return 0 +} + + + + +STRINGS_To_Lowercase() { + #___content="$1" + + + # execute + printf -- "%b" "$1" | tr '[:upper:]' '[:lower:]' + + + # report status + return 0 +} + + + + +STRINGS_To_Titlecase() { + #___content="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + printf -- "" + return 1 + fi + + + # execute + ___buffer="" + ___resevoir="$1" + ___trigger=0 + while [ -n "$___resevoir" ]; do + ## extract character + ___char="$(printf -- "%.1s" "$___resevoir")" + if [ "$___char" = '\' ]; then + ___char="$(printf -- "%.2s" "$___resevoir")" + fi + ___resevoir="${___resevoir#*${___char}}" + + ## process character + if [ $___trigger -eq 0 ]; then + ___char="$(printf -- "%s" "$___char" | tr '[:lower:]' '[:upper:]')" + else + ___char="$(printf -- "%s" "$___char" | tr '[:upper:]' '[:lower:]')" + fi + ___buffer="${___buffer}${___char}" + + ## set next character action + case "$___char" in + " "|"\r"|"\n") + ___trigger=0 + ;; + *) + ___trigger=1 + ;; + esac + done + + + # report status + printf -- "%s" "$___buffer" + return 0 +} + + + + +STRINGS_To_Uppercase() { + #___content="$1" + + + # execute + printf -- "%b" "$1" | tr '[:lower:]' '[:upper:]' + + + # report status + return 0 +} + + + + +STRINGS_Trim_Whitespace_Left() { + #___content="$1" + + + # execute + printf -- "%b" "${1#"${1%%[![:space:]]*}"}" + + + # report status + return 0 +} + + + + +STRINGS_Trim_Whitespace_Right() { + #___content="$1" + + + # execute + printf -- "%b" "${1%"${1##*[![:space:]]}"}" + + + # report status + return 0 +} + + + + +STRINGS_Trim_Whitespace() { + #___content="$1" + + + # execute + ___content="$(STRINGS_Trim_Whitespace_Left "$1")" + ___content="$(STRINGS_Trim_Whitespace_Right "$___content")" + printf -- "%b" "$___content" + unset ___content + + + # report status + return 0 +} diff --git a/automataCI/services/io/sync.ps1 b/automataCI/services/io/sync.ps1 new file mode 100644 index 0000000..40d923b --- /dev/null +++ b/automataCI/services/io/sync.ps1 @@ -0,0 +1,256 @@ +# 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. + + + + +# To use: +# $ SYNC-Exec-Parallel ${function:Function-Name}.ToString() ` +# "$(Get-Location)\control.txt" ` +# ".\tmp\parallel" ` +# "$([System.Environment]::ProcessorCount)" +# +# The subroutine function accepts a wrapper function as shown above. Here is +# an example to construct a simple parallelism executions: +# function Function-Name { +# param ( +# [string]$___line +# ) +# +# +# # initialize and import libraries from scratch +# ... +# +# +# # break line into multiple parameters (delimiter = '|') +# $___list = $___line -split "\|" +# $___arg1 = $___list[1] +# $___arg2 = $___list[2] +# ... +# +# +# +# # some tasks in your thread +# ... +# +# +# # execute +# ... +# +# +# # report status +# return 0 # signal a successful execution +# } +# +# +# # calling the parallel exec function +# SYNC-Exec-Parallel ${function:Function-Name}.ToString() ` +# "$(Get-Location)\control.txt" ` +# ".\tmp\parallel" ` +# "$([System.Environment]::ProcessorCount)" +# +# +# The control file must not have any comment and each line must be the capable +# of being executed in a single thread. Likewise, when feeding a function, +# each line is a long string with your own separator. You will have to break +# it inside your wrapper function. +# +# The subroutine function **MUST** return **ONLY** the following return code: +# 0 = signal the task execution is done and completed successfully. +# 1 = signal the task execution has error. This terminates the entire run. +function SYNC-Exec-Parallel { + param( + [string]$___parallel_command, + [string]$___parallel_control, + [string]$___parallel_directory, + [string]$___parallel_available + ) + + + # validate input + if ([string]::IsNullOrEmpty($___parallel_command)) { + return 1 + } + + if ([string]::IsNullOrEmpty($___parallel_control) -or + (-not (Test-Path -Path "${___parallel_control}"))) { + return 1 + } + + if ([string]::IsNullOrEmpty($___parallel_available)) { + $___parallel_available = [System.Environment]::ProcessorCount + } + + if ($___parallel_available -le 0) { + $___parallel_available = 1 + } + + if ([string]::IsNullOrEmpty($___parallel_directory)) { + $___parallel_directory = Split-Path -Path "${___parallel_control}" -Parent + } + + if (-not (Test-Path -Path "${___parallel_directory}" -PathType Container)) { + return 1 + } + + + # execute + $___parallel_directory = "${___parallel_directory}\flags" + $___parallel_total = 0 + + + # scan total tasks + foreach ($___line in (Get-Content "${___parallel_control}")) { + $___parallel_total += 1 + } + + + # end the execution if no task is available + if ($___parallel_total -le 0) { + return 0 + } + + + # run singularly when parallelism is unavailable or has only 1 task + if (($___parallel_available -le 1) -or ($___parallel_total -eq 1)) { + # prepare + ${function:SYNC-Run} = ${___parallel_command} + + + # execute + foreach ($___line in (Get-Content "${___parallel_control}")) { + $___process = SYNC-Run "${___line}" + if ($___process -ne 0) { + return 1 + } + } + + + # report status + return 0 + } + + + # run in parallel + $___jobs = @() + foreach ($___line in (Get-Content "${___parallel_control}")) { + $___jobs += Start-ThreadJob -ScriptBlock { + # prepare + ${function:SYNC-Run} = ${using:___parallel_command} + + + # execute + $___process = SYNC-Run "${using:___line}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 + } + } + + $null = Wait-Job -Job $___jobs + foreach ($___job in $___jobs) { + $___process = Receive-Job -Job $___job + if ($___process -ne 0) { + return 1 + } + } + + + # report status + return 0 +} + + + + +# To use: +# $ SYNC-Exec-Serial ${function:Function-Name}.ToString() "$(Get-Location)\control.txt" +# +# The subroutine function accepts a wrapper function as shown above. Here is +# an example to construct a simple parallelism executions: +# function Function-Name { +# param ( +# [string]$___line +# ) +# +# +# # initialize and import libraries from scratch +# ... +# +# +# # break line into multiple parameters (delimiter = '|') +# $___list = $___line -split "\|" +# $___arg1 = $___list[1] +# $___arg2 = $___list[2] +# ... +# +# +# # some tasks in your thread +# ... +# +# +# # execute +# ... +# +# +# # report status +# return 0 # signal a successful execution +# } +# +# +# # calling the parallel exec function +# SYNC-Exec-Serial ${function:Function-Name}.ToString() "$(Get-Location)\control.txt" +# +# +# The control file must not have any comment and each line must be the capable +# of being executed in a single thread. Likewise, when feeding a function, +# each line is a long string with your own separator. You will have to break +# it inside your wrapper function. +# +# The subroutine function **MUST** return **ONLY** the following return code: +# 0 = signal the task execution is done and completed successfully. +# 1 = signal the task execution has error. This terminates the entire run. +function SYNC-Exec-Serial { + param( + [string]$___serial_command, + [string]$___serial_control + ) + + + # validate input + if ([string]::IsNullOrEmpty($___serial_command)) { + return 1 + } + + if ([string]::IsNullOrEmpty($___serial_control) -or + (-not (Test-Path -Path "${___serial_control}"))) { + return 1 + } + + + # execute + ${function:SYNC-Run} = ${___serial_command} + foreach ($___line in (Get-Content "${___serial_control}")) { + $___process = SYNC-Run "${___line}" + if ($___process -ne 0) { + return 1 + } + } + + + # report status + return 0 +} diff --git a/automataCI/services/io/sync.sh b/automataCI/services/io/sync.sh new file mode 100644 index 0000000..b66ed65 --- /dev/null +++ b/automataCI/services/io/sync.sh @@ -0,0 +1,303 @@ +#!/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. + + + + +# To use: +# $ SYNC_Exec_Parallel "function_name" "${PWD}/parallel.txt" "/tmp/parallel" "4" +# +# The subroutine function accepts a wrapper function as shown above. Here is +# an example to construct a simple parallelism executions: +# function_name() { +# #___line="$1" +# +# +# # break line into multiple parameters (delimiter = '|') +# ___line="${1%|*}" +# +# ___last="${___line##*|}" +# ___line="${___line%|*}" +# +# ___2nd_last="${___line##*|}" +# ___line="${___line%|*}" +# +# ... +# +# +# # some tasks in your thread +# ... +# +# +# # execute +# $@ +# if [ $? -ne 0 ]; then +# return 1 # signal an error has occured +# fi +# +# +# # report status +# return 0 # signal a successful execution +# } +# +# +# # call the parallel exec +# SYNC_Exec_Parallel "function_name" "${PWD}/parallel.txt" "/tmp/parallel" "4" +# +# +# The control file must not have any comment and each line must be the capable +# of being executed in a single thread. Likewise, when feeding a function, +# each line is a long string with your own separator. You will have to break +# it inside your wrapper function. +# +# The subroutine function **MUST** return **ONLY** the following return code: +# 0 = signal the task execution is done and completed successfully. +# 1 = signal the task execution has error. This terminates the entire run. +SYNC_Exec_Parallel() { + ___parallel_command="$1" + ___parallel_control="$2" + ___parallel_directory="$3" + ___parallel_available="$4" + + + # validate input + if [ -z "$___parallel_command" ]; then + return 1 + fi + + if [ -z "$(type -t shasum)" ]; then + return 1 + fi + + if [ -z "$___parallel_control" ] || [ ! -f "$___parallel_control" ]; then + return 1 + fi + + if [ -z "$___parallel_available" ]; then + ___parallel_available=$(getconf _NPROCESSORS_ONLN) + fi + + if [ $___parallel_available -le 0 ]; then + ___parallel_available=1 + fi + + if [ -z "$___parallel_directory" ]; then + ___parallel_directory="${___parallel_control%/*}" + fi + + if [ ! -d "$___parallel_directory" ]; then + return 1 + fi + + + # execute + ___parallel_directory="${___parallel_directory}/flags" + ___parallel_total=0 + ___parallel_current=0 + ___parallel_working=0 + ___parallel_error=0 + ___parallel_done=0 + + + # scan total tasks + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + ___parallel_total=$(($___parallel_total + 1)) + done < "$___parallel_control" + IFS="$___old_IFS" && unset ___old_IFS + + + # end the execution if no task is available + if [ $___parallel_total -le 0 ]; then + return 0 + fi + + + # run singularly when parallelism is unavailable or has only 1 task + if [ $___parallel_available -le 1 ] || [ $___parallel_total -eq 1 ]; then + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + "$___parallel_command" "$___line" + if [ $? -ne 0 ]; then + return 1 + fi + done < "$___parallel_control" + IFS="$___old_IFS" && unset ___old_IFS + + + # report status + return 0 + fi + + + # run in parallel + rm -rf "$___parallel_directory" &> /dev/null + mkdir -p "$___parallel_directory" &> /dev/null + while [ $___parallel_done -ne $___parallel_total ]; do + ___parallel_done=0 + ___parallel_current=0 + ___parallel_working=0 + + # scan state + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + ___parallel_flag="$(printf -- "%b" "$___line" | shasum -a 256)" + ___parallel_flag="${___parallel_directory}/${___parallel_flag%% *}" + + # break if error flag is found + if [ -d "${___parallel_flag}.parallel-error" ]; then + ___parallel_error=$(($___parallel_error + 1)) + continue + fi + + # skip if working flag is found + if [ -d "${___parallel_flag}.parallel-working" ]; then + ___parallel_working=$(($___parallel_working + 1)) + ___parallel_current=$(($___parallel_current + 1)) + continue + fi + + # break entire scan when run is completed + if [ $___parallel_done -eq $___parallel_total ]; then + break + fi + + # skip if done flag is found + if [ -d "${___parallel_flag}.parallel-done" ]; then + ___parallel_done=$(($___parallel_done + 1)) + ___parallel_current=$(($___parallel_current + 1)) + continue + fi + + # it is a working state + if [ $___parallel_working -lt $___parallel_available ]; then + # secure parallel lock + mkdir -p "${___parallel_flag}.parallel-working" + ___parallel_working=$(($___parallel_working + 1)) + + + # initiate parallel execution + { + "$___parallel_command" $___line + + + # release lock + case $? in + 0) + mkdir -p "${___parallel_flag}.parallel-done" + ;; + *) + mkdir -p "${___parallel_flag}.parallel-error" + ;; + esac + rm -rf "${___parallel_flag}.parallel-working" \ + &> /dev/null + } & + fi + ___parallel_current=$(($___parallel_current + 1)) + done < "$___parallel_control" + IFS="$___old_IFS" && unset ___old_IFS + + + # stop the entire operation if error is detected + no more working tasks + if [ $___parallel_error -gt 0 -a $___parallel_working -eq 0 ]; then + return 1 + fi + done + + + # report status + return 0 +} + + + + +# To use: +# $ SYNC_Exec_Serial "function_name" "${PWD}/parallel.txt" +# +# The subroutine function accepts a wrapper function as shown above. Here is +# an example to construct a simple series of executions: +# function_name() { +# #___line="$1" +# +# +# # break line into multiple parameters (delimiter = '|') +# ___line="${1%|*}" +# +# ___last="${___line##*|}" +# ___line="${___line%|*}" +# +# ___2nd_last="${___line##*|}" +# ___line="${___line%|*}" +# +# ... +# +# +# # some tasks in your thread +# ... +# +# +# # execute +# $@ +# if [ $? -ne 0 ]; then +# return 1 # signal an error has occured +# fi +# +# +# # report status +# return 0 # signal a successful execution +# } +# +# +# # call the series exec +# SYNC_Exec_Serial "function_name" "${PWD}/parallel.txt" +# +# +# The control file must not have any comment and each line must be the capable +# of being executed in a single thread. Likewise, when feeding a function, +# each line is a long string with your own separator. You will have to break +# it inside your wrapper function. +# +# The subroutine function **MUST** return **ONLY** the following return code: +# 0 = signal the task execution is done and completed successfully. +# 1 = signal the task execution has error. This terminates the entire run. +SYNC_Exec_Serial() { + ___series_command="$1" + ___series_control="$2" + + + # validate input + if [ -z "$___series_command" ]; then + return 1 + fi + + if [ -z "$___series_control" ] || [ ! -f "$___series_control" ]; then + return 1 + fi + + + # execute + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + "$___series_command" "$___line" + if [ $? -ne 0 ]; then + return 1 + fi + done < "$___series_control" + IFS="$___old_IFS" && unset ___old_IFS + + + # report status + return 0 +} diff --git a/automataCI/services/io/time.ps1 b/automataCI/services/io/time.ps1 new file mode 100644 index 0000000..22d58c4 --- /dev/null +++ b/automataCI/services/io/time.ps1 @@ -0,0 +1,41 @@ +# 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. +function TIME-Format-ISO8601-Date { + 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("yyyy-MM-dd") +} + + + + +function TIME-Is-Available { + return 0 +} + + + + +function TIME-Now { + return Get-Date (Get-Date).ToUniversalTime() -UFormat %s +} diff --git a/automataCI/services/io/time.sh b/automataCI/services/io/time.sh new file mode 100644 index 0000000..57be53f --- /dev/null +++ b/automataCI/services/io/time.sh @@ -0,0 +1,72 @@ +#!/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. +TIME_Format_ISO8601_Date() { + #___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}" +"%Y-%m-%d")" + else + printf -- "%b" "$(date --date="@${1}" +"%Y-%m-%d")" + fi + + + # report status + return 0 +} + + + + +TIME_Is_Available() { + # execute + if [ -z "$(type -t date)" ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +TIME_Now() { + # validate input + TIME_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + printf -- "%b" "$(date -u '+%s')" + + + # report status + return 0 +} diff --git a/automataCI/services/publishers/apple.ps1 b/automataCI/services/publishers/apple.ps1 new file mode 100644 index 0000000..8b137cc --- /dev/null +++ b/automataCI/services/publishers/apple.ps1 @@ -0,0 +1,81 @@ +#!/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. +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" + + + + +function APPLE-Install-DMG { + param( + [string]$___target + ) + + + # validate input + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Is-Command-Available "hdiutil" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Is-Command-Available "grep" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Is-Command-Available "awk" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Is-Command-Available "cp" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___image = Mount-DiskImage -ImagePath "${___target}" -PassThru + $___volumesLine = $___image | Select-String -Pattern "Volumes" + $___volumePath = $___volumesLine -split '\s+' | Select-Object -Index 2 + $___volume = $___volumePath + if ($(STRINGS-Is-Empty "${___volume}") -eq 0) { + return 1 + } + + $null = Copy-Item \ + -Recurse \ + -Force \ + -Path "${___volume}\*.app" \ + -Destination "/Applications" + if ($?) { + $___process = 0 + } else { + $___process = 1 + } + + $null = Dismount-DiskImage -ImagePath $___image.ImagePath + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/publishers/apple.sh b/automataCI/services/publishers/apple.sh new file mode 100644 index 0000000..ee4ddc7 --- /dev/null +++ b/automataCI/services/publishers/apple.sh @@ -0,0 +1,66 @@ +#!/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" + + + + +APPLE_Install_DMG() { + #___target="$1" + + + # validate input + FS_Is_File "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "hdiutil" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "grep" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "awk" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "cp" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___volume="$(hdiutil attach $1 | grep Volumes | awk '{print $3}')" + if [ $(STRINGS_Is_Empty "$___volume") -eq 0 ]; then + return 1 + fi + + cp -rf "$___volume"/*.app /Applications + ___process=$? + hdiutil detach "$___volume" + if [ $___process -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/publishers/chocolatey.ps1 b/automataCI/services/publishers/chocolatey.ps1 new file mode 100644 index 0000000..313bdfd --- /dev/null +++ b/automataCI/services/publishers/chocolatey.ps1 @@ -0,0 +1,242 @@ +# 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\io\net\http.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\zip.ps1" + + + + +function CHOCOLATEY-Is-Available { + # execute + $___process = OS-Is-Command-Available "choco" + if ($___process -eq 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function CHOCOLATEY-Is-Valid-Nupkg { + param( + [string]$___target + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { + return 1 + } + + $___process = FS-Is-File + if ($___process -ne 0) { + return 1 + } + + if ($___target -like "*.asc") { + return 1 + } + + + # execute + $___process = FS-Is-Target-A-Chocolatey "${___target}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Target-A-Nupkg "${___target}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function CHOCOLATEY-Archive { + param ( + [string]$___destination, + [string]$___source + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___source}") -eq 0) -or + ($(STRINGS-Is-Empty "${___destination}") -eq 0)) { + return 1 + } + + $___process = ZIP-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___current_path = Get-Location + $null = Set-Location -Path "${___source}" + $___process = ZIP-Create "${___destination}" "*" + $null = Set-Location -Path "${___current_path}" + $null = Remove-Variable -Name ___current_path + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function CHOCOLATEY-Publish { + param ( + [string]$___target, + [string]$___destination + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___destination}") -eq 0)) { + return 1 + } + + + # execute + $null = FS-Make-Directory "${___destination}" + $___process = FS-Copy-File ` + "${___target}" ` + "${___destination}\$(Split-Path -Leaf -Path "${___target}")" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function CHOCOLATEY-Setup { + # validate input + $___process = OS-Is-Command-Available "choco" + if ($___process -eq 0) { + $null = choco upgrade chocolatey -y + return 0 + } + + + # execute + $___process = HTTP-Download ` + "GET" ` + "https://community.chocolatey.org/install.ps1" ` + "install.ps1" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File ".\install.ps1" + if ($___process -ne 0) { + return 1 + } + + $null = Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser + $___process = OS-Exec "powershell" ".\install.ps1" + if ($___process -ne 0) { + return 1 + } + $null = FS-Remove-Silently ".\install.ps1" + + + # return status + return OS-Is-Command-Available "choco" +} + + + + +function CHOCOLATEY-Test { + param( + [string]$___target + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + $___process = CHOCOLATEY-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___name = Split-Path -Leaf -Path "${___target}" + $___name = $___name -replace '\-chocolatey.*$', '' + + + ## test install + $___current_path = Get-Location + $null = Set-Location "$(Split-Path -Parent -Path "${___target}")" + $___arguments = "install ${___name} " ` + + "--debug " ` + + "--verbose " ` + + "--force " ` + + "--source `".`" " + $___process = OS-Exec "choco" "${___arguments}" + $null = Set-Location "${___current_path}" + $null = Remove-Variable "___current_path" + if ($___process -ne 0) { + return 1 + } + + + ## test uninstall + $___current_path = Get-Location + $null = Set-Location "$(Split-Path -Parent -Path "${___target}")" + $___arguments = "uninstall ${___name} " ` + + "--debug " ` + + "--verbose " ` + + "--force " ` + + "--source `".`" " + $___process = OS-Exec "choco" "${___arguments}" + $null = Set-Location "${___current_path}" + $null = Remove-Variable "___current_path" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/publishers/chocolatey.sh b/automataCI/services/publishers/chocolatey.sh new file mode 100644 index 0000000..3b6bcc9 --- /dev/null +++ b/automataCI/services/publishers/chocolatey.sh @@ -0,0 +1,183 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/io/net/http.sh" +. "${LIBS_AUTOMATACI}/services/archive/zip.sh" + + + + +CHOCOLATEY_Is_Available() { + # execute + OS_Is_Command_Available "choco" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +CHOCOLATEY_Is_Valid_Nupkg() { + #___target="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + if [ ! "${1%.asc*}" = "$1" ]; then + return 1 + fi + + + # execute + if [ $(FS_Is_Target_A_Chocolatey "$1") -ne 0 ]; then + return 1 + fi + + if [ $(FS_Is_Target_A_Nupkg "$1") -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +CHOCOLATEY_Archive() { + #___destination="$1" + #___source="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + ZIP_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___current_path="$PWD" && cd "$2" + ZIP_Create "$1" "*" + ___process=$? + cd "$___current_path" && unset ___current_path + if [ $___process -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +CHOCOLATEY_Publish() { + #___target="$1" + #___destination="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + + # execute + FS_Make_Housing_Directory "$2" + FS_Copy_File "$1" "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +CHOCOLATEY_Setup() { + return 1 # not supported +} + + + + +CHOCOLATEY_Test() { + #___target="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + CHOCOLATEY_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___name="${1##*/}" + ___name="${___name%%-chocolatey*}" + + + # test install + ___current_path="$PWD" + cd "${1%/*}" + choco install "${1##*/}" --debug --verbose --force --source . + ___process=$? + cd "$___current_path" && unset ___current_path + if [ $___process -ne 0 ]; then + return 1 + fi + + + # test uninstall + ___current_path="$PWD" + cd "${1%/*}" + choco uninstall "${1##*/}" --debug --verbose --force --source . + ___process=$? + cd "$___current_path" && unset ___current_path + if [ $___process -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/publishers/createrepo.ps1 b/automataCI/services/publishers/createrepo.ps1 new file mode 100644 index 0000000..95ca6d4 --- /dev/null +++ b/automataCI/services/publishers/createrepo.ps1 @@ -0,0 +1,88 @@ +# 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\io\strings.ps1" + + + + +function CREATEREPO-Is-Available { + # execute + $___process = OS-Is-Command-Available "createrepo" + if ($___process -eq 0) { + return 0 + } + + $___process = OS-Is-Command-Available "createrepo_c" + if ($___process -eq 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function CREATEREPO-Publish { + param ( + [string]$___target, + [string]$___directory + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___directory}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___target}" + if ($___process -eq 0) { + 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}" + if ($___process -eq 0) { + return 0 + } + } + + $___process = OS-Is-Command-Available "createrepo_c" + if ($___process -eq 0) { + $___process = OS-Exec "createrepo_c" "--update ${___directory}" + if ($___process -eq 0) { + return 0 + } + } + + + # report status + return 1 +} diff --git a/automataCI/services/publishers/createrepo.sh b/automataCI/services/publishers/createrepo.sh new file mode 100644 index 0000000..bd8e389 --- /dev/null +++ b/automataCI/services/publishers/createrepo.sh @@ -0,0 +1,87 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +CREATEREPO_Is_Available() { + # execute + OS_Is_Command_Available "createrepo" + if [ $? -eq 0 ]; then + return 0 + fi + + OS_Is_Command_Available "createrepo_c" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +CREATEREPO_Publish() { + ___target="$1" + ___directory="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$___target") -eq 0 ] || + [ $(STRINGS_Is_Empty "$__directory") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___target" + if [ $? -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___directory" + 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 + fi + fi + + OS_Is_Command_Available "createrepo_c" + if [ $? -eq 0 ]; then + createrepo_c --update "$__directory" + if [ $? -eq 0 ]; then + return 0 + fi + fi + + + # report status + return 1 +} diff --git a/automataCI/services/publishers/dotnet-install.ps1 b/automataCI/services/publishers/dotnet-install.ps1 new file mode 100644 index 0000000..e58412b --- /dev/null +++ b/automataCI/services/publishers/dotnet-install.ps1 @@ -0,0 +1,1569 @@ +# +# Copyright (c) .NET Foundation and contributors. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. +# + +<# +.SYNOPSIS + Installs dotnet cli +.DESCRIPTION + Installs dotnet cli. If dotnet installation already exists in the given directory + it will update it only if the requested version differs from the one already installed. + + Note that the intended use of this script is for Continuous Integration (CI) scenarios, where: + - The SDK needs to be installed without user interaction and without admin rights. + - The SDK installation doesn't need to persist across multiple CI runs. + To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer. + +.PARAMETER Channel + Default: LTS + Download from the Channel specified. Possible values: + - STS - the most recent Standard Term Support release + - LTS - the most recent Long Term Support release + - 2-part version in a format A.B - represents a specific release + examples: 2.0, 1.0 + - 3-part version in a format A.B.Cxx - represents a specific SDK release + examples: 5.0.1xx, 5.0.2xx + Supported since 5.0 release + Warning: Value "Current" is deprecated for the Channel parameter. Use "STS" instead. + Note: The version parameter overrides the channel parameter when any version other than 'latest' is used. +.PARAMETER Quality + Download the latest build of specified quality in the channel. The possible values are: daily, signed, validated, preview, GA. + Works only in combination with channel. Not applicable for STS and LTS channels and will be ignored if those channels are used. + For SDK use channel in A.B.Cxx format: using quality together with channel in A.B format is not supported. + Supported since 5.0 release. + Note: The version parameter overrides the channel parameter when any version other than 'latest' is used, and therefore overrides the quality. +.PARAMETER Version + Default: latest + Represents a build version on specific channel. Possible values: + - latest - the latest build on specific channel + - 3-part version in a format A.B.C - represents specific version of build + examples: 2.0.0-preview2-006120, 1.1.0 +.PARAMETER Internal + Download internal builds. Requires providing credentials via -FeedCredential parameter. +.PARAMETER FeedCredential + Token to access Azure feed. Used as a query string to append to the Azure feed. + This parameter typically is not specified. +.PARAMETER InstallDir + Default: %LocalAppData%\Microsoft\dotnet + Path to where to install dotnet. Note that binaries will be placed directly in a given directory. +.PARAMETER Architecture + Default: - this value represents currently running OS architecture + Architecture of dotnet binaries to be installed. + Possible values are: , amd64, x64, x86, arm64, arm +.PARAMETER SharedRuntime + This parameter is obsolete and may be removed in a future version of this script. + The recommended alternative is '-Runtime dotnet'. + Installs just the shared runtime bits, not the entire SDK. +.PARAMETER Runtime + Installs just a shared runtime, not the entire SDK. + Possible values: + - dotnet - the Microsoft.NETCore.App shared runtime + - aspnetcore - the Microsoft.AspNetCore.App shared runtime + - windowsdesktop - the Microsoft.WindowsDesktop.App shared runtime +.PARAMETER DryRun + If set it will not perform installation but instead display what command line to use to consistently install + currently requested version of dotnet cli. In example if you specify version 'latest' it will display a link + with specific version so that this command can be used deterministicly in a build script. + It also displays binaries location if you prefer to install or download it yourself. +.PARAMETER NoPath + By default this script will set environment variable PATH for the current process to the binaries folder inside installation folder. + If set it will display binaries location but not set any environment variable. +.PARAMETER Verbose + Displays diagnostics information. +.PARAMETER AzureFeed + Default: https://dotnetcli.azureedge.net/dotnet + For internal use only. + Allows using a different storage to download SDK archives from. + This parameter is only used if $NoCdn is false. +.PARAMETER UncachedFeed + For internal use only. + Allows using a different storage to download SDK archives from. + This parameter is only used if $NoCdn is true. +.PARAMETER ProxyAddress + If set, the installer will use the proxy when making web requests +.PARAMETER ProxyUseDefaultCredentials + Default: false + Use default credentials, when using proxy address. +.PARAMETER ProxyBypassList + If set with ProxyAddress, will provide the list of comma separated urls that will bypass the proxy +.PARAMETER SkipNonVersionedFiles + Default: false + Skips installing non-versioned files if they already exist, such as dotnet.exe. +.PARAMETER NoCdn + Disable downloading from the Azure CDN, and use the uncached feed directly. +.PARAMETER JSonFile + Determines the SDK version from a user specified global.json file + Note: global.json must have a value for 'SDK:Version' +.PARAMETER DownloadTimeout + Determines timeout duration in seconds for dowloading of the SDK file + Default: 1200 seconds (20 minutes) +.PARAMETER KeepZip + If set, downloaded file is kept +.PARAMETER ZipPath + Use that path to store installer, generated by default +#> +[cmdletbinding()] +param( + [string]$Channel="LTS", + [string]$Quality, + [string]$Version="Latest", + [switch]$Internal, + [string]$JSonFile, + [Alias('i')][string]$InstallDir="", + [string]$Architecture="", + [string]$Runtime, + [Obsolete("This parameter may be removed in a future version of this script. The recommended alternative is '-Runtime dotnet'.")] + [switch]$SharedRuntime, + [switch]$DryRun, + [switch]$NoPath, + [string]$AzureFeed, + [string]$UncachedFeed, + [string]$FeedCredential, + [string]$ProxyAddress, + [switch]$ProxyUseDefaultCredentials, + [string[]]$ProxyBypassList=@(), + [switch]$SkipNonVersionedFiles, + [switch]$NoCdn, + [int]$DownloadTimeout=1200, + [switch]$KeepZip, + [string]$ZipPath=[System.IO.Path]::combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName()) +) + +Set-StrictMode -Version Latest +$ErrorActionPreference="Stop" +$ProgressPreference="SilentlyContinue" + +function Say($str) { + try { + Write-Host "dotnet-install: $str" + } + catch { + # Some platforms cannot utilize Write-Host (Azure Functions, for instance). Fall back to Write-Output + Write-Output "dotnet-install: $str" + } +} + +function Say-Warning($str) { + try { + Write-Warning "dotnet-install: $str" + } + catch { + # Some platforms cannot utilize Write-Warning (Azure Functions, for instance). Fall back to Write-Output + Write-Output "dotnet-install: Warning: $str" + } +} + +# Writes a line with error style settings. +# Use this function to show a human-readable comment along with an exception. +function Say-Error($str) { + try { + # Write-Error is quite oververbose for the purpose of the function, let's write one line with error style settings. + $Host.UI.WriteErrorLine("dotnet-install: $str") + } + catch { + Write-Output "dotnet-install: Error: $str" + } +} + +function Say-Verbose($str) { + try { + Write-Verbose "dotnet-install: $str" + } + catch { + # Some platforms cannot utilize Write-Verbose (Azure Functions, for instance). Fall back to Write-Output + Write-Output "dotnet-install: $str" + } +} + +function Measure-Action($name, $block) { + $time = Measure-Command $block + $totalSeconds = $time.TotalSeconds + Say-Verbose "⏱ Action '$name' took $totalSeconds seconds" +} + +function Get-Remote-File-Size($zipUri) { + try { + $response = Invoke-WebRequest -Uri $zipUri -Method Head + $fileSize = $response.Headers["Content-Length"] + if ((![string]::IsNullOrEmpty($fileSize))) { + Say "Remote file $zipUri size is $fileSize bytes." + + return $fileSize + } + } + catch { + Say-Verbose "Content-Length header was not extracted for $zipUri." + } + + return $null +} + +function Say-Invocation($Invocation) { + $command = $Invocation.MyCommand; + $args = (($Invocation.BoundParameters.Keys | foreach { "-$_ `"$($Invocation.BoundParameters[$_])`"" }) -join " ") + Say-Verbose "$command $args" +} + +function Invoke-With-Retry([ScriptBlock]$ScriptBlock, [System.Threading.CancellationToken]$cancellationToken = [System.Threading.CancellationToken]::None, [int]$MaxAttempts = 3, [int]$SecondsBetweenAttempts = 1) { + $Attempts = 0 + $local:startTime = $(get-date) + + while ($true) { + try { + return & $ScriptBlock + } + catch { + $Attempts++ + if (($Attempts -lt $MaxAttempts) -and -not $cancellationToken.IsCancellationRequested) { + Start-Sleep $SecondsBetweenAttempts + } + else { + $local:elapsedTime = $(get-date) - $local:startTime + if (($local:elapsedTime.TotalSeconds - $DownloadTimeout) -gt 0 -and -not $cancellationToken.IsCancellationRequested) { + throw New-Object System.TimeoutException("Failed to reach the server: connection timeout: default timeout is $DownloadTimeout second(s)"); + } + throw; + } + } + } +} + +function Get-Machine-Architecture() { + Say-Invocation $MyInvocation + + # On PS x86, PROCESSOR_ARCHITECTURE reports x86 even on x64 systems. + # To get the correct architecture, we need to use PROCESSOR_ARCHITEW6432. + # PS x64 doesn't define this, so we fall back to PROCESSOR_ARCHITECTURE. + # Possible values: amd64, x64, x86, arm64, arm + if( $ENV:PROCESSOR_ARCHITEW6432 -ne $null ) { + return $ENV:PROCESSOR_ARCHITEW6432 + } + + try { + if( ((Get-CimInstance -ClassName CIM_OperatingSystem).OSArchitecture) -like "ARM*") { + if( [Environment]::Is64BitOperatingSystem ) + { + return "arm64" + } + return "arm" + } + } + catch { + # Machine doesn't support Get-CimInstance + } + + return $ENV:PROCESSOR_ARCHITECTURE +} + +function Get-CLIArchitecture-From-Architecture([string]$Architecture) { + Say-Invocation $MyInvocation + + if ($Architecture -eq "") { + $Architecture = Get-Machine-Architecture + } + + switch ($Architecture.ToLowerInvariant()) { + { ($_ -eq "amd64") -or ($_ -eq "x64") } { return "x64" } + { $_ -eq "x86" } { return "x86" } + { $_ -eq "arm" } { return "arm" } + { $_ -eq "arm64" } { return "arm64" } + default { throw "Architecture '$Architecture' not supported. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues" } + } +} + +function ValidateFeedCredential([string] $FeedCredential) +{ + if ($Internal -and [string]::IsNullOrWhitespace($FeedCredential)) { + $message = "Provide credentials via -FeedCredential parameter." + if ($DryRun) { + Say-Warning "$message" + } else { + throw "$message" + } + } + + #FeedCredential should start with "?", for it to be added to the end of the link. + #adding "?" at the beginning of the FeedCredential if needed. + if ((![string]::IsNullOrWhitespace($FeedCredential)) -and ($FeedCredential[0] -ne '?')) { + $FeedCredential = "?" + $FeedCredential + } + + return $FeedCredential +} +function Get-NormalizedQuality([string]$Quality) { + Say-Invocation $MyInvocation + + if ([string]::IsNullOrEmpty($Quality)) { + return "" + } + + switch ($Quality) { + { @("daily", "signed", "validated", "preview") -contains $_ } { return $Quality.ToLowerInvariant() } + #ga quality is available without specifying quality, so normalizing it to empty + { $_ -eq "ga" } { return "" } + default { throw "'$Quality' is not a supported value for -Quality option. Supported values are: daily, signed, validated, preview, ga. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues." } + } +} + +function Get-NormalizedChannel([string]$Channel) { + Say-Invocation $MyInvocation + + if ([string]::IsNullOrEmpty($Channel)) { + return "" + } + + if ($Channel.Contains("Current")) { + Say-Warning 'Value "Current" is deprecated for -Channel option. Use "STS" instead.' + } + + if ($Channel.StartsWith('release/')) { + Say-Warning 'Using branch name with -Channel option is no longer supported with newer releases. Use -Quality option with a channel in X.Y format instead, such as "-Channel 5.0 -Quality Daily."' + } + + switch ($Channel) { + { $_ -eq "lts" } { return "LTS" } + { $_ -eq "sts" } { return "STS" } + { $_ -eq "current" } { return "STS" } + default { return $Channel.ToLowerInvariant() } + } +} + +function Get-NormalizedProduct([string]$Runtime) { + Say-Invocation $MyInvocation + + switch ($Runtime) { + { $_ -eq "dotnet" } { return "dotnet-runtime" } + { $_ -eq "aspnetcore" } { return "aspnetcore-runtime" } + { $_ -eq "windowsdesktop" } { return "windowsdesktop-runtime" } + { [string]::IsNullOrEmpty($_) } { return "dotnet-sdk" } + default { throw "'$Runtime' is not a supported value for -Runtime option, supported values are: dotnet, aspnetcore, windowsdesktop. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues." } + } +} + + +# The version text returned from the feeds is a 1-line or 2-line string: +# For the SDK and the dotnet runtime (2 lines): +# Line 1: # commit_hash +# Line 2: # 4-part version +# For the aspnetcore runtime (1 line): +# Line 1: # 4-part version +function Get-Version-From-LatestVersion-File-Content([string]$VersionText) { + Say-Invocation $MyInvocation + + $Data = -split $VersionText + + $VersionInfo = @{ + CommitHash = $(if ($Data.Count -gt 1) { $Data[0] }) + Version = $Data[-1] # last line is always the version number. + } + return $VersionInfo +} + +function Load-Assembly([string] $Assembly) { + try { + Add-Type -Assembly $Assembly | Out-Null + } + catch { + # On Nano Server, Powershell Core Edition is used. Add-Type is unable to resolve base class assemblies because they are not GAC'd. + # Loading the base class assemblies is not unnecessary as the types will automatically get resolved. + } +} + +function GetHTTPResponse([Uri] $Uri, [bool]$HeaderOnly, [bool]$DisableRedirect, [bool]$DisableFeedCredential) +{ + $cts = New-Object System.Threading.CancellationTokenSource + + $downloadScript = { + + $HttpClient = $null + + try { + # HttpClient is used vs Invoke-WebRequest in order to support Nano Server which doesn't support the Invoke-WebRequest cmdlet. + Load-Assembly -Assembly System.Net.Http + + if(-not $ProxyAddress) { + try { + # Despite no proxy being explicitly specified, we may still be behind a default proxy + $DefaultProxy = [System.Net.WebRequest]::DefaultWebProxy; + if($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))) { + if ($null -ne $DefaultProxy.GetProxy($Uri)) { + $ProxyAddress = $DefaultProxy.GetProxy($Uri).OriginalString + } else { + $ProxyAddress = $null + } + $ProxyUseDefaultCredentials = $true + } + } catch { + # Eat the exception and move forward as the above code is an attempt + # at resolving the DefaultProxy that may not have been a problem. + $ProxyAddress = $null + Say-Verbose("Exception ignored: $_.Exception.Message - moving forward...") + } + } + + $HttpClientHandler = New-Object System.Net.Http.HttpClientHandler + if($ProxyAddress) { + $HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{ + Address=$ProxyAddress; + UseDefaultCredentials=$ProxyUseDefaultCredentials; + BypassList = $ProxyBypassList; + } + } + if ($DisableRedirect) + { + $HttpClientHandler.AllowAutoRedirect = $false + } + $HttpClient = New-Object System.Net.Http.HttpClient -ArgumentList $HttpClientHandler + + # Default timeout for HttpClient is 100s. For a 50 MB download this assumes 500 KB/s average, any less will time out + # Defaulting to 20 minutes allows it to work over much slower connections. + $HttpClient.Timeout = New-TimeSpan -Seconds $DownloadTimeout + + if ($HeaderOnly){ + $completionOption = [System.Net.Http.HttpCompletionOption]::ResponseHeadersRead + } + else { + $completionOption = [System.Net.Http.HttpCompletionOption]::ResponseContentRead + } + + if ($DisableFeedCredential) { + $UriWithCredential = $Uri + } + else { + $UriWithCredential = "${Uri}${FeedCredential}" + } + + $Task = $HttpClient.GetAsync("$UriWithCredential", $completionOption).ConfigureAwait("false"); + $Response = $Task.GetAwaiter().GetResult(); + + if (($null -eq $Response) -or ((-not $HeaderOnly) -and (-not ($Response.IsSuccessStatusCode)))) { + # The feed credential is potentially sensitive info. Do not log FeedCredential to console output. + $DownloadException = [System.Exception] "Unable to download $Uri." + + if ($null -ne $Response) { + $DownloadException.Data["StatusCode"] = [int] $Response.StatusCode + $DownloadException.Data["ErrorMessage"] = "Unable to download $Uri. Returned HTTP status code: " + $DownloadException.Data["StatusCode"] + + if (404 -eq [int] $Response.StatusCode) + { + $cts.Cancel() + } + } + + throw $DownloadException + } + + return $Response + } + catch [System.Net.Http.HttpRequestException] { + $DownloadException = [System.Exception] "Unable to download $Uri." + + # Pick up the exception message and inner exceptions' messages if they exist + $CurrentException = $PSItem.Exception + $ErrorMsg = $CurrentException.Message + "`r`n" + while ($CurrentException.InnerException) { + $CurrentException = $CurrentException.InnerException + $ErrorMsg += $CurrentException.Message + "`r`n" + } + + # Check if there is an issue concerning TLS. + if ($ErrorMsg -like "*SSL/TLS*") { + $ErrorMsg += "Ensure that TLS 1.2 or higher is enabled to use this script.`r`n" + } + + $DownloadException.Data["ErrorMessage"] = $ErrorMsg + throw $DownloadException + } + finally { + if ($null -ne $HttpClient) { + $HttpClient.Dispose() + } + } + } + + try { + return Invoke-With-Retry $downloadScript $cts.Token + } + finally + { + if ($null -ne $cts) + { + $cts.Dispose() + } + } +} + +function Get-Version-From-LatestVersion-File([string]$AzureFeed, [string]$Channel) { + Say-Invocation $MyInvocation + + $VersionFileUrl = $null + if ($Runtime -eq "dotnet") { + $VersionFileUrl = "$AzureFeed/Runtime/$Channel/latest.version" + } + elseif ($Runtime -eq "aspnetcore") { + $VersionFileUrl = "$AzureFeed/aspnetcore/Runtime/$Channel/latest.version" + } + elseif ($Runtime -eq "windowsdesktop") { + $VersionFileUrl = "$AzureFeed/WindowsDesktop/$Channel/latest.version" + } + elseif (-not $Runtime) { + $VersionFileUrl = "$AzureFeed/Sdk/$Channel/latest.version" + } + else { + throw "Invalid value for `$Runtime" + } + + Say-Verbose "Constructed latest.version URL: $VersionFileUrl" + + try { + $Response = GetHTTPResponse -Uri $VersionFileUrl + } + catch { + Say-Verbose "Failed to download latest.version file." + throw + } + $StringContent = $Response.Content.ReadAsStringAsync().Result + + switch ($Response.Content.Headers.ContentType) { + { ($_ -eq "application/octet-stream") } { $VersionText = $StringContent } + { ($_ -eq "text/plain") } { $VersionText = $StringContent } + { ($_ -eq "text/plain; charset=UTF-8") } { $VersionText = $StringContent } + default { throw "``$Response.Content.Headers.ContentType`` is an unknown .version file content type." } + } + + $VersionInfo = Get-Version-From-LatestVersion-File-Content $VersionText + + return $VersionInfo +} + +function Parse-Jsonfile-For-Version([string]$JSonFile) { + Say-Invocation $MyInvocation + + If (-Not (Test-Path $JSonFile)) { + throw "Unable to find '$JSonFile'" + } + try { + $JSonContent = Get-Content($JSonFile) -Raw | ConvertFrom-Json | Select-Object -expand "sdk" -ErrorAction SilentlyContinue + } + catch { + Say-Error "Json file unreadable: '$JSonFile'" + throw + } + if ($JSonContent) { + try { + $JSonContent.PSObject.Properties | ForEach-Object { + $PropertyName = $_.Name + if ($PropertyName -eq "version") { + $Version = $_.Value + Say-Verbose "Version = $Version" + } + } + } + catch { + Say-Error "Unable to parse the SDK node in '$JSonFile'" + throw + } + } + else { + throw "Unable to find the SDK node in '$JSonFile'" + } + If ($Version -eq $null) { + throw "Unable to find the SDK:version node in '$JSonFile'" + } + return $Version +} + +function Get-Specific-Version-From-Version([string]$AzureFeed, [string]$Channel, [string]$Version, [string]$JSonFile) { + Say-Invocation $MyInvocation + + if (-not $JSonFile) { + if ($Version.ToLowerInvariant() -eq "latest") { + $LatestVersionInfo = Get-Version-From-LatestVersion-File -AzureFeed $AzureFeed -Channel $Channel + return $LatestVersionInfo.Version + } + else { + return $Version + } + } + else { + return Parse-Jsonfile-For-Version $JSonFile + } +} + +function Get-Download-Link([string]$AzureFeed, [string]$SpecificVersion, [string]$CLIArchitecture) { + Say-Invocation $MyInvocation + + # If anything fails in this lookup it will default to $SpecificVersion + $SpecificProductVersion = Get-Product-Version -AzureFeed $AzureFeed -SpecificVersion $SpecificVersion + + if ($Runtime -eq "dotnet") { + $PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-runtime-$SpecificProductVersion-win-$CLIArchitecture.zip" + } + elseif ($Runtime -eq "aspnetcore") { + $PayloadURL = "$AzureFeed/aspnetcore/Runtime/$SpecificVersion/aspnetcore-runtime-$SpecificProductVersion-win-$CLIArchitecture.zip" + } + elseif ($Runtime -eq "windowsdesktop") { + # The windows desktop runtime is part of the core runtime layout prior to 5.0 + $PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/windowsdesktop-runtime-$SpecificProductVersion-win-$CLIArchitecture.zip" + if ($SpecificVersion -match '^(\d+)\.(.*)$') + { + $majorVersion = [int]$Matches[1] + if ($majorVersion -ge 5) + { + $PayloadURL = "$AzureFeed/WindowsDesktop/$SpecificVersion/windowsdesktop-runtime-$SpecificProductVersion-win-$CLIArchitecture.zip" + } + } + } + elseif (-not $Runtime) { + $PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-sdk-$SpecificProductVersion-win-$CLIArchitecture.zip" + } + else { + throw "Invalid value for `$Runtime" + } + + Say-Verbose "Constructed primary named payload URL: $PayloadURL" + + return $PayloadURL, $SpecificProductVersion +} + +function Get-LegacyDownload-Link([string]$AzureFeed, [string]$SpecificVersion, [string]$CLIArchitecture) { + Say-Invocation $MyInvocation + + if (-not $Runtime) { + $PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-dev-win-$CLIArchitecture.$SpecificVersion.zip" + } + elseif ($Runtime -eq "dotnet") { + $PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-win-$CLIArchitecture.$SpecificVersion.zip" + } + else { + return $null + } + + Say-Verbose "Constructed legacy named payload URL: $PayloadURL" + + return $PayloadURL +} + +function Get-Product-Version([string]$AzureFeed, [string]$SpecificVersion, [string]$PackageDownloadLink) { + Say-Invocation $MyInvocation + + # Try to get the version number, using the productVersion.txt file located next to the installer file. + $ProductVersionTxtURLs = (Get-Product-Version-Url $AzureFeed $SpecificVersion $PackageDownloadLink -Flattened $true), + (Get-Product-Version-Url $AzureFeed $SpecificVersion $PackageDownloadLink -Flattened $false) + + Foreach ($ProductVersionTxtURL in $ProductVersionTxtURLs) { + Say-Verbose "Checking for the existence of $ProductVersionTxtURL" + + try { + $productVersionResponse = GetHTTPResponse($productVersionTxtUrl) + + if ($productVersionResponse.StatusCode -eq 200) { + $productVersion = $productVersionResponse.Content.ReadAsStringAsync().Result.Trim() + if ($productVersion -ne $SpecificVersion) + { + Say "Using alternate version $productVersion found in $ProductVersionTxtURL" + } + return $productVersion + } + else { + Say-Verbose "Got StatusCode $($productVersionResponse.StatusCode) when trying to get productVersion.txt at $productVersionTxtUrl." + } + } + catch { + Say-Verbose "Could not read productVersion.txt at $productVersionTxtUrl (Exception: '$($_.Exception.Message)'. )" + } + } + + # Getting the version number with productVersion.txt has failed. Try parsing the download link for a version number. + if ([string]::IsNullOrEmpty($PackageDownloadLink)) + { + Say-Verbose "Using the default value '$SpecificVersion' as the product version." + return $SpecificVersion + } + + $productVersion = Get-ProductVersionFromDownloadLink $PackageDownloadLink $SpecificVersion + return $productVersion +} + +function Get-Product-Version-Url([string]$AzureFeed, [string]$SpecificVersion, [string]$PackageDownloadLink, [bool]$Flattened) { + Say-Invocation $MyInvocation + + $majorVersion=$null + if ($SpecificVersion -match '^(\d+)\.(.*)') { + $majorVersion = $Matches[1] -as[int] + } + + $pvFileName='productVersion.txt' + if($Flattened) { + if(-not $Runtime) { + $pvFileName='sdk-productVersion.txt' + } + elseif($Runtime -eq "dotnet") { + $pvFileName='runtime-productVersion.txt' + } + else { + $pvFileName="$Runtime-productVersion.txt" + } + } + + if ([string]::IsNullOrEmpty($PackageDownloadLink)) { + if ($Runtime -eq "dotnet") { + $ProductVersionTxtURL = "$AzureFeed/Runtime/$SpecificVersion/$pvFileName" + } + elseif ($Runtime -eq "aspnetcore") { + $ProductVersionTxtURL = "$AzureFeed/aspnetcore/Runtime/$SpecificVersion/$pvFileName" + } + elseif ($Runtime -eq "windowsdesktop") { + # The windows desktop runtime is part of the core runtime layout prior to 5.0 + $ProductVersionTxtURL = "$AzureFeed/Runtime/$SpecificVersion/$pvFileName" + if ($majorVersion -ne $null -and $majorVersion -ge 5) { + $ProductVersionTxtURL = "$AzureFeed/WindowsDesktop/$SpecificVersion/$pvFileName" + } + } + elseif (-not $Runtime) { + $ProductVersionTxtURL = "$AzureFeed/Sdk/$SpecificVersion/$pvFileName" + } + else { + throw "Invalid value '$Runtime' specified for `$Runtime" + } + } + else { + $ProductVersionTxtURL = $PackageDownloadLink.Substring(0, $PackageDownloadLink.LastIndexOf("/")) + "/$pvFileName" + } + + Say-Verbose "Constructed productVersion link: $ProductVersionTxtURL" + + return $ProductVersionTxtURL +} + +function Get-ProductVersionFromDownloadLink([string]$PackageDownloadLink, [string]$SpecificVersion) +{ + Say-Invocation $MyInvocation + + #product specific version follows the product name + #for filename 'dotnet-sdk-3.1.404-win-x64.zip': the product version is 3.1.400 + $filename = $PackageDownloadLink.Substring($PackageDownloadLink.LastIndexOf("/") + 1) + $filenameParts = $filename.Split('-') + if ($filenameParts.Length -gt 2) + { + $productVersion = $filenameParts[2] + Say-Verbose "Extracted product version '$productVersion' from download link '$PackageDownloadLink'." + } + else { + Say-Verbose "Using the default value '$SpecificVersion' as the product version." + $productVersion = $SpecificVersion + } + return $productVersion +} + +function Get-User-Share-Path() { + Say-Invocation $MyInvocation + + $InstallRoot = $env:DOTNET_INSTALL_DIR + if (!$InstallRoot) { + $InstallRoot = "$env:LocalAppData\Microsoft\dotnet" + } + return $InstallRoot +} + +function Resolve-Installation-Path([string]$InstallDir) { + Say-Invocation $MyInvocation + + if ($InstallDir -eq "") { + return Get-User-Share-Path + } + return $InstallDir +} + +function Is-Dotnet-Package-Installed([string]$InstallRoot, [string]$RelativePathToPackage, [string]$SpecificVersion) { + Say-Invocation $MyInvocation + + $DotnetPackagePath = Join-Path -Path $InstallRoot -ChildPath $RelativePathToPackage | Join-Path -ChildPath $SpecificVersion + Say-Verbose "Is-Dotnet-Package-Installed: DotnetPackagePath=$DotnetPackagePath" + return Test-Path $DotnetPackagePath -PathType Container +} + +function Get-Absolute-Path([string]$RelativeOrAbsolutePath) { + # Too much spam + # Say-Invocation $MyInvocation + + return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($RelativeOrAbsolutePath) +} + +function Get-Path-Prefix-With-Version($path) { + # example path with regex: shared/1.0.0-beta-12345/somepath + $match = [regex]::match($path, "/\d+\.\d+[^/]+/") + if ($match.Success) { + return $entry.FullName.Substring(0, $match.Index + $match.Length) + } + + return $null +} + +function Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package([System.IO.Compression.ZipArchive]$Zip, [string]$OutPath) { + Say-Invocation $MyInvocation + + $ret = @() + foreach ($entry in $Zip.Entries) { + $dir = Get-Path-Prefix-With-Version $entry.FullName + if ($null -ne $dir) { + $path = Get-Absolute-Path $(Join-Path -Path $OutPath -ChildPath $dir) + if (-Not (Test-Path $path -PathType Container)) { + $ret += $dir + } + } + } + + $ret = $ret | Sort-Object | Get-Unique + + $values = ($ret | foreach { "$_" }) -join ";" + Say-Verbose "Directories to unpack: $values" + + return $ret +} + +# Example zip content and extraction algorithm: +# Rule: files if extracted are always being extracted to the same relative path locally +# .\ +# a.exe # file does not exist locally, extract +# b.dll # file exists locally, override only if $OverrideFiles set +# aaa\ # same rules as for files +# ... +# abc\1.0.0\ # directory contains version and exists locally +# ... # do not extract content under versioned part +# abc\asd\ # same rules as for files +# ... +# def\ghi\1.0.1\ # directory contains version and does not exist locally +# ... # extract content +function Extract-Dotnet-Package([string]$ZipPath, [string]$OutPath) { + Say-Invocation $MyInvocation + + Load-Assembly -Assembly System.IO.Compression.FileSystem + Set-Variable -Name Zip + try { + $Zip = [System.IO.Compression.ZipFile]::OpenRead($ZipPath) + + $DirectoriesToUnpack = Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package -Zip $Zip -OutPath $OutPath + + foreach ($entry in $Zip.Entries) { + $PathWithVersion = Get-Path-Prefix-With-Version $entry.FullName + if (($null -eq $PathWithVersion) -Or ($DirectoriesToUnpack -contains $PathWithVersion)) { + $DestinationPath = Get-Absolute-Path $(Join-Path -Path $OutPath -ChildPath $entry.FullName) + $DestinationDir = Split-Path -Parent $DestinationPath + $OverrideFiles=$OverrideNonVersionedFiles -Or (-Not (Test-Path $DestinationPath)) + if ((-Not $DestinationPath.EndsWith("\")) -And $OverrideFiles) { + New-Item -ItemType Directory -Force -Path $DestinationDir | Out-Null + [System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $DestinationPath, $OverrideNonVersionedFiles) + } + } + } + } + catch + { + Say-Error "Failed to extract package. Exception: $_" + throw; + } + finally { + if ($null -ne $Zip) { + $Zip.Dispose() + } + } +} + +function DownloadFile($Source, [string]$OutPath) { + if ($Source -notlike "http*") { + # Using System.IO.Path.GetFullPath to get the current directory + # does not work in this context - $pwd gives the current directory + if (![System.IO.Path]::IsPathRooted($Source)) { + $Source = $(Join-Path -Path $pwd -ChildPath $Source) + } + $Source = Get-Absolute-Path $Source + Say "Copying file from $Source to $OutPath" + Copy-Item $Source $OutPath + return + } + + $Stream = $null + + try { + $Response = GetHTTPResponse -Uri $Source + $Stream = $Response.Content.ReadAsStreamAsync().Result + $File = [System.IO.File]::Create($OutPath) + $Stream.CopyTo($File) + $File.Close() + + ValidateRemoteLocalFileSizes -LocalFileOutPath $OutPath -SourceUri $Source + } + finally { + if ($null -ne $Stream) { + $Stream.Dispose() + } + } +} + +function ValidateRemoteLocalFileSizes([string]$LocalFileOutPath, $SourceUri) { + try { + $remoteFileSize = Get-Remote-File-Size -zipUri $SourceUri + $fileSize = [long](Get-Item $LocalFileOutPath).Length + Say "Downloaded file $SourceUri size is $fileSize bytes." + + if ((![string]::IsNullOrEmpty($remoteFileSize)) -and !([string]::IsNullOrEmpty($fileSize)) ) { + if ($remoteFileSize -ne $fileSize) { + Say "The remote and local file sizes are not equal. Remote file size is $remoteFileSize bytes and local size is $fileSize bytes. The local package may be corrupted." + } + else { + Say "The remote and local file sizes are equal." + } + } + else { + Say "Either downloaded or local package size can not be measured. One of them may be corrupted." + } + } + catch { + Say "Either downloaded or local package size can not be measured. One of them may be corrupted." + } +} + +function SafeRemoveFile($Path) { + try { + if (Test-Path $Path) { + Remove-Item $Path + Say-Verbose "The temporary file `"$Path`" was removed." + } + else { + Say-Verbose "The temporary file `"$Path`" does not exist, therefore is not removed." + } + } + catch { + Say-Warning "Failed to remove the temporary file: `"$Path`", remove it manually." + } +} + +function Prepend-Sdk-InstallRoot-To-Path([string]$InstallRoot) { + $BinPath = Get-Absolute-Path $(Join-Path -Path $InstallRoot -ChildPath "") + if (-Not $NoPath) { + $SuffixedBinPath = "$BinPath;" + if (-Not $env:path.Contains($SuffixedBinPath)) { + Say "Adding to current process PATH: `"$BinPath`". Note: This change will not be visible if PowerShell was run as a child process." + $env:path = $SuffixedBinPath + $env:path + } else { + Say-Verbose "Current process PATH already contains `"$BinPath`"" + } + } + else { + Say "Binaries of dotnet can be found in $BinPath" + } +} + +function PrintDryRunOutput($Invocation, $DownloadLinks) +{ + Say "Payload URLs:" + + for ($linkIndex=0; $linkIndex -lt $DownloadLinks.count; $linkIndex++) { + Say "URL #$linkIndex - $($DownloadLinks[$linkIndex].type): $($DownloadLinks[$linkIndex].downloadLink)" + } + $RepeatableCommand = ".\$ScriptName -Version `"$SpecificVersion`" -InstallDir `"$InstallRoot`" -Architecture `"$CLIArchitecture`"" + if ($Runtime -eq "dotnet") { + $RepeatableCommand+=" -Runtime `"dotnet`"" + } + elseif ($Runtime -eq "aspnetcore") { + $RepeatableCommand+=" -Runtime `"aspnetcore`"" + } + + foreach ($key in $Invocation.BoundParameters.Keys) { + if (-not (@("Architecture","Channel","DryRun","InstallDir","Runtime","SharedRuntime","Version","Quality","FeedCredential") -contains $key)) { + $RepeatableCommand+=" -$key `"$($Invocation.BoundParameters[$key])`"" + } + } + if ($Invocation.BoundParameters.Keys -contains "FeedCredential") { + $RepeatableCommand+=" -FeedCredential `"`"" + } + Say "Repeatable invocation: $RepeatableCommand" + if ($SpecificVersion -ne $EffectiveVersion) + { + Say "NOTE: Due to finding a version manifest with this runtime, it would actually install with version '$EffectiveVersion'" + } +} + +function Get-AkaMSDownloadLink([string]$Channel, [string]$Quality, [bool]$Internal, [string]$Product, [string]$Architecture) { + Say-Invocation $MyInvocation + + #quality is not supported for LTS or STS channel + if (![string]::IsNullOrEmpty($Quality) -and (@("LTS", "STS") -contains $Channel)) { + $Quality = "" + Say-Warning "Specifying quality for STS or LTS channel is not supported, the quality will be ignored." + } + Say-Verbose "Retrieving primary payload URL from aka.ms link for channel: '$Channel', quality: '$Quality' product: '$Product', os: 'win', architecture: '$Architecture'." + + #construct aka.ms link + $akaMsLink = "https://aka.ms/dotnet" + if ($Internal) { + $akaMsLink += "/internal" + } + $akaMsLink += "/$Channel" + if (-not [string]::IsNullOrEmpty($Quality)) { + $akaMsLink +="/$Quality" + } + $akaMsLink +="/$Product-win-$Architecture.zip" + Say-Verbose "Constructed aka.ms link: '$akaMsLink'." + $akaMsDownloadLink=$null + + for ($maxRedirections = 9; $maxRedirections -ge 0; $maxRedirections--) + { + #get HTTP response + #do not pass credentials as a part of the $akaMsLink and do not apply credentials in the GetHTTPResponse function + #otherwise the redirect link would have credentials as well + #it would result in applying credentials twice to the resulting link and thus breaking it, and in echoing credentials to the output as a part of redirect link + $Response= GetHTTPResponse -Uri $akaMsLink -HeaderOnly $true -DisableRedirect $true -DisableFeedCredential $true + Say-Verbose "Received response:`n$Response" + + if ([string]::IsNullOrEmpty($Response)) { + Say-Verbose "The link '$akaMsLink' is not valid: failed to get redirect location. The resource is not available." + return $null + } + + #if HTTP code is 301 (Moved Permanently), the redirect link exists + if ($Response.StatusCode -eq 301) + { + try { + $akaMsDownloadLink = $Response.Headers.GetValues("Location")[0] + + if ([string]::IsNullOrEmpty($akaMsDownloadLink)) { + Say-Verbose "The link '$akaMsLink' is not valid: server returned 301 (Moved Permanently), but the headers do not contain the redirect location." + return $null + } + + Say-Verbose "The redirect location retrieved: '$akaMsDownloadLink'." + # This may yet be a link to another redirection. Attempt to retrieve the page again. + $akaMsLink = $akaMsDownloadLink + continue + } + catch { + Say-Verbose "The link '$akaMsLink' is not valid: failed to get redirect location." + return $null + } + } + elseif ((($Response.StatusCode -lt 300) -or ($Response.StatusCode -ge 400)) -and (-not [string]::IsNullOrEmpty($akaMsDownloadLink))) + { + # Redirections have ended. + return $akaMsDownloadLink + } + + Say-Verbose "The link '$akaMsLink' is not valid: failed to retrieve the redirection location." + return $null + } + + Say-Verbose "Aka.ms links have redirected more than the maximum allowed redirections. This may be caused by a cyclic redirection of aka.ms links." + return $null + +} + +function Get-AkaMsLink-And-Version([string] $NormalizedChannel, [string] $NormalizedQuality, [bool] $Internal, [string] $ProductName, [string] $Architecture) { + $AkaMsDownloadLink = Get-AkaMSDownloadLink -Channel $NormalizedChannel -Quality $NormalizedQuality -Internal $Internal -Product $ProductName -Architecture $Architecture + + if ([string]::IsNullOrEmpty($AkaMsDownloadLink)){ + if (-not [string]::IsNullOrEmpty($NormalizedQuality)) { + # if quality is specified - exit with error - there is no fallback approach + Say-Error "Failed to locate the latest version in the channel '$NormalizedChannel' with '$NormalizedQuality' quality for '$ProductName', os: 'win', architecture: '$Architecture'." + Say-Error "Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support." + throw "aka.ms link resolution failure" + } + Say-Verbose "Falling back to latest.version file approach." + return ($null, $null, $null) + } + else { + Say-Verbose "Retrieved primary named payload URL from aka.ms link: '$AkaMsDownloadLink'." + Say-Verbose "Downloading using legacy url will not be attempted." + + #get version from the path + $pathParts = $AkaMsDownloadLink.Split('/') + if ($pathParts.Length -ge 2) { + $SpecificVersion = $pathParts[$pathParts.Length - 2] + Say-Verbose "Version: '$SpecificVersion'." + } + else { + Say-Error "Failed to extract the version from download link '$AkaMsDownloadLink'." + return ($null, $null, $null) + } + + #retrieve effective (product) version + $EffectiveVersion = Get-Product-Version -SpecificVersion $SpecificVersion -PackageDownloadLink $AkaMsDownloadLink + Say-Verbose "Product version: '$EffectiveVersion'." + + return ($AkaMsDownloadLink, $SpecificVersion, $EffectiveVersion); + } +} + +function Get-Feeds-To-Use() +{ + $feeds = @( + "https://dotnetcli.azureedge.net/dotnet", + "https://dotnetbuilds.azureedge.net/public" + ) + + if (-not [string]::IsNullOrEmpty($AzureFeed)) { + $feeds = @($AzureFeed) + } + + if ($NoCdn) { + $feeds = @( + "https://dotnetcli.blob.core.windows.net/dotnet", + "https://dotnetbuilds.blob.core.windows.net/public" + ) + + if (-not [string]::IsNullOrEmpty($UncachedFeed)) { + $feeds = @($UncachedFeed) + } + } + + return $feeds +} + +function Resolve-AssetName-And-RelativePath([string] $Runtime) { + + if ($Runtime -eq "dotnet") { + $assetName = ".NET Core Runtime" + $dotnetPackageRelativePath = "shared\Microsoft.NETCore.App" + } + elseif ($Runtime -eq "aspnetcore") { + $assetName = "ASP.NET Core Runtime" + $dotnetPackageRelativePath = "shared\Microsoft.AspNetCore.App" + } + elseif ($Runtime -eq "windowsdesktop") { + $assetName = ".NET Core Windows Desktop Runtime" + $dotnetPackageRelativePath = "shared\Microsoft.WindowsDesktop.App" + } + elseif (-not $Runtime) { + $assetName = ".NET Core SDK" + $dotnetPackageRelativePath = "sdk" + } + else { + throw "Invalid value for `$Runtime" + } + + return ($assetName, $dotnetPackageRelativePath) +} + +function Prepare-Install-Directory { + $diskSpaceWarning = "Failed to check the disk space. Installation will continue, but it may fail if you do not have enough disk space."; + + if ($PSVersionTable.PSVersion.Major -lt 7) { + Say-Verbose $diskSpaceWarning + return + } + + New-Item -ItemType Directory -Force -Path $InstallRoot | Out-Null + + $installDrive = $((Get-Item $InstallRoot -Force).PSDrive.Name); + $diskInfo = $null + try { + $diskInfo = Get-PSDrive -Name $installDrive + } + catch { + Say-Warning $diskSpaceWarning + } + + # The check is relevant for PS version >= 7, the result can be irrelevant for older versions. See https://github.com/PowerShell/PowerShell/issues/12442. + if ( ($null -ne $diskInfo) -and ($diskInfo.Free / 1MB -le 100)) { + throw "There is not enough disk space on drive ${installDrive}:" + } +} + +Say-Verbose "Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:" +Say-Verbose "- The SDK needs to be installed without user interaction and without admin rights." +Say-Verbose "- The SDK installation doesn't need to persist across multiple CI runs." +Say-Verbose "To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer.`r`n" + +if ($SharedRuntime -and (-not $Runtime)) { + $Runtime = "dotnet" +} + +$OverrideNonVersionedFiles = !$SkipNonVersionedFiles + +Measure-Action "Product discovery" { + $script:CLIArchitecture = Get-CLIArchitecture-From-Architecture $Architecture + $script:NormalizedQuality = Get-NormalizedQuality $Quality + Say-Verbose "Normalized quality: '$NormalizedQuality'" + $script:NormalizedChannel = Get-NormalizedChannel $Channel + Say-Verbose "Normalized channel: '$NormalizedChannel'" + $script:NormalizedProduct = Get-NormalizedProduct $Runtime + Say-Verbose "Normalized product: '$NormalizedProduct'" + $script:FeedCredential = ValidateFeedCredential $FeedCredential +} + +$InstallRoot = Resolve-Installation-Path $InstallDir +Say-Verbose "InstallRoot: $InstallRoot" +$ScriptName = $MyInvocation.MyCommand.Name +($assetName, $dotnetPackageRelativePath) = Resolve-AssetName-And-RelativePath -Runtime $Runtime + +$feeds = Get-Feeds-To-Use +$DownloadLinks = @() + +if ($Version.ToLowerInvariant() -ne "latest" -and -not [string]::IsNullOrEmpty($Quality)) { + throw "Quality and Version options are not allowed to be specified simultaneously. See https:// learn.microsoft.com/dotnet/core/tools/dotnet-install-script#options for details." +} + +# aka.ms links can only be used if the user did not request a specific version via the command line or a global.json file. +if ([string]::IsNullOrEmpty($JSonFile) -and ($Version -eq "latest")) { + ($DownloadLink, $SpecificVersion, $EffectiveVersion) = Get-AkaMsLink-And-Version $NormalizedChannel $NormalizedQuality $Internal $NormalizedProduct $CLIArchitecture + + if ($null -ne $DownloadLink) { + $DownloadLinks += New-Object PSObject -Property @{downloadLink="$DownloadLink";specificVersion="$SpecificVersion";effectiveVersion="$EffectiveVersion";type='aka.ms'} + Say-Verbose "Generated aka.ms link $DownloadLink with version $EffectiveVersion" + + if (-Not $DryRun) { + Say-Verbose "Checking if the version $EffectiveVersion is already installed" + if (Is-Dotnet-Package-Installed -InstallRoot $InstallRoot -RelativePathToPackage $dotnetPackageRelativePath -SpecificVersion $EffectiveVersion) + { + Say "$assetName with version '$EffectiveVersion' is already installed." + Prepend-Sdk-InstallRoot-To-Path -InstallRoot $InstallRoot + return + } + } + } +} + +# Primary and legacy links cannot be used if a quality was specified. +# If we already have an aka.ms link, no need to search the blob feeds. +if ([string]::IsNullOrEmpty($NormalizedQuality) -and 0 -eq $DownloadLinks.count) +{ + foreach ($feed in $feeds) { + try { + $SpecificVersion = Get-Specific-Version-From-Version -AzureFeed $feed -Channel $Channel -Version $Version -JSonFile $JSonFile + $DownloadLink, $EffectiveVersion = Get-Download-Link -AzureFeed $feed -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture + $LegacyDownloadLink = Get-LegacyDownload-Link -AzureFeed $feed -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture + + $DownloadLinks += New-Object PSObject -Property @{downloadLink="$DownloadLink";specificVersion="$SpecificVersion";effectiveVersion="$EffectiveVersion";type='primary'} + Say-Verbose "Generated primary link $DownloadLink with version $EffectiveVersion" + + if (-not [string]::IsNullOrEmpty($LegacyDownloadLink)) { + $DownloadLinks += New-Object PSObject -Property @{downloadLink="$LegacyDownloadLink";specificVersion="$SpecificVersion";effectiveVersion="$EffectiveVersion";type='legacy'} + Say-Verbose "Generated legacy link $LegacyDownloadLink with version $EffectiveVersion" + } + + if (-Not $DryRun) { + Say-Verbose "Checking if the version $EffectiveVersion is already installed" + if (Is-Dotnet-Package-Installed -InstallRoot $InstallRoot -RelativePathToPackage $dotnetPackageRelativePath -SpecificVersion $EffectiveVersion) + { + Say "$assetName with version '$EffectiveVersion' is already installed." + Prepend-Sdk-InstallRoot-To-Path -InstallRoot $InstallRoot + return + } + } + } + catch + { + Say-Verbose "Failed to acquire download links from feed $feed. Exception: $_" + } + } +} + +if ($DownloadLinks.count -eq 0) { + throw "Failed to resolve the exact version number." +} + +if ($DryRun) { + PrintDryRunOutput $MyInvocation $DownloadLinks + return +} + +Measure-Action "Installation directory preparation" { Prepare-Install-Directory } + +Say-Verbose "Zip path: $ZipPath" + +$DownloadSucceeded = $false +$DownloadedLink = $null +$ErrorMessages = @() + +foreach ($link in $DownloadLinks) +{ + Say-Verbose "Downloading `"$($link.type)`" link $($link.downloadLink)" + + try { + Measure-Action "Package download" { DownloadFile -Source $link.downloadLink -OutPath $ZipPath } + Say-Verbose "Download succeeded." + $DownloadSucceeded = $true + $DownloadedLink = $link + break + } + catch { + $StatusCode = $null + $ErrorMessage = $null + + if ($PSItem.Exception.Data.Contains("StatusCode")) { + $StatusCode = $PSItem.Exception.Data["StatusCode"] + } + + if ($PSItem.Exception.Data.Contains("ErrorMessage")) { + $ErrorMessage = $PSItem.Exception.Data["ErrorMessage"] + } else { + $ErrorMessage = $PSItem.Exception.Message + } + + Say-Verbose "Download failed with status code $StatusCode. Error message: $ErrorMessage" + $ErrorMessages += "Downloading from `"$($link.type)`" link has failed with error:`nUri: $($link.downloadLink)`nStatusCode: $StatusCode`nError: $ErrorMessage" + } + + # This link failed. Clean up before trying the next one. + SafeRemoveFile -Path $ZipPath +} + +if (-not $DownloadSucceeded) { + foreach ($ErrorMessage in $ErrorMessages) { + Say-Error $ErrorMessages + } + + throw "Could not find `"$assetName`" with version = $($DownloadLinks[0].effectiveVersion)`nRefer to: https://aka.ms/dotnet-os-lifecycle for information on .NET support" +} + +Say "Extracting the archive." +Measure-Action "Package extraction" { Extract-Dotnet-Package -ZipPath $ZipPath -OutPath $InstallRoot } + +# Check if the SDK version is installed; if not, fail the installation. +$isAssetInstalled = $false + +# if the version contains "RTM" or "servicing"; check if a 'release-type' SDK version is installed. +if ($DownloadedLink.effectiveVersion -Match "rtm" -or $DownloadedLink.effectiveVersion -Match "servicing") { + $ReleaseVersion = $DownloadedLink.effectiveVersion.Split("-")[0] + Say-Verbose "Checking installation: version = $ReleaseVersion" + $isAssetInstalled = Is-Dotnet-Package-Installed -InstallRoot $InstallRoot -RelativePathToPackage $dotnetPackageRelativePath -SpecificVersion $ReleaseVersion +} + +# Check if the SDK version is installed. +if (!$isAssetInstalled) { + Say-Verbose "Checking installation: version = $($DownloadedLink.effectiveVersion)" + $isAssetInstalled = Is-Dotnet-Package-Installed -InstallRoot $InstallRoot -RelativePathToPackage $dotnetPackageRelativePath -SpecificVersion $DownloadedLink.effectiveVersion +} + +# Version verification failed. More likely something is wrong either with the downloaded content or with the verification algorithm. +if (!$isAssetInstalled) { + Say-Error "Failed to verify the version of installed `"$assetName`".`nInstallation source: $($DownloadedLink.downloadLink).`nInstallation location: $InstallRoot.`nReport the bug at https://github.com/dotnet/install-scripts/issues." + throw "`"$assetName`" with version = $($DownloadedLink.effectiveVersion) failed to install with an unknown error." +} + +if (-not $KeepZip) { + SafeRemoveFile -Path $ZipPath +} + +Measure-Action "Setting up shell environment" { Prepend-Sdk-InstallRoot-To-Path -InstallRoot $InstallRoot } + +Say "Note that the script does not resolve dependencies during installation." +Say "To check the list of dependencies, go to https://learn.microsoft.com/dotnet/core/install/windows#dependencies" +Say "Installed version is $($DownloadedLink.effectiveVersion)" +Say "Installation finished" +# SIG # Begin signature block +# MIInvwYJKoZIhvcNAQcCoIInsDCCJ6wCAQExDzANBglghkgBZQMEAgEFADB5Bgor +# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG +# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCACRu+yvG+6rftW +# 7639o2K9YFU32HKgY4Dqe9C3db/p7qCCDXYwggX0MIID3KADAgECAhMzAAADTrU8 +# esGEb+srAAAAAANOMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD +# VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNy +# b3NvZnQgQ29ycG9yYXRpb24xKDAmBgNVBAMTH01pY3Jvc29mdCBDb2RlIFNpZ25p +# bmcgUENBIDIwMTEwHhcNMjMwMzE2MTg0MzI5WhcNMjQwMzE0MTg0MzI5WjB0MQsw +# CQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9u +# ZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMR4wHAYDVQQDExVNaWNy +# b3NvZnQgQ29ycG9yYXRpb24wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB +# AQDdCKiNI6IBFWuvJUmf6WdOJqZmIwYs5G7AJD5UbcL6tsC+EBPDbr36pFGo1bsU +# p53nRyFYnncoMg8FK0d8jLlw0lgexDDr7gicf2zOBFWqfv/nSLwzJFNP5W03DF/1 +# 1oZ12rSFqGlm+O46cRjTDFBpMRCZZGddZlRBjivby0eI1VgTD1TvAdfBYQe82fhm +# WQkYR/lWmAK+vW/1+bO7jHaxXTNCxLIBW07F8PBjUcwFxxyfbe2mHB4h1L4U0Ofa +# +HX/aREQ7SqYZz59sXM2ySOfvYyIjnqSO80NGBaz5DvzIG88J0+BNhOu2jl6Dfcq +# jYQs1H/PMSQIK6E7lXDXSpXzAgMBAAGjggFzMIIBbzAfBgNVHSUEGDAWBgorBgEE +# AYI3TAgBBggrBgEFBQcDAzAdBgNVHQ4EFgQUnMc7Zn/ukKBsBiWkwdNfsN5pdwAw +# RQYDVR0RBD4wPKQ6MDgxHjAcBgNVBAsTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEW +# MBQGA1UEBRMNMjMwMDEyKzUwMDUxNjAfBgNVHSMEGDAWgBRIbmTlUAXTgqoXNzci +# tW2oynUClTBUBgNVHR8ETTBLMEmgR6BFhkNodHRwOi8vd3d3Lm1pY3Jvc29mdC5j +# b20vcGtpb3BzL2NybC9NaWNDb2RTaWdQQ0EyMDExXzIwMTEtMDctMDguY3JsMGEG +# CCsGAQUFBwEBBFUwUzBRBggrBgEFBQcwAoZFaHR0cDovL3d3dy5taWNyb3NvZnQu +# Y29tL3BraW9wcy9jZXJ0cy9NaWNDb2RTaWdQQ0EyMDExXzIwMTEtMDctMDguY3J0 +# MAwGA1UdEwEB/wQCMAAwDQYJKoZIhvcNAQELBQADggIBAD21v9pHoLdBSNlFAjmk +# mx4XxOZAPsVxxXbDyQv1+kGDe9XpgBnT1lXnx7JDpFMKBwAyIwdInmvhK9pGBa31 +# TyeL3p7R2s0L8SABPPRJHAEk4NHpBXxHjm4TKjezAbSqqbgsy10Y7KApy+9UrKa2 +# kGmsuASsk95PVm5vem7OmTs42vm0BJUU+JPQLg8Y/sdj3TtSfLYYZAaJwTAIgi7d +# hzn5hatLo7Dhz+4T+MrFd+6LUa2U3zr97QwzDthx+RP9/RZnur4inzSQsG5DCVIM +# pA1l2NWEA3KAca0tI2l6hQNYsaKL1kefdfHCrPxEry8onJjyGGv9YKoLv6AOO7Oh +# JEmbQlz/xksYG2N/JSOJ+QqYpGTEuYFYVWain7He6jgb41JbpOGKDdE/b+V2q/gX +# UgFe2gdwTpCDsvh8SMRoq1/BNXcr7iTAU38Vgr83iVtPYmFhZOVM0ULp/kKTVoir +# IpP2KCxT4OekOctt8grYnhJ16QMjmMv5o53hjNFXOxigkQWYzUO+6w50g0FAeFa8 +# 5ugCCB6lXEk21FFB1FdIHpjSQf+LP/W2OV/HfhC3uTPgKbRtXo83TZYEudooyZ/A +# Vu08sibZ3MkGOJORLERNwKm2G7oqdOv4Qj8Z0JrGgMzj46NFKAxkLSpE5oHQYP1H +# tPx1lPfD7iNSbJsP6LiUHXH1MIIHejCCBWKgAwIBAgIKYQ6Q0gAAAAAAAzANBgkq +# hkiG9w0BAQsFADCBiDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24x +# EDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlv +# bjEyMDAGA1UEAxMpTWljcm9zb2Z0IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5 +# IDIwMTEwHhcNMTEwNzA4MjA1OTA5WhcNMjYwNzA4MjEwOTA5WjB+MQswCQYDVQQG +# EwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwG +# A1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSgwJgYDVQQDEx9NaWNyb3NvZnQg +# Q29kZSBTaWduaW5nIFBDQSAyMDExMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC +# CgKCAgEAq/D6chAcLq3YbqqCEE00uvK2WCGfQhsqa+laUKq4BjgaBEm6f8MMHt03 +# a8YS2AvwOMKZBrDIOdUBFDFC04kNeWSHfpRgJGyvnkmc6Whe0t+bU7IKLMOv2akr +# rnoJr9eWWcpgGgXpZnboMlImEi/nqwhQz7NEt13YxC4Ddato88tt8zpcoRb0Rrrg +# OGSsbmQ1eKagYw8t00CT+OPeBw3VXHmlSSnnDb6gE3e+lD3v++MrWhAfTVYoonpy +# 4BI6t0le2O3tQ5GD2Xuye4Yb2T6xjF3oiU+EGvKhL1nkkDstrjNYxbc+/jLTswM9 +# sbKvkjh+0p2ALPVOVpEhNSXDOW5kf1O6nA+tGSOEy/S6A4aN91/w0FK/jJSHvMAh +# dCVfGCi2zCcoOCWYOUo2z3yxkq4cI6epZuxhH2rhKEmdX4jiJV3TIUs+UsS1Vz8k +# A/DRelsv1SPjcF0PUUZ3s/gA4bysAoJf28AVs70b1FVL5zmhD+kjSbwYuER8ReTB +# w3J64HLnJN+/RpnF78IcV9uDjexNSTCnq47f7Fufr/zdsGbiwZeBe+3W7UvnSSmn +# Eyimp31ngOaKYnhfsi+E11ecXL93KCjx7W3DKI8sj0A3T8HhhUSJxAlMxdSlQy90 +# lfdu+HggWCwTXWCVmj5PM4TasIgX3p5O9JawvEagbJjS4NaIjAsCAwEAAaOCAe0w +# ggHpMBAGCSsGAQQBgjcVAQQDAgEAMB0GA1UdDgQWBBRIbmTlUAXTgqoXNzcitW2o +# ynUClTAZBgkrBgEEAYI3FAIEDB4KAFMAdQBiAEMAQTALBgNVHQ8EBAMCAYYwDwYD +# VR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBRyLToCMZBDuRQFTuHqp8cx0SOJNDBa +# BgNVHR8EUzBRME+gTaBLhklodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpL2Ny +# bC9wcm9kdWN0cy9NaWNSb29DZXJBdXQyMDExXzIwMTFfMDNfMjIuY3JsMF4GCCsG +# AQUFBwEBBFIwUDBOBggrBgEFBQcwAoZCaHR0cDovL3d3dy5taWNyb3NvZnQuY29t +# L3BraS9jZXJ0cy9NaWNSb29DZXJBdXQyMDExXzIwMTFfMDNfMjIuY3J0MIGfBgNV +# HSAEgZcwgZQwgZEGCSsGAQQBgjcuAzCBgzA/BggrBgEFBQcCARYzaHR0cDovL3d3 +# dy5taWNyb3NvZnQuY29tL3BraW9wcy9kb2NzL3ByaW1hcnljcHMuaHRtMEAGCCsG +# AQUFBwICMDQeMiAdAEwAZQBnAGEAbABfAHAAbwBsAGkAYwB5AF8AcwB0AGEAdABl +# AG0AZQBuAHQALiAdMA0GCSqGSIb3DQEBCwUAA4ICAQBn8oalmOBUeRou09h0ZyKb +# C5YR4WOSmUKWfdJ5DJDBZV8uLD74w3LRbYP+vj/oCso7v0epo/Np22O/IjWll11l +# hJB9i0ZQVdgMknzSGksc8zxCi1LQsP1r4z4HLimb5j0bpdS1HXeUOeLpZMlEPXh6 +# I/MTfaaQdION9MsmAkYqwooQu6SpBQyb7Wj6aC6VoCo/KmtYSWMfCWluWpiW5IP0 +# wI/zRive/DvQvTXvbiWu5a8n7dDd8w6vmSiXmE0OPQvyCInWH8MyGOLwxS3OW560 +# STkKxgrCxq2u5bLZ2xWIUUVYODJxJxp/sfQn+N4sOiBpmLJZiWhub6e3dMNABQam +# ASooPoI/E01mC8CzTfXhj38cbxV9Rad25UAqZaPDXVJihsMdYzaXht/a8/jyFqGa +# J+HNpZfQ7l1jQeNbB5yHPgZ3BtEGsXUfFL5hYbXw3MYbBL7fQccOKO7eZS/sl/ah +# XJbYANahRr1Z85elCUtIEJmAH9AAKcWxm6U/RXceNcbSoqKfenoi+kiVH6v7RyOA +# 9Z74v2u3S5fi63V4GuzqN5l5GEv/1rMjaHXmr/r8i+sLgOppO6/8MO0ETI7f33Vt +# Y5E90Z1WTk+/gFcioXgRMiF670EKsT/7qMykXcGhiJtXcVZOSEXAQsmbdlsKgEhr +# /Xmfwb1tbWrJUnMTDXpQzTGCGZ8wghmbAgEBMIGVMH4xCzAJBgNVBAYTAlVTMRMw +# EQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVN +# aWNyb3NvZnQgQ29ycG9yYXRpb24xKDAmBgNVBAMTH01pY3Jvc29mdCBDb2RlIFNp +# Z25pbmcgUENBIDIwMTECEzMAAANOtTx6wYRv6ysAAAAAA04wDQYJYIZIAWUDBAIB +# BQCgga4wGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcCAQQwHAYKKwYBBAGCNwIBCzEO +# MAwGCisGAQQBgjcCARUwLwYJKoZIhvcNAQkEMSIEIPHo6D4ixtuX2mtmXYtzP7Xh +# 5SbbHtBt9hwIKfR9nNCHMEIGCisGAQQBgjcCAQwxNDAyoBSAEgBNAGkAYwByAG8A +# cwBvAGYAdKEagBhodHRwOi8vd3d3Lm1pY3Jvc29mdC5jb20wDQYJKoZIhvcNAQEB +# BQAEggEAKaYy0/f2nIWjmd2w2g7hU/pz6ahK3cIahIejHpTW8JXUR3neUB9oFm8x +# GiAtgKY6zzxKsMGRJfULOEB+jV8y1TK5aAUtNWog8o7i9hl/W3JLsRtcduGhqvR8 +# oYFq4xkYPDwAjklDN96cWNqWmqsUULs/jxx4Ef0o9/2Cy9FWYwvyDK/o0bdfotsl +# +cr3Aj1fIOSkrMKjEoScITOvfGCDgNqVsu+62itzX0QvIq7yW8aqJ5xd2r94IOry +# u6iMdQFYSxR7xpIaDjKLHCH8tTmKAlrFFekhaxe1WuTvNBt154Zl1U7ukSO12s1N +# ezHYEW4AoLd4MO9zmXwDZmo3RLzFHKGCFykwghclBgorBgEEAYI3AwMBMYIXFTCC +# FxEGCSqGSIb3DQEHAqCCFwIwghb+AgEDMQ8wDQYJYIZIAWUDBAIBBQAwggFZBgsq +# hkiG9w0BCRABBKCCAUgEggFEMIIBQAIBAQYKKwYBBAGEWQoDATAxMA0GCWCGSAFl +# AwQCAQUABCCiX6fcUDSacytCBP6o92QnwRIQCE6w6Se15jgm1UebNAIGZN/N9Z2v +# GBMyMDIzMDkxODEwMDUxOS4zMjJaMASAAgH0oIHYpIHVMIHSMQswCQYDVQQGEwJV +# UzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UE +# ChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMS0wKwYDVQQLEyRNaWNyb3NvZnQgSXJl +# bGFuZCBPcGVyYXRpb25zIExpbWl0ZWQxJjAkBgNVBAsTHVRoYWxlcyBUU1MgRVNO +# OkQwODItNEJGRC1FRUJBMSUwIwYDVQQDExxNaWNyb3NvZnQgVGltZS1TdGFtcCBT +# ZXJ2aWNloIIReDCCBycwggUPoAMCAQICEzMAAAG6Hz8Z98F1vXwAAQAAAbowDQYJ +# KoZIhvcNAQELBQAwfDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24x +# EDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlv +# bjEmMCQGA1UEAxMdTWljcm9zb2Z0IFRpbWUtU3RhbXAgUENBIDIwMTAwHhcNMjIw +# OTIwMjAyMjE5WhcNMjMxMjE0MjAyMjE5WjCB0jELMAkGA1UEBhMCVVMxEzARBgNV +# BAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jv +# c29mdCBDb3Jwb3JhdGlvbjEtMCsGA1UECxMkTWljcm9zb2Z0IElyZWxhbmQgT3Bl +# cmF0aW9ucyBMaW1pdGVkMSYwJAYDVQQLEx1UaGFsZXMgVFNTIEVTTjpEMDgyLTRC +# RkQtRUVCQTElMCMGA1UEAxMcTWljcm9zb2Z0IFRpbWUtU3RhbXAgU2VydmljZTCC +# AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAIhOFYMzkjWAE9UVnXF9hRGv +# 0xBRxc+I5Hu3hxVFXyK3u38xusEb0pLkwjgGtDsaLLbrlMxqX3tFb/3BgEPEC3L0 +# wX76gD8zHt+wiBV5mq5BWop29qRrgMJKKCPcpQnSjs9B/4XMFFvrpdPicZDv43FL +# gz9fHqMq0LJDw5JAHGDS30TCY9OF43P4d44Z9lE7CaVS2pJMF3L453MXB5yYK/KD +# bilhERP1jxn2yl+tGCRguIAsMG0oeOhXaw8uSGOhS6ACSHb+ebi0038MFHyoTNhK +# f+SYo4OpSY3xP4+swBBTKDoYP1wH+CfxG6h9fymBJQPQZaqfl0riiDLjmDunQtH1 +# GD64Air5k9Jdwhq5wLmSWXjyFVL+IDfOpdixJ6f5o+MhE6H4t31w+prygHmd2UHQ +# 657UGx6FNuzwC+SpAHmV76MZYac4uAhTgaP47P2eeS1ockvyhl9ya+9JzPfMkug3 +# xevzFADWiLRMr066EMV7q3JSRAsnCS9GQ08C4FKPbSh8OPM33Lng0ffxANnHAAX/ +# DE7cHcx7l9jaV3Acmkj7oqir4Eh2u5YxwiaTE37XaMumX2ES3PJ5NBaXq7YdLJwy +# SD+U9pk/tl4dQ1t/Eeo7uDTliOyQkD8I74xpVB0T31/67KHfkBkFVvy6wye21V+9 +# IC8uSD++RgD3RwtN2kE/AgMBAAGjggFJMIIBRTAdBgNVHQ4EFgQUimLm8QMeJa25 +# j9MWeabI2HSvZOUwHwYDVR0jBBgwFoAUn6cVXQBeYl2D9OXSZacbUzUZ6XIwXwYD +# VR0fBFgwVjBUoFKgUIZOaHR0cDovL3d3dy5taWNyb3NvZnQuY29tL3BraW9wcy9j +# cmwvTWljcm9zb2Z0JTIwVGltZS1TdGFtcCUyMFBDQSUyMDIwMTAoMSkuY3JsMGwG +# CCsGAQUFBwEBBGAwXjBcBggrBgEFBQcwAoZQaHR0cDovL3d3dy5taWNyb3NvZnQu +# Y29tL3BraW9wcy9jZXJ0cy9NaWNyb3NvZnQlMjBUaW1lLVN0YW1wJTIwUENBJTIw +# MjAxMCgxKS5jcnQwDAYDVR0TAQH/BAIwADAWBgNVHSUBAf8EDDAKBggrBgEFBQcD +# CDAOBgNVHQ8BAf8EBAMCB4AwDQYJKoZIhvcNAQELBQADggIBAF/I8U6hbZhvDcn9 +# 6nZ6tkbSEjXPvKZ6wroaXcgstEhpgaeEwleLuPXHLzEWtuJuYz4eshmhXqFr49lb +# AcX5SN5/cEsP0xdFayb7U5P94JZd3HjFvpWRNoNBhF3SDM0A38sI2H+hjhB/VfX1 +# XcZiei1ROPAyCHcBgHLyQrEu6mnb3HhbIdr8h0Ta7WFylGhLSFW6wmzKusP6aOlm +# nGSac5NMfla6lRvTYHd28rbbCgfSm1RhTgoZj+W8DTKtiEMwubHJ3mIPKmo8xtJI +# WXPnXq6XKgldrL5cynLMX/0WX65OuWbHV5GTELdfWvGV3DaZrHPUQ/UP31Keqb2x +# jVCb30LVwgbjIvYS77N1dARkN8F/9pJ1gO4IvZWMwyMlKKFGojO1f1wbjSWcA/57 +# tsc+t2blrMWgSNHgzDr01jbPSupRjy3Ht9ZZs4xN02eiX3eG297NrtC6l4c/gzn2 +# 0eqoqWx/uHWxmTgB0F5osBuTHOe77DyEA0uhArGlgKP91jghgt/OVHoH65g0QqCt +# gZ+36mnCEg6IOhFoFrCc0fJFGVmb1+17gEe+HRMM7jBk4O06J+IooFrI3e3PJjPr +# Qano/MyE3h+zAuBWGMDRcUlNKCDU7dGnWvH3XWwLrCCIcz+3GwRUMsLsDdPW2OVv +# 7v1eEJiMSIZ2P+M7L20Q8aznU4OAMIIHcTCCBVmgAwIBAgITMwAAABXF52ueAptJ +# mQAAAAAAFTANBgkqhkiG9w0BAQsFADCBiDELMAkGA1UEBhMCVVMxEzARBgNVBAgT +# Cldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29m +# dCBDb3Jwb3JhdGlvbjEyMDAGA1UEAxMpTWljcm9zb2Z0IFJvb3QgQ2VydGlmaWNh +# dGUgQXV0aG9yaXR5IDIwMTAwHhcNMjEwOTMwMTgyMjI1WhcNMzAwOTMwMTgzMjI1 +# WjB8MQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMH +# UmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSYwJAYDVQQD +# Ex1NaWNyb3NvZnQgVGltZS1TdGFtcCBQQ0EgMjAxMDCCAiIwDQYJKoZIhvcNAQEB +# BQADggIPADCCAgoCggIBAOThpkzntHIhC3miy9ckeb0O1YLT/e6cBwfSqWxOdcjK +# NVf2AX9sSuDivbk+F2Az/1xPx2b3lVNxWuJ+Slr+uDZnhUYjDLWNE893MsAQGOhg +# fWpSg0S3po5GawcU88V29YZQ3MFEyHFcUTE3oAo4bo3t1w/YJlN8OWECesSq/XJp +# rx2rrPY2vjUmZNqYO7oaezOtgFt+jBAcnVL+tuhiJdxqD89d9P6OU8/W7IVWTe/d +# vI2k45GPsjksUZzpcGkNyjYtcI4xyDUoveO0hyTD4MmPfrVUj9z6BVWYbWg7mka9 +# 7aSueik3rMvrg0XnRm7KMtXAhjBcTyziYrLNueKNiOSWrAFKu75xqRdbZ2De+JKR +# Hh09/SDPc31BmkZ1zcRfNN0Sidb9pSB9fvzZnkXftnIv231fgLrbqn427DZM9itu +# qBJR6L8FA6PRc6ZNN3SUHDSCD/AQ8rdHGO2n6Jl8P0zbr17C89XYcz1DTsEzOUyO +# ArxCaC4Q6oRRRuLRvWoYWmEBc8pnol7XKHYC4jMYctenIPDC+hIK12NvDMk2ZItb +# oKaDIV1fMHSRlJTYuVD5C4lh8zYGNRiER9vcG9H9stQcxWv2XFJRXRLbJbqvUAV6 +# bMURHXLvjflSxIUXk8A8FdsaN8cIFRg/eKtFtvUeh17aj54WcmnGrnu3tz5q4i6t +# AgMBAAGjggHdMIIB2TASBgkrBgEEAYI3FQEEBQIDAQABMCMGCSsGAQQBgjcVAgQW +# BBQqp1L+ZMSavoKRPEY1Kc8Q/y8E7jAdBgNVHQ4EFgQUn6cVXQBeYl2D9OXSZacb +# UzUZ6XIwXAYDVR0gBFUwUzBRBgwrBgEEAYI3TIN9AQEwQTA/BggrBgEFBQcCARYz +# aHR0cDovL3d3dy5taWNyb3NvZnQuY29tL3BraW9wcy9Eb2NzL1JlcG9zaXRvcnku +# aHRtMBMGA1UdJQQMMAoGCCsGAQUFBwMIMBkGCSsGAQQBgjcUAgQMHgoAUwB1AGIA +# QwBBMAsGA1UdDwQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNX2 +# VsuP6KJcYmjRPZSQW9fOmhjEMFYGA1UdHwRPME0wS6BJoEeGRWh0dHA6Ly9jcmwu +# bWljcm9zb2Z0LmNvbS9wa2kvY3JsL3Byb2R1Y3RzL01pY1Jvb0NlckF1dF8yMDEw +# LTA2LTIzLmNybDBaBggrBgEFBQcBAQROMEwwSgYIKwYBBQUHMAKGPmh0dHA6Ly93 +# d3cubWljcm9zb2Z0LmNvbS9wa2kvY2VydHMvTWljUm9vQ2VyQXV0XzIwMTAtMDYt +# MjMuY3J0MA0GCSqGSIb3DQEBCwUAA4ICAQCdVX38Kq3hLB9nATEkW+Geckv8qW/q +# XBS2Pk5HZHixBpOXPTEztTnXwnE2P9pkbHzQdTltuw8x5MKP+2zRoZQYIu7pZmc6 +# U03dmLq2HnjYNi6cqYJWAAOwBb6J6Gngugnue99qb74py27YP0h1AdkY3m2CDPVt +# I1TkeFN1JFe53Z/zjj3G82jfZfakVqr3lbYoVSfQJL1AoL8ZthISEV09J+BAljis +# 9/kpicO8F7BUhUKz/AyeixmJ5/ALaoHCgRlCGVJ1ijbCHcNhcy4sa3tuPywJeBTp +# kbKpW99Jo3QMvOyRgNI95ko+ZjtPu4b6MhrZlvSP9pEB9s7GdP32THJvEKt1MMU0 +# sHrYUP4KWN1APMdUbZ1jdEgssU5HLcEUBHG/ZPkkvnNtyo4JvbMBV0lUZNlz138e +# W0QBjloZkWsNn6Qo3GcZKCS6OEuabvshVGtqRRFHqfG3rsjoiV5PndLQTHa1V1QJ +# sWkBRH58oWFsc/4Ku+xBZj1p/cvBQUl+fpO+y/g75LcVv7TOPqUxUYS8vwLBgqJ7 +# Fx0ViY1w/ue10CgaiQuPNtq6TPmb/wrpNPgkNWcr4A245oyZ1uEi6vAnQj0llOZ0 +# dFtq0Z4+7X6gMTN9vMvpe784cETRkPHIqzqKOghif9lwY1NNje6CbaUFEMFxBmoQ +# tB1VM1izoXBm8qGCAtQwggI9AgEBMIIBAKGB2KSB1TCB0jELMAkGA1UEBhMCVVMx +# EzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoT +# FU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEtMCsGA1UECxMkTWljcm9zb2Z0IElyZWxh +# bmQgT3BlcmF0aW9ucyBMaW1pdGVkMSYwJAYDVQQLEx1UaGFsZXMgVFNTIEVTTjpE +# MDgyLTRCRkQtRUVCQTElMCMGA1UEAxMcTWljcm9zb2Z0IFRpbWUtU3RhbXAgU2Vy +# dmljZaIjCgEBMAcGBSsOAwIaAxUAdqNHe113gCJ87aZIGa5QBUqIwvKggYMwgYCk +# fjB8MQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMH +# UmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSYwJAYDVQQD +# Ex1NaWNyb3NvZnQgVGltZS1TdGFtcCBQQ0EgMjAxMDANBgkqhkiG9w0BAQUFAAIF +# AOiyf1swIhgPMjAyMzA5MTgxNTQ4NDNaGA8yMDIzMDkxOTE1NDg0M1owdDA6Bgor +# BgEEAYRZCgQBMSwwKjAKAgUA6LJ/WwIBADAHAgEAAgIJSjAHAgEAAgISJDAKAgUA +# 6LPQ2wIBADA2BgorBgEEAYRZCgQCMSgwJjAMBgorBgEEAYRZCgMCoAowCAIBAAID +# B6EgoQowCAIBAAIDAYagMA0GCSqGSIb3DQEBBQUAA4GBAGK+6UVMbVgt4qWdPk/1 +# tYxGjavQWgZ3LPfp9l3mh/tQK2RhpjsBgKJO+VVBXcUW3YQb5qP9g40+jrcIFlfy +# vrAK3UpbfuIZ6DJ6AayEF30fseVPvwaqjl/BJlKUL3ofsjEMcZPdpfHQv4Zdj3rr +# cWGEIG68RqDIePRRKRZEJtI0MYIEDTCCBAkCAQEwgZMwfDELMAkGA1UEBhMCVVMx +# EzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoT +# FU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEmMCQGA1UEAxMdTWljcm9zb2Z0IFRpbWUt +# U3RhbXAgUENBIDIwMTACEzMAAAG6Hz8Z98F1vXwAAQAAAbowDQYJYIZIAWUDBAIB +# BQCgggFKMBoGCSqGSIb3DQEJAzENBgsqhkiG9w0BCRABBDAvBgkqhkiG9w0BCQQx +# IgQgYadrVhYugkNn/ywjh6tJ37ntH5tUO1WvoJ2sa5Mz6LIwgfoGCyqGSIb3DQEJ +# EAIvMYHqMIHnMIHkMIG9BCApVb08M25w+tYGWsmlGtp1gy1nPcqWfqgMF3nlWYVz +# BTCBmDCBgKR+MHwxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAw +# DgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24x +# JjAkBgNVBAMTHU1pY3Jvc29mdCBUaW1lLVN0YW1wIFBDQSAyMDEwAhMzAAABuh8/ +# GffBdb18AAEAAAG6MCIEIMHkOGC427PqmUI7Oe7xVuezks+e+hMM+17Nfgn9Gbmw +# MA0GCSqGSIb3DQEBCwUABIICAEKE7ZkmQ1xDsee8ZSZP8Kkt2YJLG3nLR32JBRu3 +# uX7TPTDw9phd40N2ryva3Xjzht/JOPa0F4mg++YIwylXVIR6EqKNVLsIA/X8AGFa +# ti+AJp6qNe9grV8DBK00whojtMK8JZhufOb7LEon5rBFEnJx3g8JhCvAqXFzxw+M +# ctqJFm6+1ynuI7mKayA89TOLBmI4RviICjMZlsW3kNXRS1GryKt7H+C8y9kiLEMX +# efauGyoMO8sToIxgrq2HZF88/b+y8c3cX+Q5iazWLzMYeWUUPrqWcIbjGjIFBMl9 +# weOXEAZVo6TSGDZOQkYi/FZxKWllnxVRN1S2Al5IUUvgXGl9ZpsW2DyM1S8Qxe+a +# VrxwkOWKzHlnFo1qGz0Iq9ImHVqr2dOC5bDVMu+jlOA1LiZC5aHxuxaHWBN73Wp7 +# Hjy8h73drsmmiXovOWly7lWLatIuPJh00iiyBXdDtjmeDjso3aadUII5FQ1QWZ4F +# 4VWo161Gx+TxGlUt//4Hns5bn4UEGE43g9OCQuQ/WFMqdb3dHCzkkHDhWHbdpBy7 +# oHHEsAdgjMdQHWfnxhCj0ZHEOupc9j1CXpQtN/B6uzsQQ/Mp34Rhsgn+/REVAwpS +# O7G69KWZrePZJiNrV/+eRn8ya6s8WNQAGB5zIQc8o+K9RGctLBOWcsRya9sqvL6r +# xUQ2 +# SIG # End signature block diff --git a/automataCI/services/publishers/dotnet-install.sh b/automataCI/services/publishers/dotnet-install.sh new file mode 100644 index 0000000..4547589 --- /dev/null +++ b/automataCI/services/publishers/dotnet-install.sh @@ -0,0 +1,1830 @@ +#!/usr/bin/env bash +# Copyright (c) .NET Foundation and contributors. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. +# + +# Stop script on NZEC +set -e +# Stop script if unbound variable found (use ${var:-} if intentional) +set -u +# By default cmd1 | cmd2 returns exit code of cmd2 regardless of cmd1 success +# This is causing it to fail +set -o pipefail + +# Use in the the functions: eval $invocation +invocation='say_verbose "Calling: ${yellow:-}${FUNCNAME[0]} ${green:-}$*${normal:-}"' + +# standard output may be used as a return value in the functions +# we need a way to write text on the screen in the functions so that +# it won't interfere with the return value. +# Exposing stream 3 as a pipe to standard output of the script itself +exec 3>&1 + +# Setup some colors to use. These need to work in fairly limited shells, like the Ubuntu Docker container where there are only 8 colors. +# See if stdout is a terminal +if [ -t 1 ] && command -v tput > /dev/null; then + # see if it supports colors + ncolors=$(tput colors || echo 0) + if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then + bold="$(tput bold || echo)" + normal="$(tput sgr0 || echo)" + black="$(tput setaf 0 || echo)" + red="$(tput setaf 1 || echo)" + green="$(tput setaf 2 || echo)" + yellow="$(tput setaf 3 || echo)" + blue="$(tput setaf 4 || echo)" + magenta="$(tput setaf 5 || echo)" + cyan="$(tput setaf 6 || echo)" + white="$(tput setaf 7 || echo)" + fi +fi + +say_warning() { + printf "%b\n" "${yellow:-}dotnet_install: Warning: $1${normal:-}" >&3 +} + +say_err() { + printf "%b\n" "${red:-}dotnet_install: Error: $1${normal:-}" >&2 +} + +say() { + # using stream 3 (defined in the beginning) to not interfere with stdout of functions + # which may be used as return value + printf "%b\n" "${cyan:-}dotnet-install:${normal:-} $1" >&3 +} + +say_verbose() { + if [ "$verbose" = true ]; then + say "$1" + fi +} + +# This platform list is finite - if the SDK/Runtime has supported Linux distribution-specific assets, +# then and only then should the Linux distribution appear in this list. +# Adding a Linux distribution to this list does not imply distribution-specific support. +get_legacy_os_name_from_platform() { + eval $invocation + + platform="$1" + case "$platform" in + "centos.7") + echo "centos" + return 0 + ;; + "debian.8") + echo "debian" + return 0 + ;; + "debian.9") + echo "debian.9" + return 0 + ;; + "fedora.23") + echo "fedora.23" + return 0 + ;; + "fedora.24") + echo "fedora.24" + return 0 + ;; + "fedora.27") + echo "fedora.27" + return 0 + ;; + "fedora.28") + echo "fedora.28" + return 0 + ;; + "opensuse.13.2") + echo "opensuse.13.2" + return 0 + ;; + "opensuse.42.1") + echo "opensuse.42.1" + return 0 + ;; + "opensuse.42.3") + echo "opensuse.42.3" + return 0 + ;; + "rhel.7"*) + echo "rhel" + return 0 + ;; + "ubuntu.14.04") + echo "ubuntu" + return 0 + ;; + "ubuntu.16.04") + echo "ubuntu.16.04" + return 0 + ;; + "ubuntu.16.10") + echo "ubuntu.16.10" + return 0 + ;; + "ubuntu.18.04") + echo "ubuntu.18.04" + return 0 + ;; + "alpine.3.4.3") + echo "alpine" + return 0 + ;; + esac + return 1 +} + +get_legacy_os_name() { + eval $invocation + + local uname=$(uname) + if [ "$uname" = "Darwin" ]; then + echo "osx" + return 0 + elif [ -n "$runtime_id" ]; then + echo $(get_legacy_os_name_from_platform "${runtime_id%-*}" || echo "${runtime_id%-*}") + return 0 + else + if [ -e /etc/os-release ]; then + . /etc/os-release + os=$(get_legacy_os_name_from_platform "$ID${VERSION_ID:+.${VERSION_ID}}" || echo "") + if [ -n "$os" ]; then + echo "$os" + return 0 + fi + fi + fi + + say_verbose "Distribution specific OS name and version could not be detected: UName = $uname" + return 1 +} + +get_linux_platform_name() { + eval $invocation + + if [ -n "$runtime_id" ]; then + echo "${runtime_id%-*}" + return 0 + else + if [ -e /etc/os-release ]; then + . /etc/os-release + echo "$ID${VERSION_ID:+.${VERSION_ID}}" + return 0 + elif [ -e /etc/redhat-release ]; then + local redhatRelease=$(&1 || true) | grep -q musl +} + +get_current_os_name() { + eval $invocation + + local uname=$(uname) + if [ "$uname" = "Darwin" ]; then + echo "osx" + return 0 + elif [ "$uname" = "FreeBSD" ]; then + echo "freebsd" + return 0 + elif [ "$uname" = "Linux" ]; then + local linux_platform_name="" + linux_platform_name="$(get_linux_platform_name)" || true + + if [ "$linux_platform_name" = "rhel.6" ]; then + echo $linux_platform_name + return 0 + elif is_musl_based_distro; then + echo "linux-musl" + return 0 + elif [ "$linux_platform_name" = "linux-musl" ]; then + echo "linux-musl" + return 0 + else + echo "linux" + return 0 + fi + fi + + say_err "OS name could not be detected: UName = $uname" + return 1 +} + +machine_has() { + eval $invocation + + command -v "$1" > /dev/null 2>&1 + return $? +} + +check_min_reqs() { + local hasMinimum=false + if machine_has "curl"; then + hasMinimum=true + elif machine_has "wget"; then + hasMinimum=true + fi + + if [ "$hasMinimum" = "false" ]; then + say_err "curl (recommended) or wget are required to download dotnet. Install missing prerequisite to proceed." + return 1 + fi + return 0 +} + +# args: +# input - $1 +to_lowercase() { + #eval $invocation + + echo "$1" | tr '[:upper:]' '[:lower:]' + return 0 +} + +# args: +# input - $1 +remove_trailing_slash() { + #eval $invocation + + local input="${1:-}" + echo "${input%/}" + return 0 +} + +# args: +# input - $1 +remove_beginning_slash() { + #eval $invocation + + local input="${1:-}" + echo "${input#/}" + return 0 +} + +# args: +# root_path - $1 +# child_path - $2 - this parameter can be empty +combine_paths() { + eval $invocation + + # TODO: Consider making it work with any number of paths. For now: + if [ ! -z "${3:-}" ]; then + say_err "combine_paths: Function takes two parameters." + return 1 + fi + + local root_path="$(remove_trailing_slash "$1")" + local child_path="$(remove_beginning_slash "${2:-}")" + say_verbose "combine_paths: root_path=$root_path" + say_verbose "combine_paths: child_path=$child_path" + echo "$root_path/$child_path" + return 0 +} + +get_machine_architecture() { + eval $invocation + + if command -v uname > /dev/null; then + CPUName=$(uname -m) + case $CPUName in + armv*l) + echo "arm" + return 0 + ;; + aarch64|arm64) + echo "arm64" + return 0 + ;; + s390x) + echo "s390x" + return 0 + ;; + ppc64le) + echo "ppc64le" + return 0 + ;; + loongarch64) + echo "loongarch64" + return 0 + ;; + esac + fi + + # Always default to 'x64' + echo "x64" + return 0 +} + +# args: +# architecture - $1 +get_normalized_architecture_from_architecture() { + eval $invocation + + local architecture="$(to_lowercase "$1")" + + if [[ $architecture == \ ]]; then + echo "$(get_machine_architecture)" + return 0 + fi + + case "$architecture" in + amd64|x64) + echo "x64" + return 0 + ;; + arm) + echo "arm" + return 0 + ;; + arm64) + echo "arm64" + return 0 + ;; + s390x) + echo "s390x" + return 0 + ;; + ppc64le) + echo "ppc64le" + return 0 + ;; + loongarch64) + echo "loongarch64" + return 0 + ;; + esac + + say_err "Architecture \`$architecture\` not supported. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues" + return 1 +} + +# args: +# version - $1 +# channel - $2 +# architecture - $3 +get_normalized_architecture_for_specific_sdk_version() { + eval $invocation + + local is_version_support_arm64="$(is_arm64_supported "$1")" + local is_channel_support_arm64="$(is_arm64_supported "$2")" + local architecture="$3"; + local osname="$(get_current_os_name)" + + if [ "$osname" == "osx" ] && [ "$architecture" == "arm64" ] && { [ "$is_version_support_arm64" = false ] || [ "$is_channel_support_arm64" = false ]; }; then + #check if rosetta is installed + if [ "$(/usr/bin/pgrep oahd >/dev/null 2>&1;echo $?)" -eq 0 ]; then + say_verbose "Changing user architecture from '$architecture' to 'x64' because .NET SDKs prior to version 6.0 do not support arm64." + echo "x64" + return 0; + else + say_err "Architecture \`$architecture\` is not supported for .NET SDK version \`$version\`. Please install Rosetta to allow emulation of the \`$architecture\` .NET SDK on this platform" + return 1 + fi + fi + + echo "$architecture" + return 0 +} + +# args: +# version or channel - $1 +is_arm64_supported() { + #any channel or version that starts with the specified versions + case "$1" in + ( "1"* | "2"* | "3"* | "4"* | "5"*) + echo false + return 0 + esac + + echo true + return 0 +} + +# args: +# user_defined_os - $1 +get_normalized_os() { + eval $invocation + + local osname="$(to_lowercase "$1")" + if [ ! -z "$osname" ]; then + case "$osname" in + osx | freebsd | rhel.6 | linux-musl | linux) + echo "$osname" + return 0 + ;; + *) + say_err "'$user_defined_os' is not a supported value for --os option, supported values are: osx, linux, linux-musl, freebsd, rhel.6. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues." + return 1 + ;; + esac + else + osname="$(get_current_os_name)" || return 1 + fi + echo "$osname" + return 0 +} + +# args: +# quality - $1 +get_normalized_quality() { + eval $invocation + + local quality="$(to_lowercase "$1")" + if [ ! -z "$quality" ]; then + case "$quality" in + daily | signed | validated | preview) + echo "$quality" + return 0 + ;; + ga) + #ga quality is available without specifying quality, so normalizing it to empty + return 0 + ;; + *) + say_err "'$quality' is not a supported value for --quality option. Supported values are: daily, signed, validated, preview, ga. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues." + return 1 + ;; + esac + fi + return 0 +} + +# args: +# channel - $1 +get_normalized_channel() { + eval $invocation + + local channel="$(to_lowercase "$1")" + + if [[ $channel == current ]]; then + say_warning 'Value "Current" is deprecated for -Channel option. Use "STS" instead.' + fi + + if [[ $channel == release/* ]]; then + say_warning 'Using branch name with -Channel option is no longer supported with newer releases. Use -Quality option with a channel in X.Y format instead.'; + fi + + if [ ! -z "$channel" ]; then + case "$channel" in + lts) + echo "LTS" + return 0 + ;; + sts) + echo "STS" + return 0 + ;; + current) + echo "STS" + return 0 + ;; + *) + echo "$channel" + return 0 + ;; + esac + fi + + return 0 +} + +# args: +# runtime - $1 +get_normalized_product() { + eval $invocation + + local product="" + local runtime="$(to_lowercase "$1")" + if [[ "$runtime" == "dotnet" ]]; then + product="dotnet-runtime" + elif [[ "$runtime" == "aspnetcore" ]]; then + product="aspnetcore-runtime" + elif [ -z "$runtime" ]; then + product="dotnet-sdk" + fi + echo "$product" + return 0 +} + +# The version text returned from the feeds is a 1-line or 2-line string: +# For the SDK and the dotnet runtime (2 lines): +# Line 1: # commit_hash +# Line 2: # 4-part version +# For the aspnetcore runtime (1 line): +# Line 1: # 4-part version + +# args: +# version_text - stdin +get_version_from_latestversion_file_content() { + eval $invocation + + cat | tail -n 1 | sed 's/\r$//' + return 0 +} + +# args: +# install_root - $1 +# relative_path_to_package - $2 +# specific_version - $3 +is_dotnet_package_installed() { + eval $invocation + + local install_root="$1" + local relative_path_to_package="$2" + local specific_version="${3//[$'\t\r\n']}" + + local dotnet_package_path="$(combine_paths "$(combine_paths "$install_root" "$relative_path_to_package")" "$specific_version")" + say_verbose "is_dotnet_package_installed: dotnet_package_path=$dotnet_package_path" + + if [ -d "$dotnet_package_path" ]; then + return 0 + else + return 1 + fi +} + +# args: +# downloaded file - $1 +# remote_file_size - $2 +validate_remote_local_file_sizes() +{ + eval $invocation + + local downloaded_file="$1" + local remote_file_size="$2" + local file_size='' + + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + file_size="$(stat -c '%s' "$downloaded_file")" + elif [[ "$OSTYPE" == "darwin"* ]]; then + # hardcode in order to avoid conflicts with GNU stat + file_size="$(/usr/bin/stat -f '%z' "$downloaded_file")" + fi + + if [ -n "$file_size" ]; then + say "Downloaded file size is $file_size bytes." + + if [ -n "$remote_file_size" ] && [ -n "$file_size" ]; then + if [ "$remote_file_size" -ne "$file_size" ]; then + say "The remote and local file sizes are not equal. The remote file size is $remote_file_size bytes and the local size is $file_size bytes. The local package may be corrupted." + else + say "The remote and local file sizes are equal." + fi + fi + + else + say "Either downloaded or local package size can not be measured. One of them may be corrupted." + fi +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +get_version_from_latestversion_file() { + eval $invocation + + local azure_feed="$1" + local channel="$2" + local normalized_architecture="$3" + + local version_file_url=null + if [[ "$runtime" == "dotnet" ]]; then + version_file_url="$azure_feed/Runtime/$channel/latest.version" + elif [[ "$runtime" == "aspnetcore" ]]; then + version_file_url="$azure_feed/aspnetcore/Runtime/$channel/latest.version" + elif [ -z "$runtime" ]; then + version_file_url="$azure_feed/Sdk/$channel/latest.version" + else + say_err "Invalid value for \$runtime" + return 1 + fi + say_verbose "get_version_from_latestversion_file: latest url: $version_file_url" + + download "$version_file_url" || return $? + return 0 +} + +# args: +# json_file - $1 +parse_globaljson_file_for_version() { + eval $invocation + + local json_file="$1" + if [ ! -f "$json_file" ]; then + say_err "Unable to find \`$json_file\`" + return 1 + fi + + sdk_section=$(cat $json_file | tr -d "\r" | awk '/"sdk"/,/}/') + if [ -z "$sdk_section" ]; then + say_err "Unable to parse the SDK node in \`$json_file\`" + return 1 + fi + + sdk_list=$(echo $sdk_section | awk -F"[{}]" '{print $2}') + sdk_list=${sdk_list//[\" ]/} + sdk_list=${sdk_list//,/$'\n'} + + local version_info="" + while read -r line; do + IFS=: + while read -r key value; do + if [[ "$key" == "version" ]]; then + version_info=$value + fi + done <<< "$line" + done <<< "$sdk_list" + if [ -z "$version_info" ]; then + say_err "Unable to find the SDK:version node in \`$json_file\`" + return 1 + fi + + unset IFS; + echo "$version_info" + return 0 +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +# version - $4 +# json_file - $5 +get_specific_version_from_version() { + eval $invocation + + local azure_feed="$1" + local channel="$2" + local normalized_architecture="$3" + local version="$(to_lowercase "$4")" + local json_file="$5" + + if [ -z "$json_file" ]; then + if [[ "$version" == "latest" ]]; then + local version_info + version_info="$(get_version_from_latestversion_file "$azure_feed" "$channel" "$normalized_architecture" false)" || return 1 + say_verbose "get_specific_version_from_version: version_info=$version_info" + echo "$version_info" | get_version_from_latestversion_file_content + return 0 + else + echo "$version" + return 0 + fi + else + local version_info + version_info="$(parse_globaljson_file_for_version "$json_file")" || return 1 + echo "$version_info" + return 0 + fi +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +# specific_version - $4 +# normalized_os - $5 +construct_download_link() { + eval $invocation + + local azure_feed="$1" + local channel="$2" + local normalized_architecture="$3" + local specific_version="${4//[$'\t\r\n']}" + local specific_product_version="$(get_specific_product_version "$1" "$4")" + local osname="$5" + + local download_link=null + if [[ "$runtime" == "dotnet" ]]; then + download_link="$azure_feed/Runtime/$specific_version/dotnet-runtime-$specific_product_version-$osname-$normalized_architecture.tar.gz" + elif [[ "$runtime" == "aspnetcore" ]]; then + download_link="$azure_feed/aspnetcore/Runtime/$specific_version/aspnetcore-runtime-$specific_product_version-$osname-$normalized_architecture.tar.gz" + elif [ -z "$runtime" ]; then + download_link="$azure_feed/Sdk/$specific_version/dotnet-sdk-$specific_product_version-$osname-$normalized_architecture.tar.gz" + else + return 1 + fi + + echo "$download_link" + return 0 +} + +# args: +# azure_feed - $1 +# specific_version - $2 +# download link - $3 (optional) +get_specific_product_version() { + # If we find a 'productVersion.txt' at the root of any folder, we'll use its contents + # to resolve the version of what's in the folder, superseding the specified version. + # if 'productVersion.txt' is missing but download link is already available, product version will be taken from download link + eval $invocation + + local azure_feed="$1" + local specific_version="${2//[$'\t\r\n']}" + local package_download_link="" + if [ $# -gt 2 ]; then + local package_download_link="$3" + fi + local specific_product_version=null + + # Try to get the version number, using the productVersion.txt file located next to the installer file. + local download_links=($(get_specific_product_version_url "$azure_feed" "$specific_version" true "$package_download_link") + $(get_specific_product_version_url "$azure_feed" "$specific_version" false "$package_download_link")) + + for download_link in "${download_links[@]}" + do + say_verbose "Checking for the existence of $download_link" + + if machine_has "curl" + then + if ! specific_product_version=$(curl -s --fail "${download_link}${feed_credential}" 2>&1); then + continue + else + echo "${specific_product_version//[$'\t\r\n']}" + return 0 + fi + + elif machine_has "wget" + then + specific_product_version=$(wget -qO- "${download_link}${feed_credential}" 2>&1) + if [ $? = 0 ]; then + echo "${specific_product_version//[$'\t\r\n']}" + return 0 + fi + fi + done + + # Getting the version number with productVersion.txt has failed. Try parsing the download link for a version number. + say_verbose "Failed to get the version using productVersion.txt file. Download link will be parsed instead." + specific_product_version="$(get_product_specific_version_from_download_link "$package_download_link" "$specific_version")" + echo "${specific_product_version//[$'\t\r\n']}" + return 0 +} + +# args: +# azure_feed - $1 +# specific_version - $2 +# is_flattened - $3 +# download link - $4 (optional) +get_specific_product_version_url() { + eval $invocation + + local azure_feed="$1" + local specific_version="$2" + local is_flattened="$3" + local package_download_link="" + if [ $# -gt 3 ]; then + local package_download_link="$4" + fi + + local pvFileName="productVersion.txt" + if [ "$is_flattened" = true ]; then + if [ -z "$runtime" ]; then + pvFileName="sdk-productVersion.txt" + elif [[ "$runtime" == "dotnet" ]]; then + pvFileName="runtime-productVersion.txt" + else + pvFileName="$runtime-productVersion.txt" + fi + fi + + local download_link=null + + if [ -z "$package_download_link" ]; then + if [[ "$runtime" == "dotnet" ]]; then + download_link="$azure_feed/Runtime/$specific_version/${pvFileName}" + elif [[ "$runtime" == "aspnetcore" ]]; then + download_link="$azure_feed/aspnetcore/Runtime/$specific_version/${pvFileName}" + elif [ -z "$runtime" ]; then + download_link="$azure_feed/Sdk/$specific_version/${pvFileName}" + else + return 1 + fi + else + download_link="${package_download_link%/*}/${pvFileName}" + fi + + say_verbose "Constructed productVersion link: $download_link" + echo "$download_link" + return 0 +} + +# args: +# download link - $1 +# specific version - $2 +get_product_specific_version_from_download_link() +{ + eval $invocation + + local download_link="$1" + local specific_version="$2" + local specific_product_version="" + + if [ -z "$download_link" ]; then + echo "$specific_version" + return 0 + fi + + #get filename + filename="${download_link##*/}" + + #product specific version follows the product name + #for filename 'dotnet-sdk-3.1.404-linux-x64.tar.gz': the product version is 3.1.404 + IFS='-' + read -ra filename_elems <<< "$filename" + count=${#filename_elems[@]} + if [[ "$count" -gt 2 ]]; then + specific_product_version="${filename_elems[2]}" + else + specific_product_version=$specific_version + fi + unset IFS; + echo "$specific_product_version" + return 0 +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +# specific_version - $4 +construct_legacy_download_link() { + eval $invocation + + local azure_feed="$1" + local channel="$2" + local normalized_architecture="$3" + local specific_version="${4//[$'\t\r\n']}" + + local distro_specific_osname + distro_specific_osname="$(get_legacy_os_name)" || return 1 + + local legacy_download_link=null + if [[ "$runtime" == "dotnet" ]]; then + legacy_download_link="$azure_feed/Runtime/$specific_version/dotnet-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz" + elif [ -z "$runtime" ]; then + legacy_download_link="$azure_feed/Sdk/$specific_version/dotnet-dev-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz" + else + return 1 + fi + + echo "$legacy_download_link" + return 0 +} + +get_user_install_path() { + eval $invocation + + if [ ! -z "${DOTNET_INSTALL_DIR:-}" ]; then + echo "$DOTNET_INSTALL_DIR" + else + echo "$HOME/.dotnet" + fi + return 0 +} + +# args: +# install_dir - $1 +resolve_installation_path() { + eval $invocation + + local install_dir=$1 + if [ "$install_dir" = "" ]; then + local user_install_path="$(get_user_install_path)" + say_verbose "resolve_installation_path: user_install_path=$user_install_path" + echo "$user_install_path" + return 0 + fi + + echo "$install_dir" + return 0 +} + +# args: +# relative_or_absolute_path - $1 +get_absolute_path() { + eval $invocation + + local relative_or_absolute_path=$1 + echo "$(cd "$(dirname "$1")" && pwd -P)/$(basename "$1")" + return 0 +} + +# args: +# input_files - stdin +# root_path - $1 +# out_path - $2 +# override - $3 +copy_files_or_dirs_from_list() { + eval $invocation + + local root_path="$(remove_trailing_slash "$1")" + local out_path="$(remove_trailing_slash "$2")" + local override="$3" + local osname="$(get_current_os_name)" + local override_switch=$( + if [ "$override" = false ]; then + if [ "$osname" = "linux-musl" ]; then + printf -- "-u"; + else + printf -- "-n"; + fi + fi) + + cat | uniq | while read -r file_path; do + local path="$(remove_beginning_slash "${file_path#$root_path}")" + local target="$out_path/$path" + if [ "$override" = true ] || (! ([ -d "$target" ] || [ -e "$target" ])); then + mkdir -p "$out_path/$(dirname "$path")" + if [ -d "$target" ]; then + rm -rf "$target" + fi + cp -R $override_switch "$root_path/$path" "$target" + fi + done +} + +# args: +# zip_uri - $1 +get_remote_file_size() { + local zip_uri="$1" + + if machine_has "curl"; then + file_size=$(curl -sI "$zip_uri" | grep -i content-length | awk '{ num = $2 + 0; print num }') + elif machine_has "wget"; then + file_size=$(wget --spider --server-response -O /dev/null "$zip_uri" 2>&1 | grep -i 'Content-Length:' | awk '{ num = $2 + 0; print num }') + else + say "Neither curl nor wget is available on this system." + return + fi + + if [ -n "$file_size" ]; then + say "Remote file $zip_uri size is $file_size bytes." + echo "$file_size" + else + say_verbose "Content-Length header was not extracted for $zip_uri." + echo "" + fi +} + +# args: +# zip_path - $1 +# out_path - $2 +# remote_file_size - $3 +extract_dotnet_package() { + eval $invocation + + local zip_path="$1" + local out_path="$2" + local remote_file_size="$3" + + local temp_out_path="$(mktemp -d "$temporary_file_template")" + + local failed=false + tar -xzf "$zip_path" -C "$temp_out_path" > /dev/null || failed=true + + local folders_with_version_regex='^.*/[0-9]+\.[0-9]+[^/]+/' + find "$temp_out_path" -type f | grep -Eo "$folders_with_version_regex" | sort | copy_files_or_dirs_from_list "$temp_out_path" "$out_path" false + find "$temp_out_path" -type f | grep -Ev "$folders_with_version_regex" | copy_files_or_dirs_from_list "$temp_out_path" "$out_path" "$override_non_versioned_files" + + validate_remote_local_file_sizes "$zip_path" "$remote_file_size" + + rm -rf "$temp_out_path" + if [ -z ${keep_zip+x} ]; then + rm -f "$zip_path" && say_verbose "Temporary zip file $zip_path was removed" + fi + + if [ "$failed" = true ]; then + say_err "Extraction failed" + return 1 + fi + return 0 +} + +# args: +# remote_path - $1 +# disable_feed_credential - $2 +get_http_header() +{ + eval $invocation + local remote_path="$1" + local disable_feed_credential="$2" + + local failed=false + local response + if machine_has "curl"; then + get_http_header_curl $remote_path $disable_feed_credential || failed=true + elif machine_has "wget"; then + get_http_header_wget $remote_path $disable_feed_credential || failed=true + else + failed=true + fi + if [ "$failed" = true ]; then + say_verbose "Failed to get HTTP header: '$remote_path'." + return 1 + fi + return 0 +} + +# args: +# remote_path - $1 +# disable_feed_credential - $2 +get_http_header_curl() { + eval $invocation + local remote_path="$1" + local disable_feed_credential="$2" + + remote_path_with_credential="$remote_path" + if [ "$disable_feed_credential" = false ]; then + remote_path_with_credential+="$feed_credential" + fi + + curl_options="-I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 " + curl $curl_options "$remote_path_with_credential" 2>&1 || return 1 + return 0 +} + +# args: +# remote_path - $1 +# disable_feed_credential - $2 +get_http_header_wget() { + eval $invocation + local remote_path="$1" + local disable_feed_credential="$2" + local wget_options="-q -S --spider --tries 5 " + + local wget_options_extra='' + + # Test for options that aren't supported on all wget implementations. + if [[ $(wget -h 2>&1 | grep -E 'waitretry|connect-timeout') ]]; then + wget_options_extra="--waitretry 2 --connect-timeout 15 " + else + say "wget extra options are unavailable for this environment" + fi + + remote_path_with_credential="$remote_path" + if [ "$disable_feed_credential" = false ]; then + remote_path_with_credential+="$feed_credential" + fi + + wget $wget_options $wget_options_extra "$remote_path_with_credential" 2>&1 + + return $? +} + +# args: +# remote_path - $1 +# [out_path] - $2 - stdout if not provided +download() { + eval $invocation + + local remote_path="$1" + local out_path="${2:-}" + + if [[ "$remote_path" != "http"* ]]; then + cp "$remote_path" "$out_path" + return $? + fi + + local failed=false + local attempts=0 + while [ $attempts -lt 3 ]; do + attempts=$((attempts+1)) + failed=false + if machine_has "curl"; then + downloadcurl "$remote_path" "$out_path" || failed=true + elif machine_has "wget"; then + downloadwget "$remote_path" "$out_path" || failed=true + else + say_err "Missing dependency: neither curl nor wget was found." + exit 1 + fi + + if [ "$failed" = false ] || [ $attempts -ge 3 ] || { [ ! -z $http_code ] && [ $http_code = "404" ]; }; then + break + fi + + say "Download attempt #$attempts has failed: $http_code $download_error_msg" + say "Attempt #$((attempts+1)) will start in $((attempts*10)) seconds." + sleep $((attempts*10)) + done + + if [ "$failed" = true ]; then + say_verbose "Download failed: $remote_path" + return 1 + fi + return 0 +} + +# Updates global variables $http_code and $download_error_msg +downloadcurl() { + eval $invocation + unset http_code + unset download_error_msg + local remote_path="$1" + local out_path="${2:-}" + # Append feed_credential as late as possible before calling curl to avoid logging feed_credential + # Avoid passing URI with credentials to functions: note, most of them echoing parameters of invocation in verbose output. + local remote_path_with_credential="${remote_path}${feed_credential}" + local curl_options="--retry 20 --retry-delay 2 --connect-timeout 15 -sSL -f --create-dirs " + local curl_exit_code=0; + if [ -z "$out_path" ]; then + curl $curl_options "$remote_path_with_credential" 2>&1 + curl_exit_code=$? + else + curl $curl_options -o "$out_path" "$remote_path_with_credential" 2>&1 + curl_exit_code=$? + fi + + if [ $curl_exit_code -gt 0 ]; then + download_error_msg="Unable to download $remote_path." + # Check for curl timeout codes + if [[ $curl_exit_code == 7 || $curl_exit_code == 28 ]]; then + download_error_msg+=" Failed to reach the server: connection timeout." + else + local disable_feed_credential=false + local response=$(get_http_header_curl $remote_path $disable_feed_credential) + http_code=$( echo "$response" | awk '/^HTTP/{print $2}' | tail -1 ) + if [[ ! -z $http_code && $http_code != 2* ]]; then + download_error_msg+=" Returned HTTP status code: $http_code." + fi + fi + say_verbose "$download_error_msg" + return 1 + fi + return 0 +} + + +# Updates global variables $http_code and $download_error_msg +downloadwget() { + eval $invocation + unset http_code + unset download_error_msg + local remote_path="$1" + local out_path="${2:-}" + # Append feed_credential as late as possible before calling wget to avoid logging feed_credential + local remote_path_with_credential="${remote_path}${feed_credential}" + local wget_options="--tries 20 " + + local wget_options_extra='' + local wget_result='' + + # Test for options that aren't supported on all wget implementations. + if [[ $(wget -h 2>&1 | grep -E 'waitretry|connect-timeout') ]]; then + wget_options_extra="--waitretry 2 --connect-timeout 15 " + else + say "wget extra options are unavailable for this environment" + fi + + if [ -z "$out_path" ]; then + wget -q $wget_options $wget_options_extra -O - "$remote_path_with_credential" 2>&1 + wget_result=$? + else + wget $wget_options $wget_options_extra -O "$out_path" "$remote_path_with_credential" 2>&1 + wget_result=$? + fi + + if [[ $wget_result != 0 ]]; then + local disable_feed_credential=false + local response=$(get_http_header_wget $remote_path $disable_feed_credential) + http_code=$( echo "$response" | awk '/^ HTTP/{print $2}' | tail -1 ) + download_error_msg="Unable to download $remote_path." + if [[ ! -z $http_code && $http_code != 2* ]]; then + download_error_msg+=" Returned HTTP status code: $http_code." + # wget exit code 4 stands for network-issue + elif [[ $wget_result == 4 ]]; then + download_error_msg+=" Failed to reach the server: connection timeout." + fi + say_verbose "$download_error_msg" + return 1 + fi + + return 0 +} + +get_download_link_from_aka_ms() { + eval $invocation + + #quality is not supported for LTS or STS channel + #STS maps to current + if [[ ! -z "$normalized_quality" && ("$normalized_channel" == "LTS" || "$normalized_channel" == "STS") ]]; then + normalized_quality="" + say_warning "Specifying quality for STS or LTS channel is not supported, the quality will be ignored." + fi + + say_verbose "Retrieving primary payload URL from aka.ms for channel: '$normalized_channel', quality: '$normalized_quality', product: '$normalized_product', os: '$normalized_os', architecture: '$normalized_architecture'." + + #construct aka.ms link + aka_ms_link="https://aka.ms/dotnet" + if [ "$internal" = true ]; then + aka_ms_link="$aka_ms_link/internal" + fi + aka_ms_link="$aka_ms_link/$normalized_channel" + if [[ ! -z "$normalized_quality" ]]; then + aka_ms_link="$aka_ms_link/$normalized_quality" + fi + aka_ms_link="$aka_ms_link/$normalized_product-$normalized_os-$normalized_architecture.tar.gz" + say_verbose "Constructed aka.ms link: '$aka_ms_link'." + + #get HTTP response + #do not pass credentials as a part of the $aka_ms_link and do not apply credentials in the get_http_header function + #otherwise the redirect link would have credentials as well + #it would result in applying credentials twice to the resulting link and thus breaking it, and in echoing credentials to the output as a part of redirect link + disable_feed_credential=true + response="$(get_http_header $aka_ms_link $disable_feed_credential)" + + say_verbose "Received response: $response" + # Get results of all the redirects. + http_codes=$( echo "$response" | awk '$1 ~ /^HTTP/ {print $2}' ) + # They all need to be 301, otherwise some links are broken (except for the last, which is not a redirect but 200 or 404). + broken_redirects=$( echo "$http_codes" | sed '$d' | grep -v '301' ) + + # All HTTP codes are 301 (Moved Permanently), the redirect link exists. + if [[ -z "$broken_redirects" ]]; then + aka_ms_download_link=$( echo "$response" | awk '$1 ~ /^Location/{print $2}' | tail -1 | tr -d '\r') + + if [[ -z "$aka_ms_download_link" ]]; then + say_verbose "The aka.ms link '$aka_ms_link' is not valid: failed to get redirect location." + return 1 + fi + + say_verbose "The redirect location retrieved: '$aka_ms_download_link'." + return 0 + else + say_verbose "The aka.ms link '$aka_ms_link' is not valid: received HTTP code: $(echo "$broken_redirects" | paste -sd "," -)." + return 1 + fi +} + +get_feeds_to_use() +{ + feeds=( + "https://dotnetcli.azureedge.net/dotnet" + "https://dotnetbuilds.azureedge.net/public" + ) + + if [[ -n "$azure_feed" ]]; then + feeds=("$azure_feed") + fi + + if [[ "$no_cdn" == "true" ]]; then + feeds=( + "https://dotnetcli.blob.core.windows.net/dotnet" + "https://dotnetbuilds.blob.core.windows.net/public" + ) + + if [[ -n "$uncached_feed" ]]; then + feeds=("$uncached_feed") + fi + fi +} + +# THIS FUNCTION MAY EXIT (if the determined version is already installed). +generate_download_links() { + + download_links=() + specific_versions=() + effective_versions=() + link_types=() + + # If generate_akams_links returns false, no fallback to old links. Just terminate. + # This function may also 'exit' (if the determined version is already installed). + generate_akams_links || return + + # Check other feeds only if we haven't been able to find an aka.ms link. + if [[ "${#download_links[@]}" -lt 1 ]]; then + for feed in ${feeds[@]} + do + # generate_regular_links may also 'exit' (if the determined version is already installed). + generate_regular_links $feed || return + done + fi + + if [[ "${#download_links[@]}" -eq 0 ]]; then + say_err "Failed to resolve the exact version number." + return 1 + fi + + say_verbose "Generated ${#download_links[@]} links." + for link_index in ${!download_links[@]} + do + say_verbose "Link $link_index: ${link_types[$link_index]}, ${effective_versions[$link_index]}, ${download_links[$link_index]}" + done +} + +# THIS FUNCTION MAY EXIT (if the determined version is already installed). +generate_akams_links() { + local valid_aka_ms_link=true; + + normalized_version="$(to_lowercase "$version")" + if [[ "$normalized_version" != "latest" ]] && [ -n "$normalized_quality" ]; then + say_err "Quality and Version options are not allowed to be specified simultaneously. See https://learn.microsoft.com/dotnet/core/tools/dotnet-install-script#options for details." + return 1 + fi + + if [[ -n "$json_file" || "$normalized_version" != "latest" ]]; then + # aka.ms links are not needed when exact version is specified via command or json file + return + fi + + get_download_link_from_aka_ms || valid_aka_ms_link=false + + if [[ "$valid_aka_ms_link" == true ]]; then + say_verbose "Retrieved primary payload URL from aka.ms link: '$aka_ms_download_link'." + say_verbose "Downloading using legacy url will not be attempted." + + download_link=$aka_ms_download_link + + #get version from the path + IFS='/' + read -ra pathElems <<< "$download_link" + count=${#pathElems[@]} + specific_version="${pathElems[count-2]}" + unset IFS; + say_verbose "Version: '$specific_version'." + + #Retrieve effective version + effective_version="$(get_specific_product_version "$azure_feed" "$specific_version" "$download_link")" + + # Add link info to arrays + download_links+=($download_link) + specific_versions+=($specific_version) + effective_versions+=($effective_version) + link_types+=("aka.ms") + + # Check if the SDK version is already installed. + if [[ "$dry_run" != true ]] && is_dotnet_package_installed "$install_root" "$asset_relative_path" "$effective_version"; then + say "$asset_name with version '$effective_version' is already installed." + exit 0 + fi + + return 0 + fi + + # if quality is specified - exit with error - there is no fallback approach + if [ ! -z "$normalized_quality" ]; then + say_err "Failed to locate the latest version in the channel '$normalized_channel' with '$normalized_quality' quality for '$normalized_product', os: '$normalized_os', architecture: '$normalized_architecture'." + say_err "Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support." + return 1 + fi + say_verbose "Falling back to latest.version file approach." +} + +# THIS FUNCTION MAY EXIT (if the determined version is already installed) +# args: +# feed - $1 +generate_regular_links() { + local feed="$1" + local valid_legacy_download_link=true + + specific_version=$(get_specific_version_from_version "$feed" "$channel" "$normalized_architecture" "$version" "$json_file") || specific_version='0' + + if [[ "$specific_version" == '0' ]]; then + say_verbose "Failed to resolve the specific version number using feed '$feed'" + return + fi + + effective_version="$(get_specific_product_version "$feed" "$specific_version")" + say_verbose "specific_version=$specific_version" + + download_link="$(construct_download_link "$feed" "$channel" "$normalized_architecture" "$specific_version" "$normalized_os")" + say_verbose "Constructed primary named payload URL: $download_link" + + # Add link info to arrays + download_links+=($download_link) + specific_versions+=($specific_version) + effective_versions+=($effective_version) + link_types+=("primary") + + legacy_download_link="$(construct_legacy_download_link "$feed" "$channel" "$normalized_architecture" "$specific_version")" || valid_legacy_download_link=false + + if [ "$valid_legacy_download_link" = true ]; then + say_verbose "Constructed legacy named payload URL: $legacy_download_link" + + download_links+=($legacy_download_link) + specific_versions+=($specific_version) + effective_versions+=($effective_version) + link_types+=("legacy") + else + legacy_download_link="" + say_verbose "Cound not construct a legacy_download_link; omitting..." + fi + + # Check if the SDK version is already installed. + if [[ "$dry_run" != true ]] && is_dotnet_package_installed "$install_root" "$asset_relative_path" "$effective_version"; then + say "$asset_name with version '$effective_version' is already installed." + exit 0 + fi +} + +print_dry_run() { + + say "Payload URLs:" + + for link_index in "${!download_links[@]}" + do + say "URL #$link_index - ${link_types[$link_index]}: ${download_links[$link_index]}" + done + + resolved_version=${specific_versions[0]} + repeatable_command="./$script_name --version "\""$resolved_version"\"" --install-dir "\""$install_root"\"" --architecture "\""$normalized_architecture"\"" --os "\""$normalized_os"\""" + + if [ ! -z "$normalized_quality" ]; then + repeatable_command+=" --quality "\""$normalized_quality"\""" + fi + + if [[ "$runtime" == "dotnet" ]]; then + repeatable_command+=" --runtime "\""dotnet"\""" + elif [[ "$runtime" == "aspnetcore" ]]; then + repeatable_command+=" --runtime "\""aspnetcore"\""" + fi + + repeatable_command+="$non_dynamic_parameters" + + if [ -n "$feed_credential" ]; then + repeatable_command+=" --feed-credential "\"""\""" + fi + + say "Repeatable invocation: $repeatable_command" +} + +calculate_vars() { + eval $invocation + + script_name=$(basename "$0") + normalized_architecture="$(get_normalized_architecture_from_architecture "$architecture")" + say_verbose "Normalized architecture: '$normalized_architecture'." + normalized_os="$(get_normalized_os "$user_defined_os")" + say_verbose "Normalized OS: '$normalized_os'." + normalized_quality="$(get_normalized_quality "$quality")" + say_verbose "Normalized quality: '$normalized_quality'." + normalized_channel="$(get_normalized_channel "$channel")" + say_verbose "Normalized channel: '$normalized_channel'." + normalized_product="$(get_normalized_product "$runtime")" + say_verbose "Normalized product: '$normalized_product'." + install_root="$(resolve_installation_path "$install_dir")" + say_verbose "InstallRoot: '$install_root'." + + normalized_architecture="$(get_normalized_architecture_for_specific_sdk_version "$version" "$normalized_channel" "$normalized_architecture")" + + if [[ "$runtime" == "dotnet" ]]; then + asset_relative_path="shared/Microsoft.NETCore.App" + asset_name=".NET Core Runtime" + elif [[ "$runtime" == "aspnetcore" ]]; then + asset_relative_path="shared/Microsoft.AspNetCore.App" + asset_name="ASP.NET Core Runtime" + elif [ -z "$runtime" ]; then + asset_relative_path="sdk" + asset_name=".NET Core SDK" + fi + + get_feeds_to_use +} + +install_dotnet() { + eval $invocation + local download_failed=false + local download_completed=false + local remote_file_size=0 + + mkdir -p "$install_root" + zip_path="${zip_path:-$(mktemp "$temporary_file_template")}" + say_verbose "Zip path: $zip_path" + + for link_index in "${!download_links[@]}" + do + download_link="${download_links[$link_index]}" + specific_version="${specific_versions[$link_index]}" + effective_version="${effective_versions[$link_index]}" + link_type="${link_types[$link_index]}" + + say "Attempting to download using $link_type link $download_link" + + # The download function will set variables $http_code and $download_error_msg in case of failure. + download_failed=false + download "$download_link" "$zip_path" 2>&1 || download_failed=true + + if [ "$download_failed" = true ]; then + case $http_code in + 404) + say "The resource at $link_type link '$download_link' is not available." + ;; + *) + say "Failed to download $link_type link '$download_link': $download_error_msg" + ;; + esac + rm -f "$zip_path" 2>&1 && say_verbose "Temporary zip file $zip_path was removed" + else + download_completed=true + break + fi + done + + if [[ "$download_completed" == false ]]; then + say_err "Could not find \`$asset_name\` with version = $specific_version" + say_err "Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support" + return 1 + fi + + remote_file_size="$(get_remote_file_size "$download_link")" + + say "Extracting zip from $download_link" + extract_dotnet_package "$zip_path" "$install_root" "$remote_file_size" || return 1 + + # Check if the SDK version is installed; if not, fail the installation. + # if the version contains "RTM" or "servicing"; check if a 'release-type' SDK version is installed. + if [[ $specific_version == *"rtm"* || $specific_version == *"servicing"* ]]; then + IFS='-' + read -ra verArr <<< "$specific_version" + release_version="${verArr[0]}" + unset IFS; + say_verbose "Checking installation: version = $release_version" + if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$release_version"; then + say "Installed version is $effective_version" + return 0 + fi + fi + + # Check if the standard SDK version is installed. + say_verbose "Checking installation: version = $effective_version" + if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$effective_version"; then + say "Installed version is $effective_version" + return 0 + fi + + # Version verification failed. More likely something is wrong either with the downloaded content or with the verification algorithm. + say_err "Failed to verify the version of installed \`$asset_name\`.\nInstallation source: $download_link.\nInstallation location: $install_root.\nReport the bug at https://github.com/dotnet/install-scripts/issues." + say_err "\`$asset_name\` with version = $effective_version failed to install with an error." + return 1 +} + +args=("$@") + +local_version_file_relative_path="/.version" +bin_folder_relative_path="" +temporary_file_template="${TMPDIR:-/tmp}/dotnet.XXXXXXXXX" + +channel="LTS" +version="Latest" +json_file="" +install_dir="" +architecture="" +dry_run=false +no_path=false +no_cdn=false +azure_feed="" +uncached_feed="" +feed_credential="" +verbose=false +runtime="" +runtime_id="" +quality="" +internal=false +override_non_versioned_files=true +non_dynamic_parameters="" +user_defined_os="" + +while [ $# -ne 0 ] +do + name="$1" + case "$name" in + -c|--channel|-[Cc]hannel) + shift + channel="$1" + ;; + -v|--version|-[Vv]ersion) + shift + version="$1" + ;; + -q|--quality|-[Qq]uality) + shift + quality="$1" + ;; + --internal|-[Ii]nternal) + internal=true + non_dynamic_parameters+=" $name" + ;; + -i|--install-dir|-[Ii]nstall[Dd]ir) + shift + install_dir="$1" + ;; + --arch|--architecture|-[Aa]rch|-[Aa]rchitecture) + shift + architecture="$1" + ;; + --os|-[Oo][SS]) + shift + user_defined_os="$1" + ;; + --shared-runtime|-[Ss]hared[Rr]untime) + say_warning "The --shared-runtime flag is obsolete and may be removed in a future version of this script. The recommended usage is to specify '--runtime dotnet'." + if [ -z "$runtime" ]; then + runtime="dotnet" + fi + ;; + --runtime|-[Rr]untime) + shift + runtime="$1" + if [[ "$runtime" != "dotnet" ]] && [[ "$runtime" != "aspnetcore" ]]; then + say_err "Unsupported value for --runtime: '$1'. Valid values are 'dotnet' and 'aspnetcore'." + if [[ "$runtime" == "windowsdesktop" ]]; then + say_err "WindowsDesktop archives are manufactured for Windows platforms only." + fi + exit 1 + fi + ;; + --dry-run|-[Dd]ry[Rr]un) + dry_run=true + ;; + --no-path|-[Nn]o[Pp]ath) + no_path=true + non_dynamic_parameters+=" $name" + ;; + --verbose|-[Vv]erbose) + verbose=true + non_dynamic_parameters+=" $name" + ;; + --no-cdn|-[Nn]o[Cc]dn) + no_cdn=true + non_dynamic_parameters+=" $name" + ;; + --azure-feed|-[Aa]zure[Ff]eed) + shift + azure_feed="$1" + non_dynamic_parameters+=" $name "\""$1"\""" + ;; + --uncached-feed|-[Uu]ncached[Ff]eed) + shift + uncached_feed="$1" + non_dynamic_parameters+=" $name "\""$1"\""" + ;; + --feed-credential|-[Ff]eed[Cc]redential) + shift + feed_credential="$1" + #feed_credential should start with "?", for it to be added to the end of the link. + #adding "?" at the beginning of the feed_credential if needed. + [[ -z "$(echo $feed_credential)" ]] || [[ $feed_credential == \?* ]] || feed_credential="?$feed_credential" + ;; + --runtime-id|-[Rr]untime[Ii]d) + shift + runtime_id="$1" + non_dynamic_parameters+=" $name "\""$1"\""" + say_warning "Use of --runtime-id is obsolete and should be limited to the versions below 2.1. To override architecture, use --architecture option instead. To override OS, use --os option instead." + ;; + --jsonfile|-[Jj][Ss]on[Ff]ile) + shift + json_file="$1" + ;; + --skip-non-versioned-files|-[Ss]kip[Nn]on[Vv]ersioned[Ff]iles) + override_non_versioned_files=false + non_dynamic_parameters+=" $name" + ;; + --keep-zip|-[Kk]eep[Zz]ip) + keep_zip=true + non_dynamic_parameters+=" $name" + ;; + --zip-path|-[Zz]ip[Pp]ath) + shift + zip_path="$1" + ;; + -?|--?|-h|--help|-[Hh]elp) + script_name="$(basename "$0")" + echo ".NET Tools Installer" + echo "Usage: $script_name [-c|--channel ] [-v|--version ] [-p|--prefix ]" + echo " $script_name -h|-?|--help" + echo "" + echo "$script_name is a simple command line interface for obtaining dotnet cli." + echo " Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:" + echo " - The SDK needs to be installed without user interaction and without admin rights." + echo " - The SDK installation doesn't need to persist across multiple CI runs." + echo " To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer." + echo "" + echo "Options:" + echo " -c,--channel Download from the channel specified, Defaults to \`$channel\`." + echo " -Channel" + echo " Possible values:" + echo " - STS - the most recent Standard Term Support release" + echo " - LTS - the most recent Long Term Support release" + echo " - 2-part version in a format A.B - represents a specific release" + echo " examples: 2.0; 1.0" + echo " - 3-part version in a format A.B.Cxx - represents a specific SDK release" + echo " examples: 5.0.1xx, 5.0.2xx." + echo " Supported since 5.0 release" + echo " Warning: Value 'Current' is deprecated for the Channel parameter. Use 'STS' instead." + echo " Note: The version parameter overrides the channel parameter when any version other than 'latest' is used." + echo " -v,--version Use specific VERSION, Defaults to \`$version\`." + echo " -Version" + echo " Possible values:" + echo " - latest - the latest build on specific channel" + echo " - 3-part version in a format A.B.C - represents specific version of build" + echo " examples: 2.0.0-preview2-006120; 1.1.0" + echo " -q,--quality Download the latest build of specified quality in the channel." + echo " -Quality" + echo " The possible values are: daily, signed, validated, preview, GA." + echo " Works only in combination with channel. Not applicable for STS and LTS channels and will be ignored if those channels are used." + echo " For SDK use channel in A.B.Cxx format. Using quality for SDK together with channel in A.B format is not supported." + echo " Supported since 5.0 release." + echo " Note: The version parameter overrides the channel parameter when any version other than 'latest' is used, and therefore overrides the quality." + echo " --internal,-Internal Download internal builds. Requires providing credentials via --feed-credential parameter." + echo " --feed-credential Token to access Azure feed. Used as a query string to append to the Azure feed." + echo " -FeedCredential This parameter typically is not specified." + echo " -i,--install-dir Install under specified location (see Install Location below)" + echo " -InstallDir" + echo " --architecture Architecture of dotnet binaries to be installed, Defaults to \`$architecture\`." + echo " --arch,-Architecture,-Arch" + echo " Possible values: x64, arm, arm64, s390x, ppc64le and loongarch64" + echo " --os Specifies operating system to be used when selecting the installer." + echo " Overrides the OS determination approach used by the script. Supported values: osx, linux, linux-musl, freebsd, rhel.6." + echo " In case any other value is provided, the platform will be determined by the script based on machine configuration." + echo " Not supported for legacy links. Use --runtime-id to specify platform for legacy links." + echo " Refer to: https://aka.ms/dotnet-os-lifecycle for more information." + echo " --runtime Installs a shared runtime only, without the SDK." + echo " -Runtime" + echo " Possible values:" + echo " - dotnet - the Microsoft.NETCore.App shared runtime" + echo " - aspnetcore - the Microsoft.AspNetCore.App shared runtime" + echo " --dry-run,-DryRun Do not perform installation. Display download link." + echo " --no-path, -NoPath Do not set PATH for the current process." + echo " --verbose,-Verbose Display diagnostics information." + echo " --azure-feed,-AzureFeed For internal use only." + echo " Allows using a different storage to download SDK archives from." + echo " This parameter is only used if --no-cdn is false." + echo " --uncached-feed,-UncachedFeed For internal use only." + echo " Allows using a different storage to download SDK archives from." + echo " This parameter is only used if --no-cdn is true." + echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable." + echo " -SkipNonVersionedFiles" + echo " --no-cdn,-NoCdn Disable downloading from the Azure CDN, and use the uncached feed directly." + echo " --jsonfile Determines the SDK version from a user specified global.json file." + echo " Note: global.json must have a value for 'SDK:Version'" + echo " --keep-zip,-KeepZip If set, downloaded file is kept." + echo " --zip-path, -ZipPath If set, downloaded file is stored at the specified path." + echo " -?,--?,-h,--help,-Help Shows this help message" + echo "" + echo "Install Location:" + echo " Location is chosen in following order:" + echo " - --install-dir option" + echo " - Environmental variable DOTNET_INSTALL_DIR" + echo " - $HOME/.dotnet" + exit 0 + ;; + *) + say_err "Unknown argument \`$name\`" + exit 1 + ;; + esac + + shift +done + +say_verbose "Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:" +say_verbose "- The SDK needs to be installed without user interaction and without admin rights." +say_verbose "- The SDK installation doesn't need to persist across multiple CI runs." +say_verbose "To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer.\n" + +if [ "$internal" = true ] && [ -z "$(echo $feed_credential)" ]; then + message="Provide credentials via --feed-credential parameter." + if [ "$dry_run" = true ]; then + say_warning "$message" + else + say_err "$message" + exit 1 + fi +fi + +check_min_reqs +calculate_vars +# generate_regular_links call below will 'exit' if the determined version is already installed. +generate_download_links + +if [[ "$dry_run" = true ]]; then + print_dry_run + exit 0 +fi + +install_dotnet + +bin_path="$(get_absolute_path "$(combine_paths "$install_root" "$bin_folder_relative_path")")" +if [ "$no_path" = false ]; then + say "Adding to current process PATH: \`$bin_path\`. Note: This change will be visible only when sourcing script." + export PATH="$bin_path":"$PATH" +else + say "Binaries of dotnet can be found in $bin_path" +fi + +say "Note that the script does not resolve dependencies during installation." +say "To check the list of dependencies, go to https://learn.microsoft.com/dotnet/core/install, select your operating system and check the \"Dependencies\" section." +say "Installation finished successfully." diff --git a/automataCI/services/publishers/dotnet.ps1 b/automataCI/services/publishers/dotnet.ps1 new file mode 100644 index 0000000..19329da --- /dev/null +++ b/automataCI/services/publishers/dotnet.ps1 @@ -0,0 +1,268 @@ +# 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\io\net\http.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\zip.ps1" + + + + +function DOTNET-Add { + param( + [string]$___order, + [string]$___version, + [string]$___destination, + [string]$___extractions + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___order}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${___version}") -eq 0) { + $___version = "latest" + } + $___version = STRINGS-To-Lowercase "${___version}" + + + # execute + ## configure settings + $___pkg = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}\${env:PROJECT_PATH_NUPKG}" + $___pkg = "${___pkg}\${___order}_${___version}" + if ($___version -eq "latest") { + $null = FS-Remove-Silently "${___pkg}" + } + + ## begin sourcing nupkg + $___process = FS-Is-File "${___pkg}/nupkg.zip" + if ($___process -ne 0) { + $___order = "https://www.nuget.org/api/v2/package/${___order}" + if ($___version -ne "latest") { + $___order = "${___order}/${___version}" + } + + $null = FS-Make-Directory "${___pkg}" + $___process = HTTP-Download "GET" "${___order}" "${___pkg}\nupkg.zip" + if ($___process -ne 0) { + FS-Remove-Silently "${___pkg}" + return 1 + } + + $___process = FS-Is-File "${___pkg}/nupkg.zip" + if ($___process -ne 0) { + FS-Remove-Silently "${___pkg}" + return 1 + } + + $___process = ZIP-Extract "${___pkg}" "${___pkg}/nupkg.zip" + if ($___process -ne 0) { + FS-Remove-Silently "${___pkg}" + return 1 + } + } + + + ## begin extraction + if ($(STRINGS-Is-Empty "${___extractions}") -eq 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${___destination}") -eq 0) { + return 1 + } + + $___process = FS-Is-File "${___destination}" + if ($___process -eq 0) { + return 1 + } + $null = FS-Make-Directory "${___destination}" + + foreach ($___target in ($___extractions -split "\|")) { + $___src = "${___pkg}\${___target}" + $___dest = "${___destination}\$(Split-Path -Leaf -Path "${___target}")" + + $___process = FS-Is-File "${___src}" + if ($___process -ne 0) { + return 1 + } + + $null = FS-Remove-Silently "${___dest}" + $___process = FS-Copy-File "${___src}" "${___dest}" + if ($___process -ne 0) { + return 1 + } + } + + + # report status + return 0 +} + + + + +function DOTNET-Activate-Environment { + # validate input + $___process = DOTNET-Is-Available + if ($___process -ne 0) { + return 1 + } + + $___process = DOTNET-Is-Activated + if ($___process -eq 0) { + return 0 + } + + + # execute + ${env:DOTNET_ROOT} = "$(DOTNET-Get-Path-Root)" + ${env:PATH} += ";${env:DOTNET_ROOT};${env:DOTNET_ROOT}\bin" + + + # report + $___process = DOTNET-Is-Activated + if ($___process -ne 0) { + return 1 + } + + return 0 +} + + + + +function DOTNET-Get-Path-Bin { + # report status + return "$(DOTNET-Get-Path-Root)\bin" +} + + + + +function DOTNET-Get-Path-Root { + # report status + return "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}\${env:PROJECT_PATH_DOTNET_ENGINE}" +} + + + + +function DOTNET-Install { + param( + [string]$___order + ) + + + # validate input + $___process = DOTNET-Is-Available + if ($___process -ne 0) { + return 1 + } + + $null = DOTNET-Activate-Environment + $___process = DOTNET-Is-Activated + if ($___process -ne 0) { + return 1 + } + + + # execute + $___arguments = "tool install --tool-path `"$(DOTNET-Get-Path-Bin)`" ${___order}" + $___process = Start-Process -Wait -NoNewWindow -PassThru ` + -FilePath "$(DOTNET-Get-Path-Root)\dotnet.exe" ` + -ArgumentList "${___arguments}" + if ($___process.ExitCode -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function DOTNET-Is-Activated { + # execute + if ($(STRINGS-Is-Empty "${env:DOTNET_ROOT}") -eq 0) { + return 1 + } + + $___process = OS-Is-Command-Available "dotnet" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function DOTNET-Is-Available { + # execute + $___process = FS-Is-Directory "$(DOTNET-Get-Path-Root)" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "$(DOTNET-Get-Path-Root)\dotnet.exe" + if ($___process -eq 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function DOTNET-Setup { + # validate input + $___process = DOTNET-Is-Available + if ($___process -eq 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_DOTNET_CHANNEL}") -eq 0) { + return 1 + } + + + # execute + $___arguments = "-ExecutionPolicy RemoteSigned " ` + + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\publishers\dotnet-install.ps1 " ` + + "-Channel ${env:PROJECT_DOTNET_CHANNEL} " ` + + "-InstallDir `"$(DOTNET-Get-Path-Root)`"" + $___process = OS-Exec "powershell" "${___arguments}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "$(DOTNET-Get-Path-Root)\dotnet.exe" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/publishers/dotnet.sh b/automataCI/services/publishers/dotnet.sh new file mode 100644 index 0000000..35011b5 --- /dev/null +++ b/automataCI/services/publishers/dotnet.sh @@ -0,0 +1,267 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/net/http.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/archive/zip.sh" + + + + +DOTNET_Add() { + ___order="$1" + ___version="$2" + ___destination="$3" + ___extractions="$4" + + + # validate input + if [ $(STRINGS_Is_Empty "$___order") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$___version") -eq 0 ]; then + ___version="latest" + fi + ___version="$(STRINGS_To_Lowercase "${___version}")" + + + # execute + ___pkg="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/${PROJECT_PATH_NUPKG}" + ___pkg="${___pkg}/${___order}_${___version}" + if [ "$___version" = "latest" ]; then + FS_Remove_Silently "$___pkg" + fi + + ## begin sourcing nupkg + FS_Is_File "${___pkg}/nupkg.zip" + if [ $? -ne 0 ]; then + ___order="https://www.nuget.org/api/v2/package/${___order}" + if [ ! "$___version" = "latest" ]; then + ___order="${___order}/${___version}" + fi + + FS_Make_Directory "$___pkg" + HTTP_Download "GET" "$___order" "${___pkg}/nupkg.zip" + if [ $? -ne 0 ]; then + FS_Remove_Silently "$___pkg" + return 1 + fi + + FS_Is_File "${___pkg}/nupkg.zip" + if [ $? -ne 0 ]; then + FS_Remove_Silently "$___pkg" + return 1 + fi + + ZIP_Extract "$___pkg" "${___pkg}/nupkg.zip" + if [ $? -ne 0 ]; then + FS_Remove_Silently "$___pkg" + return 1 + fi + fi + + ## begin extraction + if [ $(STRINGS_Is_Empty "$___extractions") -eq 0 ]; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$___destination") -eq 0 ]; then + return 1 + fi + + FS_Is_File "$___destination" + if [ $? -eq 0 ]; then + return 1 + fi + FS_Make_Directory "$___destination" + + while [ $(STRINGS_Is_Empty "$___extractions") -ne 0 ]; do + ___target="${___extractions%%|*}" + ___src="${___pkg}/${___target}" + ___dest="${___destination}/${___target##*/}" + + FS_Is_File "$___src" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Remove_Silently "$___dest" + FS_Copy_File "$___src" "$___dest" + if [ $? -ne 0 ]; then + return 1 + fi + + ### update for next extraction + ___extractions="${___extractions#*|}" + if [ "$___target" = "$___extractions" ]; then + break + fi + done + + + # report status + return 0 +} + + + + +DOTNET_Activate_Environment() { + # validate input + DOTNET_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + DOTNET_Is_Activated + if [ $? -eq 0 ]; then + return 1 + fi + + + # execute + DOTNET_ROOT="$(DOTNET_Get_Path_Root)" + DOTNET_CLI_TELEMETRY_OPTOUT=1 + alias dotnet="$(DOTNET_Get_Path_Root)/dotnet" + + + # report status + DOTNET_Is_Activated + if [ $? -ne 0 ]; then + return 1 + fi + + return 0 +} + + + + +DOTNET_Get_Path_Bin() { + # execute + printf -- "%b" "${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/dotnet-engine/bin" + + + # report status + return 0 +} + + + + +DOTNET_Get_Path_Root() { + # execute + printf -- "%b" "${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/${PROJECT_PATH_DOTNET_ENGINE}" + + + # report status + return 0 +} + + + + +DOTNET_Install() { + #__order="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + DOTNET_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + DOTNET_Activate_Environment + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + dotnet tool install --tool-path "$(DOTNET::get_path_bin)" "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +DOTNET_Is_Activated() { + # execute + if [ $(STRINGS_Is_Empty "$DOTNET_ROOT") -eq 0 ]; then + return 1 + fi + + "${DOTNET_ROOT}/dotnet" help &> /dev/null + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +DOTNET_Is_Available() { + # execute + FS_Is_File "$(DOTNET_Get_Path_Root)/dotnet" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +DOTNET_Setup() { + # validate input + DOTNET_Is_Available + if [ $? -eq 0 ]; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_DOTNET_CHANNEL") -eq 0 ]; then + return 1 + fi + + + # execute + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/publishers/dotnet-install.sh" \ + --channel "$PROJECT_DOTNET_CHANNEL" \ + --install-dir "$(DOTNET_Get_Path_Root)" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/publishers/github.ps1 b/automataCI/services/publishers/github.ps1 new file mode 100644 index 0000000..539b852 --- /dev/null +++ b/automataCI/services/publishers/github.ps1 @@ -0,0 +1,54 @@ +#!/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. +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" + + + + +function GITHUB-Setup-Actions { + # validate input + if (($(STRINGS-Is-Empty "${env:PROJECT_ROBOT_RUN}") -eq 0) -and + ($(STRINGS-Is-Empty "${env:PROJECT_ROBOT_GITHUB_TOKEN}") -eq 0)) { + return 0 # not a Github Actions run + } + + + # execute + switch ("$(OS-Get)") { + "darwin" { + # OS Image = darwin-latest + } "windows" { + # OS Image = windows-latest + } default { + # OS Image = ubuntu-latest + $___process = OS-Exec "sudo" "add-apt-repository universe" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Exec "sudo" "apt-get update" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Exec "sudo" "apt-get install -y libfuse2" + if ($___process -ne 0) { + return 1 + } + }} + + + # report status + return 0 +} diff --git a/automataCI/services/publishers/github.sh b/automataCI/services/publishers/github.sh new file mode 100644 index 0000000..fe5d64d --- /dev/null +++ b/automataCI/services/publishers/github.sh @@ -0,0 +1,66 @@ +#!/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/strings.sh" + + + + +GITHUB_Setup_Actions() { + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_ROBOT_RUN") -eq 0 ] && + [ $(STRINGS_Is_Empty "$PROJECT_ROBOT_GITHUB_TOKEN") -eq 0 ]; then + return 0 # not a Github Actions run + fi + + + # execute + case "$(OS_Get)" in + darwin) + # OS Image = darwin-latest + ;; + windows) + # OS Image = windows-latest + ;; + *) + # OS Image = ubuntu-latest + + + ## Construct sudo command if unavailable + OS_Is_Command_Available "sudo" + if [ $? -ne 0 ]; then + alias="su root --preserve-environment --command " + fi + + + ## Other UNIX systems including Linux + sudo add-apt-repository universe + if [ $? -ne 0 ]; then + return 1 + fi + + sudo apt-get update + if [ $? -ne 0 ]; then + return 1 + fi + + sudo apt-get install -y libfuse2 + if [ $? -ne 0 ]; then + return 1 + fi + esac + + + # report status + return 0 +} diff --git a/automataCI/services/publishers/homebrew.ps1 b/automataCI/services/publishers/homebrew.ps1 new file mode 100644 index 0000000..8a44dab --- /dev/null +++ b/automataCI/services/publishers/homebrew.ps1 @@ -0,0 +1,86 @@ +# 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" + + + + +function HOMEBREW-Is-Valid-Formula { + param ( + [string]$___target + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { + return 1 + } + + $___process = FS-Is-Target-A-Homebrew "${___target}" + if ($___process -ne 0) { + return 1 + } + + if ($___target -like "*.asc") { + return 1 + } + + + # execute + if ($___target -like "*.rb") { + return 1 + } + + + # report status + return 1 +} + + + + +function HOMEBREW-Publish { + param ( + [string]$___target, + [string]$___destination + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___destination}") -eq 0)) { + return 1 + } + + + # execute + $null = FS-Make-Directory "${___destination}" + $___process = FS-Copy-File ` + "${___target}" ` + "${___destination}\$(Split-Path -Leaf -Path "${___target}")" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function HOMEBREW-Setup { + # report status + return 1 # unsupported +} diff --git a/automataCI/services/publishers/homebrew.sh b/automataCI/services/publishers/homebrew.sh new file mode 100644 index 0000000..ba34251 --- /dev/null +++ b/automataCI/services/publishers/homebrew.sh @@ -0,0 +1,131 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +HOMEBREW_Is_Valid_Formula() { + #___target="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + if [ $(FS_Is_Target_A_Homebrew "$1") -ne 0 ]; then + return 1 + fi + + if [ ! "${1%.asc*}" = "$1" ]; then + return 1 + fi + + + # execute + if [ ! "${1%.rb*}" = "$1" ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +HOMEBREW_Publish() { + #___target="$1" + #___destination="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + + # execute + FS_Make_Housing_Directory "$2" + FS_Copy_File "$1" "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +HOMEBREW_Setup() { + # validate input + OS_Is_Command_Available "curl" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "brew" + if [ $? -eq 0 ]; then + return 0 + fi + + + # execute + /bin/bash -c \ + "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + if [ $? -ne 0 ]; then + return 1 + fi + + case "$PROJECT_OS" in + linux) + ___location="/home/linuxbrew/.linuxbrew/bin/brew" + ;; + darwin) + ___location="/usr/local/bin/brew" + ;; + *) + return 1 + ;; + esac + + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + if [ "$___line" = "eval \"\$(${___location} shellenv)\"" ]; then + unset ___location + break + fi + done < "${HOME}/.bash_profile" + + printf -- "eval \"\$(${___location} shellenv)\"" >> "${HOME}/.bash_profile" + if [ $? -ne 0 ]; then + return 1 + fi + eval "$(${___location} shellenv)" + + OS_Is_Command_Available "brew" + if [ $? -eq 0 ]; then + return 0 + fi + + + # report status + return 1 +} diff --git a/automataCI/services/publishers/microsoft.ps1 b/automataCI/services/publishers/microsoft.ps1 new file mode 100644 index 0000000..e434e03 --- /dev/null +++ b/automataCI/services/publishers/microsoft.ps1 @@ -0,0 +1,288 @@ +# 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\strings.ps1" + + + + +function MICROSOFT-Get-Arch { + param( + [string]$___arch + ) + + + # execute + switch ($___arch) { + i386 { + return "x86" + } mips { + return "MIPs" + } alpha { + return "Alpha" + } powerpc { + return "PowerPC" + } arm { + return "ARM" + } ia64 { + return "ia64" + } amd64 { + return "x64" + } arm64 { + return "ARM64" + } default { + return "" + }} +} + + + + +function MICROSOFT-Is-Available-Software { + param( + [string]$___software, + [string]$___version + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___software}") -eq 0) { + return 1 + } + + + # execute + $null = Import-Module -UseWindowsPowerShell -Name Appx *>$null + $___process = Get-AppxPackage -Name $___software + if (-not $___process) { + return 1 + } + + if ($(STRINGS-Is-Empty "${___software}") -ne 0) { + $___process = $___process | Where-Object { $_.Version -eq $___version } + if (-not $___process) { + return 1 + } + } + + + # report status + return 0 +} + + + + +function MICROSOFT-Is-Available-UIXAML { + param( + [string]$___version + ) + + + # execute + return MICROSOFT-Is-Available-Software "Microsoft.UI.Xaml*" $___version +} + + + + +function MICROSOFT-Is-Available-VCLibs { + param ( + [string]$___version + ) + + + # execute + return MICROSOFT-Is-Available-Software "Microsoft.VCLibs*" $___version +} + + + + +function MICROSOFT-Setup-UIXAML { + param ( + [string]$___version + ) + + + # validate input + $___process = MICROSOFT-Is-Available-UIXAML "${___version}" + if ($___process -eq 0) { + return 0 + } + + + # execute + $___url_bundle = "https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml" + if ($(STRINGS-Is-Empty "${___version}") -ne 0) { + $___url_bundle = "${___url_bundle}/${___version}" + } + $___file_bundle = "msft-ui-xaml" + + $null = Invoke-RestMethod -Uri $___url_bundle -OutFile "${___file_bundle}.zip" + if (-not (Test-Path "${___file_bundle}.zip")) { + return 1 + } + $null = Expand-Archive "${___file_bundle}.zip" + $null = Remove-Item "${___file_bundle}.zip" -ErrorAction SilentlyContinue + + $null = Import-Module -UseWindowsPowerShell -Name Appx *>$null + + $___file_bundle = ".\${___file_bundle}\tools\AppX\x64\Release" + foreach ($___file in (Get-ChildItem -Path "${___file_bundle}")) { + if (-not $___file.Name.EndsWith(".appx")) { + continue + } + + try { + $null = Add-AppxProvisionedPackage ` + -Online ` + -SkipLicense ` + -PackagePath $__file.FullName + $___process = 0 + } catch { + $___process = 1 + } + break + } + $null = Remove-Item "${___file_bundle}" -Force -Recurse -ErrorAction SilentlyContinue + + + # report status + return $___process +} + + + + +function MICROSOFT-Setup-VCLibs { + param ( + [string]$___version + ) + + + # validate input + $___process = MICROSOFT-Is-Available-VCLibs "${___version}" + if ($___process -eq 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${___version}") -ne 0) { + $___version = "14.00" + } + + + # execute + $___url_bundle = "https://aka.ms/Microsoft.VCLibs." + switch (${env:PROJECT_ARCH}) { + amd64 { + $___url_bundle += "x64" + } arm64 { + $___url_bundle += "arm64" + } i386 { + $___url_bundle += "x86" + } arm { + $___url_bundle += "arm" + } default { + return 1 + }} + $___url_bundle += ".${___version}.Desktop.appx" + $___file_bundle = "msft-vclibs.appx" + $null = Invoke-RestMethod -Uri $___url_bundle -OutFile $___file_bundle + try { + $null = Import-Module -UseWindowsPowerShell -Name Appx *>$null + $null = Add-AppxProvisionedPackage ` + -Online ` + -SkipLicense ` + -PackagePath "${___file_bundle}" + $___process = 0 + } catch { + $___process = 1 + } + $null = Remove-Item "${___file_bundle}" -Force -Recurse -ErrorAction SilentlyContinue + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function MICROSOFT-Setup-WINGET { + # validate input + $___process = OS-Is-Command-Available "winget" + if ($___process -eq 0) { + return 0 + } + + $___process = MICROSOFT-Is-Available-VCLibs + if ($___process -ne 0) { + return 1 + } + + $___process = MICROSOFT-Is-Available-UIXAML + if ($___process -ne 0) { + return 1 + } + + + # execute + $___url = "https://api.github.com/repos/microsoft/winget-cli/releases/latest" + $___url = $(Invoke-RestMethod -Uri $___url).assets.browser_download_url + $___url_bundle = $___url | Where-Object { $_.EndsWith(".msixbundle") } + $___file_bundle = "winget.msixbundle" + $___url_license = $___url | Where-Object { $_.EndsWith("_License1.xml") } + $___file_license = "winget-license.xml" + + $null = Invoke-RestMethod -Uri $___url_bundle -OutFile $___file_bundle + if (-not (Test-Path "${___file_bundle}")) { + return 1 + } + + $null = Invoke-RestMethod -Uri $___url_license -OutFile $___file_license + if (-not (Test-Path "${___file_license}")) { + return 1 + } + + try { + $null = Import-Module -UseWindowsPowerShell -Name Appx *>$null + $null = Add-AppxProvisionedPackage ` + -PackagePath $___file_bundle ` + -LicensePath $___file_license ` + -Online + $___process = 0 + } catch { + $___process = 1 + } + $null = Remove-Item $___file_bundle -ErrorAction SilentlyContinue + $null = Remove-Item $___file_license -ErrorAction SilentlyContinue + if ($___process -ne 0) { + return 1 + } + + + # Sleep for letting winget get into the path because the installer is a buggy mess + Start-Sleep -s 5 + $null = OS-Sync + $___process = OS-Is-Command-Available "winget" + if ($___process -eq 0) { + return 0 + } + + + # report status + return 1 +} diff --git a/automataCI/services/publishers/microsoft.sh b/automataCI/services/publishers/microsoft.sh new file mode 100644 index 0000000..1027de7 --- /dev/null +++ b/automataCI/services/publishers/microsoft.sh @@ -0,0 +1,91 @@ +#!/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. +MICROSOFT_Get_Arch() { + # execute + case "$1" in + alpha) + ___value="Alpha" + ;; + amd64) + ___value="x64" + ;; + arm) + ___value="ARM" + ;; + arm64) + ___value="ARM64" + ;; + i386) + ___value="x86" + ;; + ia64) + ___value="ia64" + ;; + mips) + ___value="MIPs" + ;; + powerpc) + ___value="PowerPC" + ;; + *) + ___value="" + ;; + esac + printf -- "%s" "$___value" + + + # report status + return 0 +} + + + + +MICROSOFT_Is_Available_Software() { + return 1 # not applicable +} + + + + +MICROSOFT_Is_Available_UIXAML() { + return 1 # not applicable +} + + + + +MICROSOFT_Is_Available_VCLibs() { + return 1 # not applicable +} + + + + +MICROSOFT_Setup_UIXAML() { + return 1 # not applicable +} + + + + +MICROSOFT_Setup_VCLibs() { + return 1 # not applicable +} + + + + +MICROSOFT_Setup_WINGET() { + return 1 # not applicable +} diff --git a/automataCI/services/publishers/reprepro.ps1 b/automataCI/services/publishers/reprepro.ps1 new file mode 100644 index 0000000..0aca800 --- /dev/null +++ b/automataCI/services/publishers/reprepro.ps1 @@ -0,0 +1,163 @@ +# 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:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1" + + + + +function REPREPRO-Create-Conf { + param( + [string]$__directory, + [string]$__codename, + [string]$__suite, + [string]$__components, + [string]$__architectures, + [string]$__gpg + ) + + + # validate input + if ([string]::IsNullOrEmpty($__directory) -or + [string]::IsNullOrEmpty($__codename) -or + [string]::IsNullOrEmpty($__suite) -or + [string]::IsNullOrEmpty($__components)) { + return 1 + } + + + # execute + $__filename = "${__directory}\conf\distributions" + $null = FS-Make-Housing-Directory "${__filename}" + $null = FS-Remove-Silently "${__filename}" + if ([string]::IsNullOrEmpty($__gpg)) { + $__process = FS-Write-File "${__filename}" @" +Codename: ${__codename} +Suite: ${__suite} +Components: ${__components} +Architectures: +"@ + if ($__process -ne 0) { + return 1 + } + } else { + $__process = FS-Write-File "${__filename}" @" +Codename: ${__codename} +Suite: ${__suite} +Components: ${__components} +SignWith: ${__gpg} +Architectures: +"@ + if ($__process -ne 0) { + return 1 + } + } + + + if ([string]::IsNullOrEmpty($__architectures)) { + $__architectures = @( + "armhf", "armel", "mipsn32", "mipsn32el", "mipsn32r6", + "mipsn32r6el", "mips64", "mips64el", "mips64r6", "mips64r6el", + "powerpcspe", "x32", "arm64ilp32", "alpha", "amd64", + "arc", "armeb", "arm", "arm64", "avr32", + "hppa", "loong64", "i386", "ia64", "m32r", + "m68k", "mips", "mipsel", "mipsr6", "mipsr6el", + "nios2", "or1k", "powerpc", "powerpcel", "ppc64", + "ppc64el", "riscv64", "s390", "s390x", "sh3", + "sh3eb", "sh4", "sh4eb", "sparc", "sparc64", + "tilegx") + $__oses = @( + "linux", "kfreebsd", "knetbsd", "kopensolaris", "hurd", + "darwin", "dragonflybsd", "freebsd", "netbsd", "openbsd", + "aix", "solaris") + + foreach ($__arch in $__architectures) { + $null = FS-Append-File "${__filename}" " ${__arch}" + foreach ($__os in $__oses) { + $null = FS-Append-File "${__filename}" " ${__os}-${__arch}" + } + } + + $null = FS-Append-File "${__filename}" "`n" + } else { + $null = FS-Append-File "${__filename}" " ${__architectures}`n" + } + + + # report status + return 0 +} + + + + +function REPREPRO-Is-Available { + # execute + $__process = OS-Is-Command-Available "reprepro" + if ($__process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function REPREPRO-Publish { + param ( + [string]$__target, + [string]$__directory, + [string]$__datastore, + [string]$__db_directory, + [string]$__codename + ) + + + # validate input + if ([string]::IsNullOrEmpty($__target) -or + [string]::IsNullOrEmpty($__directory) -or + [string]::IsNullOrEmpty($__datastore) -or + [string]::IsNullOrEmpty($__codename) -or + (-not (Test-Path "${__directory}" -PathType Container))) { + return 1 + } + + + # execute + $null = FS-Make-Directory "${__db_directory}" + $null = FS-Make-Directory "${__directory}" + $null = FS-Make-Directory "${__datastore}" + $__arguments = "--basedir `"${__datastore}`" " ` + + "--dbdir `"${__db_directory}`" " ` + + "--outdir `"${__directory}`" " ` + + "includedeb `"${__codename}`" " ` + + "`"${__target}`"" + $__process = OS-Exec "reprepro" "${__arguments}" + + + # report status + if ($__process -eq 0) { + return 0 + } + + return 1 +} + + + + +function REPREPRO-Setup { + return 0 # Windows do not have Reprepro +} diff --git a/automataCI/services/publishers/reprepro.sh b/automataCI/services/publishers/reprepro.sh new file mode 100644 index 0000000..17d6292 --- /dev/null +++ b/automataCI/services/publishers/reprepro.sh @@ -0,0 +1,226 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +REPREPRO_Create_Conf() { + ___directory="$1" + ___codename="$2" + ___suite="$3" + ___components="$4" + ___architectures="$5" + ___gpg="$6" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___codename") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___suite") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___components") -eq 0 ]; then + return 1 + fi + + + # execute + ___filename="${___directory}/conf/distributions" + FS_Make_Housing_Directory "$___filename" + FS_Remove_Silently "$___filename" + if [ $(STRINGS_Is_Empty "$___gpg") -eq 0 ]; then + FS_Write_File "$___filename" "\ +Codename: ${___codename} +Suite: ${___suite} +Components: ${___components} +Architectures:" + if [ $? -ne 0 ]; then + return 1 + fi + else + FS_Write_File "$___filename" "\ +Codename: ${___codename} +Suite: ${___suite} +Components: ${___components} +SignWith: ${___gpg} +Architectures:" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + + if [ $(STRINGS_Is_Empty "$___architectures") -eq 0 ]; then + ___old_IFS="$IFS" + while IFS= read -r ___arch || [ -n "$___arch" ]; do + FS_Append_File "$___filename" " $___arch" + while IFS= read -r ___os || [ -n "$___os" ]; do + FS_Append_File "$___filename" " ${___os}-${___arch}" + done << EOF +linux +kfreebsd +knetbsd +kopensolaris +hurd +darwin +dragonflybsd +freebsd +netbsd +openbsd +aix +solaris +EOF + done << EOF +armhf +armel +mipsn32 +mipsn32el +mipsn32r6 +mipsn32r6el +mips64 +mips64el +mips64r6 +mips64r6el +powerpcspe +x32 +arm64ilp32 +alpha +amd64 +arc +armeb +arm +arm64 +avr32 +hppa +loong64 +i386 +ia64 +m32r +m68k +mips +mipsel +mipsr6 +mipsr6el +nios2 +or1k +powerpc +powerpcel +ppc64 +ppc64el +riscv64 +s390 +s390x +sh3 +sh3eb +sh4 +sh4eb +sparc +sparc64 +tilegx +EOF + IFS="$___old_IFS" && unset ___line ___old_IFS + FS_Append_File "$___filename" "\n" + else + FS_Append_File "$___filename" " ${___architectures}\n" + fi + + + # report status + return 0 +} + + + + +REPREPRO_Is_Available() { + # execute + OS_Is_Command_Available "reprepro" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +REPREPRO_Publish() { + ___target="$1" + ___directory="$2" + ___datastore="$3" + ___db_directory="$4" + ___codename="$5" + + + # validate input + if [ $(STRINGS_Is_Empty "$___target") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___datastore") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___codename") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___directory" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + FS_Make_Directory "${___db_directory}" + FS_Make_Directory "${___directory}" + FS_Make_Directory "${___datastore}" + reprepro --basedir "${___datastore}" \ + --dbdir "${___db_directory}" \ + --outdir "${___directory}" \ + includedeb "${___codename}" \ + "$___target" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +REPREPRO_Setup() { + # validate input + OS_Is_Command_Available "brew" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "reprepro" + if [ $? -eq 0 ]; then + return 0 + fi + + + # execute + brew install reprepro + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/versioners/git.ps1 b/automataCI/services/versioners/git.ps1 new file mode 100644 index 0000000..4bbe961 --- /dev/null +++ b/automataCI/services/versioners/git.ps1 @@ -0,0 +1,543 @@ +# 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\io\strings.ps1" + + + + +function GIT-At-Root-Repo { + param( + [string]$___directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___directory}") -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = FS-Is-File "${___directory}\.git\config" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function GIT-Autonomous-Commit { + param( + [string]$___tracker + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___tracker}") -eq 0) { + return 1 + } + + $___process = GIT-Is-Available + if ($___process -ne 0) { + return 1 + } + + $___process = Invoke-Expression "git status --porcelain" + if ($(STRINGS-Is-Empty "${___process}") -eq 0) { + return 0 # nothing to commit + } + + + # execute + $___process = OS-Exec "git" "add ." + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Exec "git" "commit -m 'automation: published as of ${___tracker}'" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function GIT-Autonomous-Force-Commit { + param( + [string]$___tracker + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___tracker}") -eq 0) { + return 1 + } + + $___process = GIT-Is-Available + if ($___process -ne 0) { + return 1 + } + + $___process = Invoke-Expression "git status --porcelain" + if ($(STRINGS-Is-Empty "${___process}") -eq 0) { + return 0 # nothing to commit + } + + + # execute + $___process = OS-Exec "git" "add ." + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Exec "git" "commit -m 'Publish as of ${___tracker}'" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function GIT-Change-Branch { + param ( + [string]$___branch + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___branch}") -eq 0) { + return 1 + } + + $___process = GIT-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "git" "checkout ${__branch}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function GIT-Clone { + param ( + [string]$___url, + [string]$___name + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___url}") -eq 0) { + return 1 + } + + $___process = GIT-Is-Available + if ($___process -ne 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "$2") -ne 0) { + $___process = FS-Is-File "${___name}" + if ($___process -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___name}" + if ($___process -eq 0) { + return 2 + } + } + + + # execute + if ($(STRINGS-Is-Empty "${___url}") -ne 0) { + $___process = OS-Exec "git" "clone ${___url} ${___name}" + if ($___process -ne 0) { + return 1 + } + } else { + $___process = OS-Exec "git" "clone ${___url}" + if ($___process -ne 0) { + return 1 + } + } + + + # report status + return 0 +} + + + + +function GIT-Clone-Repo { + param( + [string]$___root, + [string]$___relative_path, + [string]$___current, + [string]$___git_repo, + [string]$___simulate, + [string]$___label, + [string]$___branch, + [string]$___reset + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___root}") -eq 0) -or + ($(STRINGS-Is-Empty "${___relative_path}") -eq 0) -or + ($(STRINGS-Is-Empty "${___current}") -eq 0) -or + ($(STRINGS-Is-Empty "${___git_repo}") -eq 0) -or + ($(STRINGS-Is-Empty "${___label}") -eq 0)) { + return 1 + } + + $___process = GIT-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___path = "${___root}\${___relative_path}" + $null = FS-Make-Directory "${___path}" + $___path = "${___path}\${___label}" + + $___process = FS-Is-Directory "${___path}" + if ($___process -eq 0) { + $null = Set-Location "${___path}" + $___directory = GIT-Get-Root-Directory + $null = Set-Location "${___current}" + + if ($___directory -eq $___root) { + $null = FS-Remove-Silently "${___path}" + } + } + + if ($(STRINGS-Is-Empty "${___simulate}") -ne 0) { + $null = FS-Make-Directory "${___path}" + $null = Set-Location "${___path}" + $null = OS-Exec "git" "init --initial-branch=main" + $null = OS-Exec "git" "commit --allow-empty -m `"Initial Commit`"" + $null = Set-Location "${___current}" + return 0 + } else { + $null = Set-Location "$(Split-Path -Parent -Path "${___path}")" + $___process = Git-Clone "${___git_repo}" "${___label}" + switch ($___process) { + { $_ -in 2, 0 } { + # Accepted + } default { + return 1 + }} + $null = Set-Location "${___current}" + } + + + # switch branch if available + if ($(STRINGS-Is-Empty "${___branch}") -ne 0) { + $null = FS-Make-Directory "${___path}" + $___process = GIT-Change-Branch "${___branch}" + if ($___process -ne 0) { + $null = Set-Location "${___current}" + return 1 + } + $null = Set-Location "${___current}" + } + + + # hard reset + if ($(STRINGS-Is-Empty "${___reset}") -ne 0) { + $null = FS-Make-Directory "${___path}" + $___process = GIT-Hard-Reset-To-Init "${___root}" + if ($___process -ne 0) { + $null = Set-Location "${___current}" + return 1 + } + $null = Set-Location "${___current}" + } + + + # report status + return 0 +} + + + + +function GIT-Get-First-Commit-ID { + # validate input + $___process = GIT-Is-Available + if ($___process -ne 0) { + return "" + } + + + # execute + return Invoke-Expression "git rev-list --max-parents=0 --abbrev-commit HEAD" +} + + + + +function GIT-Get-Latest-Commit-ID { + # validate input + $___process = GIT-Is-Available + if ($___process -ne 0) { + return "" + } + + + # execute + return Invoke-Expression "git rev-parse HEAD" +} + + + + +function GIT-Get-Root-Directory { + # validate input + $___process = GIT-Is-Available + if ($___process -ne 0) { + return "" + } +i + + # execute + return Invoke-Expression "git rev-parse --show-toplevel" +} + + + + +function GIT-Hard-Reset-To-Init { + param ( + [string]$___root + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___root}") -eq 0) { + return 1 + } + + $___process = GIT-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # CVE-2023-42798 - Make sure the directory is not the same as the root + # directory. If it does, bail out immediately and DO + # not proceed. + $___first = GIT-Get-Root-Directory + if ($(STRINGS-Is-Empty "${___first}") -eq 0) { + return 1 + } + + if ($___first -eq $___root) { + return 1 + } + + + # execute + $___first = GIT-Get-First-Commit-ID + if ($(STRINGS-Is-Empty "${___first}") -eq 0) { + return 1 + } + + $___process = OS-Exec "git" "reset --hard ${___first}" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Exec "git" "clean -fd" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function GIT-Is-Available { + # execute + $___process = OS-Is-Command-Available "git" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function GIT-Pull-To-Latest { + # validate input + $___process = GIT-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "git" "pull --rebase" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function GIT-Push { + param( + [string]$___repo, + [string]$___branch + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___repo}") -eq 0) -or + ($(STRINGS-Is-Empty "${___repo}") -eq 0)) { + return 1 + } + + $___process = GIT-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "git" "push ${___repo} ${___branch}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function GIT-Remove-Worktree { + param ( + [string]$___destination + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___destination}") -eq 0) { + return 1 + } + + $___process = GIT-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "git" "worktree remove `"${___destination}`"" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Remove-Silently "${___destination}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function GIT-Setup-Worktree { + param ( + [string]$___branch, + [string]$___destination + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___branch}") -eq 0) -or + ($(STRINGS-Is-Empty "${___branch}") -eq 0)) { + return 1 + } + + $___process = GIT-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $null = FS-Make-Directory "${___destination}" + $___process = OS-Exec "git" "worktree add `"${___destination}`" `"${___branch}`"" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/versioners/git.sh b/automataCI/services/versioners/git.sh new file mode 100644 index 0000000..5568c4a --- /dev/null +++ b/automataCI/services/versioners/git.sh @@ -0,0 +1,538 @@ +#!/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/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" + + + + +GIT_At_Root_Repo() { + #___directory="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + FS_Is_File "${1}/.git/config" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GIT_Autonomous_Commit() { + #___tracker="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + GIT_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$(git status --porcelain)") -eq 0 ]; then + return 0 # nothing to commit + fi + + + # execute + git add . + if [ $? -ne 0 ]; then + return 1 + fi + + git commit -m "automation: published as of ${1}" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GIT_Autonomous_Force_Commit() { + #___tracker="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + GIT_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$(git status --porcelain)") -eq 0 ]; then + return 0 # nothing to commit + fi + + + # execute + git add . + if [ $? -ne 0 ]; then + return 1 + fi + + git commit -m "automation: published as of ${1}" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GIT_Change_Branch() { + #___branch="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + GIT_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + git checkout "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GIT_Clone() { + #___url="$1" + #___name="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + GIT_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$2") -ne 0 ]; then + FS_Is_File "$2" + if [ $? -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$2" + if [ $? -eq 0 ]; then + return 2 + fi + fi + + + # execute + if [ $(STRINGS_Is_Empty "$2") -ne 0 ]; then + git clone "$1" "$2" + if [ $? -ne 0 ]; then + return 1 + fi + else + git clone "$1" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + + # report status + return 0 +} + + + + +GIT_Clone_Repo() { + ___root="$1" + ___relative_path="$2" + ___current="$3" + ___git_repo="$4" + ___simulate="$5" + ___label="$6" + ___branch="$7" + ___reset="$8" + + + # validate input + if [ $(STRINGS_Is_Empty "$___root") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___relative_path") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___current") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___git_repo") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___label") -eq 0 ]; then + return 1 + fi + + GIT_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___path="${___root}/${___relative_path}" + FS_Make_Directory "$___path" + ___path="${___path}/${___label}" + + FS_Is_Directory "$___path" + if [ $? -eq 0 ]; then + cd "${___path}" + ___directory="$(GIT_Get_Root_Directory)" + cd "$___current" + + if [ "$___directory" = "$___root" ]; then + FS_Remove_Silently "${___path}" + fi + fi + + + if [ $(STRINGS_Is_Empty "$___simulate") -ne 0 ]; then + FS_Make_Directory "${___path}" + cd "${___path}" + git init --initial-branch=main + git commit --allow-empty -m "Initial Commit" + cd "$___current" + return 0 + else + cd "${___path%/*}" + GIT_Clone "$___git_repo" "$___label" + case $? in + 0|2) + # Accepted + ;; + *) + return 1 + ;; + esac + cd "$___current" + fi + + + # switch branch if available + if [ $(STRINGS_Is_Empty "$___branch") -ne 0 ]; then + cd "${___path}" + GIT_Change_Branch "$___branch" + if [ $? -ne 0 ]; then + cd "$___current" + return 1 + fi + cd "$___current" + fi + + + # hard reset + if [ $(STRINGS_Is_Empty "$___reset") -ne 0 ]; then + cd "${___path}" + GIT_Hard_Reset_To_Init "$___root" + if [ $? -ne 0 ]; then + cd "$___current" + return 1 + fi + cd "$___current" + fi + + + # report status + return 0 +} + + + + +GIT_Get_First_Commit_ID() { + # validate input + GIT_Is_Available + if [ $? -ne 0 ]; then + printf "" + return 1 + fi + + + # execute + printf -- "$(git rev-list --max-parents=0 --abbrev-commit HEAD)" + + + # report status + return 0 +} + + + + +GIT_Get_Latest_Commit_ID() { + # validate input + GIT_Is_Available + if [ $? -ne 0 ]; then + printf "" + return 1 + fi + + + # execute + printf -- "$(git rev-parse HEAD)" + + + # report status + return 0 +} + + + + +GIT_Get_Root_Directory() { + # validate input + GIT_Is_Available + if [ $? -ne 0 ]; then + printf "" + return 1 + fi + + + # execute + printf -- "$(git rev-parse --show-toplevel)" + + + # report status + return 0 +} + + + + +GIT_Hard_Reset_To_Init() { + #___root="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + GIT_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # CVE-2023-42798 - Make sure the directory is not the same as the root + # directory. If it does, bail out immediately and DO + # not proceed. + ___first="$(GIT_Get_Root_Directory)" + if [ $(STRINGS_Is_Empty "$___first") -eq 0 ]; then + return 1 + fi + + if [ "$___first" = "$1" ]; then + return 1 + fi + + + # execute + ___first="$(GIT_Get_First_Commit_ID)" + if [ "$___first" = "" ]; then + return 1 + fi + + git reset --hard "$__first" + if [ $? -ne 0 ]; then + return 1 + fi + + git clean -fd + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GIT_Is_Available() { + # execute + OS_Is_Command_Available "git" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GIT_Pull_To_Latest() { + # validate input + GIT_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + git pull --rebase + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GIT_Push() { + #___repo="$1" + #___branch="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + GIT_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + git push "$1" "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GIT_Remove_Worktree() { + #___destination="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + GIT_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + git worktree remove "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Remove_Silently "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GIT_Setup_Worktree() { + #___branch="$1" + #___destination="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + GIT_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + FS_Make_Directory "$2" + git worktree add "$2" "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +}