diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/repo-install-test.sh | 21 | ||||
-rwxr-xr-x | scripts/repo-install-test/run-inside-docker.sh | 86 |
2 files changed, 107 insertions, 0 deletions
diff --git a/scripts/repo-install-test.sh b/scripts/repo-install-test.sh index 71e55d7..7585509 100755 --- a/scripts/repo-install-test.sh +++ b/scripts/repo-install-test.sh @@ -3,6 +3,7 @@ # * INTERACTIVE: set to 1 to keep an interactive shell open after the script ran (for debugging) # * FEED: binary package feed (e.g. "latest", "nightly") # * PROJ: OBS project namespace (e.g. "network:osmocom:latest") +# * PROJ_CONFLICT: Conflicting OBS project namespace (e.g. "network:osmocom:nightly") # * KEEP_CACHE: set to 1 to keep downloaded binary packages (for development) # * TESTS: which tests to run (all by default, see below for possible values) . "$(dirname "$0")/common.sh" @@ -23,12 +24,31 @@ CONTAINER="$DISTRO-repo-install-test-$FEED" if [ -z "$TESTS" ]; then TESTS=" + test_conflict install_repo_packages test_binaries services_check " fi +if [ -z "$PROJ_CONFLICT" ]; then + case "$FEED" in + latest) + PROJ_CONFLICT="network:osmocom:nightly" + ;; + nightly) + PROJ_CONFLICT="network:osmocom:latest" + if [ "$DISTRO" = "centos8" ]; then + # Doesn't have packages built for "latest" yet + PROJ_CONFLICT="network:osmocom:next" + fi + ;; + next) + PROJ_CONFLICT="network:osmocom:nightly" + ;; + esac +fi + # Try to run "systemctl status" 10 times, kill the container on failure check_if_systemd_is_running() { for i in $(seq 1 10); do @@ -66,6 +86,7 @@ docker run --rm \ --name "$CONTAINER" \ -e FEED="$FEED" \ -e PROJ="$PROJ" \ + -e PROJ_CONFLICT="$PROJ_CONFLICT" \ -e DISTRO="$DISTRO" \ -e TESTS="$TESTS" \ -e container=docker \ diff --git a/scripts/repo-install-test/run-inside-docker.sh b/scripts/repo-install-test/run-inside-docker.sh index 79dd3cf..f7d1449 100755 --- a/scripts/repo-install-test/run-inside-docker.sh +++ b/scripts/repo-install-test/run-inside-docker.sh @@ -2,6 +2,7 @@ # Environment variables: # * FEED: binary package feed (e.g. "latest", "nightly") # * PROJ: OBS project namespace (e.g. "network:osmocom:latest") +# * PROJ_CONFLICT: Conflicting OBS project namespace (e.g. "network:osmocom:nightly") # * KEEP_CACHE: set to 1 to keep downloaded binary packages (for development) # * DISTRO: linux distribution name (e.g. "debian", "centos") # * TESTS: which tests to run (see repo-install-test.sh) @@ -59,6 +60,12 @@ check_env() { echo "ERROR: missing environment variable \$PROJ!" exit 1 fi + if [ -n "$PROJ_CONFLICT" ]; then + echo "Checking conflicting project: $PROJ_CONFLICT" + else + echo "ERROR: missing environment variable \$PROJ_CONFLICT!" + exit 1 + fi if [ -n "$DISTRO" ]; then echo "Linux distribution: $DISTRO" else @@ -92,6 +99,12 @@ configure_osmocom_repo_debian() { } # $1: OBS project (e.g. "network:osmocom:nightly") +configure_osmocom_repo_debian_remove() { + local proj="$1" + rm "/etc/apt/sources.list.d/$proj.list" +} + +# $1: OBS project (e.g. "network:osmocom:nightly") configure_osmocom_repo_centos8() { local proj="$1" local baseurl="https://download.opensuse.org/repositories/$(proj_with_slashes "$proj")/CentOS_8" @@ -110,6 +123,12 @@ enabled=1 EOF } +# $1: OBS project (e.g. "network:osmocom:nightly") +configure_osmocom_repo_centos8_remove() { + local proj="$1" + rm "/etc/yum.repos.d/$proj.repo" +} + configure_keep_cache_debian() { if [ -z "$KEEP_CACHE" ]; then return @@ -130,6 +149,70 @@ configure_keep_cache_centos8() { echo "keepcache=1" >> /etc/dnf/dnf.conf } +# $1: file +# $2-n: patterns to look for in file with grep +find_patterns_or_exit() { + local file="$1" + local pattern + shift + + for pattern in "$@"; do + if grep -q "$pattern" "$file"; then + continue + fi + + echo "ERROR: could not find pattern '$pattern' in file '$file'!" + exit 1 + done +} + +test_conflict_debian() { + apt-get -y install libosmocore + + configure_osmocom_repo_debian_remove "$PROJ" + configure_osmocom_repo_debian "$PROJ_CONFLICT" + + (apt-get -y install osmo-mgw 2>&1 && touch /tmp/fail) | tee /tmp/out + + if [ -e /tmp/fail ]; then + echo "ERROR: unexpected exit 0!" + exit 1 + fi + + find_patterns_or_exit \ + /tmp/out \ + "requested an impossible situation" \ + "^The following packages have unmet dependencies:" \ + "Depends: osmocom-" \ + "but it is not going to be installed" + + configure_osmocom_repo_debian_remove "$PROJ_CONFLICT" + configure_osmocom_repo_debian "$PROJ" +} + +test_conflict_centos8() { + dnf -y install libosmocore-devel + + configure_osmocom_repo_centos8_remove "$PROJ" + configure_osmocom_repo_centos8 "$PROJ_CONFLICT" + + (dnf -y install osmo-mgw 2>&1 && touch /tmp/fail) | tee /tmp/out + + if [ -e /tmp/fail ]; then + echo "ERROR: unexpected exit 0!" + exit 1 + fi + + find_patterns_or_exit \ + /tmp/out \ + "^Error:" \ + "but none of the providers can be installed" \ + "conflicts with osmocom-" + + configure_osmocom_repo_centos8_remove "$PROJ_CONFLICT" + configure_osmocom_repo_centos8 "$PROJ" +} + # Filter $PWD/osmocom_packages_all.txt through a blacklist_$DISTRO.txt and store the result in # $PWD/osmocom_packages.txt. filter_packages_txt() { @@ -259,6 +342,9 @@ for test in $TESTS; do set -x case "$test" in + test_conflict) + test_conflict_${DISTRO} + ;; install_repo_packages) install_repo_packages_${DISTRO} ;; |