Scripting

Each workflow renders bash scripts that allow the developers to ensure the continued correctness of the instructions. These scripts may also be helpful to users as a basis for their own scripts. All of the scripts can be found at https://github.com/pulp/pulp_rpm/tree/master/docs/_scripts/

Some scripts have conditional statements for setting REPO_NAME. These are used by Pulp team for validity testing.

The following scripts are used in conjunction with all the workflow scripts:

Base

#!/usr/bin/env bash
set -e

echo "Setting environment variables for default hostname/port for the API and the Content app"
BASE_ADDR=${BASE_ADDR:-http://localhost:24817}
export BASE_ADDR
CONTENT_ADDR=${CONTENT_ADDR:-http://localhost:24816}
export CONTENT_ADDR

# Necessary for `django-admin`
export DJANGO_SETTINGS_MODULE=pulpcore.app.settings

# Poll a Pulp task until it is finished.
wait_until_task_finished() {
    echo "Polling the task until it has reached a final state."
    local task_url=$1
    while true
    do
        response=$(http "$task_url")
        local response
        state=$(jq -r .state <<< "${response}")
        local state
        jq . <<< "${response}"
        case ${state} in
            failed|canceled)
                echo "Task in final state: ${state}"
                exit 1
                ;;
            completed)
                echo "$task_url complete."
                break
                ;;
            *)
                echo "Still waiting..."
                sleep 1
                ;;
        esac
    done
}

Correctness Checks

Warning

These scripts can harm your data.

To check the correctness of the sync with publish and download workflow scripts, they can all be run together using:

#!/usr/bin/env bash

# This script will execute the component scripts and ensure that the documented examples
# work as expected.

# NOTE: These scripts use httpie, jq and requires a .netrc for authentication with Pulp

# From the _scripts directory, run with `source docs_check_sync_publish.sh` (source to preserve the
# environment variables)

export REPO_NAME="sync-repo"
export DIST_NAME="sync-dist"

source base.sh

source repo.sh "$REPO_NAME"
source remote.sh
source sync.sh

source publication.sh
source distribution.sh "$DIST_NAME"

source download.sh

To check the correctness of the upload with publish and download workflow scripts, they can all be run together using:

#!/usr/bin/env bash

# This script will execute the component scripts and ensure that the documented examples
# work as expected.

# NOTE: These scripts use httpie, jq, curl and requires a .netrc for authentication with Pulp

# From the _scripts directory, run with `source docs_check_upload.sh` (source to preserve
# the environment variables)

export REPO_NAME="upload-repo"
export DIST_NAME="upload-dist"

source base.sh
source repo.sh "$REPO_NAME"

source artifact.sh
source package.sh
source add_remove.sh
source advisory.sh

source publication.sh
source distribution.sh "$DIST_NAME"
source download.sh

To check the correctness of the basic copy with publish and download workflow scripts, they can all be run together using:

#!/usr/bin/env bash

# This script will execute the component scripts and ensure that the documented examples
# work as expected.

# NOTE: These scripts use httpie, jq, curl and requires a .netrc for authentication with Pulp

# From the _scripts directory, run with `source docs_check_copy.sh` (source to preserve
# the environment variables)

export REPO_NAME="copy-repo"
export DIST_NAME="copy-dist"
export REMOTE_ARTIFACT="https://fixtures.pulpproject.org/rpm-signed/shark-0.1-1.noarch.rpm"

source base.sh
source repo.sh "$REPO_NAME"

source artifact.sh $REMOTE_ARTIFACT
source package.sh
source copy_basic.sh

source publication.sh
source distribution.sh "$DIST_NAME"
source download.sh