diff --git a/README.md b/README.md index 8059123d..ce024fcf 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,8 @@ Notes: Prebuilt MicroShift artifacts are published at the [Releases](https://github.com/microshift-io/microshift/releases) page. +Nightly MicroShift RPMs are published on the COPR +[@microshift-io/microshift-nightly](https://copr.fedorainfracloud.org/coprs/g/microshift-io/microshift-nightly/). MicroShift can be run on the host or inside a Bootc container. * Install the [latest](https://github.com/microshift-io/microshift/releases/latest) @@ -48,6 +50,12 @@ MicroShift can be run on the host or inside a Bootc container. curl -s https://microshift-io.github.io/microshift/quickrpm.sh | sudo bash ``` +* Install nightly MicroShift RPM packages on your host and start the MicroShift service. + + ```bash + curl -s https://microshift-io.github.io/microshift/quickrpm.sh | sudo env RPM_SOURCE=copr-nightly bash + ``` + * Bootstrap the [latest](https://github.com/microshift-io/microshift/releases/latest) MicroShift build inside a Bootc container on your host. diff --git a/docs/run.md b/docs/run.md index bbe597a5..5d2f5541 100644 --- a/docs/run.md +++ b/docs/run.md @@ -10,6 +10,19 @@ inside a Bootc container. ### Install RPM +The following optional RPM packages are available in the repository. It is +mandatory to install either `microshift-kindnet` or `microshift-networking` +to enable the Kindnet or OVN-K networking support. + +| Package | Description | Comments | +|-----------------------|----------------------------|----------| +| microshift-kindnet | Kindnet CNI | Overrides OVN-K | +| microshift-networking | OVN-K CNI | Uninstall Kindnet to enable OVN-K | +| microshift-topolvm | TopoLVM CSI | Install to enable storage support | +| microshift-olm | Operator Lifecycle Manager | See [Operator Hub Catalogs](https://okd.io/docs/operators/) | + +#### RPMs from Releases or built locally + Run the following commands to install MicroShift RPM packages from a local repository. This repository should be either [built locally](../docs/build.md#create-rpm-packages) or downloaded from [Releases](https://github.com/microshift-io/microshift/releases). @@ -22,16 +35,19 @@ sudo dnf install -y microshift microshift-kindnet sudo ./src/rpm/create_repos.sh -delete ``` -The following optional RPM packages are available in the repository. It is -mandatory to install either `microshift-kindnet` or `microshift-networking` -to enable the Kindnet or OVN-K networking support. +#### RPMs from the COPR -| Package | Description | Comments | -|-----------------------|----------------------------|----------| -| microshift-kindnet | Kindnet CNI | Overrides OVN-K | -| microshift-networking | OVN-K CNI | Uninstall Kindnet to enable OVN-K | -| microshift-topolvm | TopoLVM CSI | Install to enable storage support | -| microshift-olm | Operator Lifecycle Manager | See [Operator Hub Catalogs](https://okd.io/docs/operators/) | +Run the following commands to install MicroShift nightly RPM packages from the COPR. +Before installing MicroShift, RHOCP beta mirror must be enabled to provide dependencies. + +> Note: This approach does not remove the configured repositories in order to get updates for +> MicroShift and dependencies whenever `dnf update` is executed. + +```bash +sudo dnf copr enable -y @microshift-io/microshift-nightly +sudo ./src/rpm/create_repos.sh -rhocp-mirror +sudo dnf install -y microshift microshift-kindnet +``` ### Start MicroShift Service diff --git a/src/quickrpm.sh b/src/quickrpm.sh index e06ec819..16c5afd4 100755 --- a/src/quickrpm.sh +++ b/src/quickrpm.sh @@ -5,6 +5,8 @@ OWNER=${OWNER:-microshift-io} REPO=${REPO:-microshift} BRANCH=${BRANCH:-main} TAG=${TAG:-latest} +RPM_SOURCE=${RPM_SOURCE:-github} # Accepted values: github, copr-nightly +COPR_REPO=${COPR_REPO:-@microshift-io/microshift-nightly} LVM_DISK="/var/lib/microshift-okd/lvmdisk.image" VG_NAME="myvg1" @@ -57,34 +59,64 @@ function centos10_cni_plugins() { containernetworking-plugins } -function install_rpms() { - # Download the RPMs from the release - mkdir -p "${WORKDIR}/rpms" - curl -L -s --retry 5 \ - "https://github.com/${OWNER}/${REPO}/releases/download/${TAG}/microshift-rpms-$(uname -m).tgz" | \ - tar zxf - -C "${WORKDIR}/rpms" +function download_script() { + local -r script=$1 + local -r scriptpath="src/rpm/${script}" + + curscriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - # Download the installation scripts - for script in create_repos.sh postinstall.sh ; do + # If the quickrpm.sh is executed from the repository, copy local script. + # Otherwise, fetch them from the github. + if [ -f "${curscriptdir}/../${scriptpath}" ]; then + cp -v "${curscriptdir}/../${scriptpath}" "${WORKDIR}/${script}" + else curl -fSsL --retry 5 --max-time 60 \ "https://github.com/${OWNER}/${REPO}/raw/${BRANCH}/src/rpm/${script}" \ -o "${WORKDIR}/${script}" chmod +x "${WORKDIR}/${script}" - done + fi +} - # Create the RPM repository and install the RPMs - "${WORKDIR}/create_repos.sh" -create "${WORKDIR}/rpms" +function install_microshift_packages() { # Disable weak dependencies to avoid the deployment of the microshift-networking # RPM, which is not necessary when microshift-kindnet RPM is installed. dnf install -y --setopt=install_weak_deps=False \ microshift microshift-kindnet microshift-topolvm - "${WORKDIR}/create_repos.sh" -delete + + # shellcheck disable=SC1091 + source /etc/os-release + if [ "${ID}" == "fedora" ]; then + # Fedora doesn't have old packages - downgrading greenboot is not possible. + return 0 + fi # Pin the greenboot package to 0.15.z until the following issue is resolved: # https://github.com/fedora-iot/greenboot-rs/issues/132 dnf install -y 'greenboot-0.15.*' } +function install_rpms_copr() { + dnf copr enable -y "${COPR_REPO}" + + "${WORKDIR}/create_repos.sh" -rhocp-mirror + install_microshift_packages + # Keep the repos, so the `dnf update` works for updated MicroShift RPMs and + # updated dependencies. +} + +function install_rpms() { + # Download the RPMs from the release + mkdir -p "${WORKDIR}/rpms" + curl -L -s --retry 5 \ + "https://github.com/${OWNER}/${REPO}/releases/download/${TAG}/microshift-rpms-$(uname -m).tgz" | \ + tar zxf - -C "${WORKDIR}/rpms" + + # Create the RPM repository and install the RPMs + "${WORKDIR}/create_repos.sh" -create "${WORKDIR}/rpms" + install_microshift_packages + "${WORKDIR}/create_repos.sh" -delete +} + function prepare_lvm_disk() { local -r lvm_disk="$1" local -r vg_name="$2" @@ -123,8 +155,8 @@ if [ "$(id -u)" -ne 0 ]; then exit 1 fi -# Update the 'latest' tag to the latest released version -if [ "${TAG}" == "latest" ] ; then +# Update the 'latest' tag to the latest released version (only for github source) +if [ "${RPM_SOURCE}" == "github" ] && [ "${TAG}" == "latest" ] ; then dnf install -y jq TAG="$(curl -s --max-time 60 "https://api.github.com/repos/${OWNER}/${REPO}/releases/latest" | jq -r .tag_name)" if [ -z "${TAG}" ] || [ "${TAG}" == "null" ] ; then @@ -136,7 +168,21 @@ fi # Run the procedures check_prerequisites centos10_cni_plugins -install_rpms +download_script create_repos.sh +download_script postinstall.sh + +case "${RPM_SOURCE}" in +github) + install_rpms + ;; +copr-nightly) + install_rpms_copr + ;; +*) + echo "ERROR: Unsupported RPM_SOURCE: ${RPM_SOURCE}. Use 'github' or 'copr-nightly'." + exit 1 + ;; +esac prepare_lvm_disk "${LVM_DISK}" "${VG_NAME}" setup_lvm_service "${LVM_DISK}" "${VG_NAME}" start_microshift diff --git a/src/rpm/create_repos.sh b/src/rpm/create_repos.sh index ac5f183c..041e7682 100755 --- a/src/rpm/create_repos.sh +++ b/src/rpm/create_repos.sh @@ -1,31 +1,36 @@ #!/bin/bash set -euo pipefail -USHIFT_LOCAL_REPO_FILE=/etc/yum.repos.d/microshift-local.repo -OCP_MIRROR_REPO_FILE=/etc/yum.repos.d/openshift-mirror-beta.repo +YUM_REPOS_D=/etc/yum.repos.d +USHIFT_LOCAL_REPO_FILE=microshift-local.repo +OCP_MIRROR_REPO_FILE_PREFIX=microshift-deps function usage() { - echo "Usage: $(basename "$0") [-create ] | [-delete]" + echo "Usage: $(basename "$0") [-create ] | [-rhocp-mirror ] | [-delete]" exit 1 } -function create_repos() { - local -r repo_path=$1 - local -r repo_version=$2 +function create_rhocp_repo() { + local -r repo_version=$1 - cat > "${USHIFT_LOCAL_REPO_FILE}" < "${file}" < "${OCP_MIRROR_REPO_FILE}" < "${YUM_REPOS_D}/${USHIFT_LOCAL_REPO_FILE}" </dev/null | cut -d. -f1,2) + if [ -z "${repo_version}" ] ; then + echo "ERROR: Failed to find version of MicroShift available in the repositories" + usage + fi + create_rhocp_repo "${repo_version}" ;; -delete)