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..b8f2960 --- /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_RUN: 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/.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/CONFIG.toml b/CONFIG.toml new file mode 100644 index 0000000..60b0753 --- /dev/null +++ b/CONFIG.toml @@ -0,0 +1,1862 @@ +# 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 = 'hestiakernel' + + +# 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 = 'HestiaKERNEL' + + +# 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. +# +# Some examples: +# 1. 'com.github.[USERNAME].[PROJECT]' (https://github.com/[USERNAME]/[PROJECT]) +# 2. 'com.example.app' (https://app.example.com) +PROJECT_APP_ID = 'com.hollowaykeanho.HestiaKERNEL' + + +# 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 = '627630F4-0814-C1FF-1E18-DDD50A9583DA' + + +# 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 HestiaKERNEL" + + +# PROJECT_PITCH +# A short elevator pitch about the project used as a short description. Max +# Max: 60 characters. +PROJECT_PITCH = 'The no-dependency kernel functions for all Hestia libraries.' + + +# 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 (e.g. RPM) will generate the final +# version number as: '0.0.1-rc1-12312' or '0.0.1-12312'. +# +# When it doubt or unused, set/reset to 1 and only increment when there is an +# actual need. +PROJECT_CADENCE = '1' + + +# PROJECT_LICENSE +# The SPDX license tag. Refer https://spdx.org/licenses/ for finding or +# constructing your license identifier. +PROJECT_LICENSE = 'chewkeanho-liberal' + + +# PROJECT_SCOPE +# The ownership of the project being housed working as a scoping domain. (e.g. +# GitHub Username|Organization Name, NPMJS scope, etc). This is required for +# certain packages' ecosystems such as but not limited to NPM. In certain cases, +# this field is commonly combined with PROJECT_SKU to form the full ID complying +# to '${PROJECT_SCOPE}-${PROJECT_SKU}' pattern. +# +# This field shall not be left empty. +PROJECT_SCOPE = 'chewkeanho' + + +# PROJECT_CONTACT_BRAND +# Contact Entity's short brand name. It should be in lowercase and should not be +# using dash ('-'), underscore ('_'), and space (' ') for maximum compatibility. +PROJECT_CONTACT_BRAND = 'chewkeanho' + + +# PROJECT_CONTACT_BRAND_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://HestiaKERNEL.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/HestiaKERNEL' + + +# PROJECT_SOURCE_GIT_REMOTE +# The git remote tag for the project release publications. This is used for +# sourcing the upstream git configurations. Unless absolute required, this field +# can be left intact. +# +# Default is: 'origin' +PROJECT_SOURCE_GIT_REMOTE = 'origin' + + +# PROJECT_SOURCE_RELEASE_TAG_LATEST +# The tag label for latest release and also a flag to trigger release branches +# strategies. +# +# Default is: 'latest' +# To enable release branch strategy: fill in the label +# To disable: leave it empty ('') +PROJECT_SOURCE_RELEASE_TAG_LATEST = 'latest' + + +# PROJECT_README +# The relative location of the project readme file from $PROJECT_PATH_ROOT +# (repository root directory). +# +# Default is 'README.md' +PROJECT_README = 'README.md' + + +# PROJECT_LICENSE_FILE +# The relative location of the project license file from $PROJECT_PATH_ROOT +# (repository root directory). +# +# Default is 'LICENSE.pdf' +PROJECT_LICENSE_FILE = 'LICENSE.pdf' + + +# PROJECT_LICENSE_ACCEPTANCE_REQUIRED +# The flag to indicate the license of the project **MUST** be explictly +# accepted. This is used in ecosystem like .NET nupkg where a special UI +# is available to interact with the end-users. +# +# Value is lowercase 'true' or 'false'. +# +# Default is 'true' +PROJECT_LICENSE_ACCEPTANCE_REQUIRED = 'true' + + +# AUTOMATACI_LANG +# Overrides AutomataCI to operate in 1 specific language. Otherwise, AutomataCI +# shall query the system language settings. Only accepts language code complying +# 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 a localized virtual environment for +# development automatically. +# +# To enable it: simply supply the path (e.g. 'Angular' for 'Angular/'). +# To disable it: simply supply an empty path (e.g. default is ''). +PROJECT_ANGULAR = '' + + + + +###################### +# BOOK TECHNOLOGY # +###################### +# PROJECT_BOOK +# This is the control variable used for enabling e-book 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 'srcBOOK'). +# To disable it: simply supply an empty path (e.g. default is ''). +PROJECT_BOOK = '' + + + + +###################### +# 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 a localized virtual environment for +# development 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 = '' + + +# PROJECT_C_BRANCH_TAG +# This is for technology tagging purposes such as but not limited to release +# branches identification. The value shall always be lowercase, short, and +# directly identify it is C technology. +# +# Default is: 'c' +# To disable: set it empty '' +PROJECT_C_BRANCH_TAG = 'c' + + + + +###################### +# 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 a localized virtual environment for +# development automatically. +# +# Do note that should the following technologies are enabled, LibreOffice shall +# be installed regardless of this control variable: +# (1) PROJECT_RESEARCH - using Libreoffice by default. +# (2) PROJECT_BOOK - using Libreoffice by default. +# +# To enable it: simply supply the path (e.g. default is 'srcLIBREOFFICE'). +# To disable it: simply supply an empty path (e.g. default is ''). +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://download.documentfoundation.org/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.4.3' for 'LibreOffice 24.4.3' +PROJECT_LIBREOFFICE_VERSION = '24.2.3' + + +# PROJECT_PATH_LIBREOFFICE_ENGINE +# This is a relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_TOOLS for +# setting up localized environment. +PROJECT_PATH_LIBREOFFICE_ENGINE = 'libreoffice-engine' + + + + +###################### +# 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 a localized virtual environment for +# development 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 a localized virtual environment for +# development 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' + + + + +###################### +# NODE TECHNOLOGY # +###################### +# PROJECT_NODE +# This is a control variable used for enabling NodeJS 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 a localized virtual environment for +# development automatically. +# +# To enable it: simply supply the path (e.g. default is 'srcNODE'). +# To disable it: simply supply an empty path (e.g. default is ''). +PROJECT_NODE = '' + + +# PROJECT_PATH_NODE_ENGINE +# This is a relative pathing to PROJECT_PATH_ROOT + PROJECT_PATH_TOOLS for +# setting up localized virtual environment. +PROJECT_PATH_NODE_ENGINE = 'node-engine' + + +# PROJECT_NODE_VERSION +# This is to specify which version of node to be downloaded for the project +# as the localized virtual environment engine. Please refer to: +# https://nodejs.org/en/download/prebuilt-binaries/current +# for values. +# +# Leaving it empty shall set AutomataCI to use the system-level NodeJS +# (e.g: your pre-configured NodeJS). +# +# To enable: specify a version (e.g. 'v22.2.0') +# To disable: keep it empty (''). +PROJECT_NODE_VERSION = 'v22.2.0' + + +# PROJECT_NODE_LOCALIZED +# This is a flag environment variable when a localized virtual environment for +# NodeJS is active. This is useful for detecting which nodeJS engine you're +# currently using for the project in a given terminal. +# +# When active, The variable's value is the pathing to the engine itself. +# +# This variable is reserved by the activator script created autonomously by +# AutomataCI. +#PROJECT_NODE_LOCALIZED - Reserved + + +# PROJECT_NODE_NPM_REGISTRY +# The registry URL for publishing the NPM packages. +# +# The following are identified: +# +# GitHub Packages: 'https://npm.pkg.github.com' +# NPMJS : 'https://registry.npmjs.com' +# +# Default is: 'https://npm.pkg.github.com' +PROJECT_NODE_NPM_REGISTRY = 'https://npm.pkg.github.com' + + +# PROJECT_NODE_BRANCH_TAG +# This is for technology tagging purposes such as but not limited to release +# branches identification. The value shall always be lowercase, short, and +# directly identify it is Node technology. +# +# Default is: 'npm' +# To disable: set it empty '' +PROJECT_NODE_BRANCH_TAG = 'npm' + + + + +###################### +# 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 a localized virtual +# environment for development 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 = '' + + +# PROJECT_RESEARCH_IDENTIFIER +# The file identifier for the compiled output paper file from its peers with the +# same formats (e.g. a bunch of PDFs). This is suffix-ed within the filename +# itself like: +# +# pattern: '${PROJECT_SKU}-${PROJECT_RESEARCH_IDENTIFIER}_v${PROJECT_VERSION}_any-any.pdf' +# example: 'automataci-RESEARCH_v100.00.100_any-any.pdf' +# +# default is: 'RESEARCH' +PROJECT_RESEARCH_IDENTIFIER = '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 - ALL # +########################## +# 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_SIMULATE_RUN +# A flag to indicate this CI job run is to be simulated (or 'dry run'). +# Depending on job, this disables certain non-resersible, critical, or high +# stake tasks (e.g. gpg-signing, release conclusion etc) and replace it with a +# simple simulation run. +# +# It is made primarily for local CI job run testing and for full automated run +# like GitHub Actions or GitLab CI. +# +# To enable, simply declare the environment variable non-empty value (e.g. 'true'). +# To disable: leave it empty. +# +# PROJECT_SIMULATE_RUN = '' # Reserved - provided externally via environment variable. + + +# PROJECT_ROBOT_RUN +# A flag to indicate the run is operating inside a CI service by its +# autonomous robot. +# +# It is made primarily for local CI job run testing and for full automated run +# like GitHub Actions or GitLab CI. +# +# To enable, simply declare the environment variable non-empty value (e.g. 'true'). +# To disable: leave it empty. +# +# PROJECT_ROBOT_RUN = '' # Reserved - provided externally via environment variable. + + +# PROJECT_RELEASE_REPO_TYPE +# The type of release repository. Available options are: +# +# 1. 'git' - git repository +# 2. 'local' - a localized directory (for manual export elsewhere). +# +# Default is 'git'. +# Leaving it empty shall fallback to git repository. +PROJECT_RELEASE_REPO_TYPE = 'git' + + +# PROJECT_RELEASE_REPO +# The URL for setting the ${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE} directory +# as a single unified repository rather than manage each of the release repos +# individually. This is designed for Git-based publishing service providers like +# GitHub/GitLab Pages and etc. +# +# Setting this field shall overrides all the distributions' git url fields +# (e.g. PROJECT_RPM_REPO, PROJECT_DEB_REPO, etc) and will only push to this +# repo at the end of the release job conclusion. +# +# Default is empty '' (favoring flat-mode repositories) +PROJECT_RELEASE_REPO = '' + + +# PROJECT_RELEASE_REPO_KEY +# The git upstream key for PROJECT_RELEASE_REPO. This field cannot be left +# empty. +# +# Default is 'origin'. +PROJECT_RELEASE_REPO_KEY = 'origin' + + +# PROJECT_RELEASE_REPO_BRANCH +# The git upstream branch for PROJECT_RELEASE_REPO. This field cannot be left +# empty. +# +# Default is 'master' or 'main'. +PROJECT_RELEASE_REPO_BRANCH = 'master' + + +# PROJECT_RELEASE_ARCHIVE +# The flag to package archive (.tar.gz | .zip) files as output. +# +# To enable : fill in some string (e.g. 'enabled') +# To disable: leave it empty ('') +PROJECT_RELEASE_ARCHIVE = 'enabled' + + +# PROJECT_RELEASE_IPK +# The flag to package ipk pipeline. +# +# To enable : fill in some string (e.g. 'enabled') +# To disable: leave it empty ('') +PROJECT_RELEASE_IPK = 'enabled' + + + + +############################# +# DISTRIBUTION - CHOCOLATEY # +############################# +# PROJECT_CHOCOLATEY_URL +# The base URL for Chocolatey & end-users to source the .nupkg packages. This +# variable is also acting as a switch to enable/disable Chocolatey distribution +# pipeline. +# +# End user may track your upstream using this URL (as in the command: +# '$ choco source add -n name -s location'). More info: +# (1) https://docs.chocolatey.org/en-us/choco/commands/sources/ +# (2) https://docs.chocolatey.org/en-us/features/host-packages/ +# +# Some examples are: +# (1) GitHub Release: +# value: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download' +# actual URL: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download/[FILE]' +# +# To enable it: set the URL without the ending slash. +# To disable it: set it empty. +# +# !! IMPORTANT !! - Please avoid ending with the URL slash. +PROJECT_CHOCOLATEY_URL = 'https://github.com/ChewKeanHo/HestiaKERNEL/releases/latest/download' + + + + +# PROJECT_CHOCOLATEY_VERSION +# The Chocolatey version as a dependency. This field SHALL NOT BE EMPTY. +# +# Default value is: '0.9.8.21' +PROJECT_CHOCOLATEY_VERSION = '0.9.8.21' + + + + +############################# +# DISTRIBUTION - CONTAINERS # +############################# +# PROJECT_CONTAINER_REGISTRY +# The container registry URI value without ending slash. This variable is also +# acting as a switch to enable/disable container distribution pipeline. +# +# Some examples: +# 1. DockerHub : registry.hub.docker.com/[ NAMESPACE ] +# 2. GitHub Package: ghcr.io/[ NAMESPACE ] +# 2. Local : localhost:5000/[ NAMESPACE ] +# +# To enable it: set the URI without the ending slash. +# To disable it: set it empty. +# +# !! IMPORTANT !! - Please avoid ending with the URL slash. +PROJECT_CONTAINER_REGISTRY = 'ghcr.io/chewkeanho' + + +# PROJECT_CONTAINER_BASE_WINDOWS +# The base Windows image of the container. If you wish to use bare scratch, set +# the value to 'scratch'. +# +# Default is: 'mcr.microsoft.com/windows/nanoserver:ltsc2022' +PROJECT_CONTAINER_BASE_WINDOWS = 'mcr.microsoft.com/windows/nanoserver:ltsc2022' + + +# PROJECT_CONTAINER_BASE_WINDOWS_ARCH +# The list of archiectures to be containerized and supported by the Windows base +# image. Leaving this field empty means accepts all which is usable for +# 'scratch' type base images. +# +# Each image is separated by a '|'. +# +# Default is: 'amd64' (mcr.microsoft.com/windows/nanoserver:ltsc2022) +PROJECT_CONTAINER_BASE_WINDOWS_ARCH = 'amd64' + + +# PROJECT_CONTAINER_BASE_LINUX +# The base Linux image of the container. If you wish to use bare scratch, set +# the value to 'scratch'. +# +# Default is: 'linuxcontainers/debian-slim:latest' +PROJECT_CONTAINER_BASE_LINUX = 'linuxcontainers/debian-slim:latest' + + +# PROJECT_CONTAINER_BASE_LINUX_ARCH +# The list of archiectures to be containerized and supported by the Linux base +# image. Leaving this field empty means accepts all which is usable for +# 'scratch' type base images. +# +# Each image is separated by a '|'. +# +# Default is: '386|amd64|arm64|ppc64le|s390x' (linuxcontainers/debian-slim:latest) +PROJECT_CONTAINER_BASE_LINUX_ARCH = '386|amd64|arm64|ppc64le|s390x' + + +# DOCKER_CLI_EXPERIMENTAL +# Enable the Docker's experimental CLI features for using buildx. If disabled, +# is shall break many of the CI job. +DOCKER_CLI_EXPERIMENTAL = 'enabled' + + + + +########################## +# DISTRIBUTION - DEB # +########################## +# PROJECT_DEB_URL +# The .debs' downloadable apt URL used for generating the +# /etc/apt/source.list.d/ source file. More info: +# (1) https://wiki.debian.org/DebianRepository/Format +# +# For flat repository mode (e.g. GitHub Release / GitLab Release), +# simply supply the URL without the last section of the pathing. For example: +# (1) GitHub Release: +# value: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest' +# actual URL: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download/[FILE]' +# +# This field also acts as the flag for enabling or disabling the deb pipeline. +# +# To enable : fill in the end-user downloadable URL without ending slash. +# To disable: leave this field empty (''). +# +# !! IMPORTANT !! - Please avoid ending with the URL slash. +PROJECT_DEB_URL = 'https://github.com/ChewKeanHo/HestiaKERNEL/releases/latest' + + +# PROJECT_DEB_DISTRIBUTION +# The 'Suite' ('Suite: ' field) distribution series for grouping .deb pakages +# by major release. The value is used for generating changelog and for +# the .deb package repository processes. More info: +# https://www.debian.org/doc/debian-policy/ch-controlfields.html#id25 +# https://www.debian.org/doc/debian-policy/ch-source.html#debian-changelog-debian-changelog +# https://wiki.debian.org/DebianRepository/Format +# +# By default, the repository is operating in the conventional pool repository +# mode (with 'dist' and 'pool' sub-directories). To enable the flat repository +# mode (e.g. GitHub Release / GitLab Release), simply ends with a slash to +# indicate it is a directory. For example: +# (1) GitHub Release: +# value: 'download/' +# actual URL: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download/[FILE]' +# +# Otherwise, the default pool repository mode is implemented. In this case, when +# in doubt, the following values are recommended for the highest compatibilities +# with all Debian-based OSes: +# (1) 'stable' = for stable branch (e.g. 'main') +# (2) 'unstable' OR 'testing' = for next release branch (e.g 'staging', or +# 'next'). +# (3) 'experimental' = for latest branch (e.g 'experimental' or +# 'edge'). +PROJECT_DEB_DISTRIBUTION = 'download/' + + +# PROJECT_DEB_COMPONENT +# The value used by deb package repository for grouping packages by +# categorization. In any case, the value **MUST** match any one of the +# 'Component:' field understood by the apt package manager. +# +# This is mainly used to group the packages by categories (e.g. 'firmware', +# 'gui', 'models', etc). Some recommended values would be your repository +# functioning name (e.g. 'main', 'next', 'dev', etc.). +# +# When in doubt or usually unused, set the value to 'main'. +PROJECT_DEB_COMPONENT = 'main' + + +# PROJECT_DEB_CODENAME +# The value used by deb package repository for tagging a release series. In any +# case, the value **MUST** match any one of the 'Codename:' field understood by +# the apt package manager. Generally, Codename is used to symlink against +# Suite for unique identification or specific release version freezes. +# +# Example values from Debian are: 'experimental', 'sid', 'bookworm', 'wheeze', +# etc (toy story characters). +# +# When in doubt or unused, It is advisble to set the following values: +# (1) In flat repository: 'stable'. +# (2) In pool repository: 'stable' or same as PROJECT_DEB_DISTRIBUTION. +PROJECT_DEB_CODENAME = 'stable' + + +# PROJECT_DEB_ARCH +# The list of overriding system architectures values for the deb package +# repository. It accepts a list of values separated by space (' ') based on +# dpkg supported architectures. The command: +# "$ dpkg-architecture --list-known" +# will print out a list of supported architectures' value based on the host +# system. +# +# Please keep in mind that the values are not used for gatekeeping purposes. +# When left empty, AutomataCI shall generate a full list from the existing +# published packages autonomously. +# +# By default and recommended, the value is empty '' for automation purposes. +PROJECT_DEB_ARCH = '' + + +# PROJECT_DEB_IS_NATIVE +# Flag to determine the project is Debian natively sponsored package. Usually +# is false. +# +# Only accept: "true/false" +# +# Default is 'false'. +PROJECT_DEB_IS_NATIVE = 'false' + + +# PROJECT_DEB_PRIORITY +# Indicate the current package's distribution priority. Strictly the following +# values arranged from highest priority to the lowest: +# (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. +# +# Default is 'optional'. +PROJECT_DEB_PRIORITY = 'optional' + + +# PROJECT_DEB_URGENCY +# The urgency value used for compiling the .deb pakage changelog. See this page +# for more info: +# https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-urgency +# https://www.debian.org/doc/debian-policy/ch-source.html#debian-changelog-debian-changelog +# +# Strictly of the following values from highest attention to the lowest: +# (1) critical +# (2) emergency +# (3) high = for user diversions +# (4) medium +# (5) low +# +# Default is 'low'. +PROJECT_DEB_URGENCY = 'low' + + +# PROJECT_DEB_SECTION +# The categories the project belongs to in the Debian .deb package ecosystem. +# Contains restricted values. Refer: +# https://www.debian.org/doc/debian-policy/ch-archive.html#sections +# For maximum compliances +PROJECT_DEB_SECTION = 'devel' + + +# PROJECT_DEB_REPO +# The git repository for publishing all .deb packages using a static file +# sharing service (e.g NGINX file hosting, GitHub/GitLab Pages, etc). When +# enabled, this repository URL shall be git clone into +# '$PROJECT_PATH_ROOT/$PROJECT_PATH_RELEASE' directory named as 'deb'. +# +# Note that if PROJECT_RELEASE_REPO is set, this field is ignored regardless of +# its value. +PROJECT_DEB_REPO = 'git@github.com:ChewKeanHo/HestiaKERNEL.wiki.git' + + +# PROJECT_DEB_REPO_KEY +# The git upstream key. Value CANNOT be empty. +# +# Default is 'origin'. +PROJECT_DEB_REPO_KEY = 'origin' + + +# PROJECT_DEB_REPO_BRANCH +# The git upstream branch. Value CANNOT be empty. +# +# Default is 'master' or 'main'. +PROJECT_DEB_REPO_BRANCH = 'master' + + +# PROJECT_DEB_PATH +# The relative pathing for organizing within the debian repository directory. +# The path is always relative to +# '${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/deb' directory which is the +# PROJECT_DEB_REPO debian repository. This is useful for cases where specific +# directory is required (e.g. 'GitHub Pages using "docs/" directory for +# publications). +# +# If left empty, AutomataCI shall use 'deb' as its value. +# +# Default is 'deb'. +PROJECT_DEB_PATH = 'deb' + + +# PROJECT_DEB_PATH_DATA +# The deb repository noDB database directory. This houses all the packages data +# for recursive compilations. When set, the pathing is strictly relative to +# '${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/data/deb' directory. +# +# Leaving it empty shall use a disposable database directory located in: +# '${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/releaser-deb-repoDB' pathing. +# +# Default is 'repoDB' ('${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/data/deb/repoDB') +PROJECT_DEB_PATH_DATA = 'repoDB' + + + + +########################## +# DISTRIBUTION - DOCS # +########################## +# PROJECT_DOCS_URL +# The base URL for viewing the published documentation (e.g. website address). +# It is made available in-case of publication needs. +# +# This field also acts as the flag for enabling or disabling the documentation +# pipeline. +# +# To enable : fill in the end-user downloadable URL without ending slash. +# To disable: leave this field empty (''). +# +# !! IMPORTANT !! - Please avoid ending with the URL slash. +PROJECT_DOCS_URL = 'https://github.io/ChewKeanHo/HestiaKERNEL' + + +# PROJECT_DOCS_REPO +# The git repository for publishing all the docs web artifacts using a static +# file sharing service (e.g NGINX file hosting, GitHub/GitLab Pages, etc). +# This repository URL shall be git clone into +# '$PROJECT_PATH_ROOT/$PROJECT_PATH_RELEASE' directory internally named as +# 'x_docsrepo'. +# +# Note that regardless of PROJECT_RELEASE_REPO is set or otherwise, this repo +# shall be deleted automatically at the end of its operation, successful or +# otherwise to prevent output distortion. +PROJECT_DOCS_REPO = 'git@github.com:ChewKeanHo/HestiaKERNEL.git' + + +# PROJECT_DOCS_REPO_KEY +# The git upstream key. Value CANNOT be empty. +# +# Default is 'origin'. +PROJECT_DOCS_REPO_KEY = 'origin' + + +# PROJECT_DOCS_REPO_BRANCH +# The git upstream branch. Value CANNOT be empty. +# +# For Website service provider using git version control system such as but not +# limited to GitHub/GitLab Pages, it is always advisable to implement 'gh-pages' +# (default settings) instead of other means. Otherwise, if the repository is +# a standalone one (e.g. [USERNAME].github.io repository as root profile) +# website, then standard branch name is used. +# +# Default is 'gh-pages'. +PROJECT_DOCS_REPO_BRANCH = 'gh-pages' + + + + +########################## +# DISTRIBUTION - FLATPAK # +########################## +# PROJECT_FLATPAK_URL +# The base URL for Flatpak to download its associated .flatpak package payload. +# This variable is also acting as a switch to enable/disable Flatpak +# distribution pipeline. +# +# AutomataCI will always compile "Single File Bundles" distribution channel by +# default. Should PROJECT_FLATPAK_REPO is set, then AutomataCI shall also +# compile and update the "Repository" distribution channel. More info: +# 1. https://docs.flatpak.org/en/latest/repositories.html +# +# In the event where "Repository" distribution channel is set +# (PROJECT_FLATPAK_REPO), then the URL shall be pointing to the repository URL +# instead of the "Single File Bundles" downlodable portal version. The value +# shall be used for creating .flakpakrepo and .flatpakref files respectively. +# +# Some examples are: +# (1) GitHub Release (Single Bundle channel only): +# value: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download' +# actual URL: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download/[FILE]' +# +# (2) GitHub Pages (Single Bundle channel + Repository): +# value: 'https://[USERNAME]github.io/flatpak/[PROJECT].flatpakrepo' +# actual URL: 'https://[USERNAME]github.io/flatpak/[PROJECT].flatpakrepo' +# +# (3) Other static file hosting services (Single Bundle channel + Repository): +# value: 'https://www.example.com/flatpak/[PROJECT].flatpakrepo' +# actual URL: 'https://www.example.com/flatpak/[PROJECT].flatpakrepo' +# +# This field also acts as the flag for enabling or disabling the flatpak +# pipeline. +# +# To enable it: set the URL without the ending slash. +# To disable it: set it empty. +# +# !! IMPORTANT !! - Please avoid ending with the URL slash. +PROJECT_FLATPAK_URL = 'https://github.com/ChewKeanHo/HestiaKERNEL/releases/latest/download' + + +# PROJECT_FLATPAK_REPO +# The Flatpak publication git repository for updating and publishing +# Flatpak packages repository. AutomataCI will always use the temporary +# directory for all flatpak packaging operations at: +# $PROJECT_PATH_ROOT/$PROJECT_PATH_TEMP/flatpak-repo +# until it is being moved to the release job when set. +# +# This field also acts as a flag for enabling "Repository" distribution channel +# when PROJECT_FLATPAK_URL is set. +# +# To enable it: set the URL without the ending slash. +# To disable it: set it empty. +# +# In the event where PROJECT_RELEASE_REPO is set, this repo shall be ignored. +# However, to maintain enabling the "Repository" distribution channel packaging +# decision, this field shall have the same value as PROJECT_RELEASE_REPO. +PROJECT_FLATPAK_REPO = 'git@github.com:ChewKeanHo/HestiaKERNEL.wiki.git' + + +# PROJECT_FLATPAK_PATH +# The relative pathing for organizing within the flatpak repository directory. +# when "Repository" distribution channel is set. +# The path is always relative to +# '${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/flatpak' directory which is the +# PROJECT_FLATPAK_REPO debian repository. This is useful for cases where +# specific directory is required (e.g. 'GitHub Pages using "docs/" directory +# for publications). +# +# If left empty, AutomataCI shall use 'flatpak' as its value. +# +# Default is 'flatpak'. +PROJECT_FLATPAK_PATH = 'flatpak' + + +# PROJECT_FLATPAK_REPO_KEY +# The git upstream key. Value CANNOT be empty. +# +# Default is 'origin'. +PROJECT_FLATPAK_REPO_KEY = 'origin' + + +# PROJECT_FLATPAK_REPO_BRANCH +# The git upstream branch. Value CANNOT be empty. +# +# Default is 'main' or 'master'. +PROJECT_FLATPAK_REPO_BRANCH = 'master' + + +# 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' + + + + +########################### +# DISTRIBUTION - HOMEBREW # +########################### +# PROJECT_HOMEBREW_URL +# The base URL for Homebrew formula to download its associated tar.*z archive +# payload. This variable is also acting as a switch to enable/disable Homebrew +# distribution pipeline. +# +# Some examples are: +# (1) GitHub Release: +# value: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download' +# actual URL: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download/[FILE]' +# +# This field also acts as the flag for enabling or disabling the homebrew +# pipeline. +# +# To enable it: set the URL without the ending slash. +# To disable it: set it empty. +# +# !! IMPORTANT !! - Please avoid ending with the URL slash. +PROJECT_HOMEBREW_URL = 'https://github.com/ChewKeanHo/HestiaKERNEL/releases/latest/download' + + +# PROJECT_HOMEBREW_REPO +# The Homebrew formula publication git repository for updating and publishing +# Homebrew's formula. This repository is ENTIRELY DIFFERENT from your project +# version (as in a tap repo: '$ brew tap [username]/[collections] [URL]'). +# More info: +# 1. https://docs.brew.sh/Taps +# +# Value CANNOT BE EMPTY. When in doubt, you can create a publishing +# 'Collections' git repository which is great for branding. For example: +# 1. (Holloway) Chew, Kean Ho: 'git@github.com:ChewKeanHo/Collections.git' +# +# Note that regardless of PROJECT_RELEASE_REPO is set or otherwise, this repo +# shall be deleted automatically at the end of its operation, successful or +# otherwise to prevent output distortion. +PROJECT_HOMEBREW_REPO = 'git@github.com:ChewKeanHo/Collections.git' + + +# PROJECT_HOMEBREW_REPO_KEY +# The git upstream key. Value CANNOT be empty. +# +# Default is 'origin'. +PROJECT_HOMEBREW_REPO_KEY = 'origin' + + +# PROJECT_HOMEBREW_REPO_BRANCH +# The git upstream branch. Value CANNOT be empty. +# +# Default is 'main' or 'master'. +PROJECT_HOMEBREW_REPO_BRANCH = 'main' + + + + +########################### +# DISTRIBUTION - MSI # +########################### +# PROJECT_MSI_INSTALL_DIRECTORY +# Defines the primary directory installation value for installer execute +# sequences ('InstallExecuteSequence'). The value can only be 'INSTALLDIR' +# (controlled value). +# +# This field also acts as the flag for enabling or disabling the homebrew +# pipeline. +# +# To enable it: set the value as 'INSTALLDIR' +# To disable it: set it empty. +# +# Default is: 'INSTALLDIR' (enabled) +PROJECT_MSI_INSTALL_DIRECTORY = 'INSTALLDIR' + + +# PROJECT_MSI_ARP_INSTALL_LOCATION +# Defines the CustomAction's ID for installer execute sequences +# ('InstallExecuteSequence'). The value can only be 'ARPINSTALLLOCATION' +# (controlled value). +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: 'ARPINSTALLLOCATION' +PROJECT_MSI_ARP_INSTALL_LOCATION = 'ARPINSTALLLOCATION' + + +# PROJECT_MSI_COMPRESSED_MODE +# Defines the compress mode for the installer. It STRICTLY accepts lowercase +# 'yes' or 'no' only. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: 'yes' +PROJECT_MSI_COMPRESSED_MODE = 'yes' + + +# PROJECT_MSI_INSTALLER_VERSION_UNIX +# Defines the MSI installer version for unix workspace (where WiX is not used). +# +# This field CANNOT BE LEFT EMPTY and is only for unix packagers. +# +# Default is: '400' (Windows Installer 4.0 - included in Vista) +PROJECT_MSI_INSTALLER_VERSION_UNIX = '400' + + +# PROJECT_MSI_INSTALLER_VERSION_WINDOWS +# Defines the MSI installer version for windows workspace (where WiX is used). +# +# This field CANNOT BE LEFT EMPTY and is only for windows packagers. +# +# Default is: '500' (WiX4) +PROJECT_MSI_INSTALLER_VERSION_WINDOWS = '500' + + +# PROJECT_MSI_CODEPAGE +# Defines the charset of the installer. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: '65001' (UTF-8) +PROJECT_MSI_CODEPAGE = '65001' + + +# PROJECT_MSI_INSTALLER_SCOPE +# Defines the installer scope. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: 'perMachine' +PROJECT_MSI_INSTALLER_SCOPE = 'perMachine' + + +# PROJECT_MSI_REGISTRY_NAME +# Defines the name of the registry. Unless aboslute needed, it's best to leave +# this as it is. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: 'InstallLocation' +PROJECT_MSI_REGISTRY_NAME = 'InstallLocation' + + +# PROJECT_MSI_REGISTRY_KEY +# Defines the location of the registry. +# +# This field is shared for both unix and windows packagers. +# +# If this field is left empty, AutomataCI shall generate a default version +# using the following pattern: +# 'Software\${PROJECT_SCOPE}\InstalledProducts\${PROJECT_SKU_TITLECASE}' +# +# Default is: '' (leave it automated) +PROJECT_MSI_REGISTRY_KEY = '' + + +# PROJECT_MSI_FEATURES_ID +# The ID for the entire installer's feature list. This the the root of the list +# consisting of main feature list, optional features list, and etc. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: 'FeaturesAll' +PROJECT_MSI_FEATURES_ID = 'FeaturesAll' + + +# PROJECT_MSI_MAIN_FEATURE_ID +# The ID for the compulsory features list. This consists of all the MUST HAVE +# components to be installed at the client side. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: 'FeaturesMain' +PROJECT_MSI_MAIN_FEATURE_ID = 'FeaturesMain' + + +# PROJECT_MSI_REGISTRIES_ID +# The ID for the compulsory main registries component. This handles the main +# registeries internal implementations. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: 'RegValInstallLocation_comp' +PROJECT_MSI_REGISTRIES_ID = 'RegValInstallLocation_comp' + + +# PROJECT_MSI_REGISTRIES_GUID +# The unique GUID for the compulsory main registries component. Its value is +# similar to a UUID type. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# When in doubt, use the PROJECT_UUID and play with the last 6 characters. +# +# Default is: '*' - in some cases may fail. +PROJECT_MSI_REGISTRIES_GUID = '627630F4-0814-C1FF-1E18-DDD50A958300' + + +# PROJECT_MSI_BIN_FEATURE_ID +# The ID for the executables features list. When available, the executables will +# be in this component. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: 'FeaturesBin' +PROJECT_MSI_BIN_FEATURE_ID = 'FeaturesBin' + + +# PROJECT_MSI_BIN_COMPONENT_ID +# The ID for the executables component. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: 'ComponentBin' +PROJECT_MSI_BIN_COMPONENT_ID = 'ComponentBin' + + +# PROJECT_MSI_BIN_COMPONENT_GUID +# The unique GUID for the executables component. Its value is similar to an UUID +# type. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# When in doubt, use the PROJECT_UUID and play with the last 6 characters. +# +# Default is: '*' - in some cases may fail. +PROJECT_MSI_BIN_COMPONENT_GUID = '627630F4-0814-C1FF-1E18-DDD50A958301' + + +# PROJECT_MSI_CONFIG_FEATURE_ID +# The ID for the config files features list. When available, the config files +# will be in this component. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: 'FeaturesBin' +PROJECT_MSI_CONFIG_FEATURE_ID = 'FeaturesConfig' + + +# PROJECT_MSI_CONFIG_COMPONENT_ID +# The ID for the config files component. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: 'ComponentConfig' +PROJECT_MSI_CONFIG_COMPONENT_ID = 'ComponentConfig' + + +# PROJECT_MSI_CONFIG_COMPONENT_GUID +# The unique GUID for the config files component. Its value is similar to +# an UUID type. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# When in doubt, use the PROJECT_UUID and play with the last 6 characters. +# +# Default is: '*' - in some cases may fail. +PROJECT_MSI_CONFIG_COMPONENT_GUID = '627630F4-0814-C1FF-1E18-DDD50A958302' + + +# PROJECT_MSI_LIB_FEATURE_ID +# The ID for the libraries features list. When available, the libraries will +# be in this component. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: 'FeaturesLib' +PROJECT_MSI_LIB_FEATURE_ID = 'FeaturesLib' + + +# PROJECT_MSI_LIB_COMPONENT_ID +# The ID for the libraries component. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: 'ComponentLib' +PROJECT_MSI_LIB_COMPONENT_ID = 'ComponentLib' + + +# PROJECT_MSI_LIB_COMPONENT_GUID +# The unique GUID for the libraries component. Its value is similar to an UUID +# type. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# When in doubt, use the PROJECT_UUID and play with the last 6 characters. +# +# Default is: '*' - in some cases may fail. +PROJECT_MSI_LIB_COMPONENT_GUID = '627630F4-0814-C1FF-1E18-DDD50A958303' + + +# PROJECT_MSI_DOCS_FEATURE_ID +# The ID for the documenations features list. When available, the documents will +# be in this component. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# When in doubt, use the PROJECT_UUID and play with the last 6 characters. +# +# Default is: '*' - in some cases may fail. +PROJECT_MSI_DOCS_FEATURE_ID = 'FeaturesDocs' + + +# PROJECT_MSI_DOCS_COMPONENT_ID +# The ID for the documentations component. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# Default is: 'ComponentDocs' +PROJECT_MSI_DOCS_COMPONENT_ID = 'ComponentDocs' + + +# PROJECT_MSI_DOCS_COMPONENT_GUID +# The unique GUID for the documentations component. Its value is similar to an +# UUID type. +# +# This field CANNOT BE LEFT EMPTY and is shared for both unix and windows +# packagers. +# +# When in doubt, use the PROJECT_UUID and play with the last 6 characters. +# +# Default is: '*' - in some cases may fail. +PROJECT_MSI_DOCS_COMPONENT_GUID = '627630F4-0814-C1FF-1E18-DDD50A958304' + + + + +########################## +# DISTRIBUTION - RPM # +########################## +# PROJECT_RPM_URL +# The .rpm' downloadable yum URL used for generating .repo source file inside +# /etc/yum.repos.d directory. More info: +# (1) https://developers.redhat.com/articles/2022/10/07/whats-inside-rpm-repo-file +# +# Some examples: +# (1) GitHub Release: +# value: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download' +# actual URL: 'https://github.com/[USERNAME]/[PROJECT]/releases/latest/download/[FILE]' +# +# This field also acts as the flag for enabling or disabling the rpm pipeline. +# +# To enable : fill in the end-user downloadable URL without ending slash. +# To disable: leave this field empty (''). +# +# !! IMPORTANT !! - Please avoid ending with the URL slash. +PROJECT_RPM_URL = 'https://github.com/ChewKeanHo/HestiaKERNEL/releases/latest/download' + + +# PROJECT_RPM_FLAT_MODE +# The flag to create a flat .rpm repository directory rather than using the +# conventional mode with repodata/ sub-directory. This is especially useful +# for filesystem without sub-directories such as but not limited to +# GitHub/GitLab Release page. +# +# To enable : leave the non-empty (e.g. 'enabled') +# To disable: leave it empty ('') +PROJECT_RPM_FLAT_MODE = 'enabled' + + +# PROJECT_RPM_REPOXML_NAME +# The filename of the repomd.xml file after the directory is flattened. This +# field SHALL NOT be left empty or it will cause catastrophic, irreversible +# effect to the release repo. +# +# Default is: 'repomd.xml' +PROJECT_RPM_REPOXML_NAME = 'repomd.xml' + + +# PROJECT_RPM_METALINK +# The filename of the METALINK file after the directory is flattened. This +# field SHALL NOT be left empty or it will cause catastrophic, irreversible +# effect to the release repo. +# +# Default is: 'METALINK_RPM' +PROJECT_RPM_METALINK = 'METALINK_RPM' + + +# PROJECT_RPM_IS_NATIVE +# Flag to determine the project is Red Hat natively sponsored package. Usually +# is false. +# +# Only accept: "true/false" +# +# Default is 'false'. +PROJECT_RPM_IS_NATIVE = 'false' + + +# PROJECT_RPM_REPO +# The git repository for publishing all .rpm packages using a static file +# sharing service (e.g NGINX file hosting, GitHub/GitLab Pages, etc). When .rpm +# is operating in the conventional mode, this repository URL shall be git clone +# into '$PROJECT_PATH_ROOT/$PROJECT_PATH_RELEASE' directory named as 'rpm'. +# +# If PROJECT_RPM_REPO_TYPE is not set to git type, then this variable shall be +# ignored. +# +# Note that if PROJECT_RELEASE_REPO is set, this field is ignored regardless of +# its value. +PROJECT_RPM_REPO = 'git@github.com:ChewKeanHo/HestiaKERNEL.wiki.git' + + +# PROJECT_RPM_REPO_KEY +# The git upstream key. Value CANNOT be empty. +# +# Default is 'origin'. +PROJECT_DEB_REPO_KEY = 'origin' + + +# PROJECT_RPM_REPO_BRANCH +# The git upstream branch. Value CANNOT be empty. +# +# Default is 'master' or 'main'. +PROJECT_RPM_REPO_BRANCH = 'master' + + +# PROJECT_RPM_PATH +# The relative pathing for organizing within the rpm repository directory. +# The path is always relative to +# '${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/rpm' directory which is the +# PROJECT_RPM_REPO rpm repository. This is useful for cases where specific +# directory is required (e.g. 'GitHub Pages using "docs/" directory for +# publications). +# +# If left empty, AutomataCI shall use 'rpm' as its value. +# +# Default is 'rpm'. +PROJECT_RPM_PATH = 'rpm' + + + + +###################### +# 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/Shell/Init.sh.ps1 b/Shell/Init.sh.ps1 deleted file mode 100644 index 4f5b36d..0000000 --- a/Shell/Init.sh.ps1 +++ /dev/null @@ -1,187 +0,0 @@ -echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" -@ECHO OFF -REM LICENSE CLAUSES HERE -REM ---------------------------------------------------------------------------- - - - - -REM ############################################################################ -REM # Windows BATCH Codes # -REM ############################################################################ -echo "[ ERROR ] Use 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 - - - - -# execute -${env:DIR_WORKSPACE} = Get-Location - - - -# determine LIBS_HESTIA location -if (-not (Test-Path -Path "${env:DIR_WORKSPACE}\libraries" -PathType Container)) { - $null = Write-Error "[ ERROR ] Missing library in workspace. Are you inside?" - return 1 -} -${env:LIBS_HESTIA} = "${env:DIR_WORKSPACE}\libraries" -${env:DIR_TEMP} = "${env:DIR_WORKSPACE}\temp" - - -# re-create temp directory -$null = Remove-Item -Recurse -Force -Path ${env:DIR_TEMP} -ErrorAction SilentlyContinue -$null = New-Item -Path ${env:DIR_TEMP} -ItemType Directory -Force - - -# facilitate recursive find function -function Find-Files-Recursive { - param ( - [string]$___directory, - [string]$___filter - ) - - - # execute - return Get-ChildItem $___directory -Filter *$___filter -} - - -# facilitate logging -function Logf { - param ( - [Parameter(Mandatory)] - [string]___format, - - [Parameter(ValueFromRemainingArguments)] - $___args - ) - - $null = Write-Host -NoNewLine ($___format -f @($___args)) -} - - -# source all init scripts if available -if (Test-Path -Path "${env:DIR_WORKSPACE}\init" -PathType Container) { - foreach ($___script in $(Find-Files-Recursive "${env:DIR_WORKSPACE}\init" ".ps1")) { - $null = Write-Host "Sourcing ${___script} ..." - $___process = . $___script - if ($___process -ne 0) { - $null = Write-Error "[ ERROR ] init failed." - return 1 - } - } -} - - -# report status -return 0 -################################################################################ -# Windows POWERSHELL Codes # -################################################################################ -exit -<# -RUN_AS_POWERSHELL - - - - -################################################################################ -# Unix Main Codes # -################################################################################ -# execute -export DIR_WORKSPACE="$PWD" - - -# determine LIBS_HESTIA location -if [ ! -d "${DIR_WORKSPACE}/libraries" ]; then - 1>&2 printf -- "[ ERROR ] Missing library in workspace. Are you inside?\n" - return 1 -fi -export LIBS_HESTIA="${DIR_WORKSPACE}/libraries" -export DIR_TEMP="${DIR_WORKSPACE}/temp" - - -# re-create temp directory -rm -rf "$DIR_TEMP" &> /dev/null -mkdir -p "$DIR_TEMP" - - -# facilitate recursive find function -Find_Files_Recursive() { - #___directory="$1" - #___filter="$2" - - - # execute - for ____item in "$1"/*; do - if [ -d "$____item" ]; then - Find_Files_Recursive "$____item" "$2" - elif [ -f "$____item" ]; then - ____filename="${____item##*/}" - if [ ! "${____filename##*"$2"}" = "$____filename" ]; then - printf -- "%s\n" "$____item" - fi - fi - done - - - # report status - return 0 -} - - -# facilitate logging -Logf() { - #___format="$1" - #___args="${@:2}" - - 1>&2 printf -- "$1" "${@:2}" -} - - -# faciliate test framework -export TEST_PASSED=0 TEST_FAILED=1 - - -# source all init scripts if available -if [ -d "${DIR_WORKSPACE}/init" ]; then - for ___script in $(Find_Files_Recursive "${DIR_WORKSPACE}/init" ".sh"); do - if [ ! -f "$___script" ]; then - continue - fi - - 1>&2 printf -- "Sourcing ${___script} ...\n" - . "$___script" - if [ $? -ne 0 ]; then - 1>&2 printf -- "[ ERROR ] init failed." - return 1 - fi - done -fi - - -# report status -return 0 -################################################################################ -# Unix Main Codes # -################################################################################ -exit $? -#> diff --git a/Shell/Test.sh.ps1 b/Shell/Test.sh.ps1 index 58052e6..64d0739 100755 --- a/Shell/Test.sh.ps1 +++ b/Shell/Test.sh.ps1 @@ -33,74 +33,16 @@ $OutputEncoding = [console]::InputEncoding ` # initialize workspace -if (-not (Test-Path -Path "$(Get-Location)\Init.sh.ps1")) { - $null = Write-Error "[ ERROR ] Missing Init.sh.ps1. Are you inside the workspace?" +if (-not (Test-Path -Path "$(Get-Location)\shell\test.ps1")) { + $null = Write-Error "[ ERROR ] Missing 'shell\test.ps1'." exit 1 } -$___process = . "$(Get-Location)\Init.sh.ps1" +$___process = . "$(Get-Location)\shell\test.ps1" if ($___process -ne 0) { exit 1 } - - - - -# execute all test scripts -$null = Write-Host "[ INFO ] BEGIN TESTS SUITE" -$___scripts_total = 0 -$___scripts_passed = 0 -if (Test-Path -Path "${env:DIR_WORKSPACE}\test" -PathType Container) { - foreach ($___script in $(Find-Files-Recursive "${env:DIR_WORKSPACE}\test" ".ps1")) { - $null = Write-Host "`n[ INFO ] Executing '${___script}' ..." - $___scripts_total += 1 - - $___job = Start-Job -ScriptBlock { - param ( - [string]$___filepath - ) - - try { - & $___filepath - if ($LASTEXITCODE -ne $null) { - exit $LASTEXITCODE - } - exit 0 - } catch { - exit 1 - } - } -ArgumentList $___script - $null = Wait-Job $___job - $___process = $___job.ChildJobs[0].JobStateInfo.Reason.ExitCode - $null = Remove-Job $___job - - $null = Write-Host "[ INFO ] Return code: ${___process}" - if ($___process -ne 0) { - $null = Write-Host "[ ERROR ] Test failed." - continue - } - - $___scripts_passed += 1 - } -} - - -# report overall test report -$null = Logf @" -`n`n -[ INFO ] TOTAL : {0}" -[ INFO ] PASSED: {1}" -[ INFO ] FAILED: {2}" - -"@ $___scripts_total $___script_passed $($___scripts_total - $___scripts_passed) - -if ($___scripts_total -ne $___scripts_passed) { - $null = Logf "[ FAILED ]`n" - exit 1 -} else { - $null = Logf "[ SUCCESS ]`n" - exit 0 -} +exit 0 ################################################################################ # Windows POWERSHELL Codes # ################################################################################ @@ -115,65 +57,16 @@ RUN_AS_POWERSHELL # Unix Main Codes # ################################################################################ # initialize workspace -if [ ! -f "${PWD}/Init.sh.ps1" ]; then - 1>&2 printf -- "[ ERROR ] Missing Init.sh.ps1. Are you inside the workspace?\n" - exit 1 -fi -. "${PWD}/Init.sh.ps1" -if [ $? -ne 0 ]; then +if [ ! -f "${PWD}/shell/test.sh" ]; then + 1>&2 printf -- "[ ERROR ] Missing './shell/test.sh'.\n" exit 1 fi - - - -# execute all test scripts -Logf "[ INFO ] BEGIN TESTS SUITE\n" -___scripts_total=0 -___scripts_passed=0 -if [ -d "${DIR_WORKSPACE}/test" ]; then - for ___script in $(Find_Files_Recursive "${DIR_WORKSPACE}/test" ".sh"); do - if [ ! -f "$___script" ]; then - continue - fi - - 1>&2 printf -- "\n\n[ INFO ] Executing '${___script}' ...\n" - ___scripts_total=$(($___scripts_total + 1)) - - if [ ! -x "$___script" ]; then - 1>&2 printf -- "[ ERROR ] Not executable!\n" - continue - fi - $(. "$___script") - ___process=$? - - 1>&2 printf -- "[ INFO ] Return Code: %s\n" "$___process" - if [ $___process -ne 0 ]; then - 1>&2 printf -- "[ ERROR ] Test failed." - continue - fi - - ___scripts_passed=$(($___scripts_passed + 1)) - done -fi - - - - -# report overall test report -Logf "\n -[ INFO ] TOTAL : %b -[ INFO ] PASSED : %b -[ INFO ] FAILED : %b -" "$___scripts_total" "$___scripts_passed" "$(($___scripts_total - $___scripts_passed))" - -if [ $___scripts_total -ne $___scripts_passed ]; then - 1>&2 printf -- "[ FAILED ]\n" +. "${PWD}/shell/test.sh" +if [ $? -ne 0 ]; then exit 1 -else - 1>&2 printf -- "[ SUCCESS ]\n" - exit 0 fi +exit 0 ################################################################################ # Unix Main Codes # ################################################################################ diff --git a/Shell/libraries/HestiaKERNEL/String/Split_Left_String.ps1 b/Shell/libraries/HestiaKERNEL/String/Split_Left_String.ps1 index 0f7acae..7e0588b 100644 --- a/Shell/libraries/HestiaKERNEL/String/Split_Left_String.ps1 +++ b/Shell/libraries/HestiaKERNEL/String/Split_Left_String.ps1 @@ -33,7 +33,8 @@ function HestiaKERNEL-Split-Left-String { $___ignore [System.Collections.Generic.List[string]]$___converted = @() foreach ($___line in $___content) { - $null = $___converted.Add($(HestiaKERNEL-To-String-From-Unicode $___line)) + $___line = HestiaKERNEL-To-String-From-Unicode $___line + $null = $___converted.Add($___line) } diff --git a/Shell/libraries/HestiaKERNEL/Unicode/Split_Left_Unicode.ps1 b/Shell/libraries/HestiaKERNEL/Unicode/Split_Left_Unicode.ps1 index cc79c12..dba75d0 100644 --- a/Shell/libraries/HestiaKERNEL/Unicode/Split_Left_Unicode.ps1 +++ b/Shell/libraries/HestiaKERNEL/Unicode/Split_Left_Unicode.ps1 @@ -83,10 +83,7 @@ function HestiaKERNEL-Split-Left-Unicode { } [System.Collections.Generic.List[uint32]]$___buffer = @() } - $null = $___converted.Add($___current) - $null = $___list.Add([uint32[]]$___converted) - [System.Collections.Generic.List[uint32]]$___converted = @() continue } @@ -134,6 +131,7 @@ function HestiaKERNEL-Split-Left-Unicode { $null = $___list.Add([uint32[]]$___converted) } + $null = Write-Host "X-DEBUG: ${___list}" # report status return [uint32[][]]$___list diff --git a/Shell/shell/init.ps1 b/Shell/shell/init.ps1 new file mode 100644 index 0000000..00bf2aa --- /dev/null +++ b/Shell/shell/init.ps1 @@ -0,0 +1,95 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$PSDefaultParameterValues['*:Encoding'] = 'utf8' +$OutputEncoding = [console]::InputEncoding ` + = [console]::OutputEncoding ` + = New-Object System.Text.UTF8Encoding + + + + +# execute +${env:DIR_WORKSPACE} = Get-Location + + + + +# determine LIBS_HESTIA location +if (-not (Test-Path -Path "${env:DIR_WORKSPACE}\libraries" -PathType Container)) { + $null = Write-Error "[ ERROR ] Missing library in workspace. Are you inside?" + return 1 +} +${env:LIBS_HESTIA} = "${env:DIR_WORKSPACE}\libraries" +${env:DIR_TEMP} = "${env:DIR_WORKSPACE}\temp" + + + + +# re-create temp directory +$null = Remove-Item -Recurse -Force -Path ${env:DIR_TEMP} -ErrorAction SilentlyContinue +$null = New-Item -Path ${env:DIR_TEMP} -ItemType Directory -Force + + + + +# facilitate recursive find function +function Find-Files-Recursive { + param ( + [string]$___directory, + [string]$___filter + ) + + + # execute + [System.Collections.Generic.List[string]]$___list = @() + foreach ($___item in (Get-ChildItem $___directory)) { + if (Test-Path -Path $___item.FullName -PathType Container) { + $___results = Find-Files-Recursive $___item.FullName $___filter + foreach ($___result in $___results) { + $___list.Add($___result) + } + } elseif (Test-Path -Path $___item.FullName -PathType Leaf) { + if ($___item.Name -like "*${___filter}*") { + $___list.Add($___item.FullName) + } + } + } + + return [string[]]$___list +} + + + + +# faciliate test framework +${env:TEST_PASSED} = 0 +${env:TEST_FAILED} = 1 + + + + +# source all init scripts if available +if (Test-Path -Path "${env:DIR_WORKSPACE}\init" -PathType Container) { + foreach ($___script in $(Find-Files-Recursive "${env:DIR_WORKSPACE}\init" ".ps1")) { + $null = Write-Host "Sourcing ${___script} ..." + $___process = . $___script + if ($___process -ne 0) { + $null = Write-Error "[ ERROR ] init failed." + return 1 + } + } +} + + + + +# report status +return 0 diff --git a/Shell/shell/init.sh b/Shell/shell/init.sh new file mode 100644 index 0000000..6519b9e --- /dev/null +++ b/Shell/shell/init.sh @@ -0,0 +1,98 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +export DIR_WORKSPACE="$PWD" + + + + +# determine LIBS_HESTIA location +if [ ! -d "${DIR_WORKSPACE}/libraries" ]; then + 1>&2 printf -- "[ ERROR ] Missing library in workspace. Are you inside?\n" + return 1 +fi +export LIBS_HESTIA="${DIR_WORKSPACE}/libraries" +export DIR_TEMP="${DIR_WORKSPACE}/temp" + + + + +# re-create temp directory +rm -rf "$DIR_TEMP" &> /dev/null +mkdir -p "$DIR_TEMP" + + + + +# facilitate recursive find function +Find_Files_Recursive() { + #___directory="$1" + #___filter="$2" + + + # execute + for ____item in "$1"/*; do + if [ -d "$____item" ]; then + Find_Files_Recursive "$____item" "$2" + elif [ -f "$____item" ]; then + ____filename="${____item##*/}" + if [ ! "${____filename##*"$2"}" = "$____filename" ]; then + printf -- "%s\n" "$____item" + fi + fi + done + + + # report status + return 0 +} + + + + +# facilitate logging +Logf() { + ___format="$1" + #___args="${@:2}" + shift + 1>&2 printf -- "$___format" "$@" +} + + + + +# faciliate test framework +export TEST_PASSED=0 TEST_FAILED=1 + + + + +# source all init scripts if available +if [ -d "${DIR_WORKSPACE}/init" ]; then + for ___script in $(Find_Files_Recursive "${DIR_WORKSPACE}/init" ".sh"); do + if [ ! -f "$___script" ]; then + continue + fi + + 1>&2 printf -- "Sourcing ${___script} ...\n" + . "$___script" + if [ $? -ne 0 ]; then + 1>&2 printf -- "[ ERROR ] init failed." + return 1 + fi + done +fi + + + + +# report status +return 0 diff --git a/Shell/shell/test.ps1 b/Shell/shell/test.ps1 new file mode 100755 index 0000000..d8af8f6 --- /dev/null +++ b/Shell/shell/test.ps1 @@ -0,0 +1,80 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$PSDefaultParameterValues['*:Encoding'] = 'utf8' +$OutputEncoding = [console]::InputEncoding ` + = [console]::OutputEncoding ` + = New-Object System.Text.UTF8Encoding + + + + +# initialize workspace +if (-not (Test-Path -Path "$(Get-Location)\shell\init.ps1")) { + $null = Write-Error "[ ERROR ] Missing '.\shell\init.ps1'." + exit 1 +} + +$___process = . "$(Get-Location)\shell\init.ps1" +if ($___process -ne 0) { + exit 1 +} + + + + +# execute all test scripts +$null = Write-Host "[ INFO ] BEGIN TESTS SUITE" +$___scripts_total = 0 +$___scripts_passed = 0 +if (Test-Path -Path "${env:DIR_WORKSPACE}\test" -PathType Container) { + foreach ($___script in $(Find-Files-Recursive "${env:DIR_WORKSPACE}\test" ".ps1")) { + $null = Write-Host "`n`n[ INFO ] Executing '${___script}' ..." + $___scripts_total += 1 + + $___process = & { + $PSDefaultParameterValues['*:Encoding'] = 'utf8' + $OutputEncoding = [console]::InputEncoding ` + = [console]::OutputEncoding ` + = New-Object System.Text.UTF8Encoding + $null = . $___script + if ($LASTEXITCODE -eq 0) { + return 0 + } + + return 1 + } + + $null = Write-Host "[ INFO ] Return code: |${___process}|" + if ($___process -ne 0) { + $null = Write-Host "[ FAILED ] Test failed." + continue + } + + + $___scripts_passed += 1 + } +} + + +# report overall test report +$___scripts_failed = $___scripts_total - $___scripts_passed +$null = Write-Host @" +`n`n +[ INFO ] TOTAL : ${___scripts_total} +[ INFO ] PASSED: ${___scripts_passed} +[ INFO ] FAILED: ${___scripts_failed} + +"@ + +if ($___scripts_failed -ne 0) { + return 1 +} +return 0 diff --git a/Shell/shell/test.sh b/Shell/shell/test.sh new file mode 100755 index 0000000..3c7d571 --- /dev/null +++ b/Shell/shell/test.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +if [ ! -f "${PWD}/shell/init.sh" ]; then + 1>&2 printf -- "[ ERROR ] Missing './shell/init.sh'.\n" + return 1 +fi +. "${PWD}/shell/init.sh" +if [ $? -ne 0 ]; then + return 1 +fi + + + + +# execute all test scripts +Logf "[ INFO ] BEGIN TESTS SUITE\n" +___scripts_total=0 +___scripts_passed=0 +if [ -d "${DIR_WORKSPACE}/test" ]; then + for ___script in $(Find_Files_Recursive "${DIR_WORKSPACE}/test" ".sh"); do + if [ ! -f "$___script" ]; then + continue + fi + + 1>&2 printf -- "\n\n[ INFO ] Executing '${___script}' ...\n" + ___scripts_total=$(($___scripts_total + 1)) + + if [ ! -x "$___script" ]; then + 1>&2 printf -- "[ ERROR ] Not executable!\n" + continue + fi + $(. "$___script") + ___process=$? + + 1>&2 printf -- "[ INFO ] Return Code: %s\n" "$___process" + if [ $___process -ne 0 ]; then + 1>&2 printf -- "[ ERROR ] Test failed." + continue + fi + + ___scripts_passed=$(($___scripts_passed + 1)) + done +fi + + + + +# report overall test report +___scripts_failed=$(($___scripts_total - $___scripts_passed)) +Logf "\n +[ INFO ] TOTAL : %b +[ INFO ] PASSED : %b +[ INFO ] FAILED : %b +" "$___scripts_total" "$___scripts_passed" "$___scripts_failed" + +if [ $___scripts_total -ne $___scripts_passed ]; then + 1>&2 printf -- "[ FAILED ]\n" + return 1 +fi + +1>&2 printf -- "[ SUCCESS ]\n" +return 0 diff --git a/Shell/test/String/Split_Left_String/0.ps1 b/Shell/test/String/Split_Left_String/0.ps1 index 947c956..492cfc4 100755 --- a/Shell/test/String/Split_Left_String/0.ps1 +++ b/Shell/test/String/Split_Left_String/0.ps1 @@ -8,17 +8,25 @@ # # You MUST ensure any interaction with the content STRICTLY COMPLIES with # the permissions and limitations set forth in the license. -$null = Logf "TEST CASE : {0}`n" "HestiaKERNEL_Split_String" -$null = Logf "DESCRIPTION:`n{0}`n" @" +$PSDefaultParameterValues['*:Encoding'] = 'utf8' +$OutputEncoding = [console]::InputEncoding ` + = [console]::OutputEncoding ` + = New-Object System.Text.UTF8Encoding + + + + +$null = Write-Host "TEST CASE : 'HestiaKERNEL_Split_String'" +$null = Write-Host "DESCRIPTION:`n{0}`n" @" Function can split a proper string. "@ -$null = Logf "Checking LIBS_HESTIA pathing: (${0})`n" ${env:LIBS_HESTIA} -if (${env:LIBS_HESTIA} = "") { - $null = Logf "[ FAILED ] variable undefined!`n`n" +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" exit ${env:TEST_FAILED} } @@ -26,45 +34,67 @@ if (${env:LIBS_HESTIA} = "") { $___target = "${env:LIBS_HESTIA}\HestiaKERNEL\String\Split_Left_String.ps1" -$null = Logf "Checking Library file ({0})`n" $___target +$null = Write-Host "Checking Library file (${___target})..." if (-not (Test-Path -Path $___target)) { - $null = Logf "[ FAILED ] missing file!`n`n" + $null = Write-Host "[ FAILED ] missing file!`n" exit ${env:TEST_FAILED} } -$null = Logf "Import function library...`n" -$___process = . $___target -if ($___process -ne 0) { - $null = Logf "[ FAILED ] error on import!`n`n" +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Split-Left-String' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" exit ${env:TEST_FAILED} } -$___input = "e你feeeff你你aergaegE你F" +$___input = "e你feeeff你你aerg aegE你F" $___target = "a" $___expect = @( "e你feeeff你你", - "erg", + "erg ", "egE你F" ) $___output = HestiaKERNEL-Split-Left-String $___input $___target -Logf "Given sample:`n|{0}|`n" $___input -Logf "Given target:`n|{0}|`n" $___target -Logf "Given expect:`n|{0}|`n" $___expect -Logf "Given output:`n|{0}|`n" $___output + +$null = Write-Host "Given input :`n|${___input}|" +$null = Write-Host "Given target:`n|${___target}|" + +$___verdict = 0 +if ($___output.Length -ne $___expect.Length) { + $___verdict = 1 + + for ($i = 0; $i -lt $___output.Length; $i++) { + $null = Write-Host "OUTPUT[${i}] = |$($___output[$i])|" + } + + for ($i = 0; $i -lt $___expect.Length; $i++) { + $null = Write-Host "EXPECT[${i}] = |$($___expect[$i])|" + } + + $null = Write-Host "(Length) OUTPUT:EXPECT = |$($___output.Length)|$($___expect.Length)|" +} else { + for ($i = 0; $i -lt $___output.Length; $i++) { + if ($___output[$i] -ne $___expect[$i]) { + $___verdict = 1 + } + + $null = Write-Host "${i}:OUTPUT:EXPECT = |$($___output[$i])|$($___expect[$i])|" + } +} # assert result -if ($___output -eq $___expect) { - Logf "[ PASSED ]`n" +if ($___verdict -eq 0) { + $null = Write-Host "[ PASSED ]" exit ${env:TEST_PASSED} } -Logf "[ FAILED ] unexpected/inconsistent output!`n" +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" exit ${env:TEST_FAILED} diff --git a/automataCI/SECRETS-template.toml b/automataCI/SECRETS-template.toml new file mode 100644 index 0000000..f45f490 --- /dev/null +++ b/automataCI/SECRETS-template.toml @@ -0,0 +1,150 @@ +########################## +# 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 = "" + + + + +########################## +# CONTAINER # +########################## +# 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 = "" + + + + +########################## +# 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 ="" + + + + +###################### +# 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 = '' + + + + +########################## +# 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 = "" + + + + +###################### +# NPM TECHNOLOGY # +###################### +# NPM_USERNAME +# The username for login. +NPM_USERNAME = "" + + +# NPM_TOKEN +# The Authentication token (e.g. _authToken) for logging into the corresponding +# NPM registry defined in the CONFIG.toml. +NPM_TOKEN = "" + + + + +###################### +# 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 = "" diff --git a/automataCI/_package-archive_unix-any.sh b/automataCI/_package-archive_unix-any.sh new file mode 100644 index 0000000..24a54b6 --- /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}/packagers-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..49da491 --- /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}\packagers-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..de9fd79 --- /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}/packagers-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..f1c74e5 --- /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}\packagers-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..87d0639 --- /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}/packagers-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" + __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..7b158d9 --- /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}\packagers-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..54bb8c4 --- /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_Date_ISO8601 "$(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..232d02c --- /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-Date-ISO8601 "$(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..f266257 --- /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}/packagers-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..8691bd9 --- /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}\packagers-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..3d75515 --- /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}/packagers-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..fb4d238 --- /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}\packagers-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..a2d0740 --- /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}/packagers-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..c8b1548 --- /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}\packagers-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..d93674f --- /dev/null +++ b/automataCI/_package-homebrew_unix-any.sh @@ -0,0 +1,90 @@ +#!/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/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 + + + + +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#*|}" + + _src="${__line%%|*}" + + + # validate input + + + # prepare workspace and required values + I18N_Create_Package "HOMEBREW" + + + # 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 + return 0 + ;; + 0) + # accepted + ;; + *) + I18N_Assemble_Failed + return 1 + ;; + esac + + + # 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..0a1c0cd --- /dev/null +++ b/automataCI/_package-homebrew_windows-any.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\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.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 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] + $_src = $__list[5] + + + # validate input + + + # prepare workspace and required values + $null = I18N-Create-Package "HOMEBREW" + + + # 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 + return 0 + } 0 { + # accepted + } Default { + $null = I18N-Assemble-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..8813d8e --- /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}/packagers-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..fdf0c15 --- /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}\packagers-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-lib_unix-any.sh b/automataCI/_package-lib_unix-any.sh new file mode 100644 index 0000000..c9b6cbb --- /dev/null +++ b/automataCI/_package-lib_unix-any.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +. "${LIBS_AUTOMATACI}/services/io/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +PACKAGE_Run_LIB() { + #__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_LIB_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-lib_windows-any.ps1 b/automataCI/_package-lib_windows-any.ps1 new file mode 100644 index 0000000..f784801 --- /dev/null +++ b/automataCI/_package-lib_windows-any.ps1 @@ -0,0 +1,73 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + return +} + + + + +function PACKAGE-Run-LIB { + 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-LIB-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-LIB-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-msi_unix-any.sh b/automataCI/_package-msi_unix-any.sh new file mode 100644 index 0000000..cc03817 --- /dev/null +++ b/automataCI/_package-msi_unix-any.sh @@ -0,0 +1,744 @@ +#!/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/msi.sh" +. "${LIBS_AUTOMATACI}/services/crypto/random.sh" +. "${LIBS_AUTOMATACI}/services/hestiaLOCALE/Vanilla.sh.ps1" +. "${LIBS_AUTOMATACI}/services/hestiaI18N/Vanilla.sh.ps1" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +PACKAGE_Seal_MSI() { + __workspace="$1" + __output_directory="$2" + + + # obtain buildable target architecture + _target_arch="$(FS_Get_File "$__workspace")" + I18N_Check "MSI: '$_target_arch'" + case "$_target_arch" in + amd64) + ;; + *) + I18N_Check_Incompatible_Skipped + return 0 # wixl does not support other arch aside amd64 + ;; + esac + + + # validate icon.ico available + __icon_filepath="${__workspace}/icon.ico" + I18N_Check "$__icon_filepath" + FS_Is_File "$__icon_filepath" + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # validate msi-banner.jpg is available + __banner_filepath="${__workspace}/msi-banner.jpg" + I18N_Check "$__banner_filepath" + FS_Is_File "$__banner_filepath" + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # validate msi-dialog.jpg is available + __dialog_filepath="${__workspace}/msi-dialog.jpg" + I18N_Check "$__dialog_filepath" + FS_Is_File "$__dialog_filepath" + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # create wxs scripts by languages + __old_IFS="$IFS" + while IFS="" read -r __language || [ -n "$__language" ]; do + # formulate destination path + __dest="${__workspace}/${PROJECT_SKU}_${__language}_windows-${_target_arch}.wxs" + I18N_Check_Availability "$__dest" + FS_Is_File "$__dest" + if [ $? -eq 0 ]; then + # user supplied - begin packaging + I18N_Package "$__dest" + MSI_Compile "$__dest" "$_target_arch" "$__language" + if [ $? -ne 0 ]; then + I18N_Package_Failed + return 1 + fi + + continue + fi + + + # creating wxs headers + I18N_Create "$__dest" + FS_Write_File "$__dest" "\ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMDLINE_${PROJECT_MSI_INSTALL_DIRECTORY} + + + + CMDLINE_${PROJECT_MSI_INSTALL_DIRECTORY} + + + + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + __source="${__workspace}/bin" + FS_Is_Directory_Empty "$__source" + if [ $? -ne 0 ]; then + ## write the opener + FS_Append_File "$__dest" "\ + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + ## loop through each file and create the following + for __file in "${__source}/"*; do + FS_Is_File "$__file" + if [ $? -ne 0 ]; then + continue + fi + + FS_Append_File "$__dest" "\ + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + done + + ## write the closure + FS_Append_File "$__dest" "\ + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + fi + + __source="${__workspace}/config" + FS_Is_Directory_Empty "$__source" + if [ $? -ne 0 ]; then + ## write the opener + FS_Append_File "$__dest" "\ + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + ## loop through each file and create the following + for __file in "${__source}/"*; do + FS_Is_File "$__file" + if [ $? -ne 0 ]; then + continue + fi + + FS_Append_File "$__dest" "\ + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + done + + ## write the closure + FS_Append_File "$__dest" "\ + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + fi + + __source="${__workspace}/lib" + FS_Is_Directory_Empty "$__source" + if [ $? -ne 0 ]; then + ## write the opener + FS_Append_File "$__dest" "\ + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + ## loop through each file and create the following + for __file in "${__source}/"*; do + FS_Is_File "$__file" + if [ $? -ne 0 ]; then + continue + fi + + FS_Append_File "$__dest" "\ + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + done + + ## write the closure + FS_Append_File "$__dest" "\ + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + fi + + __source="${__workspace}/docs" + FS_Is_Directory_Empty "$__source" + if [ $? -ne 0 ]; then + ## write the opener + FS_Append_File "$__dest" "\ + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + ## loop through each file and create the following + for __file in "${__source}/"*; do + FS_Is_File "$__file" + if [ $? -ne 0 ]; then + continue + fi + + FS_Append_File "$__dest" "\ + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + done + + ## write the closure + FS_Append_File "$__dest" "\ + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + fi + + + # close directory section + FS_Append_File "$__dest" "\ + + + + + + + + + + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # define all feature components + FS_Append_File "$__dest" "\ + + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # write bin feature list + FS_Is_Directory_Empty "${__workspace}/bin" + if [ $? -ne 0 ]; then + FS_Append_File "$__dest" "\ + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + fi + + + # write config feature list + FS_Is_Directory_Empty "${__workspace}/config" + if [ $? -ne 0 ]; then + FS_Append_File "$__dest" "\ + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + fi + + + # write lib feature list + FS_Is_Directory_Empty "${__workspace}/lib" + if [ $? -ne 0 ]; then + FS_Append_File "$__dest" "\ + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + fi + + + # write docs feature list + FS_Is_Directory_Empty "${__workspace}/docs" + if [ $? -ne 0 ]; then + FS_Append_File "$__dest" "\ + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + fi + + + # close feature list + FS_Append_File "$__dest" "\ + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # conclude the wxs write-up + FS_Append_File "$__dest" "\ + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # begin packaging + I18N_Package "$__dest" + MSI_Compile "$__dest" "$_target_arch" "$__language" + if [ $? -ne 0 ]; then + I18N_Package_Failed + return 1 + 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\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\msi.ps1" +. "${env:LIBS_AUTOMATACI}\services\crypto\random.ps1" +. "${env:LIBS_AUTOMATACI}\services\hestiaLOCALE\Vanilla.sh.ps1" +. "${env:LIBS_AUTOMATACI}\services\hestiaI18N\Vanilla.sh.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-Seal-MSI { + param( + [string]$__workspace, + [string]$__output_directory + ) + + + # obtain buildable target architecture + $_target_arch = FS-Get-File "${__workspace}" + $null = I18N-Check "MSI: '${_target_arch}'" + switch (${_target_arch}) { + { $_ -in "amd64", "arm64", "i386", "arm" } { + # accepted + } default { + $null = I18N-Check-Incompatible-Skipped + return 0 # not supported + }} + + + # validate icon.ico is available + $__icon_filepath = "${__workspace}\icon.ico" + $null = I18N-Check "${__icon_filepath}" + $___process = FS-Is-File "${__icon_filepath}" + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + + # validate msi-banner.jpg is available + $__banner_filepath = "${__workspace}\msi-banner.jpg" + $null = I18N-Check "${__banner_filepath}" + $___process = FS-Is-File "${__banner_filepath}" + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + + # validate msi-dialog.jpg is available + $__dialog_filepath = "${__workspace}\msi-banner.jpg" + $null = I18N-Check "${__dialog_filepath}" + $___process = FS-Is-File "${__dialog_filepath}" + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + + # create wxs scripts by languages + foreach ($__language in (-split $(hestiaI18N-Get-Languages-List))) { + # validate LICENSE_[LANG}.rtf is available + $__license_filepath = "${__workspace}\docs\LICENSE_${__language}.rtf" + $null = I18N-Check "${__license_filepath}" + $___process = FS-Is-File "${__license_filepath}" + if ($___process -ne 0) { + ## look for generic one as last resort + $__license_filepath = "${__workspace}\docs\LICENSE.rtf" + $null = I18N-Check "${__license_filepath}" + $___process = FS-Is-File "${__license_filepath}" + if ($___process -ne 0) { + $null = I18N-Check-Failed-Skipped + continue ## no license file - skipping + } + } + + + # formulate destination path + $__dest = "${env:PROJECT_SKU}_${__language}_windows-${_target_arch}.wxs" + $__dest = "${__workspace}\${__dest}" + $null = I18N-Check-Availability "${__dest}" + $___process = FS-Is-File "${__dest}" + if ($___process -eq 0) { + # user supplied - begin packaging + $null = I18N-Package "${__dest}" + $___process = MSI-Compile "${__dest}" "${_target_arch}" "${__language}" + if ($___process -ne 0) { + $null = I18N-Package-Failed + return 1 + } + + continue + } + + + # creating wxs headers + $null = I18N-Create "${__dest}" + $___process = FS-Write-File "${__dest}" @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + $__source = "${__workspace}\bin" + $___process = FS-Is-Directory-Empty "${__source}" + if ($___process -ne 0) { + $___process = FS-Append-File "${__dest}" @" + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + $__source = "${__workspace}\config" + $___process = FS-Is-Directory-Empty "${__source}" + if ($___process -ne 0) { + $___process = FS-Append-File "${__dest}" @" + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + $__source = "${__workspace}\lib" + $___process = FS-Is-Directory-Empty "${__source}" + if ($___process -ne 0) { + $___process = FS-Append-File "${__dest}" @" + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + + # Close directory tree definitions + $___process = FS-Append-File "${__dest}" @" + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + ## begin assemble bin/* files + $__source = "${__workspace}\bin" + $___process = FS-Is-Directory-Empty "${__source}" + if ($___process -ne 0) { + ## write the opener + $___process = FS-Append-File "${__dest}" @" + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + ## loop through each file and create the following + foreach ($__file in (Get-ChildItem "${__source}" -File)) { + $___process = FS-Append-File "${__dest}" @" + + +"@ + } + + ## write the closure + $___process = FS-Append-File "${__dest}" @" + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + + ## begin assemble config/* files + $__source = "${__workspace}\config" + $___process = FS-Is-Directory-Empty "${__source}" + if ($___process -ne 0) { + ## write the opener + $___process = FS-Append-File "${__dest}" @" + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + ## loop through each file and create the following + foreach ($__file in (Get-ChildItem "${__source}" -File)) { + $___process = FS-Append-File "${__dest}" @" + + +"@ + } + + ## write the closure + $___process = FS-Append-File "${__dest}" @" + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + + ## begin assemble lib/* files + $__source = "${__workspace}\lib" + $___process = FS-Is-Directory-Empty "${__source}" + if ($___process -ne 0) { + ## write the opener + $___process = FS-Append-File "${__dest}" @" + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + ## loop through each file and create the following + foreach ($__file in (Get-ChildItem "${__source}" -File)) { + $___process = FS-Append-File "${__dest}" @" + + +"@ + } + + ## write the closure + $___process = FS-Append-File "${__dest}" @" + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + + ## begin assemble docs/* files + $__source = "${__workspace}\docs" + $___process = FS-Is-Directory-Empty "${__source}" + if ($___process -ne 0) { + ## write the opener + $___process = FS-Append-File "${__dest}" @" + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + ## loop through each file and create the following + foreach ($__file in (Get-ChildItem "${__source}" -File)) { + $___process = FS-Append-File "${__dest}" @" + + +"@ + } + + ## write the closure + $___process = FS-Append-File "${__dest}" @" + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + + # create registry key + $___process = FS-Append-File "${__dest}" @" + + + + + + + + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # Define all feature components + $___process = FS-Append-File "${__dest}" @" + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # write bin feature list + $___process = FS-Is-Directory-Empty "${__workspace}\bin" + if ($___process -ne 0) { + $___process = FS-Append-File "${__dest}" @" + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + + # write config feature list + $___process = FS-Is-Directory-Empty "${__workspace}\config" + if ($___process -ne 0) { + $___process = FS-Append-File "${__dest}" @" + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + + # write lib feature list + $___process = FS-Is-Directory-Empty "${__workspace}\lib" + if ($___process -ne 0) { + $___process = FS-Append-File "${__dest}" @" + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + + # write docs feature list + $___process = FS-Is-Directory-Empty "${__workspace}\docs" + if ($___process -ne 0) { + $___process = FS-Append-File "${__dest}" @" + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + + # close feature list + $___process = FS-Append-File "${__dest}" @" + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # Add standard UI support + $___process = FS-Append-File "${__dest}" @" + + + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # conclude the wxs write-up + $___process = FS-Append-File "${__dest}" @" + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # begin packaging + $null = I18N-Package "${__dest}" + $___process = MSI-Compile "${__dest}" "${_target_arch}" "${__language}" + if ($___process -ne 0) { + $null = I18N-Package-Failed + return 1 + } + } + + + # begin export packages + foreach ($__line in (Get-ChildItem -Path "${__workspace}" -File ` + | Where-Object { ($_.Name -like "*.msi") })) { + $__dest = "${__output_directory}\$(FS-Get-File "${__line}")" + + $null = I18N-Export "${__dest}" + $___process = FS-Copy-File "${__line}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Export-Failed + return 1 + } + } + + + # report status + return 0 +} + + + + +function PACKAGE-Sort-MSI { + param( + [string]$__workspace + ) + + + # execute + $__source = "${__workspace}\any" + $null = I18N-Check "${__source}" + $___process = FS-Is-Directory "${__source}" + if ($___process -ne 0) { + return 0 # nothing to sort - report status + } + + :arch_loop foreach ($_arch in (Get-ChildItem -Path "${__workspace}" -Directory)) { + $_arch = $_arch.FullName + $___process = FS-Is-Directory "${_arch}" + if ($___process -ne 0) { + continue arch_loop + } + + if ("$(FS-Get-File "${_arch}")" -eq "any") { + continue arch_loop + } + + # begin merging from any + :any_loop foreach ($__target in (Get-ChildItem -Path "${__workspace}\any")) { + $__target = $__target.FullName + + $___process = FS-Is-File "${__target}" + if ($___process -eq 0) { + $__dest = FS-Get-File "${__target}" + $__dest = "${_arch}\${__dest}" + $null = I18N-Copy "${__target}" "${__dest}" + $___process = FS-Is-File "${__dest}" + if ($___process -eq 0) { + $null = I18N-Copy-Exists-Skipped + continue any_loop # do not overwrite + } + + $___process = FS-Copy-File "${__target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + continue any_loop + } + + + # it's a directory, loop it + :any_dir_loop foreach ($__file in (Get-ChildItem -Path "${__target}")) { + $__file = $__file.FullName + + $___process = FS-Is-File "${__file}" + if ($___process -ne 0) { + continue any_dir_loop + } + + $__dest = "$(FS-Get-File "${__file}")" + $__dest = "${_arch}\$(FS-Get-File "${__target}")\${__dest}" + $null = I18N-Copy "${__file}" "${__dest}" + $___process = FS-Is-File "${__dest}" + if ($___process -eq 0) { + $null = I18N-Copy-Exists-Skipped + continue any_dir_loop # do not overwrite + } + + $___process = FS-Copy-File "${__file}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + } + } + } + + + # remove 'any' to prevent bad compilation + $___process = FS-Remove "${__workspace}/any" + if ($___process -ne 0) { + $null = I18N-Check-Failed + 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] + $_src = $__list[5] + + + # 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 = "${_src}\${_target_arch}" + $null = FS-Make-Directory "${_src}\bin" + $null = FS-Make-Directory "${_src}\config" + $null = FS-Make-Directory "${_src}\docs" + $null = FS-Make-Directory "${_src}\ext" + $null = FS-Make-Directory "${_src}\lib" + + + # 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 + }} + + + # report status + 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..fd78da0 --- /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..7399772 --- /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}/packagers-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..62ee7b5 --- /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}\packagers-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..c5b4a59 --- /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" + 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}/packagers-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..f531a29 --- /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" + $___process = MANUAL-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed "MANUAL" + 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}\packagers-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..dfe0879 --- /dev/null +++ b/automataCI/_release-changelog_unix-any.sh @@ -0,0 +1,48 @@ +#!/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/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_Conclude "${PROJECT_VERSION} CHANGELOG" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + CHANGELOG_Seal \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/changelog" \ + "$PROJECT_VERSION" + if [ $? -ne 0 ]; then + I18N_Conclude_Failed + return 1 + fi + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Conclude "${PROJECT_VERSION} CHANGELOG" + fi + + + # 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..5d6d76e --- /dev/null +++ b/automataCI/_release-changelog_windows-any.ps1 @@ -0,0 +1,47 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\changelog.ps1" + + + + +# 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-Conclude "${env:PROJECT_VERSION} CHANGELOG" + if ($(OS-Is-Run-Simulated) -ne 0) { + $___process = CHANGELOG-Seal ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\changelog" ` + "${env:PROJECT_VERSION}" + if ($___process -ne 0) { + $null = I18N-Conclude-Failed + return 1 + } + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Conclude "${env:PROJECT_VERSION} CHANGELOG" + } + + + # return 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..2229127 --- /dev/null +++ b/automataCI/_release-checksum_unix-any.sh @@ -0,0 +1,193 @@ +#!/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/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_Conclude_CHECKSUM() { + #__repo_directory="$1" + + + # execute + __sha256_file="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/releaser-sha256.txt" + FS_Remove_Silently "$__sha256_file" + + __sha512_file="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/releaser-sha512.txt" + FS_Remove_Silently "$__sha512_file" + + __sha256_target="${PROJECT_SKU}-sha256_${PROJECT_VERSION}.txt" + __sha256_target="${1}/${__sha256_target}" + FS_Remove_Silently "$__sha256_target" + + __sha512_target="${PROJECT_SKU}-sha512_${PROJECT_VERSION}.txt" + __sha512_target="${1}/${__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" + __keyfile="${1}/${__keyfile}" + + I18N_Publish "$__keyfile" + FS_Remove_Silently "$__keyfile" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + GPG_Export_Public_Key "$__keyfile" "$PROJECT_GPG_ID" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + else + I18N_Simulate_Publish "$__keyfile" + fi + + # gpg sign all packages + for TARGET in "$1"/*; do + if [ ! "${TARGET%%.asc*}" = "$TARGET" ]; then + continue # it's a gpg cert + fi + + if [ ! "${TARGET%%.gpg*}" = "$TARGET" ]; then + continue # it's a gpg keyfile or cert + fi + + I18N_Sign "$TARGET" "GPG" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Notarize "$TARGET" + continue + fi + + FS_Remove_Silently "${TARGET}.asc" + GPG_Detach_Sign_File "${TARGET}.asc" "$TARGET" "$PROJECT_GPG_ID" + if [ $? -ne 0 ]; then + I18N_Sign_Failed + return 1 + fi + done + fi + + + # shasum all files + for TARGET in "$1"/*; 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} $(FS_Get_File "$TARGET")\n" + 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} $(FS_Get_File "$TARGET")\n" + if [ $? -ne 0 ]; then + I18N_Checksum_Failed + return 1 + fi + fi + done + + + FS_Is_File "$__sha256_file" + if [ $? -eq 0 ]; then + I18N_Conclude "$__sha256_target" + FS_Move "$__sha256_file" "$__sha256_target" + if [ $? -ne 0 ]; then + I18N_Conclude_Failed + return 1 + fi + fi + + + FS_Is_File "$__sha512_file" + if [ $? -eq 0 ]; then + I18N_Conclude "$__sha512_target" + FS_Move "$__sha512_file" "$__sha512_target" + if [ $? -ne 0 ]; then + I18N_Conclude_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..74c2fee --- /dev/null +++ b/automataCI/_release-checksum_windows-any.ps1 @@ -0,0 +1,201 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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\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-Conclude-CHECKSUM { + param ( + [string]$__repo_directory + ) + + + # execute + $__sha256_file = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\releaser-sha256.txt" + $null = FS-Remove-Silently "${__sha256_file}" + + $__sha512_file = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\releaser-sha512.txt" + $null = FS-Remove-Silently "${__sha512_file}" + + $__sha256_target = "${env:PROJECT_SKU}-sha256_${env:PROJECT_VERSION}.txt" + $__sha256_target = "${__repo_directory}\${__sha256_target}" + $null = FS-Remove-Silently "${__sha256_target}" + + $__sha512_target = "${env:PROJECT_SKU}-sha512_${env:PROJECT_VERSION}.txt" + $__sha512_target = "${__repo_directory}\${__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" + $__keyfile = "${__repo_directory}\${__keyfile}" + + $null = I18N-Publish "${__keyfile}" + $null = FS-Remove-Silently "${__keyfile}" + if ($(OS-Is-Run-Simulated) -ne 0) { + $___process = GPG-Export-Public-Key ` + "${__keyfile}" ` + "${env:PROJECT_GPG_ID}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + } else { + $null = I18N-Simulate-Publish "${__keyfile}" + } + + foreach ($TARGET in (Get-ChildItem -Path "${__repo_directory}")) { + $TARGET = $TARGET.FullName + + if ($("${TARGET}" -replace '^.*.asc') -ne "${TARGET}") { + continue # it's a gpg cert + } + + if ($("${TARGET}" -replace '^.*.gpg') -ne "${TARGET}") { + continue # it's a gpg keyfile or cert + } + + $null = I18N-Sign "${TARGET}" "GPG" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Notarize "${TARGET}" + continue + } + + FS-Remove-Silently "${TARGET}.asc" + $___process = GPG-Detach-Sign-File ` + "${TARGET}.asc" ` + "${TARGET}" ` + "${env:PROJECT_GPG_ID}" + if ($___process -ne 0) { + $null = I18N-Sign-Failed + return 1 + } + } + } + + + # shasum all files + foreach ($TARGET in (Get-ChildItem -Path "${__repo_directory}")) { + $TARGET = $TARGET.FullName + + $___process = FS-Is-Directory "${TARGET}" + if ($___process -eq 0) { + $null = I18N-Is-Directory-Skipped "${TARGET}" + continue + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_SHA256}") -ne 0) { + $null = I18N-Checksum $TARGET "SHA256" + $__value = SHASUM-Create-From-File $TARGET "256" + if ($(STRINGS-Is-Empty "${__value}") -eq 0) { + $null = I18N-Checksum-Failed + return 1 + } + + $___process = FS-Append-File ` + "${__sha256_file}" ` + "${__value} $(FS-Get-File "$TARGET")`n" + 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-Create-From-File $TARGET "512" + if ($(STRINGS-Is-Empty "${__value}") -eq 0) { + $null = I18N-Checksum-Failed + return 1 + } + + $___process = FS-Append-File ` + "${__sha512_file}" ` + "${__value} $(FS-Get-File "$TARGET")`n" + if ($___process -ne 0) { + $null = I18N-Checksum-Failed + return 1 + } + } + } + + + $___process = FS-Is-File "${__sha256_file}" + if ($___process -eq 0) { + $null = I18N-Conclude "${__sha256_target}" + $___process = FS-Move "${__sha256_file}" "${__sha256_target}" + if ($___process -ne 0) { + $null = I18N-Conclude-Failed + return 1 + } + } + + + $___process = FS-Is-File "${__sha512_file}" + if ($___process -eq 0) { + $null = I18N-Conclude "${__sha512_target}" + $___process = FS-Move "${__sha512_file}" "${__sha512_target}" + if ($___process -ne 0) { + $null = I18N-Conclude-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 "${env:PROJECT_GPG_ID}" + if ($___process -ne 0) { + $null = I18N-Check-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..2b950d2 --- /dev/null +++ b/automataCI/_release-citation_unix-any.sh @@ -0,0 +1,59 @@ +#!/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 + + + + +RELEASE_Run_CITATION_CFF() { + #__target="$1" + + + # validate + if [ $(FS_Is_Target_A_Citation_CFF "$1") -ne 0 ]; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_CITATION") -eq 0 ]; then + return 0 # disabled explicitly + fi + + + # execute + I18N_Publish "CITATION.cff" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + FS_Copy_File "$1" "${PROJECT_PATH_ROOT}/CITATION.cff" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Publish "CITATION.cff" + fi + + + # 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..261a7f4 --- /dev/null +++ b/automataCI/_release-citation_windows-any.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\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 +} + + + + +function RELEASE-Run-CITATION-CFF { + param( + [string]$__target + ) + + + # validate input + $___process = FS-Is-Target-A-Citation-CFF "${__target}" + if ($___process -ne 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_CITATION}") -eq 0) { + return 0 # disabled explicitly + } + + + # execute + $null = I18N-Publish "CITATION.cff" + if ($(OS-Is-Run-Simulated) -ne 0) { + $___process = FS-Copy-File "${__target}" "${env:PROJECT_PATH_ROOT}\CITATION.cff" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Publish "CITATION.cff" + } + + + # 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..05cc830 --- /dev/null +++ b/automataCI/_release-deb_unix-any.sh @@ -0,0 +1,273 @@ +#!/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/deb.sh" +. "${LIBS_AUTOMATACI}/services/versioners/git.sh" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +# define operating variables +DEB_REPO_DATA="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/releaser-deb-repoDB" +if [ $(STRINGS_Is_Empty "$PROJECT_DEB_PATH_DATA") -ne 0 ]; then + DEB_REPO_DATA="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/data/deb/${PROJECT_DEB_PATH_DATA}" +fi + +DEB_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}" # default: flat mode +if [ "${PROJECT_DEB_DISTRIBUTION%%/*}" = "$PROJECT_DEB_DISTRIBUTION" ]; then + ## conventional mode + DEB_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/deb" + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + ;; + *) + # fallback to git mode + if [ $(STRINGS_Is_Empty "$PROJECT_DEB_PATH") -ne 0 ]; then + DEB_REPO="${DEB_REPO}/${PROJECT_DEB_PATH}" + fi + ;; + esac + + ## overrides if PROJECT_RELEASE_REPO is set + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + DEB_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/deb" + fi +fi + + + + +RELEASE_Conclude_DEB() { + #__repo_directory="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_DEB_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + + # execute + I18N_Conclude "DEB" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Conclude "DEB" + return 0 + elif [ ! "${PROJECT_DEB_DISTRIBUTION%%/*}" = "$PROJECT_DEB_DISTRIBUTION" ]; then + # nothing to do in flat mode - report status + return 0 + elif [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + # do nothing - single unified repository will take over later + return 0 + fi + + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + # nothing to do for local directory type - report status + return 0 + ;; + *) + # repository is an independent git repository so proceed as follows. + ;; + esac + + + # commit release + __current_path="$PWD" && cd "$1" + GIT_Autonomous_Force_Commit \ + "$PROJECT_VERSION" \ + "$PROJECT_DEB_REPO_KEY" \ + "$PROJECT_DEB_REPO_BRANCH" + ___process=$? + cd "$__current_path" && unset __current_path + if [ $___process -ne 0 ]; then + I18N_Conclude_Failed + return 1 + fi + + + # report status + return 0 +} + + + + +RELEASE_Run_DEB() { + __target="$1" + __repo_directory="$2" + __data_directory="$3" + + + # validate input + DEB_Is_Valid "$__target" + if [ $? -ne 0 ]; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_DEB_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + + # execute + I18N_Publish "DEB" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + DEB_Publish \ + "$__repo_directory" \ + "$__data_directory" \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/releaser-deb" \ + "$__target" \ + "$PROJECT_DEB_DISTRIBUTION" \ + "$PROJECT_DEB_COMPONENT" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Publish "DEB" + fi + + + # report status + return 0 +} + + + + +RELEASE_Setup_DEB() { + #__repo_directory="$1" + + + # validate input + I18N_Check "DEB" + if [ $(STRINGS_Is_Empty "$PROJECT_DEB_URL") -eq 0 ]; then + I18N_Check_Disabled_Skipped + return 0 # disabled explicitly + fi + + + # execute + I18N_Setup "DEB" + if [ "${PROJECT_DEB_DISTRIBUTION%%/*}" = "$PROJECT_DEB_DISTRIBUTION" ]; then + # conventional mode + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + ## overridden by single unified repository + FS_Remake_Directory "$1" + return 0 + fi + + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + ## local file directory type + FS_Remake_Directory "$1" + return 0 + ;; + *) + ## fallback to git repository source + ;; + esac + + FS_Make_Housing_Directory "$1" + GIT_Clone_Repo \ + "$PROJECT_PATH_ROOT" \ + "$PROJECT_PATH_RELEASE" \ + "$PWD" \ + "$PROJECT_DEB_REPO" \ + "$PROJECT_SIMULATE_RUN" \ + "deb" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + + FS_Make_Directory "$1" + fi + + + # report status + return 0 +} + + + + +RELEASE_Update_DEB() { + #__repo_directory="$1" + #__data_directory="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_DEB_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + + # execute + I18N_Publish "DEB" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Publish "DEB" + return 0 + fi + + DEB_Publish_Conclude \ + "$1" \ + "$2" \ + "$PROJECT_DEB_DISTRIBUTION" \ + "$PROJECT_DEB_ARCH" \ + "$PROJECT_DEB_COMPONENT" \ + "$PROJECT_DEB_CODENAME" \ + "$PROJECT_GPG_ID" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + + + # create the README.md + if [ ! "${PROJECT_DEB_DISTRIBUTION%%/*}" = "$PROJECT_DEB_DISTRIBUTION" ]; then + # it's flat repo so stop here - no README.md is required + return 0 + fi + + __dest="${1}/DEB_Repository.md" + I18N_Create "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Remove_Silently "$__dest" + FS_Write_File "$__dest" "\ +# DEB Distribution Repository + +This directory is now re-purposed to host DEB packages repository. +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # 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..134c38f --- /dev/null +++ b/automataCI/_release-deb_windows-any.ps1 @@ -0,0 +1,277 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\deb.ps1" +. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + return +} + + + + +# define operating variables +$DEB_REPO_DATA = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\releaser-deb-repoDB" +if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_PATH_DATA}") -ne 0) { + $DEB_REPO_DATA = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\data\deb\${env:PROJECT_DEB_PATH_DATA}" +} + +$DEB_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}" # default: flat mode +if ("$(${env:PROJECT_DEB_DISTRIBUTION} -replace "\/.*$", '')" -eq "${env:PROJECT_DEB_DISTRIBUTION}") { + ## conventional mode + $DEB_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\deb" + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + # retain existing path + } default { + # fallback to git mode + if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_PATH}") -ne 0) { + $DEB_REPO = "${DEB_REPO}\${PROJECT_DEB_PATH}" + } + }} + + ## overrides if PROJECT_RELEASE_REPO is set + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0) { + $DEB_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\deb" + } +} + + + + +function RELEASE-Conclude-DEB { + param( + [string]$__repo_directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_URL}") -eq 0) { + return 0 # disabled explictly + } + + + # execute + $null = I18N-Conclude "DEB" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Conclude "DEB" + return 0 + } elseif ("$($___distribution -replace "\/.*$", '')" -ne $___distribution) { + # nothing to do in flat mode - report status + return 0 + } elseif ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0) { + # do nothing - single unified repository will take over later + return 0 + } + + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + # nothing to do for local directory type - report status + return 0 + } default { + # repository is an independent git repository so proceed as follows. + }} + + + # commit release + $__current_path = Get-Location + $null = Set-Location "${__repo_directory}" + $___process = Git-Autonomous-Force-Commit ` + "${env:PROJECT_VERSION}" ` + "${env:PROJECT_DEB_REPO_KEY}" ` + "${env:PROJECT_DEB_REPO_BRANCH}" + $null = Set-Location "${__curent_path}" + $null = Remove-Variable __current_path + if ($___process -ne 0) { + $null = I18N-Conclude-Failed + return 1 + } + + + # return status + return 0 +} + + + + +function RELEASE-Run-DEB { + param( + [string]$__target, + [string]$__repo_directory, + [string]$__data_directory + ) + + + # validate input + $___process = DEB-Is-Valid "${__target}" + if ($___process -ne 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_URL}") -eq 0) { + return 0 # disabled explictly + } + + + # execute + $null = I18N-Publish "DEB" + if ($(OS-Is-Run-Simulated) -ne 0) { + $___process = DEB-Publish ` + "${__repo_directory}" ` + "${__data_directory}" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\releaser-deb" ` + "${__target}" ` + "${env:PROJECT_DEB_DISTRIBUTION}" ` + "${env:PROJECT_DEB_COMPONENT}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Publish "DEB" + } + + + # report status + return 0 +} + + + + +function RELEASE-Setup-DEB { + param( + [string]$__repo_directory + ) + + + # validate input + $null = I18N-Check "DEB" + if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_URL}") -eq 0) { + $null = I18N-Check-Disabled-Skipped + return 0 # disabled explictly + } + + + # execute + $null = I18N-Setup "DEB" + if ("$($___distribution -replace "\/.*$", '')" -eq $___distribution) { + # conventional mode + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -eq 0) { + ## overridden by single unified repository + $null = FS-Remake-Directory "${__repo_directory}" + return 0 + } + + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + ## local file directory type + $null = FS-Remake-Directory "${__repo_directory}" + return 0 + } default { + ## fallback to git repository source + }} + + $null = FS-Make-Housing-Directory "${__repo_directory}" + $___process = GIT-Clone-Repo ` + "${env:PROJECT_PATH_ROOT}" ` + "${env:PROJECT_PATH_RELEASE}" ` + "$(Get-Location)" ` + "${env:PROJECT_DEB_REPO}" ` + "${env:PROJECT_SIMULATE_RUN}" ` + "deb" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + + $null = FS-Make-Directory "${__repo_directory}" + } + + + # report status + return 0 +} + + + + +function RELEASE-Update-DEB { + param( + [string]$__repo_directory, + [string]$__data_directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_URL}") -eq 0) { + return 0 # disabled explictly + } + + + # execute + $null = I18N-Publish "DEB" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Publish "DEB" + return 0 + } + + $___process = DEB-Publish-Conclude ` + "${__repo_directory}" ` + "${__data_directory}" ` + "${env:PROJECT_DEB_DISTRIBUTION}" ` + "${env:PROJECT_DEB_ARCH}" ` + "${env:PROJECT_DEB_COMPONENT}" ` + "${env:PROJECT_DEB_CODENAME}" ` + "${env:PROJECT_GPG_ID}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + + + # create the README.md + if ("$($___distribution -replace "\/.*$", '')" -ne $___distribution) { + # it's flat repo so stop here - no README.md is required + return 0 + } + + $___dest = "${__repo_directory}\DEB_Repository.md" + $null = I18N-Create "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $null = FS-Remove-Silently "${__dest}" + $___process = FS-Write-File "${__dest}" @" +# DEB Distribution Repository + +This directory is now re-purposed to host DEB packages repository. + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # 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..218b11e --- /dev/null +++ b/automataCI/_release-docker_unix-any.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. +. "${LIBS_AUTOMATACI}/services/io/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/docker.sh" + + + + +# 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" + + + # validate input + DOCKER_Is_Valid "$__target" + if [ $? -ne 0 ]; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_CONTAINER_REGISTRY") -eq 0 ]; then + return 0 # disabled explicitly + fi + + I18N_Check_Availability "DOCKER" + DOCKER_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed + return 1 + fi + + + # execute + I18N_Publish "DOCKER" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + DOCKER_Release "$__target" "$PROJECT_VERSION" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + + I18N_Clean "$__target" + FS_Remove_Silently "$__target" + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Publish "DOCKER" + 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..4435555 --- /dev/null +++ b/automataCI/_release-docker_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\io\strings.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 + ) + + + # validate input + $___process = DOCKER-Is-Valid "${__target}" + if ($___process -ne 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_CONTAINER_REGISTRY}") -eq 0) { + return 0 # disabled explicitly + } + + $null = I18N-Check-Availability "DOCKER" + $___process = DOCKER-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed + return 1 + } + + + # execute + $null = I18N-Publish "DOCKER" + if ($(OS-Is-Run-Simulated) -ne 0) { + $___process = DOCKER-Release "${__target}" "${env:PROJECT_VERSION}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + + $null = I18N-Clean "${__target}" + $null = FS-Remove-Silently "${__target}" + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Publish "DOCKER" + } + + + # 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..770c3f3 --- /dev/null +++ b/automataCI/_release-docsrepo_unix-any.sh @@ -0,0 +1,112 @@ +#!/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/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 + if [ $(STRINGS_Is_Empty "$PROJECT_DOCS_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + + # execute + I18N_Publish "DOCS" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Conclude "DOCS" + return 0 + fi + + FS_Is_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_DOCS}" + if [ $? -ne 0 ]; then + return 0 + fi + + FS_Is_File "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" + if [ $? -eq 0 ]; then + I18N_Publish_Failed + return 1 + fi + + FS_Make_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" + + I18N_Setup "DOCS" + __directory_name="x_docsrepo" + GIT_Clone_Repo \ + "$PROJECT_PATH_ROOT" \ + "$PROJECT_PATH_RELEASE" \ + "$PWD" \ + "$PROJECT_DOCS_REPO" \ + "$PROJECT_SIMULATE_RUN" \ + "$__directory_name" \ + "$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}/${__directory_name}" + + I18N_Export "$__staging" + FS_Copy_All "${__staging}/" "$__dest" + if [ $? -ne 0 ]; then + I18N_Export_Failed + FS_Remove_Silently "$__dest" + return 1 + fi + + __tag="$(GIT_Get_Latest_Commit_ID)" + I18N_Commit "$__tag" + if [ $(STRINGS_Is_Empty "$__tag") -eq 0 ]; then + I18N_Commit_Failed + FS_Remove_Silently "$__dest" + return 1 + fi + + __current_path="$PWD" && cd "$__dest" + 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 + FS_Remove_Silently "$__dest" + return 1 + fi + + FS_Remove_Silently "$__dest" + + + # report status + return 0 +} diff --git a/automataCI/_release-docsrepo_windows-any.ps1 b/automataCI/_release-docsrepo_windows-any.ps1 new file mode 100644 index 0000000..caccec5 --- /dev/null +++ b/automataCI/_release-docsrepo_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\os.ps1" +. "${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 + if ($(STRINGS-Is-Empty "${env:PROJECT_DOCS_URL}") -eq 0) { + return 0 # disabled explicitly + } + + + # execute + $null = I18N-Publish "DOCS" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Conclude "DOCS" + return 0 + } + + $___process = FS-Is-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_DOCS}" + if ($___process -ne 0) { + return 0 + } + + $___process = FS-Is-File "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + if ($___process -eq 0) { + $null = I18N-Publish-Failed + return 1 + } + + $null = FS-Make-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + + $null = I18N-Setup "DOCS" + $__directory_name = "x_docsrepo" + $___process = GIT-Clone-Repo ` + "${env:PROJECT_PATH_ROOT}" ` + "${env:PROJECT_PATH_RELEASE}" ` + "$(Get-Location)" ` + "${env:PROJECT_DOCS_REPO}" ` + "${env:PROJECT_SIMULATE_RUN}" ` + "${__directory_name}" ` + "${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}\${__directory_name}" + + $null = I18N-Export "${__staging}" + $___process = FS-Copy-All "${__staging}\" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Export-Failed + $null = FS-Remove-Silently "${__dest}" + return 1 + } + + $__tag = GIT-Get-Latest-Commit-ID + $null = I18N-Commit "${__tag}" + if ($(STRINGS-Is-Empty "${__tag}") -eq 0) { + $null = I18N-Commit-Failed + $null = FS-Remove-Silently "${__dest}" + return 1 + } + + $___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 + $null = FS-Remove-Silently "${__dest}" + return 1 + } + + $null = FS-Remove-Silently "${__dest}" + + + # return status + return 0 +} diff --git a/automataCI/_release-flatpak_unix-any.sh b/automataCI/_release-flatpak_unix-any.sh new file mode 100644 index 0000000..9a03dab --- /dev/null +++ b/automataCI/_release-flatpak_unix-any.sh @@ -0,0 +1,145 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +. "${LIBS_AUTOMATACI}/services/io/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/versioners/git.sh" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +# define operating variables +FLATPAK_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/flatpak" + + + + +RELEASE_Conclude_FLATPAK() { + #__repo_directory="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_FLATPAK_URL") -eq 0 ]; then + return 0 # disabled explicitly + elif [ $(STRINGS_Is_Empty "$PROJECT_FLATPAK_REPO") -eq 0 ] && + [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -eq 0 ]; then + return 0 # single file bundles only + elif [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + return 0 # do nothing - single unified repository will take over later + fi + + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + return 0 # do nothing + ;; + *) + # it's a git repository + ;; + esac + + + # execute + I18N_Conclude "FLATPAK" + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 0 # no repository setup during package job + fi + + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Conclude "FLATPAK" + return 0 + fi + + + # commit the git repository + __current_path="$PWD" && cd "$1" + GIT_Pull_To_Latest + if [ $? -ne 0 ]; then + cd "$__current_path" && unset __current_path + I18N_Conclude_Failed + return 1 + fi + + GIT_Autonomous_Commit "${PROJECT_SKU} ${PROJECT_VERSION}" + if [ $? -ne 0 ]; then + cd "$__current_path" && unset __current_path + I18N_Conclude_Failed + return 1 + fi + + GIT_Push "$PROJECT_FLATPAK_REPO_KEY" "$PROJECT_FLATPAK_REPO_BRANCH" + ___process=$? + cd "$__current_path" && unset __current_path + if [ $___process -ne 0 ]; then + I18N_Conclude_Failed + return 1 + fi + + + # report status + return 0 +} + + + + +RELEASE_Setup_FLATPAK() { + #__repo_directory="$1" + + + # validate input + I18N_Check "FLATPAK" + if [ $(STRINGS_Is_Empty "$PROJECT_FLATPAK_URL") -eq 0 ]; then + I18N_Check_Disabled_Skipped + return 0 # disabled explicitly + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_FLATPAK_REPO") -eq 0 ] && + [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -eq 0 ]; then + return 0 # single file bundles only + fi + + + # execute + __source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/flatpak-repo" + FS_Is_Directory "$__source" + if [ $? -ne 0 ]; then + return 0 # no repository setup during package job + fi + + I18N_Setup "FLATPAK" + FS_Remove_Silently "$1" + FS_Move "$__source" "$1" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + FS_Remove_Silently "${1}/.git" + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-flatpak_windows-any.ps1 b/automataCI/_release-flatpak_windows-any.ps1 new file mode 100644 index 0000000..010dadd --- /dev/null +++ b/automataCI/_release-flatpak_windows-any.ps1 @@ -0,0 +1,149 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + return +} + + + + +# define operating variables +$FLATPAK_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\flatpak" + + + + +function RELEASE-Conclude-FLATPAK { + param( + [string]$__repo_directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_URL}") -eq 0) { + return 0 # disabled explictly + } elseif (($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_REPO}") -eq 0) -and + ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -eq 0)) { + return 0 # single file bundles only + } + + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + return 0 # do nothing + } default { + # it's a git repository + }} + + + # execute + $null = I18N-Conclude "FLATPAK" + $___process = FS-Is-Directory "${__repo_directory}" + if ($___process -ne 0) { + return 0 # no repository setup during package job + } + + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Conclude "FLATPAK" + return 0 + } + + + # commit the git repository + $__current_path = Get-Location + $null = Set-Location "${__repo_directory}" + $___process = GIT-Pull-To-Latest + if ($___process -ne 0) { + $null = Set-Location "${__curent_path}" + $null = Remove-Variable __current_path + $null = I18N-Conclude-Failed + return 1 + } + + $___process = GIT-Autonomous-Commit "${env:PROJECT_SKU} ${env:PROJECT_VERSION}" + if ($___process -ne 0) { + $null = Set-Location "${__curent_path}" + $null = Remove-Variable __current_path + $null = I18N-Conclude-Failed + return 1 + } + + $___process = GIT-Push ` + "${env:PROJECT_FLATPAK_REPO_KEY}" ` + "${env:PROJECT_FLATPAK_REPO_BRANCH}" + $null = Set-Location "${__curent_path}" + $null = Remove-Variable __current_path + if ($___process -ne 0) { + $null = I18N-Conclude-Failed + return 1 + } + + + # return status + return 0 +} + + + + +function RELEASE-Setup-FLATPAK { + param( + [string]$__repo_directory + ) + + + # validate input + $null = I18N-Check "FLATPAK" + if ($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_URL}") -eq 0) { + $null = I18N-Check-Disabled-Skipped + return 0 # disabled explictly + } + + if (($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_REPO}") -eq 0) -and + ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -eq 0)) { + return 0 # single file bundles only + } + + + # execute + $__source = "${PROJECT_PATH_ROOT}\${PROJECT_PATH_TEMP}\flatpak-repo" + $___process = FS-Is-Directory "${__source}" + if ($___process -ne 0) { + return 0 # no repository setup during package job + } + + $null = I18N-Setup "FLATPAK" + $null = FS-Remove-Silently "${__repo_directory}" + $___process = FS-Move "${__source}" "${__repo_directory}" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0) { + $null = FS-Remove-Silently "${__repo_directory}\.git" + } + + + # report status + return 0 +} diff --git a/automataCI/_release-homebrew_unix-any.sh b/automataCI/_release-homebrew_unix-any.sh new file mode 100644 index 0000000..1ab5d17 --- /dev/null +++ b/automataCI/_release-homebrew_unix-any.sh @@ -0,0 +1,189 @@ +#!/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/homebrew.sh" +. "${LIBS_AUTOMATACI}/services/versioners/git.sh" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +# define operating variables +HOMEBREW_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/homebrew" + + + + +RELEASE_Conclude_HOMEBREW() { + #__repo_directory="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_HOMEBREW_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + + # execute + I18N_Conclude "HOMEBREW" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Conclude "HOMEBREW" + return 0 + fi + + + # commit the formula first + __current_path="$PWD" && cd "$1" + GIT_Pull_To_Latest + if [ $? -ne 0 ]; then + cd "$__current_path" && unset __current_path + I18N_Conclude_Failed + return 1 + fi + + GIT_Autonomous_Commit "${PROJECT_SKU} ${PROJECT_VERSION}" + if [ $? -ne 0 ]; then + cd "$__current_path" && unset __current_path + I18N_Conclude_Failed + return 1 + fi + + GIT_Push "$PROJECT_HOMEBREW_REPO_KEY" "$PROJECT_HOMEBREW_REPO_BRANCH" + ___process=$? + cd "$__current_path" && unset __current_path + if [ $___process -ne 0 ]; then + I18N_Conclude_Failed + return 1 + fi + + + # clean up in case of other release configurations + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + # remove traces - single unified repository will take over later + FS_Remove "$1" + if [ $? -ne 0 ]; then + I18N_Conclude_Failed + return 1 + fi + + return 0 + fi + + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + # remove traces - formula is never stray from its tap repository. + ;; + *) + return 0 + ;; + esac + + FS_Remove "$1" + if [ $? -ne 0 ]; then + I18N_Conclude_Failed + return 1 + fi + + + # report status + return 0 +} + + + + + +RELEASE_Run_HOMEBREW() { + #___target="$1" + #___repo_directory="$2" + + + # validate input + HOMEBREW_Is_Valid_Formula "$1" + if [ $? -ne 0 ]; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_HOMEBREW_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + + # execute + I18N_Publish "HOMEBREW" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + __dest="$(printf -- "%.1s" "$(FS_Get_File "$1")")" + __dest="${2}/Formula/${__dest}/$(FS_Get_File "$1")" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$1" "$__dest" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Publish "HOMEBREW" + fi + + + # report status + return 0 +} + + + + +RELEASE_Setup_HOMEBREW() { + #__repo_directory="$1" + + + # validate input + I18N_Check "HOMEBREW" + if [ $(STRINGS_Is_Empty "$PROJECT_HOMEBREW_URL") -eq 0 ]; then + I18N_Check_Disabled_Skipped + return 0 # disabled explicitly + fi + + + # execute + I18N_Setup "HOMEBREW" + FS_Make_Housing_Directory "$1" + GIT_Clone_Repo \ + "$PROJECT_PATH_ROOT" \ + "$PROJECT_PATH_RELEASE" \ + "$PWD" \ + "$PROJECT_HOMEBREW_REPO" \ + "$PROJECT_SIMULATE_RUN" \ + "homebrew" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + + FS_Make_Directory "$1" + + + # report status + return 0 +} diff --git a/automataCI/_release-homebrew_windows-any.ps1 b/automataCI/_release-homebrew_windows-any.ps1 new file mode 100644 index 0000000..a7402c5 --- /dev/null +++ b/automataCI/_release-homebrew_windows-any.ps1 @@ -0,0 +1,194 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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\homebrew.ps1" +. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + return +} + + + + +# define operating variables +$HOMEBREW_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\homebrew" + + + + +function RELEASE-Conclude-HOMEBREW { + param( + [string]$__repo_directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${env:PROJECT_HOMEBREW_URL}") -eq 0) { + return 0 # disabled explictly + } + + + # execute + $null = I18N-Conclude "HOMEBREW" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Conclude "HOMEBREW" + return 0 + } + + + # commit the formula first + $__current_path = Get-Location + $null = Set-Location "${__repo_directory}" + $___process = GIT-Pull-To-Latest + if ($___process -ne 0) { + $null = Set-Location "${__curent_path}" + $null = Remove-Variable __current_path + $null = I18N-Conclude-Failed + return 1 + } + + $___process = GIT-Autonomous-Commit "${env:PROJECT_SKU} ${env:PROJECT_VERSION}" + if ($___process -ne 0) { + $null = Set-Location "${__curent_path}" + $null = Remove-Variable __current_path + $null = I18N-Conclude-Failed + return 1 + } + + $___process = GIT-Push ` + "${env:PROJECT_HOMEBREW_REPO_KEY}" ` + "${env:PROJECT_HOMEBREW_REPO_BRANCH}" + $null = Set-Location "${__curent_path}" + $null = Remove-Variable __current_path + if ($___process -ne 0) { + $null = I18N-Conclude-Failed + return 1 + } + + + # clean up in case of other release configurations + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0) { + # remove traces - single unified repository will take over later + $___process = FS-Remove "${__repo_directory}" + if ($___process -ne 0) { + $null = I18N-Conclude-Failed + return 1 + } + } + + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + # remove traces - formula is never stray from its tap repository. + } default { + return 0 + }} + + $___process = FS-Remove "${__repo_directory}" + if ($___process -ne 0) { + $null = I18N-Conclude-Failed + return 1 + } + + + # return status + return 0 +} + + + + +function RELEASE-Run-HOMEBREW { + param( + [string]$__target, + [string]$__repo_directory + ) + + + # validate input + $___process = HOMEBREW-Is-Valid-Formula "${__target}" + if ($___process -ne 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_HOMEBREW_URL}") -eq 0) { + return 0 # disabled explictly + } + + + # execute + $null = I18N-Publish "HOMEBREW" + if ($(OS-Is-Run-Simulated) -ne 0) { + $__dest = $(FS-Get-File "${__target}").Substring(0,1) + $__dest = "${___repo_directory}\Formula\${__dest}\$(FS_Get_File "${__target}")" + $null = FS-Make-Housing-Directory "${__dest}" + $___process = FS-Copy-File "${__target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Publish "HOMEBREW" + } + + + # report status + return 0 +} + + + + +function RELEASE-Setup-HOMEBREW { + param( + [string]$__repo_directory + ) + + + # validate input + $null = I18N-Check "HOMEBREW" + if ($(STRINGS-Is-Empty "${env:PROJECT_HOMEBREW_URL}") -eq 0) { + $null = I18N-Check-Disabled-Skipped + return 0 # disabled explictly + } + + + # execute + $null = I18N-Setup "HOMEBREW" + $null = FS-Make-Housing-Directory "${__repo_directory}" + $___process = GIT-Clone-Repo ` + "${env:PROJECT_PATH_ROOT}" ` + "${env:PROJECT_PATH_RELEASE}" ` + "$(Get-Location)" ` + "${env:PROJECT_HOMEBREW_REPO}" ` + "${env:PROJECT_SIMULATE_RUN}" ` + "homebrew" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + + $null = FS-Make-Directory "${__repo_directory}" + + + # report status + return 0 +} diff --git a/automataCI/_release-lib_unix-any.sh b/automataCI/_release-lib_unix-any.sh new file mode 100644 index 0000000..cd7f60e --- /dev/null +++ b/automataCI/_release-lib_unix-any.sh @@ -0,0 +1,142 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +. "${LIBS_AUTOMATACI}/services/io/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/archive/zip.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_Run_LIBS() { + #__target="$1" + + + # validate input + if [ $(FS_Is_Target_A_Library "$1") -ne 0 ]; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_SOURCE_RELEASE_TAG_LATEST") -eq 0 ]; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_SOURCE_GIT_REMOTE") -eq 0 ]; then + return 0 + fi + + GIT_Is_Available + if [ $? -ne 0 ]; then + return 0 + fi + + + # execute + __branch="v${PROJECT_VERSION}" + if [ $(FS_Is_Target_A_NPM "$1") -eq 0 ]; then + if [ $(STRINGS_Is_Empty "$PROJECT_NODE_BRANCH_TAG") -eq 0 ]; then + return 0 + fi + + __branch="${__branch}_${PROJECT_NODE_BRANCH_TAG}" + elif [ $(FS_Is_Target_A_C "$1") -eq 0 ]; then + if [ $(STRINGS_Is_Empty "$PROJECT_C_BRANCH_TAG") -eq 0 ]; then + return 0 + fi + + __branch="${__branch}_${PROJECT_C_BRANCH_TAG}" + else + return 0 + fi + + + # begin publication + I18N_Publish "git@$__branch" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Publish "$__branch" + return 0 + fi + + + # create workspace directory + __workspace="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/release-branch_${__branch}" + GIT_Setup_Workspace_Bare "$PROJECT_SOURCE_GIT_REMOTE" "$__branch" "$__workspace" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + + + # unpack package into directory + if [ $(FS_Is_Target_A_TARGZ "$1") -eq 0 ]; then + TAR_Extract_GZ "$__workspace" "$1" + elif [ $(FS_Is_Target_A_TARXZ "$1") -eq 0 ]; then + TAR_Extract_XZ "$__workspace" "$1" + elif [ $(FS_Is_Target_A_ZIP "$1") -eq 0 ]; then + ZIP_Extract "$__workspace" "$1" + else + FS_Copy_File "$1" "${__workspace}" + fi + + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + + + # commit release + __current_path="$PWD" && cd "$__workspace" + GIT_Autonomous_Commit "$__branch" + ___process=$? + cd "$__current_path" && unset __current_path + if [ $___process -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + + + # push to upstream + GIT_Push_Specific "$__workspace" \ + "$PROJECT_SOURCE_GIT_REMOTE" \ + "$__branch" \ + "$__branch" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + + GIT_Push_Specific "$__workspace" \ + "$PROJECT_SOURCE_GIT_REMOTE" \ + "$__branch" \ + "${PROJECT_SOURCE_RELEASE_TAG_LATEST}_${__branch#*_}" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-lib_windows-any.ps1 b/automataCI/_release-lib_windows-any.ps1 new file mode 100644 index 0000000..0801736 --- /dev/null +++ b/automataCI/_release-lib_windows-any.ps1 @@ -0,0 +1,148 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\zip.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-Run-LIBS { + param( + [string]$__target + ) + + + # validate input + $___process = FS-Is-Target-A-Library "${__target}" + if ($___process -ne 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_SOURCE_RELEASE_TAG_LATEST}") -eq 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_SOURCE_GIT_REMOTE}") -eq 0) { + return 0 + } + + $___process = GIT-Is-Available + if ($___process -ne 0) { + return 0 + } + + + # execute + $__branch = "v${env:PROJECT_VERSION}" + if ($(FS-Is-Target-A-NPM "${__target}") -eq 0) { + if ($(STRINGS-Is-Empty "${env:PROJECT_NODE_BRANCH_TAG}") -eq 0) { + return 0 + } + + $__branch = "${__branch}_${env:PROJECT_NODE_BRANCH_TAG}" + } elseif ($(FS-Is-Target-A-C "${__target}") -eq 0) { + if ($(STRINGS-Is-Empty "${env:PROJECT_C_BRANCH_TAG}") -eq 0) { + return 0 + } + + $__branch = "${__branch}_${env:PROJECT_C_BRANCH_TAG}" + } else { + return 0 + } + + + # begin publication + $null = I18N-Publish "git@${__branch}" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Publish "${__branch}" + return 0 + } + + + # create workspace directory + $__workspace = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\release-branch_${__branch}" + $___process = GIT-Setup-Workspace-Bare ` + "${env:PROJECT_SOURCE_GIT_REMOTE}" ` + "${__branch}" ` + "${__workspace}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + + + # unpack package into directory + if ($(FS-Is-Target-A-TARGZ "${__target}") -eq 0) { + $___process = TAR-Extract-GZ "${__workspace}" "${__target}" + } elseif ($(FS-Is-Target-A-TARXZ "${__target}") -eq 0) { + $___process = TAR-Extract-XZ "${__workspace}" "${__target}" + } elseif ($(FS-Is-Target-A-ZIP "${__target}") -eq 0) { + $___process = ZIP-Extract "${__workspace}" "${__target}" + } else { + $___process = FS-Copy-File "${__target}" "${__workspace}" + } + + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + + + # commit release + $__current_path = Get-Location + $null = Set-Location -Path "${__workspace}" + $___process = GIT-Autonomous-Commit "${__branch}" + $null = Set-Location -Path "${__current_path}" + $null = Remove-Variable -Name __current_path + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + + + # push to upstream + $___process = GIT-Push-Specific "${__workspace}" ` + "${env:PROJECT_SOURCE_GIT_REMOTE}" ` + "${__branch}" + "${__branch}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + + $___process = GIT-Push-Specific "${__workspace}" ` + "${env:PROJECT_SOURCE_GIT_REMOTE}" ` + "${__branch}" + "${env:PROJECT_SOURCE_RELEASE_TAG_LATEST}_$($__branch -replace "^.*_", '')" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/_release-npm_unix-any.sh b/automataCI/_release-npm_unix-any.sh new file mode 100644 index 0000000..566815d --- /dev/null +++ b/automataCI/_release-npm_unix-any.sh @@ -0,0 +1,75 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +. "${LIBS_AUTOMATACI}/services/io/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/compilers/node.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_NPM() { + #__target="$1" + + + # validate input + NODE_NPM_Is_Valid "$1" + if [ $? -ne 0 ]; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_NODE") -eq 0 ]; then + return 0 # disabled explicitly + fi + + I18N_Activate_Environment + NODE_Activate_Local_Environment + if [ $? -ne 0 ]; then + I18N_Activate_Failed + return 1 + fi + + + # execute + I18N_Publish "NPM" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + I18N_Check_Login "NPM" + NODE_NPM_Check_Login + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + + NODE_NPM_Publish "$1" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Publish "NPM" + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-npm_windows-any.ps1 b/automataCI/_release-npm_windows-any.ps1 new file mode 100644 index 0000000..23e186f --- /dev/null +++ b/automataCI/_release-npm_windows-any.ps1 @@ -0,0 +1,76 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\node.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-NPM { + param( + [string]$__target + ) + + + # validate input + $___process = NODE-NPM-Is-Valid "${__target}" + if ($___process -ne 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_NODE}") -eq 0) { + return 0 # disabled explicitly + } + + $null = I18N-Activate-Environment + $___process = NODE-Activate-Local-Environment + if ($___process -ne 0) { + $null = I18N-Activate-Failed + return 1 + } + + + # execute + $null = I18N-Publish "NPM" + if ($(OS-Is-Run-Simulated) -ne 0) { + $null = I18N-Check-Login "NPM" + $___process = NODE-NPM-Check-Login + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + + $___process = NODE-NPM-Publish "${__target}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Publish "NPM" + } + + + # report status + return 0 +} diff --git a/automataCI/_release-project_unix-any.sh b/automataCI/_release-project_unix-any.sh new file mode 100644 index 0000000..939fb18 --- /dev/null +++ b/automataCI/_release-project_unix-any.sh @@ -0,0 +1,95 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +. "${LIBS_AUTOMATACI}/services/io/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" +. "${LIBS_AUTOMATACI}/services/versioners/git.sh" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +RELEASE_Conclude_PROJECT() { + # execute + I18N_Conclude "$PROJECT_VERSION" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Conclude "$PROJECT_VERSION" + return 0 + fi + + + FS_Is_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" + if [ $? -eq 0 ] && [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + # commit single unified repository + I18N_Commit "$PROJECT_RELEASE_REPO" + __current_path="$PWD" && cd "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" + GIT_Autonomous_Force_Commit \ + "$PROJECT_VERSION" \ + "$PROJECT_RELEASE_REPO_KEY" \ + "$PROJECT_RELEASE_REPO_BRANCH" + ___process=$? + cd "$__current_path" && unset __current_path + if [ $___process -ne 0 ]; then + I18N_Commit_Failed + return 1 + fi + fi + + + # report status + return 0 +} + + + + +RELEASE_Setup_PROJECT() { + # execute + I18N_Setup "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + I18N_Setup "$PROJECT_RELEASE_REPO" + GIT_Is_Available + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + + FS_Remove_Silently "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" + __current_path="$PWD" && cd "$PROJECT_PATH_ROOT" + git clone "$PROJECT_RELEASE_REPO" "$PROJECT_PATH_RELEASE" + ___process=$? + cd "$__current_path" && unset __current_path + if [ $___process -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + else + FS_Remake_Directory "${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-project_windows-any.ps1 b/automataCI/_release-project_windows-any.ps1 new file mode 100644 index 0000000..c53744e --- /dev/null +++ b/automataCI/_release-project_windows-any.ps1 @@ -0,0 +1,97 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\changelog.ps1" +. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + return +} + + + + +function RELEASE-Conclude-PROJECT { + # execute + $null = I18N-Conclude "${env:PROJECT_VERSION}" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Conclude "${env:PROJECT_VERSION}" + return 0 + } + + $___process = FS-Is-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + if (($___process -eq 0) -and ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0)) { + # commit single unified repository + $null = I18N-Commit "${env:PROJECT_RELEASE_REPO}" + $__current_path = Get-Location + $null = Set-Location "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + $___process = GIT-Autonomous-Force-Commit ` + "${env:PROJECT_VERSION}" ` + "${env:PROJECT_RELEASE_REPO_KEY}" ` + "${env:PROJECT_RELEASE_REPO_BRANCH}" + $null = Set-Location "${__current_path}" + $null = Remove-Variable __current_path + if ($___process -ne 0) { + $null = I18N-Commit-Failed + return 1 + } + } + + + # return status + return 0 +} + + + + +function RELEASE-Setup-PROJECT { + # execute + $null = I18N-Setup "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0) { + $null = I18N-Setup "${env:PROJECT_RELEASE_REPO}" + $___process = GIT-Is-Available + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + + $null = FS-Remove-Silently "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + $__current_path = Get-Location + $null = Set-Location "${env:PROJECT_PATH_ROOT}" + $___process = OS-Exec "git" ` + "clone `"${env:PROJECT_RELEASE_REPO}`" `"${env:PROJECT_PATH_RELEASE}`"" + $null = Set-Location "${__current_path}" + $null = Remove-Variable __current_path + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + } else { + $___process = FS-Remake-Directory "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + } + + + # report status + return 0 +} diff --git a/automataCI/_release-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-research_unix-any.sh b/automataCI/_release-research_unix-any.sh new file mode 100644 index 0000000..77bc2c0 --- /dev/null +++ b/automataCI/_release-research_unix-any.sh @@ -0,0 +1,62 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +. "${LIBS_AUTOMATACI}/services/io/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +RELEASE_Run_RESEARCH() { + #__target="$1" + + + # validate input + if [ $(FS_Is_Target_A_PDF "$1") -ne 0 ]; then + return 0 + fi + + if [ "${1##*${PROJECT_RESEARCH_IDENTIFIER}}" = "$1" ]; then + return 0 # not a research paper + fi + + + # execute + I18N_Publish "RESEARCH" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + __dest="PAPER.pdf" + __dest="${PROJECT_PATH_ROOT}/${__dest}" + I18N_Publish "$__dest" + FS_Copy_File "$1" "$__dest" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Publish "RESEARCH" + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-research_windows-any.ps1 b/automataCI/_release-research_windows-any.ps1 new file mode 100644 index 0000000..405d074 --- /dev/null +++ b/automataCI/_release-research_windows-any.ps1 @@ -0,0 +1,64 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + return +} + + + + +function RELEASE-Run-RESEARCH { + param( + [string]$__target + ) + + + # validate input + $___process = FS-Is-Target-A-PDF "${__target}" + if ($___process -ne 0) { + return 0 + } + + if ($($__target -replace "^.*${env:PROJECT_RESEARCH_IDENTIFIER}") -eq "${__target}") { + return 0 # not a research paper + } + + + # execute + $null = I18N-Publish "RESEARCH" + if ($(OS-Is-Run-Simulated) -ne 0) { + $__dest = "PAPER.pdf" + $null = I18N-Publish "${__dest}" + $__dest = "${env:PROJECT_PATH_ROOT}\${__dest}" + $___process = FS-Copy-File "${__target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Publish "RESEARCH" + } + + + # 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..054b79e --- /dev/null +++ b/automataCI/_release-rpm_unix-any.sh @@ -0,0 +1,291 @@ +#!/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/rpm.sh" +. "${LIBS_AUTOMATACI}/services/publishers/createrepo.sh" +. "${LIBS_AUTOMATACI}/services/versioners/git.sh" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +# define operating variables +RPM_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}" # default: flat mode +if [ $(STRINGS_Is_Empty "$PROJECT_RPM_FLAT_MODE") -eq 0 ]; then + ## conventional mode + RPM_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/rpm" + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + # retain existing path + ;; + *) + # fallback to git mode + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_PATH") -ne 0 ]; then + RPM_REPO="${RPM_REPO}/${PROJECT_RPM_PATH}" + fi + ;; + esac + + ## overrides if PROJECT_RELEASE_REPO is set + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + RPM_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_RELEASE}/rpm" + fi +fi + + + + +RELEASE_Conclude_RPM() { + #__repo_directory="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + CREATEREPO_Is_Available + if [ $? -ne 0 ]; then + return 0 # nothing to execute without createrepo or createrepo_c. + fi + + + # execute + I18N_Conclude "RPM" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Conclude "RPM" + return 0 + elif [ $(STRINGS_Is_Empty "$PROJECT_RPM_FLAT_MODE") -ne 0 ]; then + # nothing to do in flat mode - report status + return 0 + elif [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + # do nothing - single unified repository will take over later + return 0 + fi + + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + # nothing to do for local directory type - report status + return 0 + ;; + *) + # repository is an independent git repository so proceed as follows. + ;; + esac + + + # commit release + __current_path="$PWD" && cd "$1" + GIT_Autonomous_Force_Commit \ + "$PROJECT_VERSION" \ + "$PROJECT_RPM_REPO_KEY" \ + "$PROJECT_RPM_REPO_BRANCH" + ___process=$? + cd "$__current_path" && unset __current_path + if [ $___process -ne 0 ]; then + I18N_Conclude_Failed + return 1 + fi + + + # report status + return 0 +} + + + + +RELEASE_Run_RPM() { + #__target="$1" + #__repo_directory="$2" + + + # validate input + RPM_Is_Valid "$1" + if [ $? -ne 0 ]; then + return 0 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + CREATEREPO_Is_Available + if [ $? -ne 0 ]; then + return 0 # can't execute without createrepo or createrepo_c. + fi + + + # execute + I18N_Publish "RPM" + if [ $(OS_Is_Run_Simulated) -ne 0 ]; then + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_FLAT_MODE") -eq 0 ]; then + FS_Copy_File "$1" "${2}/$(FS_Get_File "$1")" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + fi + else + # always simulate in case of error or mishaps before any point of no return + I18N_Simulate_Publish "RPM" + fi + + + # report status + return 0 +} + + + + +RELEASE_Setup_RPM() { + #__repo_directory="$1" + + + # validate input + I18N_Check "RPM" + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_URL") -eq 0 ]; then + I18N_Check_Disabled_Skipped + return 0 # disabled explicitly + fi + + I18N_Check_Availability "CREATEREPO" + CREATEREPO_Is_Available + if [ $? -ne 0 ]; then + I18N_Check_Failed_Skipped + return 0 # pipeline cannot run without createrepo or createrepo_c + fi + + + # execute + I18N_Setup "RPM" + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_FLAT_MODE") -eq 0 ]; then + # conventional mode + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -ne 0 ]; then + ## overridden by single unified repository + FS_Remake_Directory "$1" + return 0 + fi + + case "$(STRINGS_To_Lowercase "$PROJECT_RELEASE_REPO_TYPE")" in + local) + ## local file directory type + FS_Remake_Directory "$1" + return 0 + ;; + *) + ## fallback to git repository source + ;; + esac + + FS_Make_Housing_Directory "$1" + GIT_Clone_Repo \ + "$PROJECT_PATH_ROOT" \ + "$PROJECT_PATH_RELEASE" \ + "$PWD" \ + "$PROJECT_RPM_REPO" \ + "$PROJECT_SIMULATE_RUN" \ + "rpm" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + + FS_Make_Directory "$1" + fi + + + # report status + return 0 +} + + + + +RELEASE_Update_RPM() { + #__repo_directory="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_URL") -eq 0 ]; then + return 0 # disabled explicitly + fi + + CREATEREPO_Is_Available + if [ $? -ne 0 ]; then + return 0 # can't execute without createrepo or createrepo_c. + fi + + + # execute + I18N_Publish "RPM" + if [ $(OS_Is_Run_Simulated) -eq 0 ]; then + I18N_Simulate_Publish "RPM" + return 0 + fi + + CREATEREPO_Publish "$1" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_FLAT_MODE") -ne 0 ]; then + # flattening requested + RPM_Flatten_Repo "$1" \ + "$PROJECT_RPM_REPOXML_NAME" \ + "$PROJECT_RPM_METALINK" \ + "$PROJECT_RPM_URL" + if [ $? -ne 0 ]; then + I18N_Publish_Failed + return 1 + fi + fi + + + # create the README.md + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_FLAT_MODE") -ne 0 ]; then + # stop here - report status + return 0 + fi + + __dest="${1}/RPM_Repository.md" + I18N_Create "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Remove_Silently "$__dest" + FS_Write_File "$__dest" "\ +# RPM Distribution Repository + +This directory is now re-purposed to host RPM packages repository. +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/_release-rpm_windows-any.ps1 b/automataCI/_release-rpm_windows-any.ps1 new file mode 100644 index 0000000..4131c13 --- /dev/null +++ b/automataCI/_release-rpm_windows-any.ps1 @@ -0,0 +1,298 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\rpm.ps1" +. "${env:LIBS_AUTOMATACI}\services\publishers\createrepo.ps1" +. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + return +} + + + + +# define operating variables +$RPM_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}" # default: flat mode +if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_FLAT_MODE}") -eq 0) { + ## conventional mode + $RPM_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\rpm" + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + # retain existing path + } default { + # fallback to git mode + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_PATH}") -ne 0) { + $RPM_REPO = "${RPM_REPO}\${PROJECT_RPM_PATH}" + } + }} + + ## overrides if PROJECT_RELEASE_REPO is set + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0) { + $RPM_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\rpm" + } +} + + + + +function RELEASE-Conclude-RPM { + param( + [string]$__repo_directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_URL}") -eq 0) { + return 0 # disabled explictly + } + + $___process = CREATEREPO-Is-Available + if ($___process -ne 0) { + return 0 # nothing to execute without createrepo or createrepo_c. + } + + + # execute + $null = I18N-Conclude "RPM" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Conclude "RPM" + return 0 + } + + + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_FLAT_MODE}") -ne 0) { + # nothing to do in flat mode - report status + return 0 + } elseif ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0) { + # do nothing - single unified repository will take over later + return 0 + } + + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + # nothing to do for local directory type - report status + return 0 + } default { + # repository is an independent git repository so proceed as follows. + }} + + + # commit release + $__current_path = Get-Location + $null = Set-Location "${__repo_directory}" + $___process = Git-Autonomous-Force-Commit ` + "${env:PROJECT_VERSION}" ` + "${env:PROJECT_RPM_REPO_KEY}" ` + "${env:PROJECT_RPM_REPO_BRANCH}" + $null = Set-Location "${__curent_path}" + $null = Remove-Variable __current_path + if ($___process -ne 0) { + $null = I18N-Conclude-Failed + return 1 + } + + + # return status + return 0 +} + + + + +function RELEASE-Run-RPM { + param( + [string]$__target, + [string]$__repo_directory + ) + + + # validate input + $___process = RPM-Is-Valid "${__target}" + if ($___process -ne 0) { + return 0 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_URL}") -eq 0) { + return 0 # disabled explictly + } + + $___process = CREATEREPO-Is-Available + if ($___process -ne 0) { + return 0 # can't execute without createrepo or createrepo_c. + } + + + # execute + $null = I18N-Publish "RPM" + if ($(OS-Is-Run-Simulated) -ne 0) { + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_FLAT_MODE}") -eq 0) { + $___process = FS-Copy-File ` + "${__target}" ` + "${__repo_directory}/$(FS-Get-File "${__target}")" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + } + } else { + # always simulate in case of error or mishaps before any point of no return + $null = I18N-Simulate-Publish "RPM" + } + + + # report status + return 0 +} + + + + +function RELEASE-Setup-RPM { + param( + [string]$__repo_directory + ) + + + # validate input + $null = I18N-Check "RPM" + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_URL}") -eq 0) { + $null = I18N-Check-Disabled-Skipped + return 0 # disabled explictly + } + + $null = I18N-Check-Availability "CREATEREPO" + $___process = CREATEREPO-Is-Available + if ($___process -ne 0) { + $null = I18N-Check-Failed-Skipped + return 0 # pipeline cannot run without createrepo or createrepo_c + } + + + # execute + $null = I18N-Setup "RPM" + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_FLAT_MODE}") -eq 0) { + # conventional mode + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -eq 0) { + ## overridden by single unified repository + $null = FS-Remake-Directory "${__repo_directory}" + return 0 + } + + switch ("$(STRINGS-To-Lowercase "${env:PROJECT_RELEASE_REPO_TYPE}")") { + "local" { + ## local file directory type + $null = FS-Remake-Directory "${__repo_directory}" + return 0 + } default { + ## fallback to git repository source + }} + + $null = FS-Make-Housing-Directory "${__repo_directory}" + $___process = GIT-Clone-Repo ` + "${env:PROJECT_PATH_ROOT}" ` + "${env:PROJECT_PATH_RELEASE}" ` + "$(Get-Location)" ` + "${env:PROJECT_RPM_REPO}" ` + "${env:PROJECT_SIMULATE_RUN}" ` + "rpm" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + + $null = FS-Make-Directory "${__repo_directory}" + } + + + # report status + return 0 +} + + + + +function RELEASE-Update-RPM { + param( + [string]$__repo_directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_URL}") -eq 0) { + return 0 # disabled explictly + } + + $___process = CREATEREPO-Is-Available + if ($___process -ne 0) { + return 0 # can't execute without createrepo or createrepo_c. + } + + + # execute + $null = I18N-Publish "RPM" + if ($(OS-Is-Run-Simulated) -eq 0) { + $null = I18N-Simulate-Publish "RPM" + return 0 + } + + $___process = CREATEREPO-Publish "${__repo_directory}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + + if ($(STRINGS-Is-Empty "$PROJECT_RPM_FLAT_MODE") -ne 0) { + $___process = RPM-Flatten-Repo "${__repo_directory}" ` + "${env:PROJECT_RPM_REPOXML_NAME}" ` + "${env:PROJECT_RPM_METALINK}" ` + "${env:PROJECT_RPM_URL}" + if ($___process -ne 0) { + $null = I18N-Publish-Failed + return 1 + } + } + + + # create the README.md + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_FLAT_MODE}") -eq 0) { + # stop here - report status + return 0 + } + + $___dest = "${__repo_directory}\RPM_Repository.md" + $null = I18N-Create "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $null = FS-Remove-Silently "${__dest}" + $___process = FS-Write-File "${__dest}" @" +# RPM Distribution Repository + +This directory is now re-purposed to host RPM packages repository. + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/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..ec6f0e4 --- /dev/null +++ b/automataCI/ci.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. + + + + +# 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}" +${env:LIBS_HESTIA} = "${env:LIBS_AUTOMATACI}\services" + + + + +# 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..0f2bfec --- /dev/null +++ b/automataCI/ci.sh @@ -0,0 +1,272 @@ +#!/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}" +export LIBS_HESTIA="${LIBS_AUTOMATACI}/services" + + + + +# 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..c4fc41c --- /dev/null +++ b/automataCI/common_unix-any.sh @@ -0,0 +1,156 @@ +#!/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_BOOK" "BOOK" +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_NODE" "NODE" +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 + + +# IMPORTANT: C can set the terminal into a very strict mode after build causing +# other technological integrations to fail after run (e.g. flatpak). +# Therefore, it shall be placed as the last one to execute. +Run_Subroutine_Exec "$PROJECT_C" "C" +if [ $? -ne 0 ]; then + return 1 +fi + + + + +# report status +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..fb71873 --- /dev/null +++ b/automataCI/common_windows-any.ps1 @@ -0,0 +1,145 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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_BOOK}" "BOOK" +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_NODE}" "NODE" +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 +} + +# IMPORTANT: C on unix has some issue with setting the terminal into ultra +# strict mode after build causing other technological integrations +# to fail after run (e.g. flatpak). Therefore, it will be placed as +# the last one to execute. +$___process = RUN-Subroutine-Exec "${env:PROJECT_C}" "C" +if ($___process -ne 0) { + return 1 +} + + + + +# 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..4217296 --- /dev/null +++ b/automataCI/env_unix-any.sh @@ -0,0 +1,191 @@ +#!/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" + + + + +# 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 "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_BOOK") -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..715f058 --- /dev/null +++ b/automataCI/env_windows-any.ps1 @@ -0,0 +1,165 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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" + + + + +# 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 +} + + +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_BOOK}") -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..12e0f00 --- /dev/null +++ b/automataCI/notarize_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 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="$(FS_Get_File "$i")" + TARGET_FILENAME="$(FS_Extension_Remove "$TARGET_FILENAME")" + 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..6b15dba --- /dev/null +++ b/automataCI/notarize_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 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 = FS-Get-File "$i" + $TARGET_FILENAME = FS-Extension-Remove "$TARGET_FILENAME" + $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..25b7382 --- /dev/null +++ b/automataCI/package_unix-any.sh @@ -0,0 +1,528 @@ +#!/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}/services/compilers/flatpak.sh" +. "${LIBS_AUTOMATACI}/services/publishers/homebrew.sh" +. "${LIBS_AUTOMATACI}/services/versioners/git.sh" + +. "${LIBS_AUTOMATACI}/_package-archive_unix-any.sh" +. "${LIBS_AUTOMATACI}/_package-cargo_unix-any.sh" +. "${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-lib_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 + + +if [ "$(STRINGS_Is_Empty "$PROJECT_HOMEBREW_URL")" -ne 0 ]; then + HOMEBREW_WORKSPACE="packagers-homebrew-${PROJECT_SKU}" + I18N_Setup "$HOMEBREW_WORKSPACE" + HOMEBREW_WORKSPACE="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/${HOMEBREW_WORKSPACE}" + FS_Remake_Directory "$HOMEBREW_WORKSPACE" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi +fi + + +if [ "$(STRINGS_Is_Empty "$PROJECT_MSI_INSTALL_DIRECTORY")" -ne 0 ]; then + MSI_WORKSPACE="packagers-msi-${PROJECT_SKU}" + I18N_Setup "$MSI_WORKSPACE" + MSI_WORKSPACE="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/${MSI_WORKSPACE}" + FS_Remake_Directory "$MSI_WORKSPACE" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_MSI_REGISTRY_KEY") -eq 0 ]; then + PROJECT_MSI_REGISTRY_KEY="\ +Software\\\\${PROJECT_SCOPE}\\\\InstalledProducts\\\\${PROJECT_SKU_TITLECASE}" + fi +fi + + +if [ "$(STRINGS_Is_Empty "$PROJECT_FLATPAK_URL")" -ne 0 ]; then + FLATPAK_REPO="flatpak-repo" + I18N_Setup "$FLATPAK_REPO" + FLATPAK_REPO="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/${FLATPAK_REPO}" + FS_Remove_Silently "$FLATPAK_REPO" + + if [ $(STRINGS_Is_Empty "$PROJECT_FLATPAK_REPO") -ne 0 ] && + [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_REPO") -eq 0 ]; then + # version controlled repository supplied; AND + # single unified repository is not enabled + FS_Make_Housing_Directory "$FLATPAK_REPO" + GIT_Clone_Repo \ + "$PROJECT_PATH_ROOT" \ + "$PROJECT_PATH_TEMP" \ + "$PWD" \ + "$PROJECT_FLATPAK_REPO" \ + "$PROJECT_SIMULATE_RUN" \ + "$(FS_Get_File "$FLATPAK_REPO")" \ + "$PROJECT_FLATPAK_REPO_BRANCH" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_FLATPAK_PATH") -ne 0 ]; then + FLATPAK_REPO="${FLATPAK_REPO}/${PROJECT_FLATPAK_PATH}" + fi + fi + + FS_Make_Directory "$FLATPAK_REPO" + if [ $? -ne 0 ]; then + I18N_Setup_Failed + return 1 + fi +fi + + +FILE_CHANGELOG_MD="${PROJECT_SKU}-CHANGELOG_${PROJECT_VERSION}.md" +FILE_CHANGELOG_MD="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}/${FILE_CHANGELOG_MD}" +FILE_CHANGELOG_DEB="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-changelog/deb.gz" +PACKAGE_Run_CHANGELOG "$FILE_CHANGELOG_MD" "$FILE_CHANGELOG_DEB" +if [ $? -ne 0 ]; then + return 1 +fi + + +FILE_CITATION_CFF="${PROJECT_SKU}-CITATION_${PROJECT_VERSION}.cff" +FILE_CITATION_CFF="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}/${FILE_CITATION_CFF}" +PACKAGE_Run_CITATION "$FILE_CITATION_CFF" +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_OS##*-}" + 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 + + __common="${DEST}|${i}|${TARGET_FILENAME}|${TARGET_OS}|${TARGET_ARCH}" + + + # begin registrations + I18N_Sync_Register "$i" + + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_ARCHIVE") -ne 0 ]; then + __log="archive_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_ARCHIVE +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_RUST") -ne 0 ]; then + __log="cargo_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_CARGO +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + # NOTE: chocolatey only serve windows + if [ $(STRINGS_Is_Empty "$PROJECT_CHOCOLATEY_URL") -ne 0 ]; then + case "$TARGET_OS" in + any|windows) + __log="chocolatey_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_CHOCOLATEY +" + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + ;; + esac + fi + + # NOTE: deb does not work in windows or mac + if [ $(STRINGS_Is_Empty "$PROJECT_DEB_URL") -ne 0 ]; then + case "$TARGET_OS" in + windows|darwin) + ;; + *) + __log="deb_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ +${__common}|${FILE_CHANGELOG_DEB}|${__log}|PACKAGE_Run_DEB +" + if [ $? -ne 0 ]; then + return 1 + fi + ;; + esac + fi + + # NOTE: container only serve windows and linux + if [ $(STRINGS_Is_Empty "$PROJECT_CONTAINER_REGISTRY") -ne 0 ]; then + case "$TARGET_OS" in + any|linux|windows) + __log="docker_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__serial_control" "\ +${__common}|${__log}|PACKAGE_Run_DOCKER +" + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + ;; + esac + fi + + # NOTE: flatpak only serve linux + FLATPAK_Is_Available + if [ $? -eq 0 ] && [ $(STRINGS_Is_Empty "$PROJECT_FLATPAK_URL") -ne 0 ]; then + case "$TARGET_OS" in + any|linux) + __log="flatpak_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__serial_control" "\ +${__common}|${FLATPAK_REPO}|${__log}|PACKAGE_Run_FLATPAK +" + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + ;; + esac + fi + + # NOTE: homebrew only serve linux and mac + if [ $(STRINGS_Is_Empty "$PROJECT_HOMEBREW_URL") -ne 0 ]; then + case "$TARGET_OS" in + any|darwin|linux) + __log="homebrew_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ +${__common}|${HOMEBREW_WORKSPACE}|${__log}|PACKAGE_Run_HOMEBREW +" + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + ;; + esac + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_IPK") -ne 0 ]; then + __log="ipk_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_IPK +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(FS_Is_Target_A_Library "$i") -eq 0 ] && + [ $(STRINGS_Is_Empty "$PROJECT_RELEASE_ARCHIVE") -ne 0 ]; then + __log="lib_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_LIB +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + # NOTE: MSI only works in windows + if [ $(STRINGS_Is_Empty "$PROJECT_MSI_INSTALL_DIRECTORY") -ne 0 ]; then + case "$TARGET_OS" in + any|windows) + __log="msi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ +${__common}|${MSI_WORKSPACE}|${__log}|PACKAGE_Run_MSI +" + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + ;; + esac + + fi + + if [ $(FS_Is_Target_A_PDF "$i") -eq 0 ]; then + __log="pdf_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_PDF +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_PYTHON") -ne 0 ]; then + __log="pypi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_PYPI +" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + # NOTE: RPM only serve linux + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_URL") -ne 0 ]; then + case "$TARGET_OS" in + any|linux) + __log="rpm_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + __log="${__log_directory}/${__log}" + FS_Append_File "$__parallel_control" "\ +${__common}|${__log}|PACKAGE_Run_RPM +" + if [ $? -ne 0 ]; then + return 1 + fi + ;; + *) + ;; + esac + 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 + + +if [ $(STRINGS_Is_Empty "$PROJECT_HOMEBREW_URL") -ne 0 ]; then + I18N_Newline + I18N_Newline + + __dest="${PROJECT_SKU}.rb" + I18N_Export "$__dest" + __dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}/${__dest}" + HOMEBREW_Seal "$__dest" \ + "${PROJECT_SKU}-homebrew_${PROJECT_VERSION}_any-any.tar.xz" \ + "$HOMEBREW_WORKSPACE" \ + "$PROJECT_SKU" \ + "$PROJECT_PITCH" \ + "$PROJECT_CONTACT_WEBSITE" \ + "$PROJECT_LICENSE" \ + "$PROJECT_HOMEBREW_URL" + if [ $? -ne 0 ];then + I18N_Export_Failed + return 1 + fi +fi + + +if [ "$(STRINGS_Is_Empty "$PROJECT_MSI_INSTALL_DIRECTORY")" -ne 0 ]; then + I18N_Newline + I18N_Newline + + # sort any arch into others + PACKAGE_Sort_MSI "$MSI_WORKSPACE" + if [ $? -ne 0 ];then + return 1 + fi + + # seal all MSI packages + for _candidate in "${MSI_WORKSPACE}/"*; do + FS_Is_Directory "$_candidate" + if [ $? -ne 0 ]; then + continue + fi + + I18N_Newline + PACKAGE_Seal_MSI "$_candidate" "${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}" + if [ $? -ne 0 ];then + return 1 + fi + done +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..9ca070b --- /dev/null +++ b/automataCI/package_windows-any.ps1 @@ -0,0 +1,551 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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}\services\compilers\flatpak.ps1" +. "${env:LIBS_AUTOMATACI}\services\publishers\homebrew.ps1" +. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" + +. "${env:LIBS_AUTOMATACI}\_package-changelog_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_package-citation_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_package-msi_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 +} + + +if ($(STRINGS-Is-Empty "${env:PROJECT_HOMEBREW_URL}") -ne 0) { + $HOMEBREW_WORKSPACE = "packagers-homebrew-${env:PROJECT_SKU}" + $null = I18N-Setup "${HOMEBREW_WORKSPACE}" + $HOMEBREW_WORKSPACE = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\${HOMEBREW_WORKSPACE}" + $___process = FS-Remake-Directory "${HOMEBREW_WORKSPACE}" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } +} + + +if ($(STRINGS-Is-Empty "${env:PROJECT_MSI_INSTALL_DIRECTORY}") -ne 0) { + $MSI_WORKSPACE = "packagers-msi-${env:PROJECT_SKU}" + $null = I18N-Setup "${MSI_WORKSPACE}" + $MSI_WORKSPACE = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\${MSI_WORKSPACE}" + $___process = FS-Remake-Directory "${MSI_WORKSPACE}" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + + + if ($(STRINGS-Is-Empty "${env:PROJECT_MSI_REGISTRY_KEY}") -eq 0) { + ${env:PROJECT_MSI_REGISTRY_KEY} = @" +Software\${env:PROJECT_SCOPE}\InstalledProducts\${env:PROJECT_SKU_TITLECASE} +"@ + } +} + + +if ($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_URL}") -ne 0) { + $FLATPAK_REPO = "flatpak-repo" + $null = I18N-Setup "${FLATPAK_REPO}" + $FLATPAK_REPO = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\${FLATPAK_REPO}" + $null = FS-Remove-Silently "$FLATPAK_REPO" + + if (($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_REPO}") -ne 0) -and + ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_REPO}") -ne 0)) { + # version controlled repository supplied; AND + # single unified repository is not enabled + $null = FS-Make-Housing-Directory "$FLATPAK_REPO" + $___process = GIT-Clone-Repo ` + "${env:PROJECT_PATH_ROOT}" ` + "${env:PROJECT_PATH_TEMP}" ` + "$(Get-Location)" ` + "${env:PROJECT_FLATPAK_REPO}" ` + "${env:PROJECT_SIMULATE_RUN}" ` + "$(FS-Get-File "${env:FLATPAK_REPO}")" ` + "${env:PROJECT_FLATPAK_REPO_BRANCH}" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_PATH}") -ne 0) { + $FLATPAK_REPO = "${FLATPAK_REPO}/${env:PROJECT_FLATPAK_PATH}" + } + } + + $___process = FS-Make-Directory "$FLATPAK_REPO" + if ($___process -ne 0) { + $null = I18N-Setup-Failed + return 1 + } +} + + +$FILE_CHANGELOG_MD = "${env:PROJECT_SKU}-CHANGELOG_${env:PROJECT_VERSION}.md" +$FILE_CHANGELOG_MD = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\${FILE_CHANGELOG_MD}" +$FILE_CHANGELOG_DEB = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-changelog\deb.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-lib_windows-any.ps1" + $null = . "${env:LIBS_AUTOMATACI}\_package-msi_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 ($i in (Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_BUILD}")) { + $i = $i.FullName + + $___process = FS-Is-File "$i" + if ($___process -ne 0) { + continue + } + + + # parse build candidate + $null = I18N-Detected "${i}" + $TARGET_FILENAME = Split-Path -Leaf $i + $TARGET_FILENAME = $TARGET_FILENAME -replace "\..*$" + $TARGET_OS = $TARGET_FILENAME -replace ".*_" + $TARGET_FILENAME = $TARGET_FILENAME -replace "_.*" + $TARGET_ARCH = $TARGET_OS -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 + } + } + + $__common = "${DEST}|${i}|${TARGET_FILENAME}|${TARGET_OS}|${TARGET_ARCH}" + + + # begin registrations + $null = I18N-Sync-Register "$i" + + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_ARCHIVE}") -ne 0) { + $__log = "archive_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-ARCHIVE + +"@ + if ($___process -ne 0) { + return 1 + } + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_RUST}") -ne 0) { + $__log = "cargo_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-CARGO + +"@ + if ($___process -ne 0) { + return 1 + } + } + + # NOTE: chocolatey only serve windows + if ($(STRINGS-Is-Empty "${env:PROJECT_CHOCOLATEY_URL}") -ne 0) { + switch ("${TARGET_OS}") { + { $_ -in "any", "windows" } { + $__log = "chocolatey_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-CHOCOLATEY + +"@ + if ($___process -ne 0) { + return 1 + } + } default { + }} + } + + # NOTE: deb does not work in windows or mac + if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_URL}") -ne 0) { + switch ("${TARGET_OS}") { + { $_ -in "windows", "darwin" } { + $__log = "deb_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${FILE_CHANGELOG_DEB}|${__log}|PACKAGE-Run-DEB + +"@ + if ($___process -ne 0) { + return 1 + } + } default { + }} + } + + # NOTE: container only server windows and linux + if ($(STRINGS-Is-Empty "${env:PROJECT_CONTAINER_REGISTRY}") -ne 0) { + switch ("${TARGET_OS}") { + { $_ -in "any", "linux", "windows" } { + $__log = "docker_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__serial_control}" @" +${__common}|${__log}|PACKAGE-Run-DOCKER + +"@ + if ($___process -ne 0) { + return 1 + } + } default { + }} + } + + # NOTE: flatpak only serve linux + $___process = FLATPAK-Is-Available + if (($___process -eq 0) -and + ($(STRINGS-Is-Empty "${env:PROJECT_FLATPAK_URL}") -ne 0)) { + switch ("${TARGET_OS}") { + { $_ -in "any", "linux" } { + $__log = "flatpak_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__serial_control}" @" +${__common}|${FLATPAK_REPO}|${__log}|PACKAGE-Run-FLATPAK + +"@ + if ($___process -ne 0) { + return 1 + } + } default { + }} + } + + # NOTE: homebrew only serve linux and mac + if ($(STRINGS-Is-Empty "${env:PROJECT_HOMEBREW_URL}") -ne 0) { + switch ("${TARGET_OS}") { + { $_ -in "any", "darwin", "linux" } { + $__log = "homebrew_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${HOMEBREW_WORKSPACE}|${__log}|PACKAGE-Run-HOMEBREW + +"@ + if ($___process -ne 0) { + return 1 + } + } default { + }} + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_IPK}") -ne 0) { + $__log = "ipk_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-IPK + +"@ + if ($___process -ne 0) { + return 1 + } + } + + if (($(FS-Is-Target-A-Library "${i}") -eq 0) -and + ($(STRINGS-Is-Empty "${env:PROJECT_RELEASE_ARCHIVE}") -ne 0)) { + $__log = "lib_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-LIB + +"@ + if ($___process -ne 0) { + return 1 + } + } + + # NOTE: MSI only works in windows + if ($(STRINGS-Is-Empty "${env:PROJECT_MSI_INSTALL_DIRECTORY}") -ne 0) { + switch ("${TARGET_OS}") { + { $_ -in "any", "windows" } { + $__log = "msi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${MSI_WORKSPACE}|${__log}|PACKAGE-Run-MSI + +"@ + if ($___process -ne 0) { + return 1 + } + } default { + }} + } + + if ($(FS-Is-Target-A-PDF "${i}") -eq 0) { + $__log = "PDF_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-PDF + +"@ + if ($___process -ne 0) { + return 1 + } + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_PYTHON}") -ne 0) { + $__log = "pypi_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-PYPI + +"@ + if ($___process -ne 0) { + return 1 + } + } + + # NOTE: RPM only serve linux + if ($(STRINGS-Is-Empty "${env:PROJECT_RPM_URL}") -ne 0) { + switch ("${TARGET_OS}") { + { $_ -in "any", "linux" } { + $__log = "rpm_${TARGET_FILENAME}_${TARGET_OS}-${TARGET_ARCH}.log" + $__log = "${__log_directory}\${__log}" + $___process = FS-Append-File "${__parallel_control}" @" +${__common}|${__log}|PACKAGE-Run-RPM + +"@ + if ($___process -ne 0) { + return 1 + } + } default { + }} + } +} +} + + +$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 + } +} + + +if ($(STRINGS-Is-Empty "${env:PROJECT_HOMEBREW_URL}") -ne 0) { + $null = I18N-Newline + $null = I18N-Newline + + $__dest = "${env:PROJECT_SKU}.rb" + $null = I18N-Export "${__dest}" + $__dest = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\${__dest}" + $___process = HOMEBREW-Seal "${__dest}" ` + "${env:PROJECT_SKU}-homebrew_${env:PROJECT_VERSION}_any-any.tar.xz" ` + "${HOMEBREW_WORKSPACE}" ` + "${env:PROJECT_SKU}" ` + "${env:PROJECT_PITCH}" ` + "${env:PROJECT_CONTACT_WEBSITE}" ` + "${env:PROJECT_LICENSE}" ` + "${env:PROJECT_HOMEBREW_URL}" + if ($___process -ne 0) { + $null = I18N-Export-Failed + return 1 + } +} + + +if ($(STRINGS-Is-Empty "${env:PROJECT_MSI_INSTALL_DIRECTORY}") -ne 0) { + $null = I18N-Newline + $null = I18N-Newline + + + # sort 'any' arch into others + $___process = PACKAGE-Sort-MSI "${MSI_WORKSPACE}" + if ($___process -ne 0) { + return 1 + } + + # seal all MSI packages + foreach ($_candidate in (Get-ChildItem -Path "${MSI_WORKSPACE}" -Directory)) { + $_candidate = $_candidate.FullName + + $null = I18N-Newline + + $___process = PACKAGE-Seal-MSI ` + "${_candidate}" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}" + if ($___process -ne 0) { + 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..3562d3e --- /dev/null +++ b/automataCI/release_unix-any.sh @@ -0,0 +1,279 @@ +#!/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-citation_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-deb_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-docker_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-flatpak_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-homebrew_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-lib_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-npm_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-project_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-pypi_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-research_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-rpm_unix-any.sh" +. "${LIBS_AUTOMATACI}/_release-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 + + + + +# determine pathing variables +PACKAGE_DIRECTORY="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}" + + + + +# initialize workspace and release job functions +OS_Is_Command_Available "RELEASE_Run_Pre_Processor" +if [ $? -eq 0 ]; then + RELEASE_Run_Pre_Processor + if [ $? -ne 0 ]; then + return 1 + fi +fi + + +RELEASE_Setup_PROJECT # !! IMPORTANT !! - always the first +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Setup_DEB "$DEB_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Setup_FLATPAK "$FLATPAK_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Setup_HOMEBREW "$HOMEBREW_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Setup_RPM "$RPM_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + + + +# scan through each product and run the release processing respectively +for TARGET in "$PACKAGE_DIRECTORY"/*; do + if [ "${TARGET%.asc*}" != "$TARGET" ]; then + continue # it's a gpg cert + fi + + if [ "${TARGET%.gpg*}" != "$TARGET" ]; then + continue # it's a gpg keyfile or cert + fi + + I18N_Processing "$TARGET" + + + RELEASE_Run_CARGO "$TARGET" + if [ $? -ne 0 ]; then + return 1 + fi + + + RELEASE_Run_CITATION_CFF "$TARGET" + if [ $? -ne 0 ]; then + return 1 + fi + + + RELEASE_Run_DEB "$TARGET" "$DEB_REPO" "$DEB_REPO_DATA" + if [ $? -ne 0 ]; then + return 1 + fi + + + RELEASE_Run_DOCKER "$TARGET" + if [ $? -ne 0 ]; then + return 1 + fi + + + RELEASE_Run_HOMEBREW "$TARGET" "$HOMEBREW_REPO" + if [ $? -ne 0 ]; then + return 1 + fi + + + RELEASE_Run_LIBS "$TARGET" + if [ $? -ne 0 ]; then + return 1 + fi + + + RELEASE_Run_NPM "$TARGET" + if [ $? -ne 0 ]; then + return 1 + fi + + + RELEASE_Run_PYPI "$TARGET" + if [ $? -ne 0 ]; then + return 1 + fi + + + RELEASE_Run_RESEARCH "$TARGET" + if [ $? -ne 0 ]; then + return 1 + fi + + + RELEASE_Run_RPM "$TARGET" "$RPM_REPO" + if [ $? -ne 0 ]; then + return 1 + fi + + + OS_Is_Command_Available "RELEASE_Run_Package_Processor" + if [ $? -eq 0 ]; then + RELEASE_Run_Package_Processor "$TARGET" + if [ $? -ne 0 ]; then + return 1 + fi + fi +done + + + + +# run one-time directory-wide release processing functions +RELEASE_Update_DEB "$DEB_REPO" "$DEB_REPO_DATA" +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Update_RPM "$RPM_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + +OS_Is_Command_Available "RELEASE_Run_Post_Processor" +if [ $? -eq 0 ]; then + RELEASE_Run_Post_Processor + if [ $? -ne 0 ]; then + return 1 + fi +fi + + + + +# conclude the release +RELEASE_Conclude_CHECKSUM "$PACKAGE_DIRECTORY" ## !! IMPORTANT !! - always the first +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Conclude_DEB "$DEB_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Conclude_FLATPAK "$FLATPAK_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Conclude_HOMEBREW "$HOMEBREW_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Conclude_RPM "$RPM_REPO" +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Conclude_DOCS +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Conclude_CHANGELOG +if [ $? -ne 0 ]; then + return 1 +fi + + +RELEASE_Conclude_PROJECT # !! IMPORTANT !! - always the last +if [ $? -ne 0 ]; then + return 1 +fi + + + + +# 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..69dd698 --- /dev/null +++ b/automataCI/release_windows-any.ps1 @@ -0,0 +1,267 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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-citation_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-deb_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-flatpak_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-docker_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-homebrew_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-lib_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-npm_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-project_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-pypi_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-research_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-rpm_windows-any.ps1" +. "${env:LIBS_AUTOMATACI}\_release-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 + } +} + + + + +# determine pathing variables +$PACKAGE_DIRECTORY = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}" + + + + +# initialize workspace and release job functions +$___process = OS-Is-Command-Available "RELEASE-Run-Pre-Processor" +if ($___process -eq 0) { + $___process = RELEASE-Run-Pre-Processor + if ($___process -ne 0) { + return 1 + } +} + + +$___process = RELEASE-Setup-PROJECT # !! IMPORTANT !! - always the first +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Setup-DEB "${DEB_REPO}" +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Setup-FLATPAK "$FLATPAK_REPO" +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Setup-HOMEBREW "${HOMEBREW_REPO}" +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Setup-RPM "${RPM_REPO}" +if ($___process -ne 0) { + return 1 +} + + + + +# scan through each product and run the release processing respectively +foreach ($TARGET in (Get-ChildItem -Path "${PACKAGE_DIRECTORY}")) { $TARGET = $TARGET.FullName + if ($TARGET -like "*.asc") { + continue # it's a gpg cert + } + + if ($TARGET -like "*.gpg") { + continue # it's a gpg keyfile or cert + } + + $null = I18N-Processing "${TARGET}" + + $___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-DEB "$TARGET" "$DEB_REPO" "$DEB_REPO_DATA" + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Run-DOCKER "$TARGET" + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Run-HOMEBREW "$TARGET" "$HOMEBREW_REPO" + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Run-LIBS "$TARGET" + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Run-NPM "$TARGET" + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Run-PYPI "$TARGET" + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Run-RESEARCH "$TARGET" + if ($___process -ne 0) { + return 1 + } + + $___process = RELEASE-Run-RPM "$TARGET" "$RPM_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 + } + } +} + + + + +# run one-time directory-wide release processing functions +$___process = RELEASE-Update-DEB "$DEB_REPO" "$DEB_REPO_DATA" +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Update-RPM "$RPM_REPO" +if ($___process -ne 0) { + return 1 +} + + +$___process = OS-Is-Command-Available "RELEASE-Run-Post-Processor" +if ($___process -eq 0) { + $___process = RELEASE-Run-Post-Processor + if ($___process -ne 0) { + return 1 + } +} + + + + +# conclude the release +$___process = RELEASE-Conclude-CHECKSUM "$PACKAGE_DIRECTORY" ## !! IMPORTANT !! - always the first +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Conclude-DEB "$DEB_REPO" +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Conclude-FLATPAK "$FLATPAK_REPO" +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Conclude-HOMEBREW "$HOMEBREW_REPO" +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Conclude-RPM "$RPM_REPO" +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Conclude-DOCS +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Conclude-CHANGELOG +if ($___process -ne 0) { + return 1 +} + + +$___process = RELEASE-Conclude-PROJECT # !! IMPORTANT !! - must always be the last +if ($___process -ne 0) { + return 1 +} + + + + +# report status +$null = I18N-Run-Successful +return 0 diff --git a/automataCI/services/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..059ab77 --- /dev/null +++ b/automataCI/services/archive/ar.ps1 @@ -0,0 +1,93 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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 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 +} + + + + +function AR-Extract { + param ( + [string]$___file + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___file}") -eq 0) { + return 1 + } + + $___process = AR-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "ar" "-x `"${___file}`"" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/archive/ar.sh b/automataCI/services/archive/ar.sh new file mode 100644 index 0000000..dac8898 --- /dev/null +++ b/automataCI/services/archive/ar.sh @@ -0,0 +1,90 @@ +#!/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" + + + + +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 +} + + + + +AR_Extract() { + #___file="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + AR_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ar -x "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} diff --git a/automataCI/services/archive/tar.ps1 b/automataCI/services/archive/tar.ps1 new file mode 100644 index 0000000..316569e --- /dev/null +++ b/automataCI/services/archive/tar.ps1 @@ -0,0 +1,309 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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 + } + + $___process = GZ-Is-Available + if ($___process -ne 0) { + return 1 + } + + if ($($___destination -replace '\.tgz.*$') -ne $___destination) { + $___dest = "$($___destination -replace '\.tgz.*$')" + } else { + $___dest = "$($___destination -replace '\.tar.gz.*$')" + } + + + # create tar archive + $___process = TAR-Create "${___dest}.tar" "${___source}" "${___owner}" "${___group}" + if ($___process -ne 0) { + return 1 + } + + + # compress archive + $___process = GZ-Create "${___dest}.tar" + if ($___process -ne 0) { + return 1 + } + + + # rename to target + if ("${___destination}" -ne "${___dest}.tar.gz") { + $___process = FS-Move "${___dest}.tar.gz" "${___destination}" + 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 + } + + if ($($___destination -replace '\.txz.*$') -ne $___destination) { + $___dest = "$($___destination -replace '\.txz.*$')" + } else { + $___dest = "$($___destination -replace '\.tar.xz.*$')" + } + + + # create tar archive + $___process = TAR-Create "${___dest}.tar" "${___source}" "${___owner}" "${___group}" + if ($___process -ne 0) { + return 1 + } + + + # compress archive + $___process = XZ-Create "${___dest}.tar" + if ($___process -ne 0) { + return 1 + } + + + # rename to target + if ("${___destination}" -ne "${___dest}.tar.xz") { + $___process = FS-Move "${___dest}.xz" "${___destination}" + if ($___process -ne 0) { + return 1 + } + } + + + # report status + return 0 +} + + + + +function TAR-Extract-GZ { + param ( + [string]$___destination, + [string]$___source + ) + + + # 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-File "${___source}" + if ($___process -ne 0) { + return 1 + } + + $___process = GZ-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # unpack tar.gz + $___process = OS-Exec "tar" "-C `"${___destination}`" -xzf `"${___source}`"" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function TAR-Extract-XZ { + param ( + [string]$___destination, + [string]$___source + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___destination}") -eq 0) -or + ($(STRINGS-Is-Empty "${___source}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___destination}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___source}" + if ($___process -ne 0) { + return 1 + } + + $___process = XZ-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # unpack tar.xz + $___process = OS-Exec "tar" "-C `"${___destination}`" -xf `"${___source}`"" + 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..6163881 --- /dev/null +++ b/automataCI/services/archive/tar.sh @@ -0,0 +1,289 @@ +#!/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 + + GZ_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + if [ "${1%.tgz*}" != "$1" ]; then + ___dest="${1%.tgz*}" + else + ___dest="${1%.tar.gz*}" + fi + + + # create tar archive + TAR_Create "${___dest}.tar" "$2" "$3" "$4" + if [ $? -ne 0 ]; then + return 1 + fi + + + # compress archive + GZ_Create "${___dest}.tar" + if [ $? -ne 0 ]; then + return 1 + fi + + + # rename to destination target + if [ ! "$1" = "${___dest}.tar.gz" ]; then + FS_Move "${___dest}.tar.gz" "$1" + if [ $? -ne 0 ]; then + return 1 + fi + 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 + + if [ "${1%.txz*}" != "$1" ]; then + ___dest="${1%.txz*}" + else + ___dest="${1%.tar.xz*}" + fi + + + # create tar archive + TAR_Create "${___dest}.tar" "$2" "$3" "$4" + if [ $? -ne 0 ]; then + return 1 + fi + + + # compress archive + XZ_Create "${___dest}.tar" + if [ $? -ne 0 ]; then + return 1 + fi + + + # rename to target + if [ ! "$1" = "${___dest}.tar.xz" ]; then + FS_Move "${___dest}.tar.xz" "$1" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + + # report status + return 0 +} + + + + +TAR_Extract_GZ() { + #___destination="$1" + #___source="$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 [ $? -eq 0 ]; then + return 1 + fi + + FS_Is_File "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + GZ_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # unpack tar.gz + tar -C "$1" -xzf "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +TAR_Extract_XZ() { + #___destination="$1" + #___source="$2" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + XZ_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # unpack tar.xz + tar -C "$1" -xf "$2" + 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..cbe7d3c --- /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" +. "${env:LIBS_AUTOMATACI}\services\io\os.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-Directory "${___destination}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___source}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $null = FS-Make-Directory "${___destination}" + try { + $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..7aa6354 --- /dev/null +++ b/automataCI/services/archive/zip.sh @@ -0,0 +1,97 @@ +#!/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" + + + + +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_Directory "$___destination" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "$___source" + if [ $? -ne 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 + + OS_Is_Command_Available "unzip" + 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..c625450 --- /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-Create-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..923a7a2 --- /dev/null +++ b/automataCI/services/checksum/md5.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/io/strings.sh" + + + + +MD5_Create_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 + ___value="$(md5sum "$1")" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + OS_Is_Command_Available "md5" + if [ $? -eq 0 ]; then + ___value="$(md5 "$1")" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + if [ $(STRINGS_Is_Empty "$___value") -eq 0 ]; then + return 1 + fi + + + # report status + printf -- "%s" "${___value%% *}" + return 0 +} + + + + +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..e0b6c9f --- /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-Create-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..634ea09 --- /dev/null +++ b/automataCI/services/compilers/c.ps1 @@ -0,0 +1,918 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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}`n" + 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}`n" + 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..d4969e1 --- /dev/null +++ b/automataCI/services/compilers/changelog.ps1 @@ -0,0 +1,462 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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}`n" + 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`n" + if ($___process -ne 0) { + return 1 + } + } + + foreach ($___line in (Get-Content "${___directory}\$($___tag -replace ".*v")")) { + $___process = FS-Append-File "${___target}" "${___line}`n" + 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`n" + $null = FS-Append-File "${___target}" "`n## ${___version}`n`n" + foreach ($___line in (Get-Content "${___directory}\latest")) { + $___process = FS-Append-File "${___target}" "* ${___line}`n" + 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`n" + foreach ($___line in (Get-Content "${___directory}\$($___tag -replace ".*v")")) { + $___process = FS-Append-File "${___target}" "* ${___line}`n" + 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`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}`n" + 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 + } + + $___dest = $___dest -replace "\/.*$", "" + + + # all good. Generate the log fragment + $null = FS-Make-Directory "${___directory}\deb" + + + # create the entry header + $null = FS-Remove-Silently "${___directory}\deb\.latest" + $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}`n" + } + $null = FS-Append-File "${___directory}\deb\.latest" "" + + + # create the entry sign-off + $null = FS-Append-File "${___directory}\deb\.latest" ` + "-- ${___name} <${___email}> ${___date}`n" + + + # 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..efddc0d --- /dev/null +++ b/automataCI/services/compilers/changelog.sh @@ -0,0 +1,459 @@ +#!/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 + + ___dist="${___dist%%/*}" + + + # all good. Generate the log fragment + FS_Make_Directory "${___directory}/deb" + + + # create the entry header + FS_Remove_Silently "${___directory}/deb/.latest" + 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..6c98bcf --- /dev/null +++ b/automataCI/services/compilers/citation.ps1 @@ -0,0 +1,235 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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}`n" + 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}`n" + 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..f8b2241 --- /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}`n" + } + + + # 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..faf5cec --- /dev/null +++ b/automataCI/services/compilers/deb.ps1 @@ -0,0 +1,1196 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\disk.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\time.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\ar.ps1" +. "${env:LIBS_AUTOMATACI}\services\crypto\gpg.ps1" +. "${env:LIBS_AUTOMATACI}\services\checksum\md5.ps1" +. "${env:LIBS_AUTOMATACI}\services\publishers\unix.ps1" + + + + +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 + } + + + # to workspace directory + $___current_path = Get-Location + + + # package control + $null = Set-Location "${___directory}\control" + $___process = TAR-Create-XZ "${___directory}\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 "${___directory}\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 every items + foreach ($___line in (Get-ChildItem -Path "${___directory}\data" -File -Recurse)) { + $___checksum = MD5-Create-From-File "${___line}" + $___path = "${___line}" -replace [regex]::Escape("${___directory}\data\"), '' + $___path = $___path -replace "\\", "/" + $___checksum = $___checksum -replace "\ .*$", '' + $___process = FS-Append-File "${___location}" "${___checksum} ${___path}`n" + 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 + }} + + + # prepare workspace + $___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-KB "${___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}`n" + } + + + # report status + return 0 +} + + + + +function DEB-Create-Source-List { + param( + [string]$___directory, + [string]$___gpg_id, + [string]$___url, + [string]$___component, + [string]$___distribution, + [string]$___keyring + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___url}") -eq 0) -or + ($(STRINGS-Is-Empty "${___component}") -eq 0) -or + ($(STRINGS-Is-Empty "${___distribution}") -eq 0) -or + ($(STRINGS-Is-Empty "${___keyring}") -eq 0)) { + return 1 + } + + 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 + $___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}" + if ("$($___distribution -replace "\/.*$", '')" -eq $___distribution) { + # it's a pool repository + $___process = FS-Write-File "${___filename}" @" +# WARNING: AUTO-GENERATED - DO NOT EDIT! +deb [signed-by=/${___key}] ${___url} ${___distribution} ${__component} + +"@ + } else { + # it's a flat repository + $___process = FS-Write-File "${___filename}" @" +# WARNING: AUTO-GENERATED - DO NOT EDIT! +deb [signed-by=/${___key}] ${___url} ${___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}" "`n" + } 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 "" + } + + + # execute + switch ($___os) { + any { + $___output = "all-" + } linux { + $___output = "" + } dragonfly { + $___output = "dragonflybsd-" + } default { + $___output = "${___os}-" + }} + $___output = "${___output}$(UNIX-Get-Arch "${___arch}")" + if ($___output -eq "all-all") { + $___output = "all" + } + + + # 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 = SHASUM-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 + } + + $___process = GPG-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 +} + + + + +function DEB-Publish { + param ( + [string]$___repo_directory, + [string]$___data_directory, + [string]$___workspace_directory, + [string]$___target, + [string]$___distribution, + [string]$___component + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___repo_directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___data_directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___workspace_directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___distribution}") -eq 0) -or + ($(STRINGS-Is-Empty "${___component}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___repo_directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___directory_unpack = "${___workspace_directory}\deb" + $___repo_is_pool = $false + if ("$($___distribution -replace "\/.*$", '')" -eq $___distribution) { + # it's a pool repository + $___repo_is_pool = $true + } else { + # it's a flat repository + $___distribution = $___distribution -replace "\/.*$", '' + } + + + # unpack package control section + $null = FS-Remake-Directory "${___directory_unpack}" + $___process = DEB-Unpack "${___directory_unpack}" "${___target}" "control" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___directory_unpack}\control\control" + if ($___process -ne 0) { + return 1 + } + + + # parse package control data + $___value_type = "binary" # currently support this for now + $___value_package = "" + $___value_version = "" + $___value_arch = "" + $___value_maintainer = "" + $___value_buffer = "" + $___value_size = "$(DISK-Calculate-Size-File-Byte "${___target}")" + $___value_sha256 = "$(SHASUM-Create-From-File "${___target}" "256")" + $___value_sha1 = "$(SHASUM-Create-From-File "${___target}" "1")" + $___value_md5 = "$(MD5-Create-From-File "${___target}")" + $___value_description = "" + + foreach ($___line in (Get-Content "${___directory_unpack}/control/control")) { + $___regex = "^.*Package:\ " + if ("$($___line -replace $___regex, '')" -ne $___line) { + if ($(STRINGS-Is-Empty "${___value_package}") -ne 0) { + ## invalid control file - multiple same fileds detected + return 1 + } + + $___value_package = $___line -replace $___regex, '' + continue + } + + $___regex = "^.*Version:\ " + if ("$($___line -replace $___regex, '')" -ne $___line) { + if ($(STRINGS-Is-Empty "${___value_version}") -ne 0) { + ## invalid control file - multiple same fileds detected + return 1 + } + + $___value_version = $___line -replace $___regex, '' + continue + } + + $___regex = "^.*Architecture:\ " + if ("$($___line -replace $___regex, '')" -ne $___line) { + if ($(STRINGS-Is-Empty "${___value_arch}") -ne 0) { + ## invalid control file - multiple same fileds detected + return 1 + } + + $___value_arch = $___line -replace $___regex, '' + continue + } + + $___regex = "^.*Maintainer:\ " + if ("$($___line -replace $___regex, '')" -ne $___line) { + if ($(STRINGS-Is-Empty "${___value_maintainer}") -ne 0) { + ## invalid control file - multiple same fileds detected + return 1 + } + + $___value_maintainer = $___line -replace $___regex, '' + continue + } + + $___regex = "^.*Description:\ " + if ("$($___line -replace $___regex, '')" -ne $___line) { + if ($(STRINGS-Is-Empty "${___value_description}") -ne 0) { + ## invalid control file - multiple same fileds detected + return 1 + } + + $___value_description = $___line + continue + } + + if ($(STRINGS-Is-Empty "${___value_description}") -eq 0) { + if ($(STRINGS-Is-Empty "${___value_buffer}") -ne 0) { + $___value_buffer = "${___value_buffer}`n" + } + + $___value_buffer = "${___value_buffer}${___line}" + } else { + if ($(STRINGS-Is-Empty "${___value_description}") -ne 0) { + $___value_description = "${___value_description}`n" + } + + $___value_description = "${___value_description}${___line}" + } + } + + + # sanitize package metadata + if (($(STRINGS-Is-Empty "${___value_type}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_package}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_version}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_arch}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_maintainer}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_size}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_sha256}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_sha1}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_md5}") -eq 0) -or + ($(STRINGS-Is-Empty "${___value_description}") -eq 0)) { + return 1 + } + + + # process filename + $___value_filename = "${___value_package}_${___value_version}_${___value_arch}.deb" + if ($___repo_is_pool) { + $___value_filename = "${___value_package}\${___value_filename}" + $___value_filename = "$($(FS-Get-File "${___value_package}").Substring(0, 1))\${___value_filename}" + $___value_filename = "pool\${___distribution}\${___value_filename}" + } + + + # write to package database + $___dest = "${___value_package}_${___value_version}_${___value_arch}" + if ($___repo_is_pool) { + $___dest = "${___value_type}-${___value_arch}/${___dest}" + $___dest = "${___component}\${___dest}" + $___dest = "${___distribution}\${___dest}" + } + $___dest = "${___data_directory}\packages\${___dest}" + $___process = FS-Is-File "${___dest}" + if ($___process -eq 0) { + return 1 # duplicated package - already registered + } + + $null = FS-Make-Housing-Directory "${___dest}" + $___process = FS-Write-File "${___dest}" @" +Package: ${___value_package} +Version: ${___value_version} +Architecture: ${___value_arch} +Maintainer: ${___value_maintainer} +${___value_buffer} +Filename: $($___value_filename -replace "\\", "/") +Size: ${___value_size} +SHA256: ${___value_sha256} +SHA1: ${___value_sha1} +MD5sum: ${___value_md5} +${___value_description} + +"@ + if ($___process -ne 0) { + return 1 + } + + + # write to arch database + $___dest = "${___data_directory}\arch\${___value_arch}" + $null = FS-Make-Housing-Directory "${___dest}" + $___process = FS-Append-File "${___dest}" "${___value_filename}`n" + if ($___process -ne 0) { + return 1 + } + + + # export deb payload to destination + $___dest = "${___repo_directory}\${___value_filename}" + $___process = FS-Is-File "${___dest}" + if ($___process -ne 0) { + $null = FS-Make-Housing-Directory "${___dest}" + $___process = FS-Move "${___target}" "${___dest}" + if ($___process -ne 0) { + return 1 + } + } else { + return 1 # duplicated package existence or corrupted run + } + + + # report status + return 0 +} + + + + +function DEB-Publish-Conclude { + param ( + [string]$___repo_directory, + [string]$___data_directory, + [string]$___distribution, + [string]$___arch_list, + [string]$___component, + [string]$___codename, + [string]$___gpg_id + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___repo_directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___data_directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___arch_list}") -eq 0) -or + ($(STRINGS-Is-Empty "${___component}") -eq 0) -or + ($(STRINGS-Is-Empty "${___codename}") -eq 0) -or + ($(STRINGS-Is-Empty "${___gpg_id}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___repo_directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Directory "${___data_directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = GPG-Is-Available "${___gpg_id}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___directory_package = "${___data_directory}\packages" + $___repo_is_pool = $false + if ("$($___distribution -replace "\/.*$", '')" -eq $___distribution) { + # it's a pool repository + $___repo_is_pool = $true + $___repo_directory = "${___repo_directory}\dists" + } else { + # it's a flat repository + $___distribution = $___distribution -replace "\/.*$", '' + } + + + # formulate arch list if empty + if ($(STRINGS-Is-Empty "${___arch_list}") -eq 0) { + Get-ChildItem -Path "${___data_directory}\arch" -File ` + | ForEach-Object { $___line = $_.FullName + if ($(STRINGS-Is-Empty "${___arch_list}") -ne 0) { + $___arch_list = "${___arch_list} " + } + + $___arch_list = "${___arch_list}$(FS-Get-File "${___line}")" + } + } + + if ($(STRINGS-Is-Empty "${___arch_list}") -eq 0) { + return 1 + } + + + # purge all Package and Release files from repository + if ($___repo_is_pool) { + $null = FS-Remove-Silently "${___repo_directory}" + } else { + Get-ChildItem -Path "${___repo_directory}" ` + | Where-Object { + ($_.Name -eq "Packages") -or + ($_.Name -eq "Packages.gz") -or + ($_.Name -eq "Releases") -or + ($_.Name -eq "Releases.gpg") -or + ($_.Name -eq "InRelease") + } | ForEach-Object { + $null = FS-Remove-Silently $_.FullName + } + } + + + # recreate Package files + Get-ChildItem -Path "${___directory_package}" -File ` + | ForEach-Object { $___line = $_.FullName + ## get relative path + $___dest = $___line -replace [regex]::Escape("${___directory_package}\"), '' + + ## determine destination path + $___dest = "$(FS-Get-Directory "${___line}")" + if ($___repo_is_pool) { + $___dest = "${___repo_directory}\${___dest}" + } else { + if ("${___dest}" -ne "${___line}") { + # skip - it is a pool mode package in flat mode operation + continue + } + + $___dest = "${___repo_directory}" + } + $null = FS-Make-Directory "${___dest}" + + ## append package entry + $___process = FS-Is-File "${___dest}\Packages" + if ($___process -eq 0) { + $___process = FS-Append-File "${___dest}\Packages" "`n" + if ($___process -ne 0) { + return 1 + } + } + + foreach ($___content in (Get-Content -Path "${___directory_package}\${___line}")) { + $___process = FS-Append-File "${___dest}\Packages" "${___content}`n" + if ($___process -ne 0) { + return 1 + } + } + + $null = FS-Append-File $___location "${___line}`n" + } + + Get-ChildItem -Path "${___repo_directory}" ` + | Where-Object { ($_.Name -eq "Packages") } ` + | ForEach-Object { $___line = $_.FullName + ## gunzip all Package files + $null = FS-Copy-File "${___line}" "${___line}.backup" + $null = FS-Remove-Silently "${___line}.gz" + $___process = GZ-Create "${___line}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Move "${___line}.backup" "${___line}" + if ($___process -ne 0) { + return 1 + } + + ## create corresponding legacy Release file for pool mode + if ($___repo_is_pool) { + $___arch = $___line -replace [regex]::Escape("${___repo_directory}\"), '' + $___arch = "$(FS-Get-Directory "${___arch}")" + + $___arch = $___arch -split "\" + $___suite = $___arch[0] + + $___component = $___arch[1] + $___arch = $___arch[2] -split "-" + + $___package_type = $___arch[0] + $___arch = $___arch[1] + + $___process = FS-Write-File ` + "$(FS-Get-Directory "${___line}")\Release" ` @" +Archive: ${___suite} +Component: ${___component} +Architecture: ${___arch} + +"@ + if ($___process -ne 0) { + return 1 + } + } + } + + + # generate repository metadata + if ($___repo_is_pool) { + $___repo_directory = "${___repo_directory}\${___distribution}" + } + $___dest_release = "${___repo_directory}\Release" + $null = FS-Remove-Silently "${___dest_release}" + $___dest_inrelease = "${___repo_directory}\InRelease" + $null = FS-Remove-Silently "${___dest_inrelease}" + $___dest_md5 = "${___repo_directory}\ReleaseMD5" + $null = FS-Remove-Silently "${___dest_md5}" + $___dest_sha1 = "${___repo_directory}\ReleaseSHA1" + $null = FS-Remove-Silently "${___dest_sha1}" + $___dest_sha256 = "${___repo_directory}\ReleaseSHA256" + $null = FS-Remove-Silently "${___dest_sha256}" + + Get-ChildItem -Path "${___repo_directory}" ` + | Where-Object { + ($_.Name -eq "Packages") -or + ($_.Name -eq "Packages.gz") -or + ($_.Name -eq "Release") + } | ForEach-Object { $___line = $_.FullName + $___size = "$(DISK-Calculate-Size-File-Byte "${___line}")" + $___path = $___line -replace [regex]::Escape("${___repo_directory}\"), '' + + $___checksum = "$(MD5-Create-From-File "${___line}")" + $___process = FS-Append-File "${___dest_md5}" ` + " ${___checksum} ${___size} ${___path}`n" + if ($___process -ne 0) { + return 1 + } + + $___checksum = "$(SHASUM-Create-From-File "${___line}" "1")" + $___process = FS-Append-File "${___dest_sha1}" ` + " ${___checksum} ${___size} ${___path}`n" + if ($___process -ne 0) { + return 1 + } + + $___checksum = "$(SHASUM-Create-From-File "${___line}" "256")" + $___process = FS-Append-File "${___dest_sha256}" ` + " ${___checksum} ${___size} ${___path}`n" + if ($___process -ne 0) { + return 1 + } + } + + + # create root Release file + $___process = FS-Write-File "${___dest_release}" @" +Suite: ${___distribution} +Codename: ${___codename} +Date: $(TIME-Format-Datetime-RFC5322-UTC "$(TIME-Now)") +Architectures: ${___arch_list} +Components: ${___component} + +"@ + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Append-File "${___dest_release}" "MD5Sum:`n" + if ($___process -ne 0) { + return 1 + } + foreach ($___line in (Get-Content -Path "${___dest_md5}")) { + $___process = FS-Append-File "${___dest_release}" "${___line}`n" + if ($___process -ne 0) { + return 1 + } + } + $___process = FS-Remove "${___dest_md5}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Append-File "${___dest_release}" "SHA1:`n" + if ($___process -ne 0) { + return 1 + } + foreach ($___line in (Get-Content -Path "${___dest_sha1}")) { + $___process = FS-Append-File "${___dest_release}" "${___line}`n" + if ($___process -ne 0) { + return 1 + } + } + $___process = FS-Remove "${___dest_sha1}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Append-File "${___dest_release}" "SHA256:`n" + if ($___process -ne 0) { + return 1 + } + foreach ($___line in (Get-Content -Path "${___dest_sha256}")) { + $___process = FS-Append-File "${___dest_release}" "${___line}`n" + if ($___process -ne 0) { + return 1 + } + } + $___process = FS-Remove "${___dest_sha256}" + if ($___process -ne 0) { + return 1 + } + + + # create InRelease file + $___process = GPG-Clear-Sign-File ` + "${___dest_inrelease}" ` + "${___dest_release}" ` + "${___gpg_id}" + if ($___process -ne 0) { + return 1 + } + + + # create Release.gpg file + $___process = GPG-Detach-Sign-File ` + "${___dest_release}.gpg" ` + "${___dest_release}" ` + "${___gpg_id}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function DEB-Unpack { + param( + [string]$___directory, + [string]$___target, + [string]$___unpack_type + ) + + # validate input + if ($(STRINGS-Is-Empty "${___directory}") -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Target-Exist "${___directory}\control" + if ($___process -eq 0) { + return 1 + } + + $___process = FS-Is-Target-Exist "${___directory}\data" + if ($___process -eq 0) { + return 1 + } + + $___process = FS-Is-Target-Exist "${___directory}\debian-binary" + if ($___process -eq 0) { + return 1 + } + + + # execute + # copy target into directory + $___process = FS-Copy-File "${___target}" "${___directory}" + if ($___process -ne 0) { + return 1 + } + + + # to workspace directory + $___current_path = Get-Location + $null = Set-Location "${___directory}" + + + # ar extract outer layer + $___source = ".\$(FS-Get-File "${___target}")" + $___process = AR-Extract "${___source}" + if ($___process -ne 0) { + $null = Set-Location -Path $___current_path + $null = Remove-Variable -Name ___current_path + return 1 + } + $null = FS-Remove-Silently "${___source}" + + + # unpack control.tar.*z by request + if ($(STRINGS-To-Lowercase "${___unpack_type}") -ne "data") { + $___source=".\control.tar.xz" + $___dest=".\control" + $null = FS-Make-Directory "${___dest}" + $___process = FS-Is-File "${___source}" + if ($___process -eq 0) { + $___process = TAR-Extract-XZ "${___dest}" "${___source}" + } else { + $___source=".\control.tar.gz" + $___process = FS-Is-File "${___source}" + if ($___process -ne 0) { + $null = Set-Location -Path $___current_path + $null = Remove-Variable -Name ___current_path + return 1 + } + + $___process = TAR-Extract-GZ "${___dest}" "${___source}" + } + $null = FS-Remove-Silently "${___source}" + } + + if ($(STRINGS-To-Lowercase "${___unpack_type}") -eq "control") { + # stop as requested. + $null = Set-Location -Path $___current_path + $null = Remove-Variable -Name ___current_path + + + # report status + if ($___process -ne 0) { + return 1 + } + return 0 + } + + + # unpack data.tar.*z by request + $___source=".\data.tar.xz" + $___dest=".\data" + $null = FS-Make-Directory "${___dest}" + $___process = FS-Is-File "${___source}" + if ($___process -eq 0) { + $___process = TAR-Extract-XZ "${___dest}" "${___source}" + } else { + $___source=".\data.tar.gz" + $___process = FS-Is-File "${___source}" + if ($___process -ne 0) { + $null = Set-Location -Path $___current_path + $null = Remove-Variable -Name ___current_path + return 1 + } + + $___process = TAR-Extract-GZ "${___dest}" "${___source}" + } + $null = FS-Remove-Silently "${___source}" + + + # back to current directory + $null = Set-Location -Path $___current_path + $null = Remove-Variable -Name ___current_path + + + # report status + if ($___process -ne 0) { + return 1 + } + return 0 +} diff --git a/automataCI/services/compilers/deb.sh b/automataCI/services/compilers/deb.sh new file mode 100644 index 0000000..4642f01 --- /dev/null +++ b/automataCI/services/compilers/deb.sh @@ -0,0 +1,1183 @@ +#!/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/disk.sh" +. "${LIBS_AUTOMATACI}/services/io/os.sh" +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/io/time.sh" +. "${LIBS_AUTOMATACI}/services/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/archive/ar.sh" +. "${LIBS_AUTOMATACI}/services/crypto/gpg.sh" +. "${LIBS_AUTOMATACI}/services/checksum/md5.sh" +. "${LIBS_AUTOMATACI}/services/publishers/unix.sh" + + + + +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 + + + # to workspace directory + ___current_path="$PWD" + + + # package control + cd "${___directory}/control" + TAR_Create_XZ "${___directory}/control.tar.xz" "." + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + + # package data + cd "${___directory}/data" + TAR_Create_XZ "${___directory}/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_Create_From_File "$___line") ${___line}" + if [ $? -ne 0 ]; then + return 1 + fi + + ___line="${___line##*${1}/data/}" + ___checksum="${___checksum%% *}" + FS_Append_File "$___location" "${___checksum} ${___line}\n" + 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_KB "${___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 + FS_Is_File "$___description_filepath" + if [ $? -ne 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" + ___component="$4" + ___distribution="$5" + ___keyring="$6" + + + # validate input + if [ $(STRINGS_Is_Empty "$___directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___url") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___component") -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 + ___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" + if [ "${___distribution%%/*}" = "$___distribution" ]; then + # it's a pool repository + FS_Write_File "$___filename" "\ +# WARNING: AUTO-GENERATED - DO NOT EDIT! +deb [signed-by=/${___key}] ${___url} ${___distribution} ${__component} +" + else + # it's a flat repository + FS_Write_File "$___filename" "\ +# WARNING: AUTO-GENERATED - DO NOT EDIT! +deb [signed-by=/${___key}] ${___url} ${___distribution} +" + fi + if [ $? -ne 0 ]; then + return 1 + fi + + 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 + + + # execute + case "$1" in + any) + ___output="all-" + ;; + linux) + ___output="" + ;; + dragonfly) + ___output="dragonflybsd-" + ;; + *) + ___output="${1}-" + ;; + esac + ___output="${___output}$(UNIX_Get_Arch "$2")" + if [ "$___output" = "all-all" ]; then + ___output="all" + fi + + + # 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 + + SHASUM_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 + + GPG_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 +} + + + + +DEB_Publish() { + ___repo_directory="$1" + ___data_directory="$2" + ___workspace_directory="$3" + ___target="$4" + ___distribution="$5" + ___component="$6" + + + # validate input + if [ $(STRINGS_Is_Empty "$___repo_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___data_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___workspace_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___target") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___distribution") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___component") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___repo_directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "$___target" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___directory_unpack="${___workspace_directory}/deb" + ___repo_is_pool=1 + if [ "${___distribution%%/*}" = "$___distribution" ]; then + ## it's a pool repository + ___repo_is_pool=0 + else + ## it's a flat repository + ___distribution="${___distribution%%/*}" + fi + + + # unpack package control section + FS_Remake_Directory "$___directory_unpack" + DEB_Unpack "$___directory_unpack" "$___target" "control" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "${___directory_unpack}/control/control" + if [ $? -ne 0 ]; then + return 1 + fi + + + # parse package control data + ___value_type="binary" # currently support this for now + ___value_package="" + ___value_version="" + ___value_arch="" + ___value_maintainer="" + ___value_buffer="" + ___value_size="$(DISK_Calculate_Size_File_Byte "$___target")" + ___value_sha256="$(SHASUM_Create_From_File "$___target" "256")" + ___value_sha1="$(SHASUM_Create_From_File "$___target" "1")" + ___value_md5="$(MD5_Create_From_File "$___target")" + ___value_description="" + + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + if [ "${___line#*Package: }" != "${___line}" ]; then + if [ $(STRINGS_Is_Empty "$___value_package") -ne 0 ]; then + ## invalid control file - multiple same fields detected + return 1 + fi + + ___value_package="${___line#*Package: }" + continue + fi + + if [ "${___line#*Version: }" != "${___line}" ]; then + if [ $(STRINGS_Is_Empty "$___value_version") -ne 0 ]; then + ## invalid control file - multiple same fields detected + return 1 + fi + + ___value_version="${___line#*Version: }" + continue + fi + + if [ "${___line#*Architecture: }" != "${___line}" ]; then + if [ $(STRINGS_Is_Empty "$___value_arch") -ne 0 ]; then + ## invalid control file - multiple same fields detected + return 1 + fi + + ___value_arch="${___line#*Architecture: }" + continue + fi + + if [ "${___line#*Maintainer: }" != "${___line}" ]; then + if [ $(STRINGS_Is_Empty "$___value_maintainer") -ne 0 ]; then + ## invalid control file - multiple same fields detected + return 1 + fi + + ___value_maintainer="${___line#*Maintainer: }" + continue + fi + + if [ "${___line#*Description: }" != "${___line}" ]; then + if [ $(STRINGS_Is_Empty "$___value_description") -ne 0 ]; then + ## invalid control file - multiple same fields detected + return 1 + fi + + ___value_description="$___line" + continue + fi + + if [ $(STRINGS_Is_Empty "$___value_description") -eq 0 ]; then + if [ $(STRINGS_Is_Empty "$___value_buffer") -ne 0 ]; then + ___value_buffer="${___value_buffer}\n" + fi + + ___value_buffer="${___value_buffer}${___line}" + else + if [ $(STRINGS_Is_Empty "$___value_description") -ne 0 ]; then + ___value_description="${___value_description}\n" + fi + + ___value_description="${___value_description}${___line}" + fi + done < "${___directory_unpack}/control/control" + IFS="$___old_IFS" && unset ___old_IFS + + + # sanitize package metadata + if [ $(STRINGS_Is_Empty "$___value_type") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_package") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_version") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_arch") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_maintainer") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_size") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_sha256") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_sha1") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_md5") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___value_description") -eq 0 ]; then + return 1 + fi + + + # process filename + ___value_filename="${___value_package}_${___value_version}_${___value_arch}.deb" + if [ $___repo_is_pool -eq 0 ]; then + ___value_filename="${___value_package}/${___value_filename}" + ___value_filename="$(printf -- "%.1s" "$(FS_Get_File "$___value_package")")/${___value_filename}" + ___value_filename="pool/${___distribution}/${___value_filename}" + fi + + + # write to package database + ___dest="${___value_package}_${___value_version}_${___value_arch}" + if [ $___repo_is_pool -eq 0 ]; then + ___dest="${___value_type}-${___value_arch}/${___dest}" + ___dest="${___component}/${___dest}" + ___dest="${___distribution}/${___dest}" + fi + ___dest="${___data_directory}/packages/${___dest}" + FS_Is_File "$___dest" + if [ $? -eq 0 ]; then + return 1 # duplicated package - already registered + fi + + FS_Make_Housing_Directory "$___dest" + FS_Write_File "$___dest" "\ +Package: ${___value_package} +Version: ${___value_version} +Architecture: ${___value_arch} +Maintainer: ${___value_maintainer} +${___value_buffer} +Filename: ${___value_filename} +Size: ${___value_size} +SHA256: ${___value_sha256} +SHA1: ${___value_sha1} +MD5sum: ${___value_md5} +${___value_description} +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # write to arch database + ___dest="${___data_directory}/arch/${___value_arch}" + FS_Make_Housing_Directory "$___dest" + FS_Append_File "$___dest" "${___value_filename}\n" + if [ $? -ne 0 ]; then + return 1 + fi + + + # export deb payload to destination + ___dest="${___repo_directory}/${___value_filename}" + FS_Is_File "$___dest" + if [ $? -ne 0 ]; then + FS_Make_Housing_Directory "$___dest" + if [ $___repo_is_pool -eq 0 ]; then + FS_Copy_File "$___target" "$___dest" + else + FS_Move "$___target" "$___dest" + fi + if [ $? -ne 0 ]; then + return 1 + fi + elif [ "$___target" != "$___dest" ]; then + return 1 # duplicated package existence or corrupted run + fi + + + # report status + return 0 +} + + + + +DEB_Publish_Conclude() { + ___repo_directory="$1" + ___data_directory="$2" + ___distribution="$3" + ___arch_list="$4" + ___component="$5" + ___codename="$6" + ___gpg_id="$7" + + + # validate input + if [ $(STRINGS_Is_Empty "$___repo_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___data_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___distribution") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___component") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___codename") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___gpg_id") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___repo_directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "$___data_directory" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "find" + if [ $? -ne 0 ]; then + return 1 + fi + + GPG_Is_Available "$___gpg_id" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___directory_package="${___data_directory}/packages" + ___repo_is_pool=1 + if [ "${___distribution%%/*}" = "$___distribution" ]; then + # it's a pool repository + ___repo_is_pool=0 + ___repo_directory="${___repo_directory}/dists" + else + ## it's a flat repository + ___distribution="${___distribution%%/*}" + fi + + + # formulate arch list if empty + if [ $(STRINGS_Is_Empty "$___arch_list") -eq 0 ]; then + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + if [ $(STRINGS_Is_Empty "$___arch_list") -ne 0 ]; then + ___arch_list="${___arch_list} " + fi + + ___arch_list="${___arch_list}$(FS_Get_File "$___line")" + done < +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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..b1b736d --- /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..b32158a --- /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..8ec7a79 --- /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 "${___directory}\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 "${___directory}\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}" "${___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..86dffe9 --- /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 "${___directory}/control.tar.gz" "." + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + + # package data + cd "${___directory}/data" + TAR_Create_GZ "${___directory}/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" "$___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..67c591d --- /dev/null +++ b/automataCI/services/compilers/libreoffice.ps1 @@ -0,0 +1,256 @@ +# 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-Local { + $___path = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}\${env:PROJECT_PATH_LIBREOFFICE_ENGINE}\bin\soffice" + + switch ("${env:PROJECT_OS}") { + "windows" { + $___path = "${___path}.exe" + } default { + # do nothing + }} + + + # report status + return $___path +} + + + + +function LIBREOFFICE-Get-Path { + # execute + $___path = LIBREOFFICE-Get-Path-Local + if ($(FS-Is-File "${___path}") -eq 0) { + return $___path + } + + switch ("${env:PROJECT_OS}") { + "darwin" { + $___path = "/Applications/LibreOffice.app/Contents/MacOS/soffice" + } "windows" { + $___path = "${___path}.exe" + if ($(FS-Is-File "${___path}") -ne 0) { + $___path = "C:\Program Files\LibreOffice\program\soffice.exe" + } + } default { + $___path = "/bin/soffice" + }} + + + # report status + return $___path +} + + + + +function LIBREOFFICE-Is-Available { + # execute + $___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 + $___dest = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}\${env:PROJECT_PATH_LIBREOFFICE_ENGINE}" + $___url = "${env:PROJECT_LIBREOFFICE_MIRROR}/stable/${env:PROJECT_LIBREOFFICE_VERSION}" + switch ("${env:PROJECT_OS}") { + "darwin" { + $___dest = "${___dest}\install.dmg" + + $___url = "${___url}/mac" + switch ("${env:PROJECT_ARCH}") { + "amd64" { + $___url = "${___url}/x86_64" + $___url = "${___url}/LibreOffice_${env:PROJECT_LIBREOFFICE_VERSION}_MacOS_x86-64.dmg" + } "arm64" { + $___url = "${___url}/aarch64" + $___url = "${___url}/LibreOffice_${env:PROJECT_LIBREOFFICE_VERSION}_MacOS_aarch64.dmg" + } default { + $___url = "" + }} + + ## attempt to download from vendor directly + if ($(STRINGS-Is-Empty "${___url}") -ne 0) { + $null = FS-Make-Housing-Directory "${___dest}" + $null = FS-Remove-Silently "${___dest}" + $___process = HTTP-Download "GET" "${___url}" "${___dest}" + if ($___process -ne 0) { + return 1 + } + + $___process = Apple-Install-DMG "${___dest}" + if ($___process -ne 0) { + return 1 + } + + $null = FS-Remove-Silently "${___dest}" + } + } "windows" { + $___dest = "${___dest}\install.msi" + + $___url = "${___url}/win" + switch ("${env:PROJECT_ARCH}") { + "amd64" { + $___url = "${___url}/x86_64" + $___url = "${___url}/LibreOffice_${env:PROJECT_LIBREOFFICE_VERSION}_Win_x86-64.msi" + } "arm64" { + $___url = "${___url}/aarch64" + $___url = "${___url}/LibreOffice_${env:PROJECT_LIBREOFFICE_VERSION}_Win_aarch64.msi" + } default { + $___url = "" + }} + + if ($(STRINGS-Is-Empty "${___url}") -ne 0) { + $null = FS-Make-Housing-Directory "${___dest}" + $null = FS-Remove-Silently "${___dest}" + $___process = HTTP-Download "GET" "${___url}" "${___dest}" + if ($___process -eq 0) { + $___process = MSI-Install-Silent "${___dest}" + $null = FS-Remove-Silently "${___dest}" + } + } + + ## fallback to choco as the last resort + if (($(STRINGS-Is-Empty "${___url}") -eq 0) -or ($___process -ne 0)) { + $___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 + } + } "linux" { + $___process = OS-Is-Command-Available "flatpak" + if ($___process -eq 0) { + $___process = OS-Exec "flatpak" "--user install org.libreoffice.LibreOffice" + } + + ## download appimage as last resort + if ($___process -ne 0) { + $___dest = LIBREOFFICE-Get-Path-Local + $___url = "https://appimages.libreitalia.org" + switch ("${env:PROJECT_ARCH}") { + "amd64" { + $___url = "${___url}/LibreOffice-fresh.full-x86_64.AppImage" + } default { + return 1 + }} + + if ($(STRINGS-Is-Empty "${___url}") -ne 0) { + $null = FS-Make-Housing-Directory "${___dest}" + $null = FS-Remove-Silently "${___dest}" + $___process = HTTP-Download "GET" "${___url}" "${___dest}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___dest}" + if ($___process -ne 0) { + return 1 + } + } + } + } default { + return 1 # unsupported + }} + + + # test the output + $___process = LIBREOFFICE-Is-Available + 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..8272b81 --- /dev/null +++ b/automataCI/services/compilers/libreoffice.sh @@ -0,0 +1,295 @@ +#!/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_Local() { + # execute + ___path="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/${PROJECT_PATH_LIBREOFFICE_ENGINE}/bin/soffice" + + case "$PROJECT_OS" in + windows) + ___path="${___path}.exe" + ;; + *) + ;; + esac + + + # report status + printf -- "%b" "$___path" + return 0 +} + + + + +LIBREOFFICE_Get_Path() { + # execute + ___path="$(LIBREOFFICE_Get_Path_Local)" + FS_Is_File "$___path" + if [ $? -eq 0 ]; then + printf -- "%b" "$___path" + return 0 + fi + + case "$PROJECT_OS" in + darwin) + ___path="/Applications/LibreOffice.app/Contents/MacOS/soffice" + ;; + windows) + ___path="C:\\Program Files\\LibreOffice\\program\\soffice.exe" + ;; + *) + ___path="/bin/soffice" + ;; + 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 + ___dest="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/${PROJECT_PATH_LIBREOFFICE_ENGINE}" + ___url="${PROJECT_LIBREOFFICE_MIRROR}/stable/${PROJECT_LIBREOFFICE_VERSION}" + case "$PROJECT_OS" in + darwin) + ___dest="${___dest}/install.dmg" + + ___url="${___url}/mac" + case "$PROJECT_ARCH" in + amd64) + ___url="${___url}/x86_64" + ___url="${___url}/LibreOffice_${PROJECT_LIBREOFFICE_VERSION}_MacOS_x86-64.dmg" + ;; + arm64) + ___url="${___url}/aarch64" + ___url="${___url}/LibreOffice_${PROJECT_LIBREOFFICE_VERSION}_MacOS_aarch64.dmg" + ;; + *) + ___url="" + ;; + esac + + ## attempt to download from vendor directly + if [ $(STRINGS_Is_Empty "$___url") -ne 0 ]; then + FS_Make_Housing_Directory "$___dest" + FS_Remove_Silently "$___dest" + HTTP_Download "GET" "$___url" "$___dest" + if [ $? -ne 0 ]; then + return 1 + fi + + APPLE_Install_DMG "$___dest" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Remove_Silently "$___dest" + fi + ;; + windows) + ___dest="${___dest}/install.msi" + + ___url="${___url}/win" + case "$PROJECT_ARCH" in + amd64) + ___url="${___url}/aarch64" + ___url="${___url}/LibreOffice_${PROJECT_LIBREOFFICE_VERSION}_Win_X86-64.msi" + ;; + arm64) + ___url="${___url}/aarch64" + ___url="${___url}/LibreOffice_${PROJECT_LIBREOFFICE_VERSION}_Win_aarch64.msi" + ;; + *) + ___url="" + ;; + esac + + if [ $(STRINGS_Is_Empty "$___url") -ne 0 ]; then + FS_Make_Housing_Directory "$___dest" + FS_Remove_Silently "$___dest" + HTTP_Download "GET" "$___url" "$___dest" + ___process=$? + if [ $___process -eq 0 ]; then + MSI_Install_Silent "$___dest" + ___process=$? + FS_Remove_Silently "$___dest" + fi + fi + + ## fallback to choco as the last resort + if [ $(STRINGS_Is_Empty "$___url") -eq 0 ] || [ $___process -ne 0 ]; then + OS_Is_Command_Available "choco" + if [ $? -ne 0 ]; then + return 1 + fi + + choco install libreoffice-fresh -y + if [ $? -ne 0 ]; then + return 1 + fi + fi + ;; + linux) + OS_Is_Command_Available "flatpak" + ___process=$? + if [ $___process -eq 0 ]; then + flatpak --user install org.libreoffice.LibreOffice + ___process=$? + fi + + ## download appimage as last resort + if [ $___process -ne 0 ]; then + ___dest="$(LIBREOFFICE_Get_Path_Local)" + ___url="https://appimages.libreitalia.org" + case "$PROJECT_ARCH" in + amd64) + ___url="${___url}/LibreOffice-fresh.full-x86_64.AppImage" + ;; + *) + return 1 + ;; + esac + + if [ $(STRINGS_Is_Empty "$___url") -ne 0 ]; then + 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 + fi + ;; + *) + return 1 # unsupported + ;; + esac + + + # test the output + LIBREOFFICE_Is_Available + if [ $? -eq 0 ]; then + return 0 + 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..c69a758 --- /dev/null +++ b/automataCI/services/compilers/msi.ps1 @@ -0,0 +1,269 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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 + } + + $___lang = MSI-Get-Culture "${___lang}" + if ($(STRINGS-Is-Empty "${___lang}") -eq 0) { + return 1 + } + + + # execute + $___arguments = @" +build -arch ${___arch} -culture ${___lang} -out `"$(FS-Extension-Replace "${___target}" ".wxs" ".msi")`" +"@ + + foreach ($___ext in (Get-ChildItem "$(FS-Get-Directory "${___target}")\ext" -File -Filter "*.dll")) { + $___arguments += " -ext ${___ext}" + } + $___arguments += " ${___target}" + + $___process = OS-Exec "wix" "${___arguments}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function MSI-Get-Directory-Program-Files { + param( + [string]$___arch + ) + + + # execute + switch ("${___arch}") { + { $_ -in "amd64", "arm64" } { + return "ProgramFiles64Folder" + } { $_ -in "i386", "arm" } { + return "ProgramFilesFolder" + } default { + return "ProgramFiles6432Folder" + }} +} + + + + +function MSI-Get-Culture { + param( + [string]$___lang + ) + + + # execute + # IMPORTANT NOTE: this is a temporary function for handling WiX's + # localization bug. More info: + # (1) https://github.com/wixtoolset/issues/issues/7896 + # (2) https://wixtoolset.org/docs/tools/wixext/wixui/#translated-strings + switch (STRINGS-To-Lowercase "${___lang}") { + "ar" { + return "ar-SA" + } "bg" { + return "bg-BG" + } "ca" { + return "ca-ES" + } "cs" { + return "cs-CZ" + } "da" { + return "da-DK" + } "de" { + return "de-DE" + } "el" { + return "el-GR" + } "en" { + return "en-US" + } "es" { + return "es-ES" + } "et" { + return "et-EE" + } "fi" { + return "fi-FI" + } "fr" { + return "fr-FR" + } "he" { + return "he-IL" + } "hi" { + return "hi-IN" + } "hr" { + return "hr-HR" + } "hu" { + return "hu-HU" + } "it" { + return "it-IT" + } "ja" { + return "ja-JP" + } "kk" { + return "kk-KZ" + } "ko" { + return "ko-KR" + } "lt" { + return "lt-LT" + } "lv" { + return "lv-LV" + } "nb" { + return "nb-NO" + } "nl" { + return "nl-NL" + } "pl" { + return "pl-PL" + } "pt" { + return "pt-PT" + } "ro" { + return "ro-RO" + } "ru" { + return "ru-RU" + } "sk" { + return "sk-SK" + } "sl" { + return "sl-SI" + } "sq" { + return "sq-AL" + } "sr" { + return "sr-Latn-RS" + } "sv" { + return "sv-SE" + } "th" { + return "th-TH" + } "tr" { + return "tr-TR" + } "uk" { + return "uk-UA" + } "zh-hant" { + return "zh-TW" + } { $_ -in "zh", "zh-hans" } { + return "zh-CN" + } default { + return "" + }} +} + + + + +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..ac471e2 --- /dev/null +++ b/automataCI/services/compilers/msi.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/publishers/microsoft.sh" + + + + +MSI_Compile() { + #___target="$1" + #___arch="$2" + #___lang="$3" + + + # 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 + + ___ext="" + ___extensions="$(FS_Get_Directory "$1")/ext" + for ___file in "$(FS_Get_Directory "$1")/ext/"*; do + FS_Is_File "$___file" + if [ $? -ne 0 ]; then + continue + fi + + if [ ! "${___file%%.dll*}" = "$___file" ]; then + ___ext="${___ext} -ext \"${___file}\"" + fi + done + + + # execute + wixl --verbose --arch "${___arch}" ${___ext} --output "${1%.wxs*}.msi" "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +MSI_Get_Directory_Program_Files() { + #___arch="$1" + + + # execute + case "$1" in + amd64|arm64) + printf -- "ProgramFiles64Folder" + ;; + i386|arm) + printf -- "ProgramFilesFolder" + ;; + *) + printf -- "" + ;; + esac + + + # 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..da631e2 --- /dev/null +++ b/automataCI/services/compilers/nim.ps1 @@ -0,0 +1,459 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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..5c088a9 --- /dev/null +++ b/automataCI/services/compilers/node.ps1 @@ -0,0 +1,443 @@ +# 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\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\net\http.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\zip.ps1" + + + + +function NODE-Activate-Local-Environment { + # validate input + $___process = NODE-Is-Localized + if ($___process -eq 0) { + $___process = NODE-Is-Available + if ($___process -ne 0) { + return 1 + } + + return 0 + } + + + # execute + $___location = "$(NODE-Get-Activator-Path)" + $___process = FS-Is-File "${___location}" + if ($___process -ne 0) { + return 1 + } + + . "${___location}" + $___process = NODE-Is-Localized + if ($___process -ne 0) { + return 1 + } + + $___process = NODE-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function NODE-Get-Activator-Path { + return "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}\${env:PROJECT_PATH_NODE_ENGINE}\Activate.ps1" +} + + + + +function NODE-Is-Available { + # execute + if ($(STRINGS-Is-Empty "${env:PROJECT_NODE_VERSION}") -ne 0) { + ## check existing localized engine + $___target = "$(NODE-Get-Activator-Path)" + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + $___target = "$(FS-Get-Directory "${___target}")" + + ## check localized node command availability + $___process = FS-Is-File "${___target}\node.exe" + if ($___process -ne 0) { + return 1 + } + + ## check localized npm command availability + $___process = FS-Is-File "${___target}\npm" + if ($___process -ne 0) { + return 1 + } + + ## check localized npm command availability + $___process = FS-Is-File "${___target}\npx" + if ($___process -ne 0) { + return 1 + } + + return 0 + } + + $___process = OS-Is-Command-Available "npm" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Is-Command-Available "npx" + if ($___process -ne 0) { + return 1 + } + + $___process = OS-Is-Command-Available "node" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 1 +} + + + + +function NODE-Is-Localized { + # execute + if ($(STRINGS-Is-Empty "${env:PROJECT_NODE_LOCALIZED}") -ne 0) { + return 0 + } + + + # report status + return 1 +} + + + + +function NODE-NPM-Check-Login { + # execute + if ($(STRINGS-Is-Empty "${env:PROJECT_NODE_NPM_REGISTRY}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:NPM_USERNAME}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:NPM_TOKEN}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_SCOPE}") -eq 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function NODE-NPM-Install-Dependencies-All { + # validate input + $___process = NODE-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "npm" "install" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function NODE-NPM-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 + $___process = FS-Is-Target-A-NPM "$1" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function NODE-NPM-Publish { + param( + [string]$___target + ) + + + # validate input + if ($(STRINGS-Is-Empty "$1") -eq 0) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + $___process = NODE-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___workspace = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\release-npm" + $___package = "${env:PROJECT_SKU}.tgz" + $___npmrc = ".npmrc" + + ## setup workspace + $null = FS-Remake-Directory "${___workspace}" + $___process = FS-Copy-File "${___target}" "${___workspace}\${___package}" + if ($___process -ne 0) { + return 1 + } + + $___current_path = Get-Location + $null = Set-Location "${___workspace}" + $___process = FS-Write-File "${___npmrc}" @" +registry=${env:PROJECT_NODE_NPM_REGISTRY} +scope=@${env:PROJECT_SCOPE} +email=$env:NPM_USERNAME +//${PROJECT_NODE_NPM_REGISTRY#*://}/:_authToken=${env:NPM_TOKEN} +"@ + if ($___process -ne 0) { + $null = FS-Remove-Silently "${___npmrc}" + return 1 + } + + $___process = FS-Is-File "${___npmrc}" + if ($___process -ne 0) { + return 1 + } + + ## publish + $___process = OS-Exec "npm" "publish `"${___package}`"" + $null = FS-Remove-Silently "${___npmrc}" + $null = Set-Location "${___current_path}" + $null = Remove-Variable ___current_path + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function NODE-NPM-Run { + param( + [string]$___name + ) + + + # validate input + $___process = NODE-Is-Available + if ($___process -ne 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${___name}") -eq 0) { + return 1 + } + + + # execute + $___process = OS-Exec "npm" "run `"${___name}`"" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function NODE-Setup { + # validate input + $___process = NODE-Is-Available + if ($___process -eq 0) { + return 0 + } + + + # execute + $___filepath = "" + switch ("${env:PROJECT_ARCH}") { + "amd64" { + $___filepath = "x64" + } "arm" { + $___filepath = "armv7l" + } "arm64" { + $___filepath = "arm64" + } "ppc64le" { + $___filepath = "ppc64le" + } "s390x" { + $___filepath = "s390x" + } default { + return 1 + }} + + switch ("${env:PROJECT_OS}") { + "aix" { + $___filepath = "aix-${___filepath}.tar.xz" + } "darwin" { + $___filepath = "darwin-${___filepath}.tar.xz" + } "windows" { + $___filepath = "win-${___filepath}.zip" + } "linux" { + $___filepath = "linux-${___filepath}.tar.xz" + } default { + return 1 + }} + + ## download engine + $___filepath = "node-${env:PROJECT_NODE_VERSION}-${___filepath}" + $___url = "https://nodejs.org/dist/${env:PROJECT_NODE_VERSION}/${___filepath}" + $___filepath = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}\${___filepath}" + + $null = FS-Make-Housing-Directory "${___filepath}" + $null = FS-Remove-Silently "${___filepath}" + $___process = HTTP-Download "GET" "${___url}" "${___filepath}" + if ($___process -ne 0) { + return 1 + } + + ## unpack engine + $___process = FS-Is-File "${___filepath}" + if ($___process -ne 0) { + return 1 + } + + $___location = "$(NODE-Get-Activator-Path)" + $___directory = "$(FS-Get-Directory "${___location}")" + $null = FS-Remove-Silently "${___directory}" + + $___target = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TOOLS}\" + $null = FS-Make-Directory "${___target}" + switch ("${env:PROJECT_OS}") { + "windows" { + $___process = ZIP-Extract "${___target}" "${___filepath}" + $null = FS-Remove-Silently "${___filepath}" + $___target = FS-Extension-Replace "${___filepath}" ".zip" "" + } default { + $___process = TAR-Extract-XZ "${___target}" "${___filepath}" + $null = FS-Remove-Silently "${___filepath}" + $___target = FS-Extension-Replace "${___filepath}" ".tar.xz" "" + }} + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Move "${___target}" "${___directory}" + if ($___process -ne 0) { + return 1 + } + + ## create activator script + $___label = "(${env:PROJECT_PATH_NODE_ENGINE})" + $___target = "${___directory}" + $null = FS-Write-File "${___location}" @" +`$___target = `"${___target}`" + + +function deactivate { + `$env:Path = (`$env:Path.Split(';') | Where-Object { `$_ -ne "`${___target}" }) -join ';' + + `${env:PROJECT_NODE_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_NODE_LOCALIZED})) { + return +} + + +# activate +`$env:Path = `$env:Path + ";" + "`${___target}" + +`${env:PROJECT_NODE_LOCALIZED} = "${___location}" +`$null = 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 + } + + ## test activator script + $___process = NODE-Activate-Local-Environment + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/node.sh b/automataCI/services/compilers/node.sh new file mode 100644 index 0000000..b645f1e --- /dev/null +++ b/automataCI/services/compilers/node.sh @@ -0,0 +1,458 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/os.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/io/net/http.sh" +. "${LIBS_AUTOMATACI}/services/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/archive/zip.sh" + + + + +NODE_Activate_Local_Environment() { + # validate input + NODE_Is_Localized + if [ $? -eq 0 ]; then + NODE_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + return 0 + fi + + + # execute + ___location="$(NODE_Get_Activator_Path)" + FS_Is_File "$___location" + if [ $? -ne 0 ]; then + return 1 + fi + + . "$___location" + NODE_Is_Localized + if [ $? -ne 0 ]; then + return 1 + fi + + NODE_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NODE_Get_Activator_Path() { + printf -- "${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/${PROJECT_PATH_NODE_ENGINE}/activate.sh" +} + + + + +NODE_Is_Available() { + # execute + if [ $(STRINGS_Is_Empty "$PROJECT_NODE_VERSION") -ne 0 ]; then + ## check existing localized engine + ___target="$(NODE_Get_Activator_Path)" + FS_Is_File "$___target" + if [ $? -ne 0 ]; then + return 1 + fi + ___target="$(FS_Get_Directory "$___target")" + + ## check localized node command availablity + FS_Is_File "${___target}/bin/node" + if [ $? -ne 0 ]; then + return 1 + fi + + ## check localized npm command availablity + FS_Is_File "${___target}/bin/npm" + if [ $? -ne 0 ]; then + return 1 + fi + + ## check localized npm command availablity + FS_Is_File "${___target}/bin/npx" + if [ $? -ne 0 ]; then + return 1 + fi + + return 0 + fi + + OS_Is_Command_Available "npm" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "npx" + if [ $? -ne 0 ]; then + return 1 + fi + + OS_Is_Command_Available "node" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 1 +} + + + + +NODE_Is_Localized() { + # execute + if [ $(STRINGS_Is_Empty "$PROJECT_NODE_LOCALIZED") -ne 0 ] ; then + return 0 + fi + + + # report status + return 1 +} + + + + +NODE_NPM_Check_Login() { + # execute + if [ $(STRINGS_Is_Empty "$PROJECT_NODE_NPM_REGISTRY") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$NPM_USERNAME") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$NPM_TOKEN") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$PROJECT_SCOPE") -eq 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NODE_NPM_Install_Dependencies_All() { + # validate input + NODE_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + npm install + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NODE_NPM_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 [ $(FS_Is_Target_A_NPM "$1") -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NODE_NPM_Publish() { + #___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 + + NODE_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___workspace="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/release-npm" + ___package="${PROJECT_SKU}.tgz" + ___npmrc=".npmrc" + + ## setup workspace + FS_Remake_Directory "$___workspace" + FS_Copy_File "$1" "${___workspace}/${___package}" + if [ $? -ne 0 ]; then + return 1 + fi + + ___current_path="$PWD" && cd "$___workspace" + FS_Write_File "$___npmrc" "\ +registry=${PROJECT_NODE_NPM_REGISTRY} +scope=@${PROJECT_SCOPE} +email=${NPM_USERNAME} +//${PROJECT_NODE_NPM_REGISTRY#*://}/:_authToken=${NPM_TOKEN} +" + if [ $? -ne 0 ]; then + FS_Remove_Silently "$___npmrc" + return 1 + fi + + FS_Is_File "$___npmrc" + if [ $? -ne 0 ]; then + return 1 + fi + + ## publish + npm publish "$___package" + ___process=$? + FS_Remove_Silently "$___npmrc" + cd "$___current_path" && unset ___current_path + if [ $___process -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NODE_NPM_Run() { + #___name="$1" + + + # validate input + NODE_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + + # execute + npm run "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +NODE_Setup() { + # validate input + NODE_Is_Available + if [ $? -eq 0 ]; then + return 0 + fi + + + # execute + ___filepath="" + case "$PROJECT_ARCH" in + amd64) + ___filepath="x64" + ;; + arm) + ___filepath="armv7l" + ;; + arm64) + ___filepath="arm64" + ;; + ppc64le) + ___filepath="ppc64le" + ;; + s390x) + ___filepath="s390x" + ;; + *) + return 1 + ;; + esac + + case "$PROJECT_OS" in + aix) + ___filepath="aix-${___filepath}.tar.xz" + ;; + darwin) + ___filepath="darwin-${___filepath}.tar.xz" + ;; + windows) + ___filepath="win-${___filepath}.zip" + ;; + linux) + ___filepath="linux-${___filepath}.tar.xz" + ;; + *) + return 1 + ;; + esac + + ## download engine + ___filepath="node-${PROJECT_NODE_VERSION}-${___filepath}" + ___url="https://nodejs.org/dist/${PROJECT_NODE_VERSION}/${___filepath}" + ___filepath="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/${___filepath}" + + FS_Make_Housing_Directory "$___filepath" + FS_Remove_Silently "$___filepath" + HTTP_Download "GET" "$___url" "$___filepath" + if [ $? -ne 0 ]; then + return 1 + fi + + ## unpack engine + FS_Is_File "$___filepath" + if [ $? -ne 0 ]; then + return 1 + fi + + ___location="$(NODE_Get_Activator_Path)" + FS_Remove_Silently "$(FS_Get_Directory "$___location")" + + ___target="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/" + FS_Make_Directory "$___target" + case "$PROJECT_OS" in + windows) + ZIP_Extract "$___target" "$___filepath" + ___process=$? + FS_Remove_Silently "$___filepath" + ___target="$(FS_Extension_Replace "$___filepath" ".zip" "")" + ;; + *) + TAR_Extract_XZ "$___target" "$___filepath" + ___process=$? + FS_Remove_Silently "$___filepath" + ___target="$(FS_Extension_Replace "$___filepath" ".tar.xz" "")" + ;; + esac + if [ $___process -ne 0 ]; then + return 1 + fi + + ___directory="$(FS_Get_Directory "$___location")" + FS_Move "$___target" "$___directory" + if [ $? -ne 0 ]; then + return 1 + fi + + + ## create activator script + ___label="($PROJECT_PATH_NODE_ENGINE)" + ___target="${___directory}/bin" + FS_Write_File "$___location" "\ +#!/bin/sh +___target=\"${___target}\" + + +deactivate() { + ___path=:\$PATH: + ___path=\${___path/:\$___target:/:} + ___path=\${___path%:} + ___path=\${___path#:} + PATH=\$___path + + export PS1=\"\${PS1##*${___label} }\" + unset PROJECT_NODE_LOCALIZED + return 0 +} + + + + +# check +if [ ! -z \"\$PROJECT_NODE_LOCALIZED\" ]; then + return 0 +fi + + + + +# activate +export PATH=\"\${___target}:\${PATH}\" + +export PROJECT_NODE_LOCALIZED='${___location}' +export PS1=\"${___label} \${PS1}\" +return 0 +" + FS_Is_File "$___location" + if [ $? -ne 0 ]; then + return 1 + fi + + ## test activator script + NODE_Activate_Local_Environment + 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..0df151c --- /dev/null +++ b/automataCI/services/compilers/rpm.ps1 @@ -0,0 +1,748 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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\disk.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\time.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\changelog.ps1" +. "${env:LIBS_AUTOMATACI}\services\checksum\md5.ps1" +. "${env:LIBS_AUTOMATACI}\services\checksum\shasum.ps1" + + + + +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]$___metalink, + [string]$___name, + [string]$___scope, + [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 "${___scope}") -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 + $___key = "usr\local\share\keyrings\${___sku}-keyring.gpg" + $___filename = "etc\yum.repos.d\${___sku}.repo" + + if ($(STRINGS-Is-Empty "${___metalink}") -ne 0) { + $___url = @" +#baseurl=${___url} # note: flat repository - base url is only for reference +metalink=${___metalink} + +"@ + } else { + $___url = @" +baseurl=${___url} + +"@ + +} + + $___process = FS-Is-File "${___directory}\BUILD\$(FS-Get-File "${___filename}")" + if ($___process -eq 0) { + return 10 + } + + $___process = FS-Is-File "${___directory}\BUILD\$(FS-Get-File "${___key}")" + if ($___process -eq 0) { + return 1 + } + + $null = FS-Make-Directory "${___directory}\BUILD" + $___process = FS-Write-File "${___directory}\BUILD\$(FS-Get-File "${___filename}")" @" +# WARNING: AUTO-GENERATED - DO NOT EDIT! +[${___scope}-${___sku}] +name=${___name} +${___url} +gpgcheck=1 +gpgkey=file:///${___key} + +"@ + if ($___process -ne 0) { + return 1 + } + + $___process = GPG-Export-Public-Keyring ` + "${___directory}\BUILD\$(FS-Get-File "${___key}")" ` + "${___gpg_id}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Append-File "${___directory}\SPEC_INSTALL" @" +install --directory %{buildroot}/$(FS-Get-Directory "${___filename}") +install -m 0644 $(FS-Get-File "${___filename}") %{buildroot}/$(FS-Get-Directory "${___filename}") + +install --directory %{buildroot}/$(FS-Get-Directory "${___key}") +install -m 0644 $(FS-Get-File "${___key}") %{buildroot}/$(FS-Get-Directory "${___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 -replace "#.*$")`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 -replace "#.*$")`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_FILES" + } 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-Flatten-Repo { + param( + [string]$___repo_directory, + [string]$___filename_repomdxml, + [string]$___filename_metalink, + [string]$___base_url + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___repo_directory}") -eq 0) -or + ($(STRINGS-Is-Empty "${___filename_repomdxml}") -eq 0) -or + ($(STRINGS-Is-Empty "${___filename_metalink}") -eq 0) -or + ($(STRINGS-Is-Empty "${___base_url}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___repo_directory}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Directory "${___repo_directory}\repodata" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-File "${___repo_directory}\repodata\repomd.xml" + if ($___process -ne 0) { + return 1 + } + + $___repomd = "${___repo_directory}\repomd.xml" + if ($(STRINGS-Is-Empty "${___filename_repomdxml}") -ne 0) { + $___repomd = "${___repo_directory}\${___filename_repomdxml}" + } + + $___metalink = "${___repo_directory}\METALINK_RPM" + if ($(STRINGS-Is-Empty "${___filename_metalink}") -ne 0) { + $___repomd = "${___repo_directory}\${___filename_metalink}" + } + + + # patch repomd.xml location fields and write to main directory + $null = FS-Remove-Silently "${___repomd}" + + foreach ($___line in (Get-Content -Path "${___repo_directory}/repodata/repomd.xml")) { + ## patch location fields + if ($($___line -replace "^\s* + + + + ${___time} + $(DISK-Calculate-Size-File-Byte "${___repomd}") + + $(MD5-Create-From-File "${___repomd}") + $(SHASUM-Create-From-File "${___repomd}" "1") + $(SHASUM-Create-From-File "${___repomd}" "256") + $(SHASUM-Create-From-File "${___repomd}" "512") + + + ${___url} + + + + + +"@ + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function RPM-Is-Available { + param( + [string]$___os, + [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 +} + + + + +function RPM-Register { + param( + [string]$___workspace, + [string]$___source, + [string]$___target, + [string]$___is_directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___workspace}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${___source}") -eq 0) { + return 1 + } + + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___workspace}" + if ($___process -ne 0) { + return 1 + } + + + # execute + ## write into SPEC_INSTALL + $___spec = "${___workspace}/SPEC_INSTALL" + if ($(STRINGS-Is-Empty "${___is_directory}") -ne 0) { + $___content = @" +mkdir -p %{buildroot}/${___target} +cp -r $(FS_Get_Directory "${___source}") %{buildroot}/${___target}/. + +"@ + } else { + $___content = @" +mkdir -p %{buildroot}/$(FS-Get-Directory "${___target}") +cp -r ${___source} %{buildroot}/${___target}/. + +"@ + } + + $___process = FS-Append-File "${___spec}" "${___content}" + if ($___process -ne 0) { + return 1 + } + + # write into SPEC_FILES + $___spec = "${___workspace}/SPEC_FILES" + $___content = "/${___content}" + if ($(STRINGS-Is-Empty "${___is_directory}") -ne 0) { + $___content = "${___content}/$(FS-Get-Directory "${___target}")" + } + $___content = "${___content}`n" + $___process = FS-Append-File "${___spec}" "${___content}" + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} diff --git a/automataCI/services/compilers/rpm.sh b/automataCI/services/compilers/rpm.sh new file mode 100644 index 0000000..28afbf9 --- /dev/null +++ b/automataCI/services/compilers/rpm.sh @@ -0,0 +1,752 @@ +#!/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/disk.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/io/time.sh" +. "${LIBS_AUTOMATACI}/services/compilers/changelog.sh" +. "${LIBS_AUTOMATACI}/services/checksum/md5.sh" +. "${LIBS_AUTOMATACI}/services/checksum/shasum.sh" + + + + +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" + ___metalink="$5" + ___name="$6" + ___scope="$7" + ___sku="$8" + + + # 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 "$___scope") -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 + ___key="usr/local/share/keyrings/${___sku}-keyring.gpg" + ___filename="etc/yum.repos.d/${___sku}.repo" + + if [ $(STRINGS_Is_Empty "$___metalink") -ne 0 ]; then + ___url="\ +#baseurl=${___url} # note: flat repository - only for reference +metalink=${___metalink} +" + else + ___url="\ +baseurl=${___url} +" + fi + + FS_Is_File "${___directory}/BUILD/$(FS_Get_File "$___filename")" + if [ $? -eq 0 ]; then + return 10 + fi + + FS_Is_File "${___directory}/BUILD/$(FS_Get_File "$___key")" + if [ $? -eq 0 ]; then + return 1 + fi + + FS_Make_Directory "${___directory}/BUILD" + FS_Write_File "${___directory}/BUILD/$(FS_Get_File "$___filename")" "\ +# WARNING: AUTO-GENERATED - DO NOT EDIT! +[${___scope}-${___sku}] +name=${___name} +${___url} +gpgcheck=1 +gpgkey=file:///${___key} +" + if [ $? -ne 0 ]; then + return 1 + fi + + GPG_Export_Public_Keyring "${___directory}/BUILD/$(FS_Get_File "$___key")" "$___gpg_id" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Append_File "${___directory}/SPEC_INSTALL" " +install --directory %{buildroot}/$(FS_Get_Directory "$___filename") +install -m 0644 $(FS_Get_File "$___filename") %{buildroot}/$(FS_Get_Directory "$___filename") + +install --directory %{buildroot}/$(FS_Get_Directory "$___key") +install -m 0644 $(FS_Get_File "$___key") %{buildroot}/$(FS_Get_Directory "$___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_Flatten_Repo() { + ___repo_directory="$1" + ___filename_repomdxml="$2" + ___filename_metalink="$3" + ___base_url="$4" + + + # validate input + if [ $(STRINGS_Is_Empty "$___repo_directory") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___filename_repomdxml") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___filename_metalink") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___base_url") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___repo_directory" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "${___repo_directory}/repodata" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_File "${___repo_directory}/repodata/repomd.xml" + if [ $? -ne 0 ]; then + return 1 + fi + + ___repomd="${___repo_directory}/repomd.xml" + if [ $(STRINGS_Is_Empty "$___filename_repomdxml") -ne 0 ]; then + ___repomd="${___repo_directory}/${___filename_repomdxml}" + fi + + ___metalink="${___repo_directory}/METALINK_RPM" + if [ $(STRINGS_Is_Empty "$___filename_metalink") -ne 0 ]; then + ___metalink="${___repo_directory}/${___filename_metalink}" + fi + + + # patch repomd.xml location fields and write to main directory + FS_Remove_Silently "$___repomd" + + ___old_IFS="$IFS" + while IFS= read -r ___line || [ -n "$___line" ]; do + ## patch location fields + if [ ! "${___line##* + + + + ${___time} + $(DISK_Calculate_Size_File_Byte "$___repomd") + + $(MD5_Create_From_File "$___repomd") + $(SHASUM_Create_From_File "$___repomd" "1") + $(SHASUM_Create_From_File "$___repomd" "256") + $(SHASUM_Create_From_File "$___repomd" "512") + + + ${___url} + + + + +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +RPM_Is_Available() { + ___os="$1" + ___arch="$2" + + + # 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 os + 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 +} + + + + +RPM_Register() { + #___workspace="$1" + #___source="$2" + #___target="$3" + #___is_directory="$4" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$2") -eq 0 ]; then + return 1 + fi + + if [ $(STRINGS_Is_Empty "$3") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + # write into SPEC_INSTALL + ___spec="${1}/SPEC_INSTALL" + if [ $(STRINGS_Is_Empty "$4") -ne 0 ]; then + ___content="\ +mkdir -p %{buildroot}/${3} +cp -r $(FS_Get_Directory "$2") %{buildroot}/${3}/. +" + else + ___content="\ +mkdir -p %{buildroot}/$(FS_Get_Directory "$3") +cp -r ${2} %{buildroot}/${3} +" + fi + + FS_Append_File "$___spec" "$___content" + if [ $? -ne 0 ]; then + return 1 + fi + + # write into SPEC_FILES + ___spec="${1}/SPEC_FILES" + ___content="/${3}" + if [ $(STRINGS_Is_Empty "$4") -ne 0 ]; then + ___content="${___content}/$(FS_Get_Directory "$2")" + fi + ___content="${___content}\n" + FS_Append_File "$___spec" "$___content" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} 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..a3210c5 --- /dev/null +++ b/automataCI/services/compilers/rust.ps1 @@ -0,0 +1,611 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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}`n" + 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..6739dd7 --- /dev/null +++ b/automataCI/services/crypto/gpg.ps1 @@ -0,0 +1,205 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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-Clear-Sign-File { + param ( + [string]$___output, + [string]$___target, + [string]$___id + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___output}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___id}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Target-Exist "${___output}" + if ($___process -eq 0) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + $___process = GPG-Is-Available "${___id}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "gpg" @" +--armor --clear-sign --local-user `"${___id}`" --output `"${___output}`" `"${___target}`" +"@ + if ($___process -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function GPG-Detach-Sign-File { + param ( + [string]$___output, + [string]$___target, + [string]$___id + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___output}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target}") -eq 0) -or + ($(STRINGS-Is-Empty "${___id}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Target-Exists "${___output}" + if ($___process -eq 0) { + return 1 + } + + $___process = FS-Is-File "${___target}" + if ($___process -ne 0) { + return 1 + } + + $___process = GPG-Is-Available "${___id}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $___process = OS-Exec "gpg" @" +--armor --detach-sign --local-user `"${___id}`" --output `"${___output}`" `"${___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 + } + + if ($(STRINGS-Is-Empty "${___id}") -eq 0) { + return 0 + } + + $___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..934ecd8 --- /dev/null +++ b/automataCI/services/crypto/gpg.sh @@ -0,0 +1,190 @@ +#!/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_Clear_Sign_File() { + #___output="$1" + #___target="$2" + #___id="$3" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || + [ $(STRINGS_Is_Empty "$2") -eq 0 ] || + [ $(STRINGS_Is_Empty "$3") -eq 0 ]; then + return 1 + fi + + FS_Is_Target_Exist "$1" + if [ $? -eq 0 ]; then + return 1 + fi + + FS_Is_File "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + GPG_Is_Available "$3" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + gpg --armor --clear-sign --local-user "$3" --output "$1" "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + + # report status + return 0 +} + + + + +GPG_Detach_Sign_File() { + #___output="$1" + #___target="$2" + #___id="$3" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || + [ $(STRINGS_Is_Empty "$2") -eq 0 ] || + [ $(STRINGS_Is_Empty "$3") -eq 0 ]; then + return 1 + fi + + FS_Is_Target_Exist "$1" + if [ $? -eq 0 ]; then + return 1 + fi + + FS_Is_File "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + GPG_Is_Available "$3" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + gpg --armor --detach-sign --local-user "$3" --output "$1" "$2" + 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 + + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 0 + 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/hestiaI18N/Get_Languages_List.sh.ps1 b/automataCI/services/hestiaI18N/Get_Languages_List.sh.ps1 new file mode 100755 index 0000000..6f4a16b --- /dev/null +++ b/automataCI/services/hestiaI18N/Get_Languages_List.sh.ps1 @@ -0,0 +1,65 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Get-Languages-List { + return @" +en +zh-hans + +"@ +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Get_Languages_List() { + printf -- "%s" "\ +en +zh-hans +" +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Translate-All-Components-Description.sh.ps1 b/automataCI/services/hestiaI18N/Translate-All-Components-Description.sh.ps1 new file mode 100755 index 0000000..47f41d2 --- /dev/null +++ b/automataCI/services/hestiaI18N/Translate-All-Components-Description.sh.ps1 @@ -0,0 +1,92 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Translate-All-Components-Description() { + param( + [string]$___locale + ) + + + # execute + switch ("${___locale}") { + "zh-hans" { + # 简体中文 + return "包装里的所有元件。" + } default { + # fallback to default english + return "All components in this package." + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Translate_All_Components_Description() { + #___locale="$1" + + + # execute + case "$1" in + zh-hans) + # 简体中文 + printf -- "%b" "包装里的所有元件。" + ;; + *) + # fallback to default english + printf -- "%b" "All components in this package." + ;; + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Translate-All-Components-Title.sh.ps1 b/automataCI/services/hestiaI18N/Translate-All-Components-Title.sh.ps1 new file mode 100755 index 0000000..6f5a520 --- /dev/null +++ b/automataCI/services/hestiaI18N/Translate-All-Components-Title.sh.ps1 @@ -0,0 +1,92 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Translate-All-Components-Title() { + param( + [string]$___locale + ) + + + # execute + switch ("${___locale}") { + "zh-hans" { + # 简体中文 + return "所有元件" + } default { + # fallback to default english + return "All Components" + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Translate_All_Components_Title() { + #___locale="$1" + + + # execute + case "$1" in + zh-hans) + # 简体中文 + printf -- "%b" "所有元件" + ;; + *) + # fallback to default english + printf -- "%b" "All Components" + ;; + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Translate-Already-Latest-Version.sh.ps1 b/automataCI/services/hestiaI18N/Translate-Already-Latest-Version.sh.ps1 new file mode 100755 index 0000000..a69b790 --- /dev/null +++ b/automataCI/services/hestiaI18N/Translate-Already-Latest-Version.sh.ps1 @@ -0,0 +1,91 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Translate-Already-Latest-Version() { + param( + [string]$___locale + ) + + + # execute + switch ("${___locale}") { + "zh-hans" { + # 简体中文 + return "您已经有同样或是最新的版本了。那就不需要任何另外加工吧。" + } default { + # fallback to default english + return "You have the same/latest version. No further action is required." + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Translate_Already_Latest_Version() { + #___locale="$1" + + + # execute + case "$1" in + zh-hans) + # 简体中文 + printf -- "%b" "您已经有同样或是最新的版本了。那就不需要任何另外加工吧。" + ;; + *) + # fallback to default english + printf -- "%b" "You have the same/latest version. No further action is required." + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Translate-Bin-Components-Description.sh.ps1 b/automataCI/services/hestiaI18N/Translate-Bin-Components-Description.sh.ps1 new file mode 100755 index 0000000..d170f5f --- /dev/null +++ b/automataCI/services/hestiaI18N/Translate-Bin-Components-Description.sh.ps1 @@ -0,0 +1,92 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Translate-Bin-Components-Description() { + param( + [string]$___locale + ) + + + # execute + switch ("${___locale}") { + "zh-hans" { + # 简体中文 + return "所有可启动的软件产品。" + } default { + # fallback to default english + return "All executable software products." + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Translate_Bin_Components_Description() { + #___locale="$1" + + + # execute + case "$1" in + zh-hans) + # 简体中文 + printf -- "%b" "所有可启动的软件产品。" + ;; + *) + # fallback to default english + printf -- "%b" "All executable software products." + ;; + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Translate-Bin-Components-Title.sh.ps1 b/automataCI/services/hestiaI18N/Translate-Bin-Components-Title.sh.ps1 new file mode 100755 index 0000000..cc9bac9 --- /dev/null +++ b/automataCI/services/hestiaI18N/Translate-Bin-Components-Title.sh.ps1 @@ -0,0 +1,92 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Translate-Bin-Components-Title() { + param( + [string]$___locale + ) + + + # execute + switch ("${___locale}") { + "zh-hans" { + # 简体中文 + return "软件元件" + } default { + # fallback to default english + return "Executables Components" + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Translate_Bin_Components_Title() { + #___locale="$1" + + + # execute + case "$1" in + zh-hans) + # 简体中文 + printf -- "%b" "软件元件" + ;; + *) + # fallback to default english + printf -- "%b" "Executables Components" + ;; + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Translate-Config-Components-Description.sh.ps1 b/automataCI/services/hestiaI18N/Translate-Config-Components-Description.sh.ps1 new file mode 100755 index 0000000..2820d6a --- /dev/null +++ b/automataCI/services/hestiaI18N/Translate-Config-Components-Description.sh.ps1 @@ -0,0 +1,92 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Translate-Config-Components-Description() { + param( + [string]$___locale + ) + + + # execute + switch ("${___locale}") { + "zh-hans" { + # 简体中文 + return "所有设定的文件。" + } default { + # fallback to default english + return "All configuration files." + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Translate_Config_Components_Description() { + #___locale="$1" + + + # execute + case "$1" in + zh-hans) + # 简体中文 + printf -- "%b" "所有设定的文件。" + ;; + *) + # fallback to default english + printf -- "%b" "All configuration files." + ;; + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Translate-Config-Components-Title.sh.ps1 b/automataCI/services/hestiaI18N/Translate-Config-Components-Title.sh.ps1 new file mode 100755 index 0000000..ce0214c --- /dev/null +++ b/automataCI/services/hestiaI18N/Translate-Config-Components-Title.sh.ps1 @@ -0,0 +1,92 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Translate-Config-Components-Title() { + param( + [string]$___locale + ) + + + # execute + switch ("${___locale}") { + "zh-hans" { + # 简体中文 + return "设定元件" + } default { + # fallback to default english + return "Configurations Components" + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Translate_Config_Components_Title() { + #___locale="$1" + + + # execute + case "$1" in + zh-hans) + # 简体中文 + printf -- "%b" "设定元件" + ;; + *) + # fallback to default english + printf -- "%b" "Configurations Components" + ;; + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Translate-Docs-Components-Description.sh.ps1 b/automataCI/services/hestiaI18N/Translate-Docs-Components-Description.sh.ps1 new file mode 100755 index 0000000..cfdd493 --- /dev/null +++ b/automataCI/services/hestiaI18N/Translate-Docs-Components-Description.sh.ps1 @@ -0,0 +1,92 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Translate-Docs-Components-Description() { + param( + [string]$___locale + ) + + + # execute + switch ("${___locale}") { + "zh-hans" { + # 简体中文 + return "所有笔记书写文稿。" + } default { + # fallback to default english + return "All articles and documentations." + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Translate_Docs_Components_Description() { + #___locale="$1" + + + # execute + case "$1" in + zh-hans) + # 简体中文 + printf -- "%b" "所有笔记书写文稿。" + ;; + *) + # fallback to default english + printf -- "%b" "All articles and documentations." + ;; + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Translate-Docs-Components-Title.sh.ps1 b/automataCI/services/hestiaI18N/Translate-Docs-Components-Title.sh.ps1 new file mode 100755 index 0000000..f6133dd --- /dev/null +++ b/automataCI/services/hestiaI18N/Translate-Docs-Components-Title.sh.ps1 @@ -0,0 +1,92 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Translate-Docs-Components-Title() { + param( + [string]$___locale + ) + + + # execute + switch ("${___locale}") { + "zh-hans" { + # 简体中文 + return "书写笔记元件" + } default { + # fallback to default english + return "Documentations Components" + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Translate_Docs_Components_Title() { + #___locale="$1" + + + # execute + case "$1" in + zh-hans) + # 简体中文 + printf -- "%b" "书写笔记元件" + ;; + *) + # fallback to default english + printf -- "%b" "Documentations Components" + ;; + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Translate-Lib-Components-Description.sh.ps1 b/automataCI/services/hestiaI18N/Translate-Lib-Components-Description.sh.ps1 new file mode 100755 index 0000000..8f480f3 --- /dev/null +++ b/automataCI/services/hestiaI18N/Translate-Lib-Components-Description.sh.ps1 @@ -0,0 +1,92 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Translate-Lib-Components-Description() { + param( + [string]$___locale + ) + + + # execute + switch ("${___locale}") { + "zh-hans" { + # 简体中文 + return "所有可开发的码库类产品。" + } default { + # fallback to default english + return "All importable libraries products." + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Translate_Lib_Components_Description() { + #___locale="$1" + + + # execute + case "$1" in + zh-hans) + # 简体中文 + printf -- "%b" "所有可开发的码库类产品。" + ;; + *) + # fallback to default english + printf -- "%b" "All importable libraries products." + ;; + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Translate-Lib-Components-Title.sh.ps1 b/automataCI/services/hestiaI18N/Translate-Lib-Components-Title.sh.ps1 new file mode 100755 index 0000000..b438df2 --- /dev/null +++ b/automataCI/services/hestiaI18N/Translate-Lib-Components-Title.sh.ps1 @@ -0,0 +1,92 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Translate-Lib-Components-Title() { + param( + [string]$___locale + ) + + + # execute + switch ("${___locale}") { + "zh-hans" { + # 简体中文 + return "代码库类型元件" + } default { + # fallback to default english + return "Libraries Components" + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Translate_Lib_Components_Title() { + #___locale="$1" + + + # execute + case "$1" in + zh-hans) + # 简体中文 + printf -- "%b" "代码库类型元件" + ;; + *) + # fallback to default english + printf -- "%b" "Libraries Components" + ;; + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Translate-Main-Components-Description.sh.ps1 b/automataCI/services/hestiaI18N/Translate-Main-Components-Description.sh.ps1 new file mode 100755 index 0000000..644af0c --- /dev/null +++ b/automataCI/services/hestiaI18N/Translate-Main-Components-Description.sh.ps1 @@ -0,0 +1,92 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Translate-Main-Components-Description() { + param( + [string]$___locale + ) + + + # execute + switch ("${___locale}") { + "zh-hans" { + # 简体中文 + return "所有第一重要无法缺乏的产品。" + } default { + # fallback to default english + return "All critical and core products." + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Translate_Main_Components_Description() { + #___locale="$1" + + + # execute + case "$1" in + zh-hans) + # 简体中文 + printf -- "%b" "所有第一重要无法缺乏的产品。" + ;; + *) + # fallback to default english + printf -- "%b" "All critical and core products." + ;; + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Translate-Main-Components-Title.sh.ps1 b/automataCI/services/hestiaI18N/Translate-Main-Components-Title.sh.ps1 new file mode 100755 index 0000000..5eabc9d --- /dev/null +++ b/automataCI/services/hestiaI18N/Translate-Main-Components-Title.sh.ps1 @@ -0,0 +1,92 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Translate-Main-Components-Title() { + param( + [string]$___locale + ) + + + # execute + switch ("${___locale}") { + "zh-hans" { + # 简体中文 + return "主要元件" + } default { + # fallback to default english + return "Main Components" + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Translate_Main_Components_Title() { + #___locale="$1" + + + # execute + case "$1" in + zh-hans) + # 简体中文 + printf -- "%b" "主要元件" + ;; + *) + # fallback to default english + printf -- "%b" "Main Components" + ;; + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Translate-Only-Install-On-Windows.sh.ps1 b/automataCI/services/hestiaI18N/Translate-Only-Install-On-Windows.sh.ps1 new file mode 100755 index 0000000..198b5d0 --- /dev/null +++ b/automataCI/services/hestiaI18N/Translate-Only-Install-On-Windows.sh.ps1 @@ -0,0 +1,209 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +function hestiaI18N-Translate-Only-Install-On-Windows() { + param( + [string]$___locale, + [string]$___arch + ) + + + # execute + switch (${___locale}) { + "zh-hans" { + # 简体中文 + switch ("${___arch}") { + "32" { + return @" +真遗憾。您只能在32位微软Windows操作系统里安装。 +"@ + } "64" { + return @" +真遗憾。您只能在64位微软Windows操作系统里安装。 +"@ + } "amd64" { + return @" +真遗憾。您只能在amd64型芯片的微软Windows操作系统里安装。 +"@ + } "arm64" { + return @" +真遗憾。您只能在arm64型芯片的微软Windows操作系统里安装。 +"@ + } "i386" { + return @" +真遗憾。您只能在i386型芯片的微软Windows操作系统里安装。 +"@ + } "arm" { + return @" +真遗憾。您只能在arm型芯片的微软Windows操作系统里安装。 +"@ + } default { + return @" +真遗憾。您只能在微软Windows操作系统里安装。 +"@ + }} + } default { + # fallback to default english + switch ("${___arch}") { + "32" { + return @" +Unfortunately, you can only install this in a 32-bits Microsoft Windows operating system. +"@ + } "64" { + return @" +Unfortunately, you can only install this in a 64-bits Microsoft Windows operating system. +"@ + } "amd64" { + return @" +Unfortunately, you can only install this in an amd64 Microsoft Windows operating system. +"@ + } "arm64" { + return @" +Unfortunately, you can only install this in an arm64 Microsoft Windows operating system. +"@ + } "i386" { + return @" +Unfortunately, you can only install this in an i386 Microsoft Windows operating system. +"@ + } "arm" { + return @" +Unfortunately, you can only install this in an arm Microsoft Windows operating system. +"@ + } default { + return @" +Unfortunately, you can only install this in a Microsoft Windows operating system. +"@ + }} + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +hestiaI18N_Translate_Only_Install_On_Windows() { + #___locale="$1" + #___arch="$2" + + + # execute + case "$1" in + zh-hans) + # 简体中文 + case "$2" in + 32) + printf -- "%b" "\ +真遗憾。您只能在32位微软Windows操作系统里安装。" + ;; + 64) + printf -- "%b" "\ +真遗憾。您只能在64位微软Windows操作系统里安装。" + ;; + amd64) + printf -- "%b" "\ +真遗憾。您只能在amd64型芯片的微软Windows操作系统里安装。" + ;; + arm64) + printf -- "%b" "\ +真遗憾。您只能在arm64型芯片的微软Windows操作系统里安装。" + ;; + i386) + printf -- "%b" "\ +真遗憾。您只能在i386型芯片的微软Windows操作系统里安装。" + ;; + arm) + printf -- "%b" "\ +真遗憾。您只能在arm型芯片的微软Windows操作系统里安装。" + ;; + *) + printf -- "%b" "\ +真遗憾。您只能在微软Windows操作系统里安装。" + ;; + esac + ;; + *) + # fallback to default english + case "$2" in + 32) + printf -- "%b" "\ +Unfortunately, you can only install this in a 32-bits Microsoft Windows operating system." + ;; + 64) + printf -- "%b" "\ +Unfortunately, you can only install this in a 64-bits Microsoft Windows operating system." + ;; + amd64) + printf -- "%b" "\ +Unfortunately, you can only install this in an amd64 Microsoft Windows operating system." + ;; + arm64) + printf -- "%b" "\ +Unfortunately, you can only install this in an arm64 Microsoft Windows operating system." + ;; + i386) + printf -- "%b" "\ +Unfortunately, you can only install this in an i386 Microsoft Windows operating system." + ;; + arm) + printf -- "%b" "\ +Unfortunately, you can only install this in an arm Microsoft Windows operating system." + ;; + *) + printf -- "%b" "\ +Unfortunately, you can only install this in a Microsoft Windows operating system." + ;; + esac + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaI18N/Vanilla.sh.ps1 b/automataCI/services/hestiaI18N/Vanilla.sh.ps1 new file mode 100755 index 0000000..2dc2478 --- /dev/null +++ b/automataCI/services/hestiaI18N/Vanilla.sh.ps1 @@ -0,0 +1,82 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +. "${env:LIBS_HESTIA}\hestiaI18N\Get_Languages_List.sh.ps1" +. "${env:LIBS_HESTIA}\hestiaI18N\Translate-Already-Latest-Version.sh.ps1" +. "${env:LIBS_HESTIA}\hestiaI18N\Translate-All-Components-Description.sh.ps1" +. "${env:LIBS_HESTIA}\hestiaI18N\Translate-All-Components-Title.sh.ps1" +. "${env:LIBS_HESTIA}\hestiaI18N\Translate-Bin-Components-Description.sh.ps1" +. "${env:LIBS_HESTIA}\hestiaI18N\Translate-Bin-Components-Title.sh.ps1" +. "${env:LIBS_HESTIA}\hestiaI18N\Translate-Docs-Components-Description.sh.ps1" +. "${env:LIBS_HESTIA}\hestiaI18N\Translate-Docs-Components-Title.sh.ps1" +. "${env:LIBS_HESTIA}\hestiaI18N\Translate-Config-Components-Description.sh.ps1" +. "${env:LIBS_HESTIA}\hestiaI18N\Translate-Config-Components-Title.sh.ps1" +. "${env:LIBS_HESTIA}\hestiaI18N\Translate-Lib-Components-Description.sh.ps1" +. "${env:LIBS_HESTIA}\hestiaI18N\Translate-Lib-Components-Title.sh.ps1" +. "${env:LIBS_HESTIA}\hestiaI18N\Translate-Main-Components-Description.sh.ps1" +. "${env:LIBS_HESTIA}\hestiaI18N\Translate-Main-Components-Title.sh.ps1" +. "${env:LIBS_HESTIA}\hestiaI18N\Translate-Only-Install-On-Windows.sh.ps1" +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +. "${LIBS_HESTIA}/hestiaI18N/Get_Languages_List.sh.ps1" +. "${LIBS_HESTIA}/hestiaI18N/Translate-Already-Latest-Version.sh.ps1" +. "${LIBS_HESTIA}/hestiaI18N/Translate-All-Components-Description.sh.ps1" +. "${LIBS_HESTIA}/hestiaI18N/Translate-All-Components-Title.sh.ps1" +. "${LIBS_HESTIA}/hestiaI18N/Translate-Bin-Components-Description.sh.ps1" +. "${LIBS_HESTIA}/hestiaI18N/Translate-Bin-Components-Title.sh.ps1" +. "${LIBS_HESTIA}/hestiaI18N/Translate-Docs-Components-Description.sh.ps1" +. "${LIBS_HESTIA}/hestiaI18N/Translate-Docs-Components-Title.sh.ps1" +. "${LIBS_HESTIA}/hestiaI18N/Translate-Config-Components-Description.sh.ps1" +. "${LIBS_HESTIA}/hestiaI18N/Translate-Config-Components-Title.sh.ps1" +. "${LIBS_HESTIA}/hestiaI18N/Translate-Lib-Components-Description.sh.ps1" +. "${LIBS_HESTIA}/hestiaI18N/Translate-Lib-Components-Title.sh.ps1" +. "${LIBS_HESTIA}/hestiaI18N/Translate-Main-Components-Description.sh.ps1" +. "${LIBS_HESTIA}/hestiaI18N/Translate-Main-Components-Title.sh.ps1" +. "${LIBS_HESTIA}/hestiaI18N/Translate-Only-Install-On-Windows.sh.ps1" +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaLOCALE/Get-LCID.sh.ps1 b/automataCI/services/hestiaLOCALE/Get-LCID.sh.ps1 new file mode 100755 index 0000000..72d2291 --- /dev/null +++ b/automataCI/services/hestiaLOCALE/Get-LCID.sh.ps1 @@ -0,0 +1,113 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +## More Info: +## https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f +function hestiaLOCALE-Get-LCID { + param( + [string]$___locale + ) + + + # execute + switch ("${___locale}") { + "en" { + return 9 + } { $_ -in "en-US", "en-us" } { + return 1033 + } "zh" { + return 30724 + } { $_ -in "zh-CN", "zh-cn" } { + return 2052 + } { $_ -in "zh-Hans", "zh-hans" } { + return 4 + } default { + return + }} + + + # report status + return 0 +} +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +## More Info: +## https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f +hestiaLOCALE_Get_LCID() { + #___locale="$1" + + + # execute + case "$1" in + en) + printf -- "9" + ;; + en-US|en-us) + printf -- "1033" + ;; + zh) + printf -- "30724" + ;; + zh-CN|zh-cn) + printf -- "2052" + ;; + zh-Hans|zh-hans) + printf -- "4" + ;; + *) + printf -- "" + return 1 + ;; + esac + + + # report status + return 0 +} +################################################################################ +# Unix Main Codes # +################################################################################ +return 0 +#> diff --git a/automataCI/services/hestiaLOCALE/Vanilla.sh.ps1 b/automataCI/services/hestiaLOCALE/Vanilla.sh.ps1 new file mode 100755 index 0000000..eda087c --- /dev/null +++ b/automataCI/services/hestiaLOCALE/Vanilla.sh.ps1 @@ -0,0 +1,54 @@ +echo \" <<'RUN_AS_BATCH' >/dev/null ">NUL "\" \`" <#" +@ECHO OFF +REM LICENSE CLAUSES HERE +REM ---------------------------------------------------------------------------- + + + + +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +where /q powershell +if errorlevel 1 ( + echo "ERROR: missing powershell facility." + exit /b 1 +) + +copy /Y "%~nx0" "%~n0.ps1" >nul +timeout /t 1 /nobreak >nul +powershell -executionpolicy remotesigned -Command "& '.\%~n0.ps1' %*" +start /b "" cmd /c del "%~f0" & exit /b %errorcode% +REM ############################################################################ +REM # Windows BATCH Codes # +REM ############################################################################ +RUN_AS_BATCH +#> | Out-Null + + + + +echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +. "${env:LIBS_HESTIA}\hestiaLOCALE\Get-LCID.sh.ps1" +################################################################################ +# Windows POWERSHELL Codes # +################################################################################ +return +<# +RUN_AS_POWERSHELL + + + + +################################################################################ +# Unix Main Codes # +################################################################################ +. "${LIBS_HESTIA}/hestiaLOCALE/Get-LCID.sh.ps1" +################################################################################ +# Unix Main Codes # +################################################################################ +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-available-skipped.ps1 b/automataCI/services/i18n/_check-available-skipped.ps1 new file mode 100644 index 0000000..84eb740 --- /dev/null +++ b/automataCI/services/i18n/_check-available-skipped.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-Check-Available-Skipped { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning "It's available. Skipping...`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-available-skipped.sh b/automataCI/services/i18n/_check-available-skipped.sh new file mode 100644 index 0000000..0f5d528 --- /dev/null +++ b/automataCI/services/i18n/_check-available-skipped.sh @@ -0,0 +1,29 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${LIBS_AUTOMATACI}/services/i18n/__printer.sh" + + + + +I18N_Check_Available_Skipped() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "It's available. Skipping...\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-disabled-skipped.ps1 b/automataCI/services/i18n/_check-disabled-skipped.ps1 new file mode 100644 index 0000000..0b43c55 --- /dev/null +++ b/automataCI/services/i18n/_check-disabled-skipped.ps1 @@ -0,0 +1,29 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\i18n\__printer.ps1" + + + + +function I18N-Check-Disabled-Skipped { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning ` + "explicit disabled action detected. Skipping...`n`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_check-disabled-skipped.sh b/automataCI/services/i18n/_check-disabled-skipped.sh new file mode 100644 index 0000000..7cfd441 --- /dev/null +++ b/automataCI/services/i18n/_check-disabled-skipped.sh @@ -0,0 +1,29 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${LIBS_AUTOMATACI}/services/i18n/__printer.sh" + + + + +I18N_Check_Disabled_Skipped() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "explicit disabled action detected. Skipping...\n\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_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/_conclude.ps1 b/automataCI/services/i18n/_conclude.ps1 new file mode 100644 index 0000000..157f5dd --- /dev/null +++ b/automataCI/services/i18n/_conclude.ps1 @@ -0,0 +1,35 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\i18n\__printer.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\__param.ps1" + + + + +function I18N-Conclude { + param( + [string]$___subject + ) + + + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $___subject = I18N-Param-Process "${___subject}" + $null = I18N-Status-Print info "concluding '${___subject}'...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_conclude.sh b/automataCI/services/i18n/_conclude.sh new file mode 100644 index 0000000..f3f8416 --- /dev/null +++ b/automataCI/services/i18n/_conclude.sh @@ -0,0 +1,31 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${LIBS_AUTOMATACI}/services/i18n/__printer.sh" +. "${LIBS_AUTOMATACI}/services/i18n/__param.sh" + + + + +I18N_Conclude() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + ___subject="$(I18N_Param_Process "$1")" + I18N_Status_Print info "concluding '${___subject}'...\n" + ;; + esac + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_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-exists-skipped.ps1 b/automataCI/services/i18n/_copy-exists-skipped.ps1 new file mode 100644 index 0000000..6192a0d --- /dev/null +++ b/automataCI/services/i18n/_copy-exists-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-Copy-Exists-Skipped { + # execute + switch (${env:AUTOMATACI_LANG}) { + default { + # fallback to default english + $null = I18N-Status-Print warning "target exists. Skip copying...`n" + }} + + + # report status + return 0 +} diff --git a/automataCI/services/i18n/_copy-exists-skipped.sh b/automataCI/services/i18n/_copy-exists-skipped.sh new file mode 100644 index 0000000..37e66fe --- /dev/null +++ b/automataCI/services/i18n/_copy-exists-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_Copy_Exists_Skipped() { + # execute + case "$AUTOMATACI_LANG" in + *) + # fallback to default english + I18N_Status_Print warning "target exists. Skip copying...\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..2f65ba4 --- /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-Conclude { + 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..65ebf27 --- /dev/null +++ b/automataCI/services/i18n/translations.ps1 @@ -0,0 +1,125 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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-available-skipped.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_check-disabled-skipped.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_check-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_check-failed-skipped.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_check-function.ps1" +. "${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\_commit.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_commit-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_conclude.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_configure-build-settings.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_configure-failed.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_copy.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\_copy-exists-skipped.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..5761889 --- /dev/null +++ b/automataCI/services/i18n/translations.sh @@ -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. +. "${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-available-skipped.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_check-disabled-skipped.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_check-failed.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_check-failed-skipped.sh" +. "${LIBS_AUTOMATACI}/services/i18n/_check-function.sh" +. "${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/_conclude.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-exists-skipped.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..9aa2a39 --- /dev/null +++ b/automataCI/services/io/disk.ps1 @@ -0,0 +1,71 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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-Directory-KB { + param ( + [string]$___directory + ) + + + # validate input + if ([string]::IsNullOrEmpty($___directory) -or + (-not (Test-Path -Path "${___directory}"))) { + return 1 + } + + $___process = DISK-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___value = Get-ChildItem "${___directory}" -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-Calculate-Size-File-Byte { + param ( + [string]$___file + ) + + + # validate input + if ([string]::IsNullOrEmpty($___file) -or (-not (Test-Path -Path "${___file}"))) { + return 1 + } + + $___process = DISK-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___value = Get-ChildItem $___file ` + | Measure-Object -Property length -Sum ` + | Select-Object sum + return [math]::Round($___value.sum / 1, 0) +} + + + + +function DISK-Is-Available { + return 0 +} diff --git a/automataCI/services/io/disk.sh b/automataCI/services/io/disk.sh new file mode 100644 index 0000000..bc2cc55 --- /dev/null +++ b/automataCI/services/io/disk.sh @@ -0,0 +1,83 @@ +#!/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_Directory_KB() { + #___directory="$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_Calculate_Size_File_Byte() { + #___file="$1" + + + # validate input + if [ -z "$1" ] || [ -d "$1" ]; then + return 1 + fi + + DISK_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___size="$(du -b "$1")" + if [ $? -ne 0 ]; then + return 1 + fi + printf -- "%b" "${___size%%[!0-9]*}" + + + # report status + return 0 +} + + + + +DISK_Is_Available() { + # execute + if [ ! -z "$(type -t du)" ]; then + 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..af92f28 --- /dev/null +++ b/automataCI/services/io/fs.ps1 @@ -0,0 +1,1148 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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 -NoNewline + 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 + } + + $___process = FS-Is-Directory "${___source}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Directory "${___destination}" + if ($___process -ne 0) { + return 1 + } + + + # execute + $null = Copy-Item -Path "${___source}\*" -Destination "${___destination}" -Recurse + 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 + } + + $___process = FS-Is-File "${___source}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Is-Target-Exist "${___destination}" + if ($___process -eq 0) { + return 1 + } + + + # execute + $null = Copy-Item -Path "${___source}" -Destination "${___destination}" + 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]$___path, + [string]$___extension, + [string]$___candidate + ) + + + # validate input + if ([string]::IsNullOrEmpty($___path)) { + return "" + } + + + # execute + ## prepare working parameters + $___target = Split-Path -Leaf "${___path}" + + if ($___extension -eq "*") { + ## trim all extensions to the first period + $___target = $___target -replace '(\.\w+)+$' + + ## restore directory pathing when available + if (-not [string]::IsNullOrEmpty($(Split-Path -Parent "${___path}"))) { + $___target = $(Split-Path -Parent "${___path}") + "\" + "${___target}" + } + } elseif (-not [string]::IsNullOrEmpty($___extension)) { + ## trim off existing extension + if ($___extension.Substring(0,1) -eq ".") { + $___extension = $___extension.Substring(1) + } + $___target = $___target -replace "\.${___extension}$" + + ## append new extension when available + if ($___target -ne $___path) { + if (-not [string]::IsNullOrEmpty($___candidate)) { + if ($___candidate.Substring(0,1) -eq ".") { + $___target += "." + $___candidate.Substring(1) + } else { + $___target += "." + $___candidate + } + } + } + + ## restore directory pathing when available + if (-not [string]::IsNullOrEmpty($(Split-Path -Parent "${___path}"))) { + $___target = $(Split-Path -Parent "${___path}") + "\" + "${___target}" + } + } else { + ## do nothing + $___target = $___path + } + + + # 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-Directory-Empty { + param ( + [string]$___target + ) + + + # validate input + $___process = FS-Is-Directory "${___target}" + if ($___process -ne 0) { + return 0 + } + + + # execute + if((Get-ChildItem "${___target}" -force ` + | Select-Object -First 1 ` + | Measure-Object).Count -ne 0) { + return 1 + } + + + # report status + return 0 +} + + + + +function FS-Is-File { + param ( + [string]$___target + ) + + + # 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-C { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + if ($(FS-Is-Target-A-Cargo "${___target}") -eq 0) { + return 1 + } + + if ($(FS-Is-Target-A-Chocolatey "${___target}") -eq 0) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*-C.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-c.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*\.c$', '') -ne "${___file_subject}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Cargo { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*-cargo.*', '') -ne "${___file_subject}") { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Chocolatey { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*-chocolatey.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-choco.*', '') -ne "${___file_subject}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Citation-CFF { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*\.cff$', '') -ne "${___file_subject}") { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Docs { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*-doc.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-docs.*', '') -ne "${___file_subject}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Homebrew { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*-homebrew.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-brew.*', '') -ne "${___file_subject}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Library { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '^lib.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*\.a$', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*\.dll$', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-lib.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-libs.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-library.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-libraries.*', '') -ne "${___file_subject}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-MSI { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*\.msi$', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-msi.*', '') -ne "${___file_subject}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-NPM { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*_js-js\.tgz$', '') -ne "${___file_subject}") { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Nupkg { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*\.nupkg$', '') -ne "${___file_subject}") { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-PDF { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*\.pdf$', '') -ne "${___file_subject}") { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-PYPI { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*-pypi.*', '') -ne "${___file_subject}") { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-Source { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*-src.*', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*-source.*', '') -ne "${___file_subject}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-TARGZ { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*\.tar\.gz$', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*\.tgz$', '') -ne "${___file_subject}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-TARXZ { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if (($("${___file_subject}" -replace '.*\.tar\.xz$', '') -ne "${___file_subject}") -or + ($("${___file_subject}" -replace '.*\.txz$', '') -ne "${___file_subject}")) { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-WASM { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*-wasm.*', '') -ne "${___file_subject}") { + return 0 + } + + + # report status + return 1 +} + + + + +function FS-Is-Target-A-WASM-JS { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + if ($(FS-Is-Target-A-WASM "${___target}") -ne 0) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '.*\.js$', '') -eq "${___file_subject}") { + return 1 + } + + + # report status + return 0 +} + + + + +function FS-Is-Target-A-ZIP { + param ( + [string]$___target + ) + + + # execute + if ([string]::IsNullOrEmpty("${___target}")) { + return 1 + } + + $___file_subject = FS-Get-File "${___target}" + if ($("${___file_subject}" -replace '^.*\.zip$', '') -ne "${___file_subject}") { + return 0 + } + + + # report status + return 1 +} + + + + +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 + } + + $___process = FS-Is-Target-Exist $___source + if ($___process -ne 0) { + 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 -NoNewline + 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..aaaf22f --- /dev/null +++ b/automataCI/services/io/fs.sh @@ -0,0 +1,1113 @@ +#!/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 + + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Directory "$2" + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + cp -r "${1}"* "${2}/." + 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 + + FS_Is_File "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Target_Exist "$2" + if [ $? -eq 0 ]; then + return 1 + fi + + + # execute + cp "$1" "$2" + 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() { + #___path="$1" + #___extension="$2" + #___candidate="$3" + + + # validate input + if [ -z "$1" ]; then + printf -- "" + return 0 + fi + + + # execute + ## prepare working parameters + ___target="${1##*/}" + + if [ "$2" = "*" ]; then + ## trim all extensions to the first period + ___target="${___target%%.*}" + + ## restore directory pathing when available + if [ ! -z "${1%/*}" ] && [ ! "${1%/*}" = "$1" ]; then + ___target="${1%/*}/${___target}" + fi + elif [ ! -z "$2" ]; then + ## trim off existing extension + if [ "$(printf -- "%.1s" "$2")" = "." ]; then + ___extension="${2#*.}" + else + ___extension="$2" + fi + ___target="${___target%.${___extension}*}" + + ## append new extension when available + if [ ! "${___target}" = "${1##*/}" ]; then + if [ ! -z "$3" ]; then + if [ "$(printf -- "%.1s" "$3")" = "." ]; then + ___target="${___target}.${3#*.}" + else + ___target="${___target}.${3}" + fi + fi + fi + + ## restore directory pathing when available + if [ ! -z "${1%/*}" ] && [ ! "${1%/*}" = "$1" ]; then + ___target="${1%/*}/${___target}" + fi + else + ## do nothing + ___target="$1" + fi + + + # report status + printf -- "%s" "$___target" + 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_Directory_Empty() { + #___target="$1" + + + # validate input + FS_Is_Directory "$1" + if [ $? -ne 0 ]; then + return 0 + fi + + + # execute + for ___item in "$1"/*; do + if [ -e "$___item" ]; then + return 1 + fi + done + + + # report status + return 0 +} + + + + +FS_Is_File() { + #___target="$1" + + + # 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_C() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + if [ $(FS_Is_Target_A_Cargo "$1") -eq 0 ]; then + return 1 + fi + + if [ $(FS_Is_Target_A_Chocolatey "$1") -eq 0 ]; then + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-C}" != "$___file_subject" ] || + [ "${___file_subject#*-c}" != "$___file_subject" ] || + [ "${___file_subject#*.c}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Cargo() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-cargo}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Chocolatey() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-chocolatey}" != "$___file_subject" ] || + [ "${___file_subject#*-choco}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Citation_CFF() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*.cff}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Docs() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-doc}" != "$___file_subject" ] || + [ "${___file_subject#*-docs}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Homebrew() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-homebrew}" != "$___file_subject" ] || + [ "${___file_subject#*-brew}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Library() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#lib*}" != "$___file_subject" ] || + [ "${___file_subject#*.a}" != "$___file_subject" ] || + [ "${___file_subject#*.dll}" != "$___file_subject" ] || + [ "${___file_subject#*-lib}" != "$___file_subject" ] || + [ "${___file_subject#*-libs}" != "$___file_subject" ] || + [ "${___file_subject#*-library}" != "$___file_subject" ] || + [ "${___file_subject#*-libraries}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_MSI() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-msi}" != "$___file_subject" ] || + [ "${___file_subject#*.msi}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_NPM() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*_js-js.tgz}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Nupkg() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*.nupkg}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_PDF() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*.pdf}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_PYPI() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-pypi}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_Source() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-src}" != "$___file_subject" ] || + [ "${___file_subject#*-source}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_TARGZ() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*.tar.gz}" != "$___file_subject" ] || + [ "${___file_subject#*.tgz}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_TARXZ() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*.tar.xz}" != "$___file_subject" ] || + [ "${___file_subject#*.txz}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_WASM() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*-wasm}" != "$___file_subject" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +FS_Is_Target_A_WASM_JS() { + #___subject="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + if [ $(FS_Is_Target_A_WASM "$1") -ne 0 ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*.js}" == "$___file_subject" ]; then + printf -- "1" + return 1 + fi + + + # report status + printf -- "0" + return 0 +} + + + + +FS_Is_Target_A_ZIP() { + #___target="$1" + + + # execute + if [ "$1" = "" ]; then + printf -- "1" + return 1 + fi + + ___file_subject="$(FS_Get_File "$1")" + if [ "${___file_subject#*.zip}" != "${___file_subject}" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +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 + + FS_Is_Target_Exist "$1" + if [ $? -ne 0 ]; 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" + + + # validate input + if [ -z "$1" ] || [ -z "$2" ]; then + return 1 + fi + + FS_Is_Target_Exist "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + FS_Is_Target_Exist "$2" + if [ $? -eq 0 ]; then + return 1 + fi + + + # execute + FS_Move "$1" "$2" + return $? +} + + + + +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..9d40732 --- /dev/null +++ b/automataCI/services/io/net/http.ps1 @@ -0,0 +1,197 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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) { + $null = curl --location ` + --header $___user_agent ` + --header $___auth_header ` + --output $___filepath ` + --request $___method ` + $___url + if ($LASTEXITCODE -ne 0) { + $null = Remove-Item $___filepath ` + -Force ` + -Recurse ` + -ErrorAction SilentlyContinue + return 1 + } + } elseif (Get-Command wget -ErrorAction SilentlyContinue) { + $null = wget --max-redirect 16 ` + --header $___user_agent ` + --header=$___auth_header ` + --output-file=$___filepath ` + --method=$___method ` + $___url + if ($LASTEXITCODE -ne 0) { + $null = Remove-Item $___filepath ` + -Force ` + -Recurse ` + -ErrorAction SilentlyContinue + return 1 + } + } else { + $null = Remove-Item $___filepath ` + -Force ` + -Recurse ` + -ErrorAction SilentlyContinue + return 1 + } + } else { + if (Get-Command curl -ErrorAction SilentlyContinue) { + $null = curl --location ` + --header $___user_agent ` + --output $___filepath ` + --request $___method ` + $___url + if ($LASTEXITCODE -ne 0) { + $null = Remove-Item $___filepath ` + -Force ` + -Recurse ` + -ErrorAction SilentlyContinue + return 1 + } + } elseif (Get-Command wget -ErrorAction SilentlyContinue) { + $null = wget --max-redirect 16 ` + --header $___user_agent ` + --output-file=$___filepath ` + --method=$___method ` + $___url + if ($LASTEXITCODE -ne 0) { + $null = Remove-Item $___filepath ` + -Force ` + -Recurse ` + -ErrorAction SilentlyContinue + return 1 + } + } else { + $null = Remove-Item $___filepath ` + -Force ` + -Recurse ` + -ErrorAction SilentlyContinue + 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..8953209 --- /dev/null +++ b/automataCI/services/io/net/http.sh @@ -0,0 +1,166 @@ +#!/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" + if [ $? -ne 0 ]; then + rm -rf "$___filepath" &> /dev/null + return 1 + fi + elif [ ! -z "$(type -t wget)" ]; then + wget --max-redirect 16 \ + --header "$___user_agent" \ + --header="$___auth_header" \ + --output-file"$___filepath" \ + --method="$___method" \ + "$___url" + if [ $? -ne 0 ]; then + rm -rf "$___filepath" &> /dev/null + return 1 + fi + else + rm -rf "$___filepath" &> /dev/null + return 1 + fi + else + if [ ! -z "$(type -t curl)" ]; then + curl --location \ + --header "$___user_agent" \ + --output "$___filepath" \ + --request "$___method" \ + "$___url" + if [ $? -ne 0 ]; then + rm -rf "$___filepath" &> /dev/null + return 1 + fi + elif [ ! -z "$(type -t wget)" ]; then + wget --max-redirect 16 \ + --header "$___user_agent" \ + --output-file"$___filepath" \ + --method="$___method" \ + "$___url" + if [ $? -ne 0 ]; then + rm -rf "$___filepath" &> /dev/null + return 1 + fi + else + rm -rf "$___filepath" &> /dev/null + 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..45ea61e --- /dev/null +++ b/automataCI/services/io/os.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. +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_RUN}"))) { + return 0 + } + + + # report status + return 1 +} + + + + +function OS-Remove-Path { + param( + [string]$___path + ) + + + # validate input + if ([string]::IsNullOrEmpty("${___path}")) { + return 1 + } + + + # execute + $env:Path = ($env:Path.Split(';') | Where-Object { $_ -ne "${___path}" }) -join ';' + + + # report status + return 0 +} + + + + +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..cd9572f --- /dev/null +++ b/automataCI/services/io/os.sh @@ -0,0 +1,182 @@ +#!/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_RUN" ]; then + printf -- "0" + return 0 + fi + + + # report status + printf -- "1" + return 1 +} + + + + +OS_Remove_Path() { + #___path="$1" + + + # validate input + if [ -z "$1" ]; then + return 1 + fi + + + # execute + ___paths=:$PATH: + ___paths=${___paths/:$1:/:} + ___paths=${___paths%:} + ___paths=${___paths#:} + PATH=$___paths + + + # report status + return 0 +} + + + + +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..5eedd9b --- /dev/null +++ b/automataCI/services/io/time.ps1 @@ -0,0 +1,81 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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-Date-ISO8601 { + 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-Format-Datetime-RFC5322 { + param( + [string]$___epoch + ) + + + # validate input + if ([string]::IsNullOrEmpty($___epoch)) { + return 1 + } + + + # execute + $___t = (Get-Date "1970-01-01 00:00:00.000Z") + ([TimeSpan]::FromSeconds($___epoch)) + return $___t.ToString("ddd, dd MMM YYYY HH:mm:ss zzz") +} + + + + +function TIME-Format-Datetime-RFC5322-UTC { + param( + [string]$___epoch + ) + + + # validate input + if ([string]::IsNullOrEmpty($___epoch)) { + return 1 + } + + + # execute + $___t = (Get-Date "1970-01-01 00:00:00.000Z") + ([TimeSpan]::FromSeconds($___epoch)) + return $___t.ToUniversalTime().ToString("ddd, dd MMM YYYY HH:mm:ss zzz") +} + + + + +function TIME-Is-Available { + return 0 +} + + + + +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..dc2cbbd --- /dev/null +++ b/automataCI/services/io/time.sh @@ -0,0 +1,134 @@ +#!/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_Date_ISO8601() { + #___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_Format_Datetime_RFC5322() { + #___epoch="$1" + + + # validate input + if [ -z "$1" ]; then + printf -- "" + return 1 + fi + + TIME_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + if [ "$(echo "$(uname)" | tr '[:upper:]' '[:lower:]')" = "darwin" ]; then + printf -- "%b" "$(date -j -f "%s" "${1}" +"%a, %d %b %Y %H:%M:%S %z")" + else + printf -- "%b" "$(date --date="@${1}" +"%a, %d %b %Y %H:%M:%S %z")" + fi + + + # report status + return 0 +} + + + + +TIME_Format_Datetime_RFC5322_UTC() { + #___epoch="$1" + + + # validate input + if [ -z "$1" ]; then + printf -- "" + return 1 + fi + + TIME_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + if [ "$(echo "$(uname)" | tr '[:upper:]' '[:lower:]')" = "darwin" ]; then + printf -- "%b" "$(date -u -j -f "%s" "${1}" +"%a, %d %b %Y %H:%M:%S %z")" + else + printf -- "%b" "$(date -u --date="@${1}" +"%a, %d %b %Y %H:%M:%S %z")" + fi + + + # report status + return 0 +} + + + + +TIME_Is_Available() { + # execute + if [ -z "$(type -t date)" ]; then + 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..1e1fe7a --- /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..f21a2f4 --- /dev/null +++ b/automataCI/services/publishers/createrepo.ps1 @@ -0,0 +1,76 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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]$___directory + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { + return 1 + } + + $___process = FS-Is-Directory "${___target}" + if ($___process -eq 0) { + return 1 + } + + + # execute + $___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..b7cdb84 --- /dev/null +++ b/automataCI/services/publishers/createrepo.sh @@ -0,0 +1,77 @@ +#!/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() { + #___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 + OS_Is_Command_Available "createrepo" + if [ $? -eq 0 ]; then + createrepo --update "$1" + if [ $? -ne 0 ]; then + return 1 + fi + + return 0 + fi + + OS_Is_Command_Available "createrepo_c" + if [ $? -eq 0 ]; then + createrepo_c --update "$1" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + + # report status + return 0 +} 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..0ef1f0f --- /dev/null +++ b/automataCI/services/publishers/homebrew.ps1 @@ -0,0 +1,273 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\checksum\shasum.ps1" + + + + +function HOMEBREW-Is-Valid-Formula { + param ( + [string]$___target + ) + + + # validate input + if ($(STRINGS-Is-Empty "${___target}") -eq 0) { + return 1 + } + + if ($___target -like "*.asc") { + return 1 + } + + + # execute + if ($___target -like "*.rb") { + return 1 + } + + + # report status + return 1 +} + + + + +function HOMEBREW-Seal { + param ( + [string]$___formula, + [string]$___archive_name, + [string]$___workspace, + [string]$___sku, + [string]$___description, + [string]$___website, + [string]$___license, + [string]$___base_url + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___formula}") -eq 0) -or + ($(STRINGS-Is-Empty "${___archive_name}") -eq 0) -or + ($(STRINGS-Is-Empty "${___workspace}") -eq 0) -or + ($(STRINGS-Is-Empty "${___sku}") -eq 0) -or + ($(STRINGS-Is-Empty "${___description}") -eq 0) -or + ($(STRINGS-Is-Empty "${___website}") -eq 0) -or + ($(STRINGS-Is-Empty "${___license}") -eq 0) -or + ($(STRINGS-Is-Empty "${___base_url}") -eq 0)) { + return 1 + } + + $___process = FS-Is-Directory "${___workspace}" + if ($___process -ne 0) { + return 1 + } + + $___export_directory = "$(FS-Get-Directory "${___formula}")" + if ($___export_directory -eq $___formula) { + return 1 + } + $null = FS-Make-Directory "${___export_directory}" + + + # execute + ## generate the init script + $___dest = "${___workspace}/init.sh" + $___process = FS-Write-File "${___dest}" @" +#!/bin/sh +OS_Get_Arch() { + ___output="`$(uname -m)" + ___output="`$(printf -- "%b" "`$___output" | tr '[:upper:]' '[:lower:]')" + case "`$___output" in + i686-64) + export ___output='ia64' # Intel Itanium. + ;; + i386|i486|i586|i686) + export ___output='i386' + ;; + x86_64) + export ___output='amd64' + ;; + sun4u) + export ___output='sparc' + ;; + 'power macintosh') + export ___output='powerpc' + ;; + ip*) + export ___output='mips' + ;; + *) + ;; + esac + + + # report status + printf -- "%b" "`$___output" + return 0 +} + + +OS_Get() { + # execute + ___output="`$(uname)" + ___output="`$(printf -- "%b" "`${___output}" | tr '[:upper:]' '[:lower:]')" + case "`$___output" in + windows*|ms-dos*) + ___output='windows' + ;; + cygwin*|mingw*|mingw32*|msys*) + ___output='windows' + ;; + *freebsd) + ___output='freebsd' + ;; + dragonfly*) + ___output='dragonfly' + ;; + *) + ;; + esac + + + # report status + printf -- "%b" "`$___output" + return 0 +} + + +main() { + host_os="`$(OS_Get)" + host_arch="`$(OS_Get_Arch)" + for ___file in './bin/'*; do + if [ ! -e "`$___file" ]; then + continue + fi + + ___system="`${___file##*/}" + ___system="`${___system%%.*}" + ___system="`${___system##*_}" + ___os="`${___system%%-*}" + ___arch="`${___system##*-}" + + case "`$___os" in + any|"`$host_os") + ;; + *) + rm -f "`$___file" &> /dev/null + continue + ;; + esac + + case "`$___arch" in + any|"`$host_arch") + mv "`$___file" "`${___file%%_*}" + ;; + *) + rm -f "`$___file" &> /dev/null + ;; + esac + done + + return 0 +} +main `$* +return `$? + +"@ + if ($___process -ne 0) { + return 1 + } + + ## seal the workspace + $___current_path = Get-Location + $null = Set-Location -Path "${___workspace}" + $___process = TAR-Create-XZ "${___export_directory}\${___archive_name}" "." + $null = Set-Location -Path "${___current_path}" + $null = Remove-Variable -Name ___current_path + if ($___process -ne 0) { + return 1 + } + + ## create the formula + $___shasum = SHASUM-Create-From-File "${___export_directory}/${___archive_name}" "256" + if ($(STRINGS-Is-Empty "${___shasum}") -eq 0) { + return 1 + } + + $null = FS-Make-Housing-Directory "${___formula}" + $___process = FS-Write-File "${___formula}" @" +class $(STRINGS-To-Titlecase "${___sku}") < Formula + desc '${___description}' + homepage '${___website}' + license '${___license}' + url '${___base_url}/${___archive_name}' + sha256 '${___shasum}' + + def install + if File.file?('init.sh.ps1') + chmod 755, './init.sh.ps1' + system './init.sh.ps1' + else + chmod 755, './init.sh' + system './init.sh' + end + + if File.directory?('bin') + Dir.foreach('bin') do |filename| + next if filename == '.' or filename == '..' + chmod 0755, filename + libexec.install 'bin/' + filename + bin.install_symlink 'libexec/bin/' + filename => filename + end + end + + if File.directory?('lib') + Dir.foreach('lib') do |filename| + next if filename == '.' or filename == '..' + chmod 0544, filename + libexec.install 'lib/' + filename + lib.install_symlink 'libexec/lib/' + filename => filename + end + end + end + + test do + if File.file?('init.sh.ps1') + assert_predicate 'init.sh.ps1', :exist? + else + assert_predicate 'init.sh', :exist? + end + end +end + +"@ + if ($___process -ne 0) { + return 1 + } + + + # 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..f2c9bba --- /dev/null +++ b/automataCI/services/publishers/homebrew.sh @@ -0,0 +1,319 @@ +#!/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/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/checksum/shasum.sh" + + + + +HOMEBREW_Is_Valid_Formula() { + #___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 [ ! "${1%.rb*}" = "$1" ]; then + return 0 + fi + + + # report status + return 1 +} + + + + +HOMEBREW_Seal() { + ___formula="$1" + ___archive_name="$2" + ___workspace="$3" + ___sku="$4" + ___description="$5" + ___website="$6" + ___license="$7" + ___base_url="$8" + + + # validate input + if [ $(STRINGS_Is_Empty "$___formula") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___archive_name") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___workspace") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___sku") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___description") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___website") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___license") -eq 0 ] || + [ $(STRINGS_Is_Empty "$___base_url") -eq 0 ]; then + return 1 + fi + + FS_Is_Directory "$___workspace" + if [ $? -ne 0 ]; then + return 1 + fi + + ___export_directory="$(FS_Get_Directory "$___formula")" + if [ "$___export_directory" = "$___formula" ]; then + return 1 + fi + FS_Make_Directory "$___export_directory" + + + # execute + ## generate the init script + ___dest="${___workspace}/init.sh" + FS_Write_File "$___dest" "\ +#!/bin/sh +OS_Get_Arch() { + ___output=\"\$(uname -m)\" + ___output=\"\$(printf -- \"%b\" \"\$___output\" | tr '[:upper:]' '[:lower:]')\" + case \"\$___output\" in + i686-64) + export ___output='ia64' # Intel Itanium. + ;; + i386|i486|i586|i686) + export ___output='i386' + ;; + x86_64) + export ___output='amd64' + ;; + sun4u) + export ___output='sparc' + ;; + 'power macintosh') + export ___output='powerpc' + ;; + ip*) + export ___output='mips' + ;; + *) + ;; + esac + + + # report status + printf -- \"%b\" \"\$___output\" + return 0 +} + + +OS_Get() { + # execute + ___output=\"\$(uname)\" + ___output=\"\$(printf -- \"%b\" \"\${___output}\" | tr '[:upper:]' '[:lower:]')\" + case \"\$___output\" in + windows*|ms-dos*) + ___output='windows' + ;; + cygwin*|mingw*|mingw32*|msys*) + ___output='windows' + ;; + *freebsd) + ___output='freebsd' + ;; + dragonfly*) + ___output='dragonfly' + ;; + *) + ;; + esac + + + # report status + printf -- \"%b\" \"\$___output\" + return 0 +} + + +main() { + host_os=\"\$(OS_Get)\" + host_arch=\"\$(OS_Get_Arch)\" + for ___file in './bin/'*; do + if [ ! -e \"\$___file\" ]; then + continue + fi + + ___system=\"\${___file##*/}\" + ___system=\"\${___system%%.*}\" + ___system=\"\${___system##*_}\" + ___os=\"\${___system%%-*}\" + ___arch=\"\${___system##*-}\" + + case \"\$___os\" in + any|\"\$host_os\") + ;; + *) + rm -f \"\$___file\" &> /dev/null + continue + ;; + esac + + case \"\$___arch\" in + any|\"\$host_arch\") + mv \"\$___file\" \"\${___file%%_*}\" + ;; + *) + rm -f \"\$___file\" &> /dev/null + ;; + esac + done + + return 0 +} +main \$* +return \$? +" + if [ $? -ne 0 ]; then + return 1 + fi + + ## seal the workspace + ___current_path="$PWD" && cd "$___workspace" + TAR_Create_XZ "${___export_directory}/${___archive_name}" "." + ___process=$? + cd "$___current_path" && unset ___current_path + if [ $___process -ne 0 ]; then + return 1 + fi + + ## create the formula + ___shasum="$(SHASUM_Create_From_File "${___export_directory}/${___archive_name}" "256")" + if [ $(STRINGS_Is_Empty "$___shasum") -eq 0 ]; then + return 1 + fi + + FS_Make_Housing_Directory "$___formula" + FS_Write_File "$___formula" "\ +class $(STRINGS_To_Titlecase "$___sku") < Formula + desc '${___description}' + homepage '${___website}' + license '${___license}' + url '${___base_url}/${___archive_name}' + sha256 '${___shasum}' + + def install + if File.file?('init.sh.ps1') + chmod 755, './init.sh.ps1' + system './init.sh.ps1' + else + chmod 755, './init.sh' + system './init.sh' + end + + if File.directory?('bin') + Dir.foreach('bin') do |filename| + next if filename == '.' or filename == '..' + chmod 0755, filename + libexec.install 'bin/' + filename + bin.install_symlink 'libexec/bin/' + filename => filename + end + end + + if File.directory?('lib') + Dir.foreach('lib') do |filename| + next if filename == '.' or filename == '..' + chmod 0544, filename + libexec.install 'lib/' + filename + lib.install_symlink 'libexec/lib/' + filename => filename + end + end + end + + test do + if File.file?('init.sh.ps1') + assert_predicate 'init.sh.ps1', :exist? + else + assert_predicate 'init.sh', :exist? + end + end +end +" + if [ $? -ne 0 ]; then + return 1 + fi + + + # 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..e5bbdfe --- /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..3fb4ace --- /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/publishers/unix.ps1 b/automataCI/services/publishers/unix.ps1 new file mode 100644 index 0000000..961c590 --- /dev/null +++ b/automataCI/services/publishers/unix.ps1 @@ -0,0 +1,51 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" + + + + +function UNIX-Get-Arch { + param( + [string]$___arch + ) + + + # execute + switch ($___arch) { + "any" { + return "all" + } { $_ -in "386", "i386", "486", "i486", "586", "i586", "686", "i686" } { + return "i386" + } "armle" { + return "armel" + } "mipsle" { + return "mipsel" + } "mipsr6le" { + return "mips64r6el" + } "mipsn32le" { + return "mipsn32el" + } "mipsn32r6le" { + return "mipsn32r6el" + } "mips64le" { + return "mips64el" + } "mipsn64r6le" { + return "mipsn64r6el" + } "powerpcle" { + return "powerpcel" + } "ppc64le" { + return "ppc64el" + } default { + return $___arch + }} +} diff --git a/automataCI/services/publishers/unix.sh b/automataCI/services/publishers/unix.sh new file mode 100644 index 0000000..a6b0e60 --- /dev/null +++ b/automataCI/services/publishers/unix.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +UNIX_Get_Arch() { + # execute + case "$1" in + any) + ___value="all" + ;; + 386|i386|486|i486|586|i586|686|i686) + ___value="i386" + ;; + armle) + ___value="armel" + ;; + mipsle) + ___value="mipsel" + ;; + mipsr6le) + ___value="mipsr6el" + ;; + mipsn32le) + ___value="mipsn32el" + ;; + mipsn32r6le) + ___value="mipsn32r6el" + ;; + mips64le) + ___value="mips64el" + ;; + mips64r6le) + ___value="mips64r6el" + ;; + powerpcle) + ___value="powerpcel" + ;; + ppc64le) + ___value="ppc64el" + ;; + *) + ___value="$1" + ;; + esac + printf -- "%s" "$___value" + + + # report status + return 0 +} diff --git a/automataCI/services/versioners/git.ps1 b/automataCI/services/versioners/git.ps1 new file mode 100644 index 0000000..2b0b7bc --- /dev/null +++ b/automataCI/services/versioners/git.ps1 @@ -0,0 +1,647 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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-Push-Specific { + param( + [string]$___workspace, + [string]$___remote, + [string]$___source, + [string]$___target + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___workspace}") -eq 0) -or + ($(STRINGS-Is-Empty "${___remote}") -eq 0) -or + ($(STRINGS-Is-Empty "${___source}") -eq 0) -or + ($(STRINGS-Is-Empty "${___target}") -eq 0)) { + return 1 + } + + $___process = GIT-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___current_path = Get-Location + $null = Set-Location -Path "${___workspace}" + $___process = OS-Exec "git" "push -f `"${___remote}`" `"${___source}`":`"${___target}`"" + $null = Set-Location -Path "${___current_path}" + $null = Remove-Variable -Name ___current_path + 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 +} + + + + +function GIT-Setup-Workspace-Bare { + param( + [string]$___remote, + [string]$___branch, + [string]$___destination + ) + + + # validate input + if (($(STRINGS-Is-Empty "${___remote}") -eq 0) -or + ($(STRINGS-Is-Empty "${___branch}") -eq 0) -or + ($(STRINGS-Is-Empty "${___destination}") -eq 0)) { + return 1 + } + + $___process = GIT-Is-Available + if ($___process -ne 0) { + return 1 + } + + + # execute + $___url = "$(GIT-Get-Remote-URL "${___remote}")" + if ($(STRINGS-Is-Empty "${___url}") -eq 0) { + return 1 + } + + $null = FS-Remake-Directory "${___destination}" + $___current_path = Get-Location + $null = Set-Location -Path "${___workspace}" + + $___process = OS-Exec "git" "init" + if ($___process -ne 0) { + $null = Set-Location -Path "${___current_path}" + $null = Remove-Variable -Name ___current_path + return 1 + } + + $___process = OS-Exec "git" "remote add `"${___remote}`" `"${___url}`"" + if ($___process -ne 0) { + $null = Set-Location -Path "${___current_path}" + $null = Remove-Variable -Name ___current_path + return 1 + } + + $___process = OS-Exec "git" "checkout --orphan `"${___branch}`"" + if ($___process -ne 0) { + $null = Set-Location -Path "${___current_path}" + $null = Remove-Variable -Name ___current_path + return 1 + } + + $null = Set-Location -Path "${___current_path}" + $null = Remove-Variable -Name ___current_path + + + # report status + return 0 +} diff --git a/automataCI/services/versioners/git.sh b/automataCI/services/versioners/git.sh new file mode 100644 index 0000000..ccc031c --- /dev/null +++ b/automataCI/services/versioners/git.sh @@ -0,0 +1,654 @@ +#!/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_Remote_URL() { + #___remote="$1" + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + return 1 + fi + + + # execute + printf -- "%s" "$(git remote get-url "$1")" + if [ $? -ne 0 ]; then + return 1 + fi + + + # 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_Push_Specific() { + #___workspace="$1" + #___remote="$2" + #___source="$3" + #___target="$4" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || + [ $(STRINGS_Is_Empty "$2") -eq 0 ] || + [ $(STRINGS_Is_Empty "$3") -eq 0 ] || + [ $(STRINGS_Is_Empty "$4") -eq 0 ]; then + return 1 + fi + + GIT_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___current_path="$PWD" && cd "$1" + git push -f "$2" "$3":"$4" + ___process=$? + cd "$___current_path" && unset ___current_path + 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 +} + + + + +GIT_Setup_Workspace_Bare() { + #___remote="$1" + #___branch="$2" + #___destination="$3" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ] || + [ $(STRINGS_Is_Empty "$2") -eq 0 ] || + [ $(STRINGS_Is_Empty "$3") -eq 0 ]; then + return 1 + fi + + GIT_Is_Available + if [ $? -ne 0 ]; then + return 1 + fi + + + # execute + ___url="$(GIT_Get_Remote_URL "$1")" + if [ $(STRINGS_Is_Empty "$___url") -eq 0 ]; then + return 1 + fi + + FS_Remake_Directory "$3" + ___current_path="$PWD" && cd "$3" + git init &> /dev/null + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + git remote add "$1" "$___url" + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + git checkout --orphan "$2" + if [ $? -ne 0 ]; then + cd "$___current_path" && unset ___current_path + return 1 + fi + + cd "$___current_path" && unset ___current_path + + + # report status + return 0 +} diff --git a/src/.ci/_package-archive_unix-any.sh b/src/.ci/_package-archive_unix-any.sh new file mode 100644 index 0000000..066772c --- /dev/null +++ b/src/.ci/_package-archive_unix-any.sh @@ -0,0 +1,144 @@ +#!/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}" + __dest="${_directory}/docs" + + FS_Is_Directory "$__source" + if [ $? -ne 0 ]; then + return 10 # not applicable + fi + + I18N_Assemble "$__source" "$__dest" + FS_Make_Directory "$__dest" + FS_Copy_All "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_Library "$_target") -eq 0 ]; then + return 10 # handled by lib packager + elif [ $(FS_Is_Target_A_WASM_JS "$_target") -eq 0 ]; then + return 10 # handled by wasm instead + elif [ $(FS_Is_Target_A_WASM "$_target") -eq 0 ]; then + __dest="${_directory}/assets/$(FS_Get_File "$_target")" + + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + __source="$(FS_Extension_Remove "$_target" ".wasm").js" + FS_Is_File "$__source" + if [ $? -eq 0 ]; then + __dest="${__dest}/$(FS_Get_File "$__source")" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + 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 + __dest="${_directory}/bin/${PROJECT_SKU}" + if [ "$_target_os" = "windows" ]; then + __dest="${__dest}.exe" + fi + + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + fi + + + # copy user guide + for __source in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/USER-GUIDES"*.pdf; do + FS_Is_Target_Exist "$__source" + if [ $? -ne 0 ]; then + continue + fi + + __dest="${_directory}/$(FS_Get_File "$__source")" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + done + + + # copy license file + for __source in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/licenses/LICENSE"*.pdf; do + FS_Is_Target_Exist "$__source" + if [ $? -ne 0 ]; then + continue + fi + + __dest="${_directory}/$(FS_Get_File "$__source")" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + done + + + # report status + 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..0d28260 --- /dev/null +++ b/src/.ci/_package-archive_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. + + + + +# 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}" + $__dest = "${_directory}\docs" + + $___process = FS-Is-Directory "${__source}" + if ($___process -ne 0) { + return 10 # not applicable + } + + $null = I18N-Assemble "${__source}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = FS-Copy-All "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { + return 10 # handled by lib packager + } elseif ($(FS-Is-Target-A-WASM-JS "${_target}") -eq 0) { + return 10 # handled by wasm instead + } elseif ($(FS-Is-Target-A-WASM "${_target}") -eq 0) { + $__dest = "${_directory}\assets\$(FS-Get-File "${_target}")" + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $__source = "$(FS-Extension-Remove "${_target}" ".wasm").js" + $___process = FS-Is-File "${__source}" + if ($___process -eq 0) { + $__dest = "${__dest}\$(FS-Get-File "${__source}")" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + } 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 { + $__dest = "${_directory}\bin\${env:PROJECT_SKU}" + if ($_target_os -eq "windows") { + $__dest = "${__dest}.exe" + } + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # copy user guide + Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs" ` + | Where-Object { ($_.Name -like "USER-GUIDES*.pdf") } ` + | ForEach-Object { $__source = $_.FullName + $__dest = "${_directory}\$(FS-Get-File "${__source}")" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # copy license file + Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses" ` + | Where-Object { ($_.Name -like "LICENSE*.pdf") } ` + | ForEach-Object { $__source = $_.FullName + $__dest = "${_directory}\$(FS-Get-File "${__source}")" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # 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..c8523df --- /dev/null +++ b/src/.ci/_package-chocolatey_unix-any.sh @@ -0,0 +1,256 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" == "" ]; then + >&2 printf "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + + + + +PACKAGE_Assemble_CHOCOLATEY_Content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # validate input + case "$_target_os" in + any|windows) + ;; + *) + return 10 # not supported + ;; + esac + + if [ $(FS_Is_Target_A_Source "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Docs "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Library "$_target") -eq 0 ]; then + __dest="${_directory}/lib" + + if [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_TARGZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_GZ "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_TARXZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_XZ "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_ZIP "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + ZIP_Extract "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + else + # copy library file + __dest="${__dest}/$(FS_Get_File "$_target")" + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + fi + + _package="lib${PROJECT_SKU}" + elif [ $(FS_Is_Target_A_WASM_JS "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_WASM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Chocolatey "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Homebrew "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Cargo "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_MSI "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then + return 10 # not applicable + else + # copy main program + __dest="${_directory}/bin/${PROJECT_SKU}.exe" + + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + _package="${PROJECT_SKU}" + fi + + __source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/icons/icon-128x128.png" + __dest="${_directory}/icon.png" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + __source="${PROJECT_PATH_ROOT}/${PROJECT_README}" + __dest="${_directory}/${PROJECT_README}" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + + # REQUIRED: chocolatey required tools\ directory + __dest="${_directory}/tools" + I18N_Create "$__dest" + FS_Make_Directory "$__dest" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # OPTIONAL: chocolatey tools\chocolateyBeforeModify.ps1 + __dest="${_directory}/tools/chocolateyBeforeModify.ps1" + I18N_Create "$__dest" + FS_Write_File "$__dest" "\ +# REQUIRED - BEGIN EXECUTION +Write-Host \"Performing pre-configurations...\" +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # REQUIRED: chocolatey tools\chocolateyinstall.ps1 + __dest="${_directory}/tools/chocolateyinstall.ps1" + I18N_Create "$__dest" + FS_Write_File "$__dest" "\ +# REQUIRED - PREPARING INSTALLATION +Write-Host \"Installing ${PROJECT_SKU} (${PROJECT_VERSION})...\" +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # REQUIRED: chocolatey tools\chocolateyuninstall.ps1 + __dest="${_directory}/tools/chocolateyuninstall.ps1" + I18N_Create "$__dest" + FS_Write_File "$__dest" "\ +# REQUIRED - PREPARING UNINSTALLATION +Write-Host \"Uninstalling ${PROJECT_SKU} (${PROJECT_VERSION})...\" +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # REQUIRED: chocolatey xml.nuspec file + __dest="${_directory}/${_package}.nuspec" + I18N_Create "$__dest" + FS_Write_File "$__dest" "\ + + + + ${PROJECT_SKU} + ${PROJECT_NAME} + ${PROJECT_VERSION} + ${PROJECT_CONTACT_NAME} + ${PROJECT_CONTACT_NAME} + ${PROJECT_CONTACT_WEBSITE} + ${PROJECT_LICENSE} + ${PROJECT_PITCH} + ${PROJECT_README} + icon.png + + + + + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + FS_Is_Directory_Empty "${_directory}/bin" + if [ $? -ne 0 ]; then + FS_Append_File "$__dest" "\ + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + fi + + FS_Is_Directory_Empty "${_directory}/lib" + if [ $? -ne 0 ]; then + FS_Append_File "$__dest" "\ + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + fi + + FS_Append_File "$__dest" "\ + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # execute + return 0 +} diff --git a/src/.ci/_package-chocolatey_windows-any.ps1 b/src/.ci/_package-chocolatey_windows-any.ps1 new file mode 100644 index 0000000..0bd8bd8 --- /dev/null +++ b/src/.ci/_package-chocolatey_windows-any.ps1 @@ -0,0 +1,263 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + exit 1 +} + +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + + + + +function PACKAGE-Assemble-CHOCOLATEY-Content { + param ( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # validate project + switch ("${_target_os}") { + { $_ -in "any", "windows" } { + # accepted + } default { + return 10 # not supported + }} + + if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Docs "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { + $__dest = "${_directory}\lib" + + if ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-TARGZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-GZ "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-TARXZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-XZ "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-ZIP "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = ZIP-Extract "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } else { + # copy library file + $__dest = "${__dest}\$(FS-Get-File "${_target}")" + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + $_package = "lib${env:PROJECT_SKU}" + } elseif ($(FS-Is-Target-A-WASM-JS "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-WASM "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Chocolatey "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Homebrew "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Cargo "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-MSI "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-PDF "${_target}") -eq 0) { + return 10 # not applicable + } else { + # copy main program + $__dest = "${_directory}\bin\${env:PROJECT_SKU}.exe" + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $_package = "${env:PROJECT_SKU}" + } + + + $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\icons\icon-128x128.png" + $__dest = "${_directory}\icon.png" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_README}" + $__dest = "${_directory}\${env:PROJECT_README}" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + + # REQUIRED: chocolatey required tools\ directory + $__dest = "${_directory}\tools" + $null = I18N-Create "${__dest}" + $___process = FS-Make-Directory "${__dest}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # OPTIONAL: chocolatey tools\chocolateyBeforeModify.ps1 + $__dest = "${_directory}\tools\chocolateyBeforeModify.ps1" + $null = I18N-Create "${__dest}" + $___process = FS-Write-File "${__dest}" @" +# REQUIRED - BEGIN EXECUTION +Write-Host "Performing pre-configurations..." +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # REQUIRED: chocolatey tools\chocolateyinstall.ps1 + $__dest = "${_directory}\tools\chocolateyinstall.ps1" + $null = I18N-Create "${__dest}" + $___process = FS-Write-File "${__dest}" @" +# REQUIRED - PREPARING INSTALLATION +Write-Host "Installing ${env:PROJECT_SKU} (${env:PROJECT_VERSION})..." + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # REQUIRED: chocolatey tools\chocolateyuninstall.ps1 + $__dest = "${_directory}\tools\chocolateyuninstall.ps1" + $null = I18N-Create "${__dest}" + $___process = FS-Write-File "${__dest}" @" +# REQUIRED - PREPARING UNINSTALLATION +Write-Host "Uninstalling ${env:PROJECT_SKU} (${env:PROJECT_VERSION})..." + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # REQUIRED: chocolatey xml.nuspec file + $__dest = "${_directory}\${env:PROJECT_SKU}.nuspec" + $null = I18N-Create "${__dest}" + $___process = FS-Write-File "${__dest}" @" + + + + ${env:PROJECT_SKU} + ${env:PROJECT_NAME} + ${env:PROJECT_VERSION} + ${env:PROJECT_CONTACT_NAME} + ${env:PROJECT_CONTACT_NAME} + ${env:PROJECT_CONTACT_WEBSITE} + ${env:PROJECT_LICENSE} + ${env:PROJECT_PITCH} + ${env:PROJECT_README} + icon.png + + + + + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + $___process = FS-Is-Directory-Empty "${_directory}\bin" + if ($___process -ne 0) { + $___process = FS-Append-File "${__dest}" @" + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + $___process = FS-Is-Directory-Empty "${_directory}\lib" + if ($___process -ne 0) { + $___process = FS-Append-File "${__dest}" @" + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + } + + $___process = FS-Append-File "${__dest}" @" + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/src/.ci/_package-deb_unix-any.sh b/src/.ci/_package-deb_unix-any.sh new file mode 100644 index 0000000..8cb012c --- /dev/null +++ b/src/.ci/_package-deb_unix-any.sh @@ -0,0 +1,259 @@ +#!/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/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/archive/zip.sh" +. "${LIBS_AUTOMATACI}/services/compilers/copyright.sh" +. "${LIBS_AUTOMATACI}/services/compilers/deb.sh" +. "${LIBS_AUTOMATACI}/services/compilers/manual.sh" + + + + +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 + + + # execute + ## determine base path + ## TIP: (1) by design, usually is: usr/local/ + ## (2) please avoid: usr/, usr/{TYPE}/, usr/bin/, & usr/lib{TYPE}/ + ## whenever possible for avoiding conflicts with your OS native + ## system packages. + _chroot="${_directory}/data/usr" + if [ ! "$(STRINGS_To_Lowercase "$PROJECT_DEB_IS_NATIVE")" = "true" ]; then + _chroot="${_chroot}/local" + fi + + _gpg_keyring="$PROJECT_SKU" + _package="$PROJECT_SKU" + if [ $(FS_Is_Target_A_Source "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Docs "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Library "$_target") -eq 0 ]; then + __dest="${_chroot}/lib/${PROJECT_SCOPE}/${PROJECT_SKU}" + + if [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_TARGZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_GZ "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_TARXZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_XZ "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_ZIP "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + ZIP_Extract "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + else + # copy library file + __dest="${__dest}/$(FS_Get_File "$_target")" + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + fi + + _gpg_keyring="lib$PROJECT_SKU" + _package="lib$PROJECT_SKU" + elif [ $(FS_Is_Target_A_WASM_JS "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_WASM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Chocolatey "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Homebrew "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Cargo "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_MSI "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then + return 10 # not applicable + else + # copy main program + __dest="${_chroot}/bin/${PROJECT_SKU}" + + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + fi + + + # NOTE: REQUIRED file + __dest="${_chroot}/share/doc/${PROJECT_SCOPE}/${PROJECT_SKU}/changelog.gz" + I18N_Create "$__dest" + DEB_Create_Changelog "$__dest" "$_changelog" "$PROJECT_SKU" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # NOTE: REQUIRED file + __dest="${_chroot}/share/doc/${PROJECT_SCOPE}/${PROJECT_SKU}/copyright" + I18N_Create "$__dest" + COPYRIGHT_Create \ + "$__dest" \ + "${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 + __dest="${_chroot}/share/man/man1/${PROJECT_SCOPE}-${PROJECT_SKU}.1" + I18N_Create "$__dest" + MANUAL_Create \ + "$__dest" \ + "$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" + __url="$PROJECT_STATIC_URL" + if [ $(STRINGS_Is_Empty "$PROJECT_DEB_URL") -ne 0 ]; then + __url="$PROJECT_DEB_URL" + fi + + DEB_Create_Source_List \ + "$_directory" \ + "$PROJECT_GPG_ID" \ + "$__url" \ + "$PROJECT_DEB_COMPONENT" \ + "$PROJECT_DEB_DISTRIBUTION" \ + "$_gpg_keyring" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # WARNING: THIS REQUIRED FILE MUST BE THE LAST ONE + __arch="$_target_arch" + if [ "$__arch" = "any" ]; then + __arch="all" + fi + + __os="$_target_os" + if [ "$__os" = "any" ]; then + __os="all" + fi + + I18N_Create "${_directory}/control/control" + DEB_Create_Control \ + "$_directory" \ + "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}" \ + "$_package" \ + "$PROJECT_VERSION" \ + "$__arch" \ + "$__os" \ + "$PROJECT_CONTACT_NAME" \ + "$PROJECT_CONTACT_EMAIL" \ + "$PROJECT_CONTACT_WEBSITE" \ + "$PROJECT_PITCH" \ + "$PROJECT_DEB_PRIORITY" \ + "$PROJECT_DEB_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..9ff15d6 --- /dev/null +++ b/src/.ci/_package-deb_windows-any.ps1 @@ -0,0 +1,259 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\zip.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\copyright.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\deb.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\manual.ps1" + + + + +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 + }} + + + # execute + ## determine base path + ## TIP: (1) by design, usually is: usr/local/ + ## (2) please avoid: usr/, usr/{TYPE}/, usr/bin/, & usr/lib{TYPE}/ + ## whenever possible for avoiding conflicts with your OS native + ## system packages. + $_chroot = "${_directory}/data/usr" + if ($(STRINGS-To-Lowercase "${env:PROJECT_DEB_IS_NATIVE}") -ne "true") { + $_chroot = "${_chroot}/local" + } + + $_gpg_keyring = "${env:PROJECT_SKU}" + $_package = "${env:PROJECT_SKU}" + if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Docs "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { + $__dest = "${_chroot}\lib\${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + + if ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-TARGZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-GZ "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-TARXZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-XZ "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-ZIP "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = ZIP-Extract "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } else { + # copy library file + $__dest = "${__dest}\$(FS-Get-File "${_target}")" + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + $_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 + $__dest = "${_chroot}\bin\${env:PROJECT_SKU}" + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # NOTE: REQUIRED file + $__dest = "${_chroot}\share\doc\${env:PROJECT_SCOPE}\${env:PROJECT_SKU}\changelog.gz" + $null = I18N-Create "${__dest}" + $___process = DEB-Create-Changelog "${__dest}" "${_changelog}" "${env:PROJECT_SKU}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # NOTE: REQUIRED file + $__dest = "${_chroot}\share\doc\${env:PROJECT_SCOPE}\${env:PROJECT_SKU}\copyright" + $null = I18N-Create "${__dest}" + $___process = COPYRIGHT-Create ` + "${__dest}" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses\deb-copyright" ` + "${env:PROJECT_SKU}" ` + "${env:PROJECT_CONTACT_NAME}" ` + "${env:PROJECT_CONTACT_EMAIL}" ` + "${env:PROJECT_CONTACT_WEBSITE}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # NOTE: REQUIRED file + $__dest = "${_chroot}\share\man\man1\${env:PROJECT_SCOPE}-${env:PROJECT_SKU}.1" + $null = I18N-Create "${__dest}" + $___process = MANUAL-Create ` + "${__dest}" ` + "${env:PROJECT_DEB_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" + $__url = "${env:PROJECT_STATIC_URL}" + if ($(STRINGS-Is-Empty "${env:PROJECT_DEB_URL}") -ne 0) { + $__url = "${env:PROJECT_DEB_URL}" + } + + $___process = DEB-Create-Source-List ` + "${_directory}" ` + "${env:PROJECT_GPG_ID}" ` + "${__url}" ` + "${env:PROJECT_DEB_COMPONENT}" ` + "${env:PROJECT_DEB_DISTRIBUTION}" ` + "${_gpg_keyring}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # WARNING: THIS REQUIRED FILE MUST BE THE LAST ONE + $__arch = "${_target_arch}" + if ($__arch -eq "any") { + $__arch = "all" + } + + $__os = "${_target_os}" + if ($__os -eq "any") { + $__os = "all" + } + + + $null = I18N-Create "${_directory}\control\control" + $___process = DEB-Create-Control ` + "${_directory}" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}" ` + "${_package}" ` + "${env:PROJECT_VERSION}" ` + "${__arch}" ` + "${__os}" ` + "${env:PROJECT_CONTACT_NAME}" ` + "${env:PROJECT_CONTACT_EMAIL}" ` + "${env:PROJECT_CONTACT_WEBSITE}" ` + "${env:PROJECT_PITCH}" ` + "${env:PROJECT_DEB_PRIORITY}" ` + "${env:PROJECT_DEB_SECTION}" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\ABSTRACTS.txt" + if ($___process -ne 0) { + $null = I18N-Create-Failed + 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..9a183d0 --- /dev/null +++ b/src/.ci/_package-docker_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. + + + + +# 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 + any) + _target_image="scratch" + __arch_list="" + ;; + linux) + _target_image="$PROJECT_CONTAINER_BASE_LINUX" + __arch_list="$PROJECT_CONTAINER_BASE_LINUX_ARCH" + ;; + windows) + _target_image="$PROJECT_CONTAINER_BASE_WINDOWS" + __arch_list="$PROJECT_CONTAINER_BASE_WINDOWS_ARCH" + ;; + *) + return 10 # not supported + ;; + esac + + __supported_arch=1 + if [ $(STRINGS_Is_Empty "$__arch_list") -ne 0 ] && + [ ! "$_target_image" = "scratch" ]; then + while [ ! "$__arch_list" = '' ]; do + __arch="${__arch_list%%|*}" + __arch_list="${__arch_list#*|}" + + if [ "$__arch_list" = "$__arch" ]; then + __arch_list="" + fi + + if [ "$_target_arch" = "$__arch" ]; then + __supported_arch=0 + break + fi + done + else + __supported_arch=0 + fi + + if [ $__supported_arch -ne 0 ]; then + return 10 # not supported + fi + + + # assemble the package + FS_Copy_File "$_target" "${_directory}/${PROJECT_SKU}" + 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" "\ +FROM --platform=${_target_os}/${_target_arch} ${_target_image} + +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/.placeholder +ADD --chmod=765 ${PROJECT_SKU} /usr/local/bin/${PROJECT_SKU} + +# Set network port exposures +EXPOSE 80 + +# Set entry point +ENTRYPOINT ['/usr/local/bin/${PROJECT_SKU}'] +CMD ['help'] +" + 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..136a81b --- /dev/null +++ b/src/.ci/_package-docker_windows-any.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. + + + + +# 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 + } elseif ($(FS-Is-Target-A-PDF "${_target}") -eq 0) { + return 10 # not applicable + } + + switch ($_target_os) { + 'any' { + $_target_image = "scratch" + $__arch_list = "" + } 'linux' { + $_target_image = "${env:PROJECT_CONTAINER_BASE_LINUX}" + $__arch_list = "${env:PROJECT_CONTAINER_BASE_LINUX_ARCH}" + } 'windows' { + $_target_image = "${env:PROJECT_CONTAINER_BASE_WINDOWS}" + $__arch_list = "${env:PROJECT_CONTAINER_BASE_WINDOWS_ARCH}" + } default { + return 10 # not supported + }} + + $__supported = 1 + if (($(STRINGS-Is-Empty "${__arch_list}") -ne 0) -and ($_target_image -ne "scratch")) { + $__arch_list.Split("|") | ForEach { + if ($_target_arch -eq $_) { + $__supported = 0 + break + } + } + } else { + $__supported = 0 + } + + if ($__supported -ne 0) { + return 10 # not supported + } + + + # assemble the package + $___process = FS-Copy-File "${_target}" "${_directory}\${env:PROJECT_SKU}" + if ($___process -ne 0) { + return 1 + } + + $___process = FS-Touch-File "${_directory}\.blank" + if ($___process -ne 0) { + return 1 + } + + + # generate the Dockerfile + $null = FS-Write-File "${_directory}\Dockerfile" @" +FROM --platform=${_target_os}/${_target_arch} ${_target_image} + +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) { + $null = FS-Append-File "${_directory}\Dockerfile" @" +LABEL org.opencontainers.image.url=`"${env:PROJECT_CONTACT_WEBSITE}`" + +"@ + } + + if ($(STRINGS-Is-Empty "${env:PROJECT_SOURCE_URL}") -ne 0) { + $null = FS-Append-File "${_directory}\Dockerfile" @" +LABEL org.opencontainers.image.source=`"${env:PROJECT_SOURCE_URL}`" + +"@ + } + + $___process = FS-Append-File "${_directory}\Dockerfile" @" + +# Defining environment variables +ENV ARCH ${_target_arch} +ENV OS ${_target_os} +ENV PORT 80 + +# Assemble the file structure +COPY .blank /tmp/.placeholder +ADD --chmod 765 ${PROJECT_SKU} /usr/local/bin/${PROJECT_SKU} + +# Set network port exposures +EXPOSE 80 + +# Set entry point +ENTRYPOINT ['/usr/local/bin/${PROJECT_SKU}'] +CMD ['help'] + +"@ + 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..d73c3e8 --- /dev/null +++ b/src/.ci/_package-flatpak_windows-any.ps1 @@ -0,0 +1,224 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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..8e39131 --- /dev/null +++ b/src/.ci/_package-homebrew_unix-any.sh @@ -0,0 +1,130 @@ +#!/bin/sh +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + + + + +PACKAGE_Assemble_HOMEBREW_Content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # validate input + if [ "$(STRINGS_Is_Empty "$PROJECT_HOMEBREW_URL")" -eq 0 ]; then + return 10 # disabled explictly + fi + + case "$_target_os" in + any|darwin|linux) + ;; + *) + return 10 # not supported + ;; + esac + + + # execute + if [ $(FS_Is_Target_A_Source "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Docs "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Library "$_target") -eq 0 ]; then + __dest="${_directory}/lib" + + if [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_TARGZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_GZ "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_TARXZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_XZ "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_ZIP "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + ZIP_Extract "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + else + # copy library file + __dest="${__dest}/$(FS_Get_File "$_target")" + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + fi + elif [ $(FS_Is_Target_A_WASM_JS "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_WASM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Chocolatey "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Homebrew "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Cargo "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_MSI "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then + return 10 # not applicable + else + # copy main program + __dest="${_directory}/bin/$(FS_Get_File "$_target")" + + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + fi + + + # report status + return 0 +} diff --git a/src/.ci/_package-homebrew_windows-any.ps1 b/src/.ci/_package-homebrew_windows-any.ps1 new file mode 100644 index 0000000..de198b0 --- /dev/null +++ b/src/.ci/_package-homebrew_windows-any.ps1 @@ -0,0 +1,128 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + exit 1 +} + +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + + + + +function PACKAGE-Assemble-HOMEBREW-Content { + param ( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # validate project + if ($(STRINGS-Is-Empty "${env:PROJECT_HOMEBREW_URL}") -eq 0) { + return 10 # disabled explictly + } + + switch ("${_target_os}") { + { $_ -in "any", "darwin", "linux" } { + # accepted + } default { + return 10 # not supported + }} + + if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Docs "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { + $__dest = "${_directory}\lib" + + if ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-TARGZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-GZ "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-TARXZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-XZ "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-ZIP "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = ZIP-Extract "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } else { + # copy library file + $__dest = "${__dest}\$(FS-Get-File "${_target}")" + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + } elseif ($(FS-Is-Target-A-WASM-JS "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-WASM "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Chocolatey "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Homebrew "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Cargo "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-MSI "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-PDF "${_target}") -eq 0) { + return 10 # not applicable + } else { + # copy main program + $__dest = "${_directory}\bin\$(FS-Get-File "${_target}")" + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # report status + return 0 +} diff --git a/src/.ci/_package-ipk_unix-any.sh b/src/.ci/_package-ipk_unix-any.sh new file mode 100644 index 0000000..26189ae --- /dev/null +++ b/src/.ci/_package-ipk_unix-any.sh @@ -0,0 +1,167 @@ +#!/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/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/archive/zip.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 + + + # execute + ## determine base path + ## TIP: (1) by design, usually is: usr/local/ + ## (2) please avoid: usr/, usr/{TYPE}/, usr/bin/, & usr/lib{TYPE}/ + ## whenever possible for avoiding conflicts with your OS native + ## system packages. + _chroot="${_directory}/data/usr" + if [ ! "$(STRINGS_To_Lowercase "$PROJECT_DEB_IS_NATIVE")" = "true" ]; then + _chroot="${_chroot}/local" + fi + + _gpg_keyring="$PROJECT_SKU" + _package="$PROJECT_SKU" + if [ $(FS_Is_Target_A_Source "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Docs "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Library "$_target") -eq 0 ]; then + __dest="${_chroot}/lib/${PROJECT_SCOPE}/${PROJECT_SKU}" + + if [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_TARGZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_GZ "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_TARXZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_XZ "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_ZIP "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + ZIP_Extract "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + else + # copy library file + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + fi + + _gpg_keyring="lib$PROJECT_SKU" + _package="lib$PROJECT_SKU" + elif [ $(FS_Is_Target_A_WASM_JS "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_WASM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Chocolatey "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Homebrew "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Cargo "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_MSI "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then + return 10 # not applicable + else + # copy main program + __dest="${_chroot}/bin/${PROJECT_SKU}" + if [ "$_target_os" = "windows" ]; then + __dest="${__dest}.exe" + fi + + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + fi + + + # WARNING: THIS REQUIRED FILE MUST BE THE LAST ONE + I18N_Create "${_directory}/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_DEB_PRIORITY" \ + "$PROJECT_DEB_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..88b8372 --- /dev/null +++ b/src/.ci/_package-ipk_windows-any.ps1 @@ -0,0 +1,169 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\zip.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\ipk.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 + }} + + + # execute + ## determine base path + ## TIP: (1) by design, usually is: usr/local/ + ## (2) please avoid: usr/, usr/{TYPE}/, usr/bin/, & usr/lib{TYPE}/ + ## whenever possible for avoiding conflicts with your OS native + ## system packages. + $_chroot = "${_directory}/data/usr" + if ($(STRINGS-To-Lowercase "${env:PROJECT_DEB_IS_NATIVE}") -ne "true") { + $_chroot = "${_chroot}/local" + } + + $_gpg_keyring = "${env:PROJECT_SKU}" + $_package = "${env:PROJECT_SKU}" + if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Docs "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { + $__dest = "${_chroot}\lib\${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + + if ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-TARGZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-GZ "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-TARXZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-XZ "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-ZIP "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = ZIP-Extract "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } else { + # copy library file + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + $_gpg_keyring = "lib${env:PROJECT_SKU}" + $_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 + } elseif ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { + return 10 # not applicable + } else { + # copy main program + $__dest = "${_chroot}\bin\${env:PROJECT_SKU}" + if ($_target_os -eq "windows") { + $__dest = "${__dest}.exe" + } + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # WARNING: THIS REQUIRED FILE MUST BE THE LAST ONE + $null = I18N-Create "${_directory}\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_DEB_PRIORITY}" ` + "${env:PROJECT_DEB_SECTION}" ` + "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\ABSTRACTS.txt" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # report status + return 0 +} diff --git a/src/.ci/_package-lib_unix-any.sh b/src/.ci/_package-lib_unix-any.sh new file mode 100644 index 0000000..3e2324b --- /dev/null +++ b/src/.ci/_package-lib_unix-any.sh @@ -0,0 +1,244 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +. "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" +. "${LIBS_AUTOMATACI}/services/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/archive/zip.sh" +. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" + + + + +# initialize +if [ "$PROJECT_PATH_ROOT" = "" ]; then + >&2 printf "[ ERROR ] - Please run from automataCI/ci.sh.ps1 instead!\n" + return 1 +fi + + + + +PACKAGE_Assemble_LIB_Content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # validate project + if [ $(FS_Is_Target_A_Library "$_target") -ne 0 ]; then + return 10 # not applicable + fi + + + # execute + _workspace="packagers-lib-$(FS_Get_File "$_target")" + _workspace="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/${_workspace}" + FS_Remove_Silently "$_workspace" + + __dest="${_workspace}/lib" + if [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then + # copy over - do not further modify its content anymore + __dest="lib${PROJECT_SKU}-NPM_${PROJECT_VERSION}_js-js.tgz" + __dest="${_directory}/${__dest}" + I18N_Copy "$_target" "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + return 0 + elif [ $(FS_Is_Target_A_TARGZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_GZ "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_TARXZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_XZ "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_ZIP "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + ZIP_Extract "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + else + # assumed it is a standalone library file + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + fi + + + # sanity check before proceeding + FS_Is_Directory_Empty "$__dest" + if [ $? -eq 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + + # copy README.md + __source="${PROJECT_PATH_ROOT}/${PROJECT_README}" + __dest="${_workspace}/${PROJECT_README}" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + + # copy user guide files + for __source in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/USER-GUIDES"*.pdf; do + FS_Is_Target_Exist "$__source" + if [ $? -ne 0 ]; then + continue + fi + + __dest="${_workspace}/$(FS_Get_File "$__source")" + I18N_Copy "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + done + + + # copy license files + for __source in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/licenses/LICENSE"*.pdf; do + FS_Is_Target_Exist "$__source" + if [ $? -ne 0 ]; then + continue + fi + + __dest="${_workspace}/$(FS_Get_File "$__source")" + I18N_Copy "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + done + + + # assemble icon.png + __source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/icons/icon-128x128.png" + __dest="${_workspace}/icon.png" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + + # begin packaging + __current_path="$PWD" && cd "$_workspace" + + ## package tar.xz + __dest="lib${PROJECT_SKU}_${PROJECT_VERSION}_${_target_os}-${_target_arch}.tar.xz" + I18N_Create_Package "$__dest" + __dest="${_directory}/${__dest}" + TAR_Create_XZ "$__dest" "." + if [ $? -ne 0 ]; then + I18N_Create_Failed + cd "$__current_path" && unset __current_path + return 1 + fi + + ## package zip + __dest="lib${PROJECT_SKU}_${PROJECT_VERSION}_${_target_os}-${_target_arch}.zip" + I18N_Create_Package "$__dest" + __dest="${_directory}/${__dest}" + ZIP_Create "$__dest" "." + if [ $? -ne 0 ]; then + I18N_Create_Failed + cd "$__current_path" && unset __current_path + return 1 + fi + + ## package nupkg + __acceptance="false" + if [ $(STRINGS_To_Lowercase "$PROJECT_LICENSE_ACCEPTANCE_REQUIRED") = "true" ]; then + __acceptance="true" + fi + + __dest="lib${PROJECT_SKU}.nuspec" + I18N_Create "$__dest" + FS_Write_File "./${__dest}" "\ + + + + ${PROJECT_SKU} + ${PROJECT_VERSION} + ${PROJECT_CONTACT_NAME} + ${PROJECT_CONTACT_NAME} + ${PROJECT_SOURCE_URL} + ${PROJECT_NAME} + ${PROJECT_PITCH} + ${PROJECT_LICENSE} + ${__acceptance} + ${PROJECT_README} + icon.png + + + + + + + +" + if [ $? -ne 0 ]; then + I18N_Create_Failed + cd "$__current_path" && unset __current_path + return 1 + fi + + __dest="lib${PROJECT_SKU}_${PROJECT_VERSION}_${_target_os}-${_target_arch}.nupkg" + I18N_Create_Package "$__dest" + __dest="${_directory}/${__dest}" + ZIP_Create "$__dest" "." + if [ $? -ne 0 ]; then + I18N_Create_Failed + cd "$__current_path" && unset __current_path + return 1 + fi + + ## done - clean up + cd "$__current_path" && unset __current_path + + + # report status + return 0 +} diff --git a/src/.ci/_package-lib_windows-any.ps1 b/src/.ci/_package-lib_windows-any.ps1 new file mode 100644 index 0000000..9cdd117 --- /dev/null +++ b/src/.ci/_package-lib_windows-any.ps1 @@ -0,0 +1,246 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\zip.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + exit 1 +} + + + + +function PACKAGE-Assemble-LIB-Content { + param ( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # validate project + if ($(FS-Is-Target-A-Library "${_target}") -ne 0) { + return 10 # not applicable + } + + + # execute + $_workspace = "packagers-lib-lib${env:PROJECT_SKU}_${_target_os}-${_target_arch}" + $_workspace = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\${_workspace}" + $null = FS-Remove-Silently "${_workspace}" + + $__dest = "${_workspace}\lib" + if ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { + # copy over - do not modify anymore + $__dest = "lib${env:PROJECT_SKU}-NPM_${env:PROJECT_VERSION}_js-js.tgz" + $__dest = "${_directory}\${__dest}" + $null = I18N-Copy "${_target}" "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + return 0 + } elseif ($(FS-Is-Target-A-TARGZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-GZ "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-TARXZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-XZ "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-ZIP "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = ZIP-Extract "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } else { + # assumed it is a standalone library file + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # sanity check before proceeding + $___process = FS-Is-Directory-Empty "${__dest}" + if ($___process -eq 0) { + $null = I18N-Assemble-Failed + return 1 + } + + + # copy README.md + $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_README}" + $__dest = "${_workspace}\${env:PROJECT_README}" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + + # copy user guide + Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs" ` + | Where-Object { ($_.Name -like "USER-GUIDES*.pdf") } ` + | ForEach-Object { $__source = $_.FullName + $__dest = "${_workspace}\$(FS-Get-File "${__source}")" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # copy license file + Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses" ` + | Where-Object { ($_.Name -like "LICENSE*.pdf") } ` + | ForEach-Object { $__source = $_.FullName + $__dest = "${_workspace}\$(FS-Get-File "${__source}")" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # assemble icon.png + $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\icons\icon-128x128.png" + $__dest = "${_workspace}\icon.png" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + + # begin packaging + $__current_path = Get-Location + $null = Set-Location -Path "${_workspace}" + + ## package tar.xz + $__dest = "lib${env:PROJECT_SKU}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}.tar.xz" + $null = I18N-Create-Package "${__dest}" + $__dest = "${_directory}\${__dest}" + $___process = TAR-Create-XZ "${__dest}" "." + if ($___process -ne 0) { + $null = I18N-Create-Failed + $null = Set-Location -Path "${__current_path}" + $null = Remove-Variable -Name __current_path + return 1 + } + + ## package zip + $__dest = "lib${env:PROJECT_SKU}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}.zip" + $null = I18N-Create-Package "${__dest}" + $__dest = "${_directory}\${__dest}" + $___process = ZIP-Create "${__dest}" "." + if ($___process -ne 0) { + $null = I18N-Create-Failed + $null = Set-Location -Path "${__current_path}" + $null = Remove-Variable -Name __current_path + return 1 + } + + ## package nupkg + $__acceptance = "false" + if ($(STRINGS-To-Lowercase "${env:PROJECT_LICENSE_ACCEPTANCE_REQUIRED}") -eq "true") { + $__acceptance = "true" + } + + $__dest = "lib${env:PROJECT_SKU}.nuspec" + $null = I18N-Create "${__dest}" + $__dest = ".\${__dest}" + $___process = FS-Write-File "${__dest}" @" + + + + ${env:PROJECT_SKU} + ${env:PROJECT_VERSION} + ${env:PROJECT_CONTACT_NAME} + ${env:PROJECT_CONTACT_NAME} + ${env:PROJECT_SOURCE_URL} + ${env:PROJECT_NAME} + ${env:PROJECT_PITCH} + ${env:PROJECT_LICENSE} + ${__acceptance} + ${env:PROJECT_README} + + + + + + + + +"@ + if ($___process -ne 0) { + $null = I18N-Create-Failed + $null = Set-Location -Path "${__current_path}" + $null = Remove-Variable -Name __current_path + return 1 + } + + $__dest = "lib${env:PROJECT_SKU}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}.nupkg" + $null = I18N-Create-Package "${__dest}" + $__dest = "${_directory}\${__dest}" + $___process = ZIP-Create "${__dest}" "." + if ($___process -ne 0) { + $null = I18N-Create-Failed + $null = Set-Location -Path "${__current_path}" + $null = Remove-Variable -Name __current_path + return 1 + } + + ## done - clean up + $null = Set-Location -Path "${__current_path}" + $null = Remove-Variable -Name __current_path + + + # report status + return 0 +} diff --git a/src/.ci/_package-msi_unix-any.sh b/src/.ci/_package-msi_unix-any.sh new file mode 100644 index 0000000..c4979a5 --- /dev/null +++ b/src/.ci/_package-msi_unix-any.sh @@ -0,0 +1,238 @@ +#!/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_MSI_Content() { + _target="$1" + _directory="$2" + _target_name="$3" + _target_os="$4" + _target_arch="$5" + + + # validate input + case "$_target_os" in + any|windows) + ;; + *) + return 10 # not supported + ;; + esac + + case "$_target_arch" in + any|amd64) + ;; + arm64|i386|arm) + return 10 # wixl can only support amd64 + ;; + *) + return 10 # not supported + ;; + esac + + + # execute + 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 + # unpack to the designated lib/ directory + __dest="${_directory}/lib" + + if [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_TARGZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_GZ "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_TARXZ "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_XZ "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_ZIP "$_target") -eq 0 ]; then + # unpack library + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + ZIP_Extract "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + else + # copy library file + __dest="${__dest}/$(FS_Get_File "${_target}")" + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + fi + elif [ $(FS_Is_Target_A_WASM_JS "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_WASM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Chocolatey "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Homebrew "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Cargo "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_MSI "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_PDF "$_target") -eq 0 ]; then + return 10 # not applicable + else + # copy main program to the designated bin/ directory + __dest="${_directory}/bin/${PROJECT_SKU}.exe" + + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + fi + + + # copy README.md into the designated docs/ directory + __source="${PROJECT_PATH_ROOT}/${PROJECT_README}" + __dest="${_directory}/docs/${PROJECT_README}" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + + # copy user guide files to the designated docs/ directory + for __source in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/USER-GUIDES"*.pdf; do + FS_Is_Target_Exist "$__source" + if [ $? -ne 0 ]; then + continue + fi + + __dest="${_directory}/docs/$(FS_Get_File "$__source")" + I18N_Copy "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + done + + + # copy PDF license files to the designated docs/ directory + for __source in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/licenses/LICENSE"*.pdf; do + FS_Is_Target_Exist "$__source" + if [ $? -ne 0 ]; then + continue + fi + + __dest="${_directory}/docs/$(FS_Get_File "$__source")" + I18N_Copy "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + done + + + # copy RTF license files to the designated docs/ directory + for __source in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/licenses/LICENSE"*.rtf; do + FS_Is_Target_Exist "$__source" + if [ $? -ne 0 ]; then + continue + fi + + __dest="${_directory}/docs/$(FS_Get_File "$__source")" + I18N_Copy "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + done + + + # copy icon ico file to the designated base directory + __source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/icons/icon.ico" + __dest="${_directory}/icon.ico" + I18N_Assemble "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + + # copy MSI banner jpg file to the designated base directory + __source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/icons/msi-banner.jpg" + __dest="${_directory}/msi-banner.jpg" + I18N_Copy "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + + # copy MSI dialog jpg file to the designated base directory + __source="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/icons/msi-dialog.jpg" + __dest="${_directory}/msi-dialog.jpg" + I18N_Copy "$__source" "$__dest" + FS_Copy_File "$__source" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + + ## OPTIONAL - create a '[LANG].wxs' recipe if you wish to override one + ## and place it inside the designated base directory. + ## Otherwise, AutomataCI shall create one for you using its + ## packaging structure. + + + # 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..1f54d69 --- /dev/null +++ b/src/.ci/_package-msi_windows-any.ps1 @@ -0,0 +1,235 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + + + +# initialize +if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { + Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" + exit 1 +} + +. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" + + + + +function PACKAGE-Assemble-MSI-Content { + param ( + [string]$_target, + [string]$_directory, + [string]$_target_name, + [string]$_target_os, + [string]$_target_arch + ) + + + # validate project + switch ("${_target_os}") { + { $_ -in "any", "windows" } { + # accepted + } default { + return 10 # not supported + }} + + switch (${_target_arch}) { + { $_ -in "any", "amd64", "arm64", "i386", "arm" } { + # accepted + } default { + return 10 # not supported + }} + + + # download required UI extensions into designated ext/ directory + $__toolkit_ui = 'WixToolset.UI.wixext' + $__dest = "wixext4\${__toolkit_ui}.dll" + $null = I18N-Assemble "${__toolkit_ui}" "${_directory}\ext\${__dest}" + $___process = DOTNET-Add "${__toolkit_ui}" "4.0.3" "${_directory}\ext" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + + # processing target + 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) { + # unpack to the designated lib/ directory + $__dest = "${_directory}\lib" + + if ($(FS-Is-Target-A-NPM "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-TARGZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-GZ "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-TARXZ "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-XZ "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-ZIP "${_target}") -eq 0) { + # unpack library + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = ZIP-Extract "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } else { + # copy library file + $__dest = "${__dest}\$(FS-Get-File "${_target}")" + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + } 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 to the designated bin/ directory + $__dest = "${_directory}\bin\${env:PROJECT_SKU}.exe" + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Housing-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # copy README.md into the designated docs/ directory + $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_README}" + $__dest = "${_directory}\docs\${env:PROJECT_README}" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + + # copy user guide files to the designated docs/ directory + Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs" ` + | Where-Object { ($_.Name -like "USER-GUIDES*.pdf") } ` + | ForEach-Object { $__source = $_.FullName + $__dest = "${_directory}\docs\$(FS-Get-File "${__source}")" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # copy PDF license files to the designated docs/ directory + Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses" ` + | Where-Object { ($_.Name -like "LICENSE*.pdf") } ` + | ForEach-Object { $__source = $_.FullName + $__dest = "${_directory}\docs\$(FS-Get-File "${__source}")" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # copy RTF license files to the designated docs/ directory + Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\licenses" ` + | Where-Object { ($_.Name -like "LICENSE*.rtf") } ` + | ForEach-Object { $__source = $_.FullName + $__dest = "${_directory}\docs\$(FS-Get-File "${__source}")" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + + # copy icon.ico file to the designated base directory + $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\icons\icon.ico" + $__dest = "${_directory}\icon.ico" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + + # copy MSI banner jpg file to the designated base directory + $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\icons\msi-banner.jpg" + $__dest = "${_directory}\msi-banner.jpg" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + + # copy MSI dialog jpg file to the designated base directory + $__source = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\icons\msi-dialog.jpg" + $__dest = "${_directory}\msi-dialog.jpg" + $null = I18N-Assemble "${__source}" "${__dest}" + $___process = FS-Copy-File "${__source}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + ## OPTIONAL - create a '[LANG].wxs' recipe if you wish to override one + ## and place it inside the designated base directory. + ## Otherwise, AutomataCI shall create one for you using its + ## packaging structure. + + + # 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..a9d8735 --- /dev/null +++ b/src/.ci/_package-pdf_unix-any.sh @@ -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. +. "${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 + __dest="${_directory}/$(FS_Get_File "$_target")" + I18N_Copy "$_target" "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Copy_Failed + return 1 + fi + + + # report status + return 0 +} diff --git a/src/.ci/_package-pdf_windows-any.ps1 b/src/.ci/_package-pdf_windows-any.ps1 new file mode 100644 index 0000000..e769fe5 --- /dev/null +++ b/src/.ci/_package-pdf_windows-any.ps1 @@ -0,0 +1,55 @@ +# 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 + $__dest = "${_directory}\$(FS-Get-File "${_target}")" + $null = I18N-Copy "${_target}" "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Copy-Failed + return 1 + } + + + # 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..14c68d3 --- /dev/null +++ b/src/.ci/_package-rpm_unix-any.sh @@ -0,0 +1,285 @@ +#!/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/archive/tar.sh" +. "${LIBS_AUTOMATACI}/services/archive/zip.sh" +. "${LIBS_AUTOMATACI}/services/compilers/rpm.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 + + + # execute + ## determine base path + ## TIP: (1) by design, usually is: usr/local/ + ## (2) please avoid: usr/, usr/{TYPE}/, usr/bin/, & usr/lib{TYPE}/ + ## whenever possible for avoiding conflicts with your OS native + ## system packages. + _chroot="usr" + if [ ! "$(STRINGS_To_Lowercase "$PROJECT_RPM_IS_NATIVE")" = "true" ]; then + _chroot="${_chroot}/local" + fi + + _gpg_keyring="$PROJECT_SKU" + if [ $(FS_Is_Target_A_Source "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Docs "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_Library "$_target") -eq 0 ]; then + if [ $(FS_Is_Target_A_NPM "$_target") -eq 0 ]; then + return 10 # not applicable + elif [ $(FS_Is_Target_A_TARGZ "$_target") -eq 0 ]; then + # unpack library + __source="${PROJECT_SCOPE}/${PROJECT_SKU}" + __dest="${_directory}/BUILD/${__source}" + __target="${_chroot}/lib" + + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_GZ "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + RPM_Register "$_directory" "$__source" "$__target" "true" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_TARXZ "$_target") -eq 0 ]; then + # unpack library + __source="${PROJECT_SCOPE}/${PROJECT_SKU}" + __dest="${_directory}/BUILD/${__source}" + __target="${_chroot}/lib" + + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + TAR_Extract_XZ "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + RPM_Register "$_directory" "$__source" "$__target" "true" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + elif [ $(FS_Is_Target_A_ZIP "$_target") -eq 0 ]; then + # unpack library + __source="${PROJECT_SCOPE}/${PROJECT_SKU}" + __dest="${_directory}/BUILD/${__source}" + __target="${_chroot}/lib" + + I18N_Assemble "$_target" "$__dest" + FS_Make_Directory "$__dest" + ZIP_Extract "$__dest" "$_target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + RPM_Register "$_directory" "$__source" "$__target" "true" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + else + # copy library file + __source="$(FS_Get_File "$_target")" + __dest="${_directory}/BUILD/${__source}" + __target="${_chroot}/lib/${__source}" + + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + RPM_Register "$_directory" "$__source" "$__target" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + fi + + _gpg_keyring="lib$PROJECT_SKU" + _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 + __source="$(FS_Get_File "$_target")" + __dest="${_directory}/BUILD/${__source}" + __target="${_chroot}/bin/${PROJECT_SKU}" + + I18N_Assemble "$_target" "$__dest" + FS_Make_Housing_Directory "$__dest" + FS_Copy_File "$_target" "$__dest" + if [ $? -ne 0 ]; then + I18N_Assemble_Failed + return 1 + fi + + RPM_Register "$_directory" "$__source" "$__target" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + _package="$PROJECT_SKU" + fi + + + # NOTE: REQUIRED file + __source="copyright" + __dest="${_directory}/BUILD/${__source}" + __target="${_chroot}/share/doc/${PROJECT_SCOPE}/${PROJECT_SKU}/${__source}" + I18N_Create "$__source" + COPYRIGHT_Create \ + "$__dest" \ + "${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 + + RPM_Register "$_directory" "$__source" "$__target" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # NOTE: REQUIRED file + __source="${PROJECT_SCOPE}-${PROJECT_SKU}.1" + __dest="${_directory}/BUILD/${__source}" + __source="${__source}.gz" + __target="${_chroot}/share/man/man1/${__source}" + I18N_Create "$__source" + MANUAL_Create \ + "$__dest" \ + "$PROJECT_SKU" \ + "$PROJECT_CONTACT_NAME" \ + "$PROJECT_CONTACT_EMAIL" \ + "$PROJECT_CONTACT_WEBSITE" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + RPM_Register "$_directory" "$__source" "$__target" + if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 + fi + + + # NOTE: OPTIONAL (Comment to turn it off) + I18N_Create "source.repo" + ___metalink="" + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_FLAT_MODE") -ne 0 ]; then + # flat mode enabled + if [ $(STRINGS_Is_Empty "$PROJECT_RPM_METALINK") -eq 0 ]; then + I18N_Create_Failed + return 1 + fi + + ___metalink="${PROJECT_RPM_URL}/${PROJECT_RPM_METALINK}" + fi + + RPM_Create_Source_Repo \ + "$PROJECT_SIMULATE_RUN" \ + "$_directory" \ + "$PROJECT_GPG_ID" \ + "$PROJECT_RPM_URL" \ + "$___metalink" \ + "$PROJECT_NAME" \ + "$PROJECT_SCOPE" \ + "$_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..30a7a59 --- /dev/null +++ b/src/.ci/_package-rpm_windows-any.ps1 @@ -0,0 +1,297 @@ +# Copyright 2023 (Holloway) Chew, Kean Ho +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# 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\archive\tar.ps1" +. "${env:LIBS_AUTOMATACI}\services\archive\zip.ps1" +. "${env:LIBS_AUTOMATACI}\services\compilers\rpm.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 + }} + + + # execute + ## determine base path + ## TIP: (1) by design, usually is: usr/local/ + ## (2) please avoid: usr/, usr/{TYPE}/, usr/bin/, & usr/lib{TYPE}/ + ## whenever possible for avoiding conflicts with your OS native + ## system packages. + $_chroot = "usr" + if ("$(STRINGS-To-Lowercase "$PROJECT_RPM_IS_NATIVE")" -eq "true") { + $_chroot = "${_chroot}/local" + } + + $_gpg_keyring = "${env:PROJECT_SKU}" + if ($(FS-Is-Target-A-Source "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Docs "${_target}") -eq 0) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-Library "${_target}") -eq 0) { + if ($(FS-Is-Target-A-NPM "${_target}" -eq 0)) { + return 10 # not applicable + } elseif ($(FS-Is-Target-A-TARGZ "${_target}" -eq 0)) { + # unpack library + $__source = "${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + $__dest = "${_directory}\BUILD\${__source}" + $__target = "${_chroot}\lib" + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-GZ "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $___process = RPM-Register ` + "${_directory}" ` + "${__source}" ` + "${__target}" ` + "true" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-TARXZ "${_target}" -eq 0)) { + # unpack library + $__source = "${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + $__dest = "${_directory}\BUILD\${__source}" + $__target = "${_chroot}\lib" + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = TAR-Extract-XZ "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $___process = RPM-Register ` + "${_directory}" ` + "${__source}" ` + "${__target}" ` + "true" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } elseif ($(FS-Is-Target-A-ZIP "${_target}" -eq 0)) { + # unpack library + $__source = "${env:PROJECT_SCOPE}\${env:PROJECT_SKU}" + $__dest = "${_directory}\BUILD\${__source}" + $__target = "${_chroot}\lib" + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = ZIP-Extract "${__dest}" "${_target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $___process = RPM-Register ` + "${_directory}" ` + "${__source}" ` + "${__target}" ` + "true" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } else { + # copy library file + $__source = "$(FS-Get-File "${_target}")" + $___dest = "${_directory}\BUILD\${__source}" + $__target = "${_chroot}\lib" + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $___process = RPM-Register "${_directory}" "${__source}" "${__target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + } + + $_gpg_keyring = "lib${env:PROJECT_SKU}" + $_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 + $__source = "$(FS-Get-File "${_target}")" + $__dest = "${_directory}\BUILD\${__source}" + $__target = "${_chroot}\bin\${env:PROJECT_SKU}" + + $null = I18N-Assemble "${_target}" "${__dest}" + $null = FS-Make-Directory "${__dest}" + $___process = FS-Copy-File "${_target}" "${__dest}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $___process = RPM-Register "${_directory}" "${__source}" "${__target}" + if ($___process -ne 0) { + $null = I18N-Assemble-Failed + return 1 + } + + $_package = "${env:PROJECT_SKU}" + } + + + # NOTE: REQUIRED file + $__source = "copyright" + $__dest = "${_directory}/BUILD/${__source}" + $__target = "${_chroot}/share/doc/${env:PROJECT_SCOPE}/${env:PROJECT_SKU}/${__source}" + $null = I18N-Create "${___source}" + $___process = COPYRIGHT-Create ` + "${__dest}" ` + "${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 + } + + $___process = RPM-Register "${_directory}" "${__source}" "${__target}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # NOTE: REQUIRED file + $__source = "${env:PROJECT_SCOPE}-${env:PROJECT_SKU}.1" + $__dest = "${_directory}/BUILD/${__source}" + $__source = "${__source}.gz" + $__target = "${_chroot}/share/man/man1/${__source}" + $null = I18N-Create "${__source}" + $___process = MANUAL-Create ` + "${__dest}" ` + "${env:PROJECT_SKU}" ` + "${env:PROJECT_CONTACT_NAME}" ` + "${env:PROJECT_CONTACT_EMAIL}" ` + "${env:PROJECT_CONTACT_WEBSITE}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + $___process = RPM-Register "${_directory}" "${__source}" "${__target}" + if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + + # NOTE: OPTIONAL (Comment to turn it off) + $null = I18N-Create "source.repo" + $___metalink = "" + if ($(STRINGS-IS-Empty "${env:PROJECT_RPM_FLAT_MODE}") -ne 0) { + # flat mode enabled + if ($(STRINGS-IS-Empty "${env:PROJECT_RPM_METALINK}") -ne 0) { + $null = I18N-Create-Failed + return 1 + } + + $___metalink = "${env:PROJECT_RPM_URL}\${env:PROJECT_RPM_METALINK}" + } + + $___process = RPM-Create-Source-Repo ` + "${env:PROJECT_SIMULATE_RUN}" ` + "${_directory}" ` + "${env:PROJECT_GPG_ID}" ` + "${env:PROJECT_RPM_URL}" ` + "${___metalink}" ` + "${env:PROJECT_NAME}" ` + "${env:PROJECT_SCOPE}" ` + "${_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..4aaa765 --- /dev/null +++ b/src/.ci/build_unix-any.sh @@ -0,0 +1,71 @@ +#!/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/time.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 +__directory="${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/changelog" +I18N_Create "${PROJECT_VERSION} DATA CHANGELOG" +CHANGELOG_Build_Data_Entry "$__directory" +if [ $? -ne 0 ]; then + I18N_Create_Failed + return 1 +fi + + +I18N_Create "${PROJECT_VERSION} DEB CHANGELOG" +CHANGELOG_Build_DEB_Entry \ + "$__directory" \ + "$PROJECT_VERSION" \ + "$PROJECT_SKU" \ + "$PROJECT_DEB_DISTRIBUTION" \ + "$PROJECT_DEB_URGENCY" \ + "$PROJECT_CONTACT_NAME" \ + "$PROJECT_CONTACT_EMAIL" \ + "$(TIME_Format_Datetime_RFC5322 "$(TIME_Now)")" +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..cc4cdcd --- /dev/null +++ b/src/.ci/build_windows-any.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. + + + + +# 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\time.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 +$__directory = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\changelog" +$null = I18N-Create "${env:PROJECT_VERSION} DATA CHANGELOG" +$___process = CHANGELOG-Build-DATA-Entry $__directory +if ($___process -ne 0) { + $null = I18N-Create-Failed + return 1 +} + + +$null = I18N-Create "${env:PROJECT_VERSION} DEB CHANGELOG" +$___process = CHANGELOG-Build-DEB-Entry ` + "${__directory}" ` + "$env:PROJECT_VERSION" ` + "$env:PROJECT_SKU" ` + "$env:PROJECT_DEB_DISTRIBUTION" ` + "$env:PROJECT_DEB_URGENCY" ` + "$env:PROJECT_CONTACT_NAME" ` + "$env:PROJECT_CONTACT_EMAIL" ` + "$(TIME-Format-Datetime-RFC5322 "$(TIME-Now)")" +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..e81727d --- /dev/null +++ b/src/.ci/package_unix-any.sh @@ -0,0 +1,41 @@ +#!/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-lib_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-msi_unix-any.sh" +. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/${PROJECT_PATH_CI}/_package-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..6423336 --- /dev/null +++ b/src/.ci/package_windows-any.ps1 @@ -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. + + + + +# 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-lib_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-msi_windows-any.ps1" +. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\${env:PROJECT_PATH_CI}\_package-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..7c569ba --- /dev/null +++ b/src/.ci/test_unix-any.sh @@ -0,0 +1,39 @@ +#!/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 +___current_path="$PWD" && cd "${PROJECT_PATH_ROOT}/Shell" +/bin/sh ./Test.sh.ps1 +___process=$? +cd "$___current_path" && unset ___current_path +if [ $___process -ne 0 ]; then + return 1 +fi + + + + +# 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..0efed68 --- /dev/null +++ b/src/.ci/test_windows-any.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. + + + + +# 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" + + + +# execute +$___current_path = Get-Location +$null = Set-Location "${env:PROJECT_PATH_ROOT}\Shell" +$___process = OS-Exec 'powershell' '.\Test.sh.ps1' +if ($___process -ne 0) { + return 1 +} +$null = Set-Location $___current_path +$___current_path = $null +if ($___process -ne 0) { + return 1 +} + + + + +# report status +return 0