From 1f756b5dd51b892cf135c46c10399fe53a4c05e0 Mon Sep 17 00:00:00 2001 From: Tim Gurney aka Wolf Date: Thu, 14 Oct 2021 01:14:57 +0100 Subject: [PATCH] update --- .github/ISSUE_TEMPLATE/ask_question.md | 10 - .github/ISSUE_TEMPLATE/ask_question.yml | 22 ++ .github/ISSUE_TEMPLATE/bug_report.md | 30 -- .github/ISSUE_TEMPLATE/bug_report.yml | 58 +++ .github/ISSUE_TEMPLATE/config.yml | 7 + .github/ISSUE_TEMPLATE/feature_request.md | 20 - .github/ISSUE_TEMPLATE/feature_request.yml | 43 +++ .github/SUPPORT.md | 8 - .github/workflows/pipeline.yml | 151 ++++++++ .travis.yml | 145 -------- CHANGELOG.md | 2 + Dockerfiles/alpine/{3.10 => 3.14}/Dockerfile | 0 Dockerfiles/alpine/{3.10 => 3.14}/manage.sh | 0 Dockerfiles/debian/10/manage.sh | 2 +- Dockerfiles/debian/11/manage.sh | 2 +- Dockerfiles/debian/12-slim/Dockerfile | 28 ++ Dockerfiles/debian/12-slim/manage.sh | 8 + Dockerfiles/debian/12/Dockerfile | 28 ++ Dockerfiles/debian/12/manage.sh | 8 + Dockerfiles/ubuntu/14.04/Dockerfile | 27 ++ Dockerfiles/ubuntu/14.04/manage.sh | 8 + LICENSE.md | 2 +- README.md | 88 ++--- Scripts/get-versions.sh | 371 +++++++++++++++++++ Scripts/utils.sh | 123 +++++- Scripts/version-grabber.sh | 134 +++++++ 26 files changed, 1051 insertions(+), 274 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/ask_question.md create mode 100644 .github/ISSUE_TEMPLATE/ask_question.yml delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml delete mode 100644 .github/SUPPORT.md create mode 100644 .github/workflows/pipeline.yml delete mode 100644 .travis.yml rename Dockerfiles/alpine/{3.10 => 3.14}/Dockerfile (100%) rename Dockerfiles/alpine/{3.10 => 3.14}/manage.sh (100%) create mode 100644 Dockerfiles/debian/12-slim/Dockerfile create mode 100755 Dockerfiles/debian/12-slim/manage.sh create mode 100644 Dockerfiles/debian/12/Dockerfile create mode 100755 Dockerfiles/debian/12/manage.sh create mode 100644 Dockerfiles/ubuntu/14.04/Dockerfile create mode 100755 Dockerfiles/ubuntu/14.04/manage.sh create mode 100755 Scripts/get-versions.sh create mode 100755 Scripts/version-grabber.sh diff --git a/.github/ISSUE_TEMPLATE/ask_question.md b/.github/ISSUE_TEMPLATE/ask_question.md deleted file mode 100644 index adfe740..0000000 --- a/.github/ISSUE_TEMPLATE/ask_question.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: Ask a question -about: Feel free to ask us a question -title: '' -labels: 'question' -assignees: 'TGWolf' - ---- - -**What would you like to know?** diff --git a/.github/ISSUE_TEMPLATE/ask_question.yml b/.github/ISSUE_TEMPLATE/ask_question.yml new file mode 100644 index 0000000..d290b8c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/ask_question.yml @@ -0,0 +1,22 @@ +name: Ask a question +description: If you don't have a specific issue or bug to report you can still ask us questions and we will do our best to answer them +title: "[Question]: " +labels: [question, triage] +assignees: + - tgwolf +body: + - type: textarea + id: question + attributes: + label: What is your question? + description: Please give us time to review your question and formulate an answer. + validations: + required: true + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com) + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 906afcb..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: 'bug' -assignees: 'TGWolf' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. -2. -3. -4. - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Environment** -Any relevant information about your environment, OS version, virtualised or not. - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..04cbaa8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,58 @@ +name: Report a bug +description: Found a bug? Let us knonw what the issue is and we will attempt to fix it +title: "[Bug]: " +labels: [bug, triage] +assignees: + - tgwolf +body: + - type: textarea + id: what-happened + attributes: + label: What happened? + description: A clear and concise description of what the bug is. + validations: + required: true + - type: textarea + id: expected-behavior + attributes: + label: Expected behavior + description: A clear and concise description of what you expected to happen. + validations: + required: true + - type: textarea + id: reproduce + attributes: + label: How do we reproduct the bug? + description: What are the steps we need to take to reproduce the behavior? + validations: + required: true + - type: textarea + id: logs + attributes: + label: Relevant log output + description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + render: shell + validations: + required: false + - type: textarea + id: screenshoots + attributes: + label: Screeenshots + description: Upload any screenshots that might help demonstrate the bug. + validations: + required: false + - type: textarea + id: additional-information + attributes: + label: Additional information + description: Please provide any additional information that you think will help us to resolve this bug. + validations: + required: false + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com) + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 3ba13e0..cabd7e8 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1 +1,8 @@ blank_issues_enabled: false +contact_links: + - name: Support us + url: https://ko-fi.com/wolfsoftware + about: Show your support + - name: Visit our website + url: https://wolfsoftware.com/ + about: Visit the Wolf Software website and see what else we do and what services we offer diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 4134b6b..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: 'enhancement' -assignees: 'TGWolf' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..fe89e10 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,43 @@ +name: Request a new feature +description: Got an idea for a new feature? Let us know what you want and we will see if we can add it +title: "[Feature Request]: " +labels: [enhancement, triage] +assignees: + - tgwolf +body: + - type: textarea + id: releated-to + attributes: + label: Is your feature request related to a problem? + description: A clear and concise description of what the problem is. E.g. I'm always frustrated when ... + validations: + required: true + - type: textarea + id: suggested-solution + attributes: + label: Suggested Solution + description: A clear and concise description of what you want to see implemented. + validations: + required: true + - type: textarea + id: alternatives + attributes: + label: Describe alternatives you've considered + description: A clear and concise description of any alternative solutions or features you've considered. + validations: + required: true + - type: textarea + id: additional-information + attributes: + label: Additional information + description: Please provide any additional information that you think will help us to resolve this bug. + validations: + required: false + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com) + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/SUPPORT.md b/.github/SUPPORT.md deleted file mode 100644 index 26d62ce..0000000 --- a/.github/SUPPORT.md +++ /dev/null @@ -1,8 +0,0 @@ -# Support - -If the documentation is not providing the information that you require then you have a couple of options: - -1. [Start a discussion](https://github.com/DockerToolbox/rbenv/discussions). -1. [Open an issue](https://github.com/DockerToolbox/rbenv/issues), using the `Ask a question` option. - -> This project has a [code of conduct](CODE_OF_CONDUCT.md). By interacting with this repository, organization, or community you agree to abide by its terms. diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml new file mode 100644 index 0000000..8361f5a --- /dev/null +++ b/.github/workflows/pipeline.yml @@ -0,0 +1,151 @@ +name: pipeline +on: + push: + pull_request: + schedule: + - cron: '0 3 * * *' + +jobs: + alpine: + runs-on: ubuntu-latest + strategy: + matrix: + version: [ '3.11', '3.12', '3.13', '3.14' ] + name: Build on Alpine Linux ${{ matrix.version }} + steps: + - uses: actions/checkout@v2 + - name: Set up Docker + uses: docker-practice/actions-setup-docker@master + - name: Generate Dockerfile for Alpine Linux ${{ matrix.version }} + run: Dockerfiles/alpine/${{ matrix.version }}/manage.sh generate + - name: Build on Alpine Linux ${{ matrix.version }} + run: Dockerfiles/alpine/${{ matrix.version }}/manage.sh build clean + - name: Login to Docker Hub + run: echo ${{secrets.DOCKERHUB_PASSWORD}} | docker login --username ${{secrets.DOCKERHUB_USERNAME}} --password-stdin + - name: Publish Container + run: Dockerfiles/alpine/${{ matrix.version }}/manage.sh publish + amazonlinux: + runs-on: ubuntu-latest + strategy: + matrix: + version: [ '1', '2' ] + name: Build on Amazon Linux ${{ matrix.version }} + steps: + - uses: actions/checkout@v2 + - name: Set up Docker + uses: docker-practice/actions-setup-docker@master + - name: Generate Dockerfile for Amazon Linux ${{ matrix.version }} + run: Dockerfiles/amazonlinux/${{ matrix.version }}/manage.sh generate + - name: Build on Amazon Linux ${{ matrix.version }} + run: Dockerfiles/amazonlinux/${{ matrix.version }}/manage.sh build clean + - name: Login to Docker Hub + run: echo ${{secrets.DOCKERHUB_PASSWORD}} | docker login --username ${{secrets.DOCKERHUB_USERNAME}} --password-stdin + - name: Publish Container + run: Dockerfiles/amazonlinux/${{ matrix.version }}/manage.sh publish + centos: + runs-on: ubuntu-latest + strategy: + matrix: + version: [ '7', '8' ] + name: Build on Centos ${{ matrix.version }} + steps: + - uses: actions/checkout@v2 + - name: Set up Docker + uses: docker-practice/actions-setup-docker@master + - name: Generate Dockerfile for Centos ${{ matrix.version }} + run: Dockerfiles/centos/${{ matrix.version }}/manage.sh generate + - name: Build on Centos ${{ matrix.version }} + run: Dockerfiles/centos/${{ matrix.version }}/manage.sh build clean + - name: Login to Docker Hub + run: echo ${{secrets.DOCKERHUB_PASSWORD}} | docker login --username ${{secrets.DOCKERHUB_USERNAME}} --password-stdin + - name: Publish Container + run: Dockerfiles/centos/${{ matrix.version }}/manage.sh publish + debian: + runs-on: ubuntu-latest + strategy: + matrix: + version: [ '9', '9-slim', '10', '10-slim', '11', '11-slim', '12', '12-slim' ] + name: Build on Debian ${{ matrix.version }} + steps: + - uses: actions/checkout@v2 + - name: Set up Docker + uses: docker-practice/actions-setup-docker@master + - name: Generate Dockerfile for Debian ${{ matrix.version }} + run: Dockerfiles/debian/${{ matrix.version }}/manage.sh generate + - name: Build on Debian ${{ matrix.version }} + run: Dockerfiles/debian/${{ matrix.version }}/manage.sh build clean + - name: Login to Docker Hub + run: echo ${{secrets.DOCKERHUB_PASSWORD}} | docker login --username ${{secrets.DOCKERHUB_USERNAME}} --password-stdin + - name: Publish Container + run: Dockerfiles/debian/${{ matrix.version }}/manage.sh publish + ubuntu: + runs-on: ubuntu-latest + strategy: + matrix: + version: [ '14.04', '16.04', '18.04', '20.04' ] + name: Build on Ubuntu ${{ matrix.version }} + steps: + - uses: actions/checkout@v2 + - name: Set up Docker + uses: docker-practice/actions-setup-docker@master + - name: Generate Dockerfile for Ubuntu ${{ matrix.version }} + run: Dockerfiles/ubuntu/${{ matrix.version }}/manage.sh generate + - name: Build on Ubuntu ${{ matrix.version }} + run: Dockerfiles/ubuntu/${{ matrix.version }}/manage.sh build clean + - name: Login to Docker Hub + run: echo ${{secrets.DOCKERHUB_PASSWORD}} | docker login --username ${{secrets.DOCKERHUB_USERNAME}} --password-stdin + - name: Publish Container + run: Dockerfiles/ubuntu/${{ matrix.version }}/manage.sh publish + awesomebot: + name: Awesomebot + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby 3.0 + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0 + - name: Run Awesomebot + env: + FLAGS: "default" + EXCLUDE_FILES: "CHANGELOG.md" + WHITELIST: "https://img.shields.io" + run: bash <(curl -s https://raw.githubusercontent.com/CICDToolbox/awesomebot/master/pipeline.sh) + shellcheck: + name: ShellCheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run Shellcheck + run: bash <(curl -s https://raw.githubusercontent.com/CICDToolbox/shellcheck/master/pipeline.sh) + yaml-lint: + name: YAML Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby 3.0 + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0 + - name: Run YAML-Lint + run: bash <(curl -s https://raw.githubusercontent.com/CICDToolbox/yaml-lint/master/pipeline.sh) + slack-workflow-status: + if: always() + name: Slack Post Workflow Notification + needs: + - alpine + - amazonlinux + - centos + - debian + - ubuntu + - awesomebot + - shellcheck + - yaml-lint + runs-on: ubuntu-latest + steps: + - name: Slack Post Workflow Notification + uses: Gamesight/slack-workflow-status@master + with: + include_jobs: true + repo_token: ${{secrets.GITHUB_TOKEN}} + slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1dd71b0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,145 +0,0 @@ -matrix: - include: - - services: - - docker - name: Docker Version - script: - - docker --version - - services: - - docker - name: Alpine Linux 3.10 - script: - - ./Dockerfiles/alpine/3.10/manage.sh build clean - - services: - - docker - name: Alpine Linux 3.11 - script: - - ./Dockerfiles/alpine/3.11/manage.sh build clean - - services: - - docker - name: Alpine Linux 3.12 - script: - - ./Dockerfiles/alpine/3.12/manage.sh build clean - - services: - - docker - name: Alpine Linux 3.13 - script: - - ./Dockerfiles/alpine/3.13/manage.sh build clean - - services: - - docker - name: Amazon Linux 1 - script: - - ./Dockerfiles/amazonlinux/1/manage.sh build clean - - services: - - docker - name: Amazon Linux 2 - script: - - ./Dockerfiles/amazonlinux/2/manage.sh build clean - - services: - - docker - name: Centos 7 - script: - - ./Dockerfiles/centos/7/manage.sh build clean - - services: - - docker - name: Centos 8 - script: - - ./Dockerfiles/centos/8/manage.sh build clean - - services: - - docker - name: Debian 9 (Stretch) - script: - - ./Dockerfiles/debian/9/manage.sh build clean - - services: - - docker - name: Debian 9 (Stretch Slim) - script: - - ./Dockerfiles/debian/9-slim/manage.sh build clean - - services: - - docker - name: Debian 10 (Buster) - script: - - ./Dockerfiles/debian/10/manage.sh build clean - - services: - - docker - name: Debian 10 (Buster Slim) - script: - - ./Dockerfiles/debian/10-slim/manage.sh build clean - - services: - - docker - name: Debian 11 (Bullseye) - script: - - echo "Skipping build as travis currently due to known issue - local build works fine" - - services: - - docker - name: Debian 11 (Bullseye Slim) - script: - - echo "Skipping build as travis currently due to known issue - local build works fine" - - services: - - docker - name: Ubuntu 16.04 (Xenial Xerus / Xenial) - script: - - ./Dockerfiles/ubuntu/16.04/manage.sh build clean - - services: - - docker - name: Ubuntu 18.04 (Bionic Beaver / Bionic) - script: - - ./Dockerfiles/ubuntu/18.04/manage.sh build clean - - services: - - docker - name: Ubuntu 20.04 (Focal Fossa / Focal) - script: - - ./Dockerfiles/ubuntu/20.04/manage.sh build clean - - services: - - docker - name: Dockerfile Linting (Hadolint) - before_install: - - git clone https://github.com/TravisToolbox/hadolint - install: - - "./hadolint/install.sh" - script: - - "./hadolint/scan.sh" - - language: ruby - name: Github Linguist (rvm 2.7) - rvm: 2.7 - before_install: - - git clone https://github.com/TravisToolbox/github-linguist - install: - - "./github-linguist/install.sh" - script: - - "./github-linguist/scan.sh" - - language: ruby - name: YAML Linting (rvm 2.7) - rvm: 2.7 - before_install: - - git clone https://github.com/TravisToolbox/yaml-lint - install: - - "./yaml-lint/install.sh" - script: - - "./yaml-lint/scan.sh" - - language: bash - name: Shellcheck (Bash) - os: linux - arch: arm64-graviton2 - before_install: - - git clone https://github.com/TravisToolbox/shellcheck - install: - - "./shellcheck/install.sh" - script: - - "./shellcheck/scan.sh" - - language: ruby - name: Link Checking (rvm 2.7) - rvm: 2.7 - env: - - WHITELIST="https://img.shields.io" - - EXCLUDE_FILES="CHANGELOG.md" - before_install: - - git clone https://github.com/TravisToolbox/awesomebot - install: - - "./awesomebot/install.sh" - script: - - "./awesomebot/scan.sh" -notifications: - email: false - slack: - secure: elSO/SVoYPacD1oMJ9NsvVtEzBvbFHBv4J1bGRz6XsgANaa9gX9q0NqfIsaVHGSUZwz4/lKZRpHFwCV5KEynLh+rzrjIe0RN8k2WxEjLZq4SuFZ3I/xBIeo+chF2D+zzA4dcAHe9ka9MvdsDEQfcAnlFFawmv0WdaOMmaSPc6aM6DNA0RpSiTJSEhicjvMDGNCBsb3GIbJvDKNBDm2dO/tP4B46SlyYhgjRlQj67fkdo6R3uNVE0p+JEGUe40yfMxwGhuIZYh9YiyV/Iy9Tk177KhBm7NyXM+6j9/vrduBxmgiurC2v4X4RfU5znQszWyc6CY3deBbi6gUpR8oDraIspvokFXzl1I7JGLbX022+BtHMlXnJ1A8snS0CDtU+PDbHcT9MmwyJ/CNLgfSOx0SDk5YRaA2HGylqwOdTJHeaa40Cokyg9gMYR7Jk0JBabaFBSUKo87RecsK8LeuKQpmUfQFkq3QQrpzD+T4nUz3NPAsEiazwvUNlPm+OMh+MeoYG3kd8qrY4/oJnFbp3VGVRSlvVyH0PidFKFEudsLkt50cVP2gRiZVmxpE1911QfGWdF8cA2peYlW+AyMvFwutAR1J4ScMhtF6i3kUb1suG4tKSWUy+gj1IScQv/A218JlMy+pdoH+uk7DOmpVK+1xDmeoSpk/558qdv724dfdY= diff --git a/CHANGELOG.md b/CHANGELOG.md index e35eb2b..1f8d448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ This changelog was automatically generated using [Caretaker](https://github.com/ - update [`[head]`](https://github.com/DockerToolbox/rbenv/commit/) +- update [`[67a30d1]`](https://github.com/DockerToolbox/rbenv/commit/67a30d13ce16a7b7fe2e1429e3301b0320f1b13c) + - update [`[b3ced1e]`](https://github.com/DockerToolbox/rbenv/commit/b3ced1ef2d5a02ccb2c496a936ed114d0e22cf9c) - The initial commit [`[bb37bcb]`](https://github.com/DockerToolbox/rbenv/commit/bb37bcb344c02fdf6d95bdb7d1fb5c28d0660adf) diff --git a/Dockerfiles/alpine/3.10/Dockerfile b/Dockerfiles/alpine/3.14/Dockerfile similarity index 100% rename from Dockerfiles/alpine/3.10/Dockerfile rename to Dockerfiles/alpine/3.14/Dockerfile diff --git a/Dockerfiles/alpine/3.10/manage.sh b/Dockerfiles/alpine/3.14/manage.sh similarity index 100% rename from Dockerfiles/alpine/3.10/manage.sh rename to Dockerfiles/alpine/3.14/manage.sh diff --git a/Dockerfiles/debian/10/manage.sh b/Dockerfiles/debian/10/manage.sh index a089ea9..5f0ff16 100755 --- a/Dockerfiles/debian/10/manage.sh +++ b/Dockerfiles/debian/10/manage.sh @@ -5,4 +5,4 @@ cd "$(dirname "$0")" || exit 1 # shellcheck disable=SC1091 source ../../../Scripts/utils.sh -manage_container "${1}" "${2}" "${CONTAINER_OS_VERSION},buster,latest" +manage_container "${1}" "${2}" "${CONTAINER_OS_VERSION},buster" diff --git a/Dockerfiles/debian/11/manage.sh b/Dockerfiles/debian/11/manage.sh index e106333..8692217 100755 --- a/Dockerfiles/debian/11/manage.sh +++ b/Dockerfiles/debian/11/manage.sh @@ -5,4 +5,4 @@ cd "$(dirname "$0")" || exit 1 # shellcheck disable=SC1091 source ../../../Scripts/utils.sh -manage_container "${1}" "${2}" "${CONTAINER_OS_VERSION},bullseye" +manage_container "${1}" "${2}" "${CONTAINER_OS_VERSION},bullseye,latest" diff --git a/Dockerfiles/debian/12-slim/Dockerfile b/Dockerfiles/debian/12-slim/Dockerfile new file mode 100644 index 0000000..36b7bfc --- /dev/null +++ b/Dockerfiles/debian/12-slim/Dockerfile @@ -0,0 +1,28 @@ +FROM debian:bullseye + +# hadolint ignore=SC2016,DL4006 +RUN apt-get update && \ + apt-get -y --no-install-recommends install \ + build-essential=12.9 \ + bzip2=1.0.8-4 \ + ca-certificates=20210119 \ + git=1:2.30.0-1 \ + libreadline-dev=8.1-1 \ + libssl-dev=1.1.1i-3 \ + wget=1.21-1+b1 \ + zlib1g-dev=1:1.2.11.dfsg-2 \ + && \ + echo 'PATH=${HOME}/.rbenv/shims:${HOME}/.rbenv/bin:${PATH}' >> ~/.bashrc && \ + export PATH=${HOME}/.rbenv/shims:${HOME}/.rbenv/bin:${PATH} && \ + wget -q https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer -O- | bash && \ + echo 'eval "$(rbenv init -)"' >> ~/.bashrc && \ + apt-get -y remove --purge \ + git \ + && \ + apt-get -y autoremove && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /root + +ENTRYPOINT ["/bin/bash"] + diff --git a/Dockerfiles/debian/12-slim/manage.sh b/Dockerfiles/debian/12-slim/manage.sh new file mode 100755 index 0000000..7e2e284 --- /dev/null +++ b/Dockerfiles/debian/12-slim/manage.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +cd "$(dirname "$0")" || exit 1 + +# shellcheck disable=SC1091 +source ../../../Scripts/utils.sh + +manage_container "${1}" "${2}" "${CONTAINER_OS_VERSION},bookworm-slim" diff --git a/Dockerfiles/debian/12/Dockerfile b/Dockerfiles/debian/12/Dockerfile new file mode 100644 index 0000000..36b7bfc --- /dev/null +++ b/Dockerfiles/debian/12/Dockerfile @@ -0,0 +1,28 @@ +FROM debian:bullseye + +# hadolint ignore=SC2016,DL4006 +RUN apt-get update && \ + apt-get -y --no-install-recommends install \ + build-essential=12.9 \ + bzip2=1.0.8-4 \ + ca-certificates=20210119 \ + git=1:2.30.0-1 \ + libreadline-dev=8.1-1 \ + libssl-dev=1.1.1i-3 \ + wget=1.21-1+b1 \ + zlib1g-dev=1:1.2.11.dfsg-2 \ + && \ + echo 'PATH=${HOME}/.rbenv/shims:${HOME}/.rbenv/bin:${PATH}' >> ~/.bashrc && \ + export PATH=${HOME}/.rbenv/shims:${HOME}/.rbenv/bin:${PATH} && \ + wget -q https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer -O- | bash && \ + echo 'eval "$(rbenv init -)"' >> ~/.bashrc && \ + apt-get -y remove --purge \ + git \ + && \ + apt-get -y autoremove && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /root + +ENTRYPOINT ["/bin/bash"] + diff --git a/Dockerfiles/debian/12/manage.sh b/Dockerfiles/debian/12/manage.sh new file mode 100755 index 0000000..f722f9c --- /dev/null +++ b/Dockerfiles/debian/12/manage.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +cd "$(dirname "$0")" || exit 1 + +# shellcheck disable=SC1091 +source ../../../Scripts/utils.sh + +manage_container "${1}" "${2}" "${CONTAINER_OS_VERSION},bookworm" diff --git a/Dockerfiles/ubuntu/14.04/Dockerfile b/Dockerfiles/ubuntu/14.04/Dockerfile new file mode 100644 index 0000000..47711be --- /dev/null +++ b/Dockerfiles/ubuntu/14.04/Dockerfile @@ -0,0 +1,27 @@ +FROM ubuntu:16.04 + +# hadolint ignore=SC2016,DL4006 +RUN apt-get update && \ + apt-get -y --no-install-recommends install \ + build-essential=12.1ubuntu2 \ + bzip2=1.0.6-8ubuntu0.2 \ + ca-certificates=20210119~16.04.1 \ + git=1:2.7.4-0ubuntu1.9 \ + libreadline-dev=6.3-8ubuntu2 \ + libssl-dev=1.0.2g-1ubuntu4.19 \ + wget=1.17.1-1ubuntu1.5 \ + zlib1g-dev=1:1.2.8.dfsg-2ubuntu4.3 \ + && \ + echo 'PATH=${HOME}/.rbenv/shims:${HOME}/.rbenv/bin:${PATH}' >> ~/.bashrc && \ + export PATH=${HOME}/.rbenv/shims:${HOME}/.rbenv/bin:${PATH} && \ + wget -q https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer -O- | bash && \ + echo 'eval "$(rbenv init -)"' >> ~/.bashrc && \ + apt-get -y remove --purge \ + git \ + && \ + apt-get -y autoremove && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /root + +ENTRYPOINT ["/bin/bash"] diff --git a/Dockerfiles/ubuntu/14.04/manage.sh b/Dockerfiles/ubuntu/14.04/manage.sh new file mode 100755 index 0000000..ab335b1 --- /dev/null +++ b/Dockerfiles/ubuntu/14.04/manage.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +cd "$(dirname "$0")" || exit 1 + +# shellcheck disable=SC1091 +source ../../../Scripts/utils.sh + +manage_container "${1}" "${2}" "${CONTAINER_OS_VERSION_RAW},trusty" diff --git a/LICENSE.md b/LICENSE.md index 0577248..946b3da 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,7 @@ The MIT License (MIT) ===================== -Copyright © `2009-2021` `Wolf Software Limited` +Copyright © `2009-2021` `Wolf Software` Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/README.md b/README.md index 94c8baf..c5790bb 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,34 @@ -

- - Wolf Software Logo - -
- Docker containers with rbenv installed -

-

- - Build Status - - - Release - - - Commits since release - - - Software License - -
- - - - - - - - - - - - + + DockerToolbox logo + +
+ + Github Build Status + + + Release + + + Commits since release + +
+ + + + + + + + + + + + +
+ + +

## Overview @@ -42,20 +39,23 @@ We try to offer as many operating system flavours as possible, but we only use c | Dockerfile | Docker Hub Repo | Docker Hub Tags | | --- | --- | --- | -| [Alpine Linux 3.10](Dockerfiles/alpine/3.10/Dockerfile) | [wolfsoftwareltd/rbenv-alpine](https://hub.docker.com/r/wolfsoftwareltd/rbenv-alpine) | 3.10 | | [Alpine Linux 3.11](Dockerfiles/alpine/3.11/Dockerfile) | [wolfsoftwareltd/rbenv-alpine](https://hub.docker.com/r/wolfsoftwareltd/rbenv-alpine) | 3.11 | | [Alpine Linux 3.12](Dockerfiles/alpine/3.12/Dockerfile) | [wolfsoftwareltd/rbenv-alpine](https://hub.docker.com/r/wolfsoftwareltd/rbenv-alpine) | 3.12 | | [Alpine Linux 3.13](Dockerfiles/alpine/3.13/Dockerfile) | [wolfsoftwareltd/rbenv-alpine](https://hub.docker.com/r/wolfsoftwareltd/rbenv-alpine) | 3.13, latest | +| [Alpine Linux 3.14](Dockerfiles/alpine/3.14/Dockerfile) | [wolfsoftwareltd/rbenv-alpine](https://hub.docker.com/r/wolfsoftwareltd/rbenv-alpine) | 3.14 | | [Amazon Linux 1](Dockerfiles/amazonlinux/1/Dockerfile) | [wolfsoftwareltd/rbenv-amazonlinux](https://hub.docker.com/r/wolfsoftwareltd/rbenv-amazonlinux) | 1 | | [Amazon Linux 2](Dockerfiles/amazonlinux/2/Dockerfile) | [wolfsoftwareltd/rbenv-amazonlinux](https://hub.docker.com/r/wolfsoftwareltd/rbenv-amazonlinux) | 2, latest | | [Centos 7](Dockerfiles/centos/7/Dockerfile) | [wolfsoftwareltd/rbenv-centos](https://hub.docker.com/r/wolfsoftwareltd/rbenv-centos) | 7, | | [Centos 8](Dockerfiles/centos/8/Dockerfile) | [wolfsoftwareltd/rbenv-centos](https://hub.docker.com/r/wolfsoftwareltd/rbenv-centos) | 8, latest | | [Debian 9 (Stretch)](Dockerfiles/debian/9/Dockerfile) | [wolfsoftwareltd/rbenv-debian](https://hub.docker.com/r/wolfsoftwareltd/rbenv-debian) | 9, stretch | | [Debian 9 (Stretch Slim)](Dockerfiles/debian/9-slim/Dockerfile) | [wolfsoftwareltd/rbenv-debian](https://hub.docker.com/r/wolfsoftwareltd/rbenv-debian) | 9-slim, stretch-slim | -| [Debian 10 (Buster)](Dockerfiles/debian/10/Dockerfile) | [wolfsoftwareltd/rbenv-debian](https://hub.docker.com/r/wolfsoftwareltd/rbenv-debian) | 10, buster, latest | +| [Debian 10 (Buster)](Dockerfiles/debian/10/Dockerfile) | [wolfsoftwareltd/rbenv-debian](https://hub.docker.com/r/wolfsoftwareltd/rbenv-debian) | 10, buster | | [Debian 10 (Buster Slim)](Dockerfiles/debian/10-slim/Dockerfile) | [wolfsoftwareltd/rbenv-debian](https://hub.docker.com/r/wolfsoftwareltd/rbenv-debian) | 10-slim, buster-slim | -| [Debian 11 (Bullseye)](Dockerfiles/debian/11/Dockerfile) | [wolfsoftwareltd/rbenv-centos](https://hub.docker.com/r/wolfsoftwareltd/rbenv-centos) | 11, bullseye | +| [Debian 11 (Bullseye)](Dockerfiles/debian/11/Dockerfile) | [wolfsoftwareltd/rbenv-centos](https://hub.docker.com/r/wolfsoftwareltd/rbenv-centos) | 11, bullseye, latest | | [Debian 11 (Bullseye Slim)](Dockerfiles/debian/11-slim/Dockerfile) | [wolfsoftwareltd/rbenv-debian](https://hub.docker.com/r/wolfsoftwareltd/rbenv-debian) | 11-slim, bullseye-slim | +| [Debian 12 (Bookworm)](Dockerfiles/debian/12/Dockerfile) | [wolfsoftwareltd/rbenv-centos](https://hub.docker.com/r/wolfsoftwareltd/rbenv-centos) | 12, bookworm | +| [Debian 12 (Bookworm Slim)](Dockerfiles/debian/12-slim/Dockerfile) | [wolfsoftwareltd/rbenv-debian](https://hub.docker.com/r/wolfsoftwareltd/rbenv-debian) | 12-slim, bookworm-slim | +| [Ubuntu 14.04 (Trusty Tahr)](Dockerfiles/ubuntu/14.04/Dockerfile) | [wolfsoftwareltd/rbenv-ubuntu](https://hub.docker.com/r/wolfsoftwareltd/rbenv-ubuntu) | 14.04, trusty | | [Ubuntu 16.04 (Xenial Xerus)](Dockerfiles/ubuntu/16.04/Dockerfile) | [wolfsoftwareltd/rbenv-ubuntu](https://hub.docker.com/r/wolfsoftwareltd/rbenv-ubuntu) | 16.04, xenial | | [Ubuntu 18.04 (Bionic Beaver)](Dockerfiles/ubuntu/18.04/Dockerfile) | [wolfsoftwareltd/rbenv-ubuntu](https://hub.docker.com/r/wolfsoftwareltd/rbenv-ubuntu) | 18.04, bionic | | [Ubuntu 20.04 (Focal Fossa)](Dockerfiles/ubuntu/20.04/Dockerfile) | [wolfsoftwareltd/rbenv-ubuntu](https://hub.docker.com/r/wolfsoftwareltd/rbenv-ubuntu) | 20.04, focal, latest | @@ -75,19 +75,3 @@ We try to offer as many operating system flavours as possible, but we only use c ``` wolfsoftwareltd/rbenv-: e.g. wolfsoftwareltd/rbenv-debian:10 ``` - -## Contributors - -

- - - -

- -## Show Support - -

- - - -

diff --git a/Scripts/get-versions.sh b/Scripts/get-versions.sh new file mode 100755 index 0000000..bcb53ce --- /dev/null +++ b/Scripts/get-versions.sh @@ -0,0 +1,371 @@ +#! /usr/bin/env bash + +# -------------------------------------------------------------------------------- # +# Description # +# -------------------------------------------------------------------------------- # +# When building docker containers it is considered best (or at least good) # +# practice to pin the packages you install to specific versions. Identifying all # +# these versions can be a long, slow and often boring process. # +# # +# This is a tool to assist in generating a list of packages and their associated # +# versions for use within a Dockerfile. # +# -------------------------------------------------------------------------------- # + +# -------------------------------------------------------------------------------- # +# Required commands # +# -------------------------------------------------------------------------------- # +# These commands MUST exist in order for the script to correctly run. # +# -------------------------------------------------------------------------------- # + +PREREQ_COMMANDS=( "docker" ) + +# -------------------------------------------------------------------------------- # +# Flags # +# -------------------------------------------------------------------------------- # +# A set of global flags that we use for configuration. # +# -------------------------------------------------------------------------------- # + +NO_HEADERS=false +USE_COLOURS=true # Should we use colours in our output ? +WIDTH=120 + +# -------------------------------------------------------------------------------- # +# The wrapper function # +# -------------------------------------------------------------------------------- # +# This is where you code goes and is effectively your main() function. # +# -------------------------------------------------------------------------------- # + +function wrapper() +{ + draw_header + + docker run --rm -v "${GRABBER_SCRIPT}":/version-grabber --env-file="${CONFIG_FILE}" "${OSNAME}":"${TAGNAME}" "${SHELLNAME}" /version-grabber + + draw_line +} + +# -------------------------------------------------------------------------------- # +# Usage (-h parameter) # +# -------------------------------------------------------------------------------- # +# This function is used to show the user 'how' to use the script. # +# -------------------------------------------------------------------------------- # + +function usage() +{ + if [[ -n ${1:-} ]]; + then + show_error " Error: ${1}" + fi + +cat < /dev/null 2>&1; then + return + fi + + ncolors=$(tput colors) + + if ! test -n "${ncolors}" || test "${ncolors}" -le 7; then + return + fi + + red=$(tput setaf 1) + yellow=$(tput setaf 3) + green=$(tput setaf 2) + reset=$(tput sgr0) +} + +# -------------------------------------------------------------------------------- # +# Show Error # +# -------------------------------------------------------------------------------- # +# A simple wrapper function to show something was an error. # +# -------------------------------------------------------------------------------- # + +function show_error() +{ + if [[ -n $1 ]]; then + printf '%s%s%s\n' "${red}" "${*}" "${reset}" 1>&2 + fi +} + +# -------------------------------------------------------------------------------- # +# Show Warning # +# -------------------------------------------------------------------------------- # +# A simple wrapper function to show something was a warning. # +# -------------------------------------------------------------------------------- # + +function show_warning() +{ + if [[ -n $1 ]]; then + printf '%s%s%s\n' "${yellow}" "${*}" "${reset}" 1>&2 + fi +} + +# -------------------------------------------------------------------------------- # +# Show Success # +# -------------------------------------------------------------------------------- # +# A simple wrapper function to show something was a success. # +# -------------------------------------------------------------------------------- # + +function show_success() +{ + if [[ -n $1 ]]; then + printf '%s%s%s\n' "${green}" "${*}" "${reset}" 1>&2 + fi +} + +function draw_header +{ + if [[ "${NO_HEADERS}" = false ]]; then + + local config_string_raw config_string + config_string_raw="Config File: $(basename "${CONFIG_FILE}") Grabber Script: $(basename "${GRABBER_SCRIPT}") Docker Container: ${OSNAME}:${TAGNAME} Shell: ${SHELLNAME}" + config_string="${green}Config File:${reset} $(basename "${CONFIG_FILE}") ${green}Grabber Script:${reset} $(basename "${GRABBER_SCRIPT}") ${green}Docker Container:${reset} ${OSNAME}:${TAGNAME} ${green}Shell:${reset} ${SHELLNAME}" + + draw_line + center_text "Docker package version grabber" + draw_line + center_text "${config_string}" "${#config_string_raw}" + draw_line + fi +} + +# -------------------------------------------------------------------------------- # +# abs # +# -------------------------------------------------------------------------------- # +# Return the absolute value for a given number. # +# -------------------------------------------------------------------------------- # + +function abs() +{ + (( $1 < 0 )) && echo "$(( $1 * -1 ))" || echo "$1" +} + +# -------------------------------------------------------------------------------- # +# Center Text # +# -------------------------------------------------------------------------------- # +# A simple wrapper function to some text centered on the screen. # +# -------------------------------------------------------------------------------- # + +function center_text() +{ + if [[ -n ${2} ]]; then + textsize=${2} + extra=$(abs "$(( textsize - ${#1} ))") + else + textsize=${#1} + extra=0 + fi + span=$(( ( (WIDTH + textsize) / 2) + extra )) + + printf '%*s\n' "${span}" "$1" +} + +# -------------------------------------------------------------------------------- # +# Draw Line # +# -------------------------------------------------------------------------------- # +# A simple wrapper function to draw a line on the screen. # +# -------------------------------------------------------------------------------- # + +function draw_line() +{ + if [[ "${NO_HEADERS}" = false ]]; then + + local start=$'\e(0' end=$'\e(B' line='qqqqqqqqqqqqqqqq' + + while ((${#line} < "${WIDTH}")); + do + line+="$line"; + done + printf '%s%s%s\n' "$start" "${line:0:WIDTH}" "$end" + fi +} + + +# -------------------------------------------------------------------------------- # +# Check Prerequisites # +# -------------------------------------------------------------------------------- # +# Check to ensure that the prerequisite commmands exist. # +# -------------------------------------------------------------------------------- # + +function check_prereqs() +{ + local error_count=0 + + for i in "${PREREQ_COMMANDS[@]}" + do + command=$(command -v "${i}" || true) + if [[ -z $command ]]; then + show_error "$i is not in your command path" + error_count=$((error_count+1)) + fi + done + + if [[ $error_count -gt 0 ]]; then + show_error "$error_count errors located - fix before re-running"; + clean_exit 1; + fi +} + +# -------------------------------------------------------------------------------- # +# Clean Exit # +# -------------------------------------------------------------------------------- # +# Unset the traps and exit cleanly, with an optional exit code / message. # +# -------------------------------------------------------------------------------- # + +function clean_exit() +{ + if [[ -n ${2:-} ]]; + then + show_error "${2}" + fi + exit "${1:-0}" +} + +# -------------------------------------------------------------------------------- # +# Main() # +# -------------------------------------------------------------------------------- # +# The main function where all of the heavy lifting and script config is done. # +# -------------------------------------------------------------------------------- # + +function main() +{ + check_colours + check_prereqs + process_arguments "${@}" +} + +# -------------------------------------------------------------------------------- # +# Main() # +# -------------------------------------------------------------------------------- # +# This is the actual 'script' and the functions/sub routines are called in order. # +# -------------------------------------------------------------------------------- # + +main "${@}" + +# -------------------------------------------------------------------------------- # +# End of Script # +# -------------------------------------------------------------------------------- # +# This is the end - nothing more to see here. # +# -------------------------------------------------------------------------------- # diff --git a/Scripts/utils.sh b/Scripts/utils.sh index a871bcd..79a6d27 100644 --- a/Scripts/utils.sh +++ b/Scripts/utils.sh @@ -19,10 +19,45 @@ function setup() LOCAL_CONTAINER_NAME="${CONTAINER_TMP//.}" PUBLISHED_CONTAINER_NAME="${DOCKER_HUB_ORG}/${CONTAINER_PREFIX}-${CONTAINER_OS_NAME}" + if [[ "${CONTAINER_OS_NAME}" == "debian" ]]; then + case "${CONTAINER_OS_VERSION_RAW}" in + 9) + CONTAINER_OS_VERSION_ALT="stretch" + ;; + 9-slim) + CONTAINER_OS_VERSION_ALT="stretch-slim" + ;; + 10) + CONTAINER_OS_VERSION_ALT="buster" + ;; + 10-slim) + CONTAINER_OS_VERSION_ALT="buster-slim" + ;; + 11) + CONTAINER_OS_VERSION_ALT="bullseye" + ;; + 11-slim) + CONTAINER_OS_VERSION_ALT="bullseye-slim" + ;; + 12) + CONTAINER_OS_VERSION_ALT="bookworm" + ;; + 12-slim) + CONTAINER_OS_VERSION_ALT="bookworm-slim" + ;; + *) + echo "${fgRed}${bold}Unknown debian version ${CONTAINER_OS_VERSION_RAW} - update utils.sh - aborting${reset}" + exit + esac + else + CONTAINER_OS_VERSION_ALT=$CONTAINER_OS_VERSION_RAW + fi + export PUBLISHED_CONTAINER_NAME export LOCAL_CONTAINER_NAME export CONTAINER_OS_VERSION_RAW export CONTAINER_OS_VERSION + export CONTAINER_OS_VERSION_ALT } function manage_container() @@ -31,15 +66,28 @@ function manage_container() clean="${2:-}" tags="${3:-}" - if [[ "${type}" != "publish" ]]; then - build_container "${clean}" - else - publish_container "${tags}" - fi + case "${type}" in + generate) + generate_container + ;; + build) + build_container "${clean}" + ;; + scan) + scan_container + ;; + publish) + publish_container "${tags}" + ;; + *) + echo "${fgRed}${bold}Unknown option ${type} aborting${reset}" + ;; + esac } function set_colours() { + export TERM=xterm fgRed=$(tput setaf 1) fgGreen=$(tput setaf 2) fgYellow=$(tput setaf 3) @@ -49,6 +97,62 @@ function set_colours() reset=$(tput sgr0) } +function check_template() +{ + if [[ ! -f "${1}" ]]; then + echo "${fgRed}${bold}${1} is missing aborting Dockerfile generation for ${CONTAINER_OS_NAME}:${CONTAINER_OS_VERSION_ALT}${reset}" + exit 1 + fi +} + +function generate_container() +{ + echo "${fgGreen}${bold}Generating new Dockerfile for ${CONTAINER_OS_NAME}:${CONTAINER_OS_VERSION_ALT}${reset}" + + check_template "Templates/install.tpl" + check_template "Templates/cleanup.tpl" + check_template "Templates/entrypoint.tpl" + + INSTALL=$(Dockerfile < /dev/null 2>&1 + + output="RUN apk update && \\\\\n" + output="${output}\\tapk add --no-cache \\\\\n" + + for package in $packages; do + version=$(apk policy "${package}" 2>/dev/null | sed -n 2p | sed 's/:$//g' | sed 's/^[[:space:]]*//') + if [[ -n "${version}" ]]; then + output="${output}\\t\t$package=$version \\\\\n" + fi + done + output="${output}\t\t&& \\\\\n" + echo -e "${output}" + else + echo " No packages have been defined." + fi +} + +# -------------------------------------------------------------------------------- # +# Get apt versions # +# -------------------------------------------------------------------------------- # +# Get version information for apt based operating systems. # +# -------------------------------------------------------------------------------- # + +function get_apt_versions() +{ + local packages="${APT_PACKAGES}" + local output + + if [[ -n "${packages}" ]]; then + apt-get update > /dev/null 2>&1 + + output="RUN apt-get update && \\\\\n" + output="${output}\tapt-get -y --no-install-recommends install \\\\\n" + + for package in $packages; do + version=$(apt-cache policy "${package}" 2>/dev/null | grep 'Candidate:' | awk -F ' ' '{print $2}') + if [[ -n "${version}" ]]; then + output="${output}\t\t$package=$version \\\\\n" + fi + done + output="${output}\t\t&& \\\\\n" + echo -e "${output}" + else + echo " No packages have been defined." + fi +} + +# -------------------------------------------------------------------------------- # +# Get yum versions # +# -------------------------------------------------------------------------------- # +# Get version information for yum based operating systems. # +# -------------------------------------------------------------------------------- # + +function get_yum_versions() +{ + local packages="${YUM_PACKAGES}" + local output + + if [[ -n "${packages}" ]]; then + yum makecache > /dev/null 2>&1 + + output="RUN yum makecache && \\\\\n" + output="${output}\tyum install -y \\\\\n" + + for package in $packages; do + version=$(yum info "${package}" 2>/dev/null | grep '^Version' | head -n 1 | awk -F ' : ' '{print $2}') + if [[ -n "${version}" ]]; then + output="${output}\t\t$package-$version \\\\\n" + fi + done + output="${output}\t\t&& \\\\\n" + echo -e "${output}" + else + echo " No packages have been defined." + fi +} + +# -------------------------------------------------------------------------------- # +# Identify provider # +# -------------------------------------------------------------------------------- # +# Identify which package provider the OS is using. # +# -------------------------------------------------------------------------------- # + +function identify_provider +{ + if command -v apk > /dev/null; then + get_apk_versions + elif command -v apt > /dev/null; then + get_apt_versions + elif command -v yum > /dev/null; then + get_yum_versions + else + echo "Unsupport OS type" + fi +} + +# -------------------------------------------------------------------------------- # +# Main() # +# -------------------------------------------------------------------------------- # +# This is the actual 'script' and the functions/sub routines are called in order. # +# -------------------------------------------------------------------------------- # + +identify_provider + +# -------------------------------------------------------------------------------- # +# End of Script # +# -------------------------------------------------------------------------------- # +# This is the end - nothing more to see here. # +# -------------------------------------------------------------------------------- #