File openSUSE-repos-20240516.5431918.obscpio of Package openSUSE-repos
07070100000000000041ED0000000000000000000000026645FE3900000000000000000000000000000000000000000000002800000000openSUSE-repos-20240516.5431918/.github07070100000001000041ED0000000000000000000000026645FE3900000000000000000000000000000000000000000000003200000000openSUSE-repos-20240516.5431918/.github/workflows07070100000002000081A40000000000000000000000016645FE39000003E2000000000000000000000000000000000000004200000000openSUSE-repos-20240516.5431918/.github/workflows/repo_checks.yml# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Runs a single command using the runners shell. use run: | to run multiple (command per line)
- name: Run a one-line script
run: bash checks/repo_checks
07070100000003000081A40000000000000000000000016645FE3900000104000000000000000000000000000000000000003C00000000openSUSE-repos-20240516.5431918/.github/workflows/test.yaml---
name: CI
on: [pull_request, workflow_dispatch] # yamllint disable-line rule:truthy
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Test
run: |
cd t && \
make test_container
07070100000004000081A40000000000000000000000016645FE3900000F1E000000000000000000000000000000000000002A00000000openSUSE-repos-20240516.5431918/README.md # openSUSE-repos
**Definitions for openSUSE repository management via zypp-services.**
[openSUSE-repos](https://github.com/openSUSE/openSUSE-repos) simplifies openSUSE repository management by utilizing [Repository Index Service (RIS)](https://en.opensuse.org/openSUSE:Standards_Repository_Index_Service) for core distribution.
Current version utilizes the new [cdn.opensuse.org](https://code.opensuse.org/leap/features/issue/128).
This feature was originally requested as part of https://code.opensuse.org/leap/features/issue/91
## Example manual usage of zypper as
```
$ tree /somewhere # zypp expects repo/repoindex.xml
/somewhere
└── repo
└── repoindex.xml
$ zypper addservice /somewhere openSUSE # Use openSUSE prefix for all reposistories managed by service
$ zypper ref -s # optionally force refresh services
Repositories managed by zypp-services can be easily identified as they will have openSUSE: prefix (or any other that you have chosen).
```
## How to enable or disable source or debug repositories with openSUSE-repos
### Enabling / Disabling openSUSE source repo
```
$ sudo zypper modifyrepo -e openSUSE:repo-oss-source
Repository 'openSUSE:repo-oss-source' has been successfully enabled.
$ sudo zypper modifyrepo -d openSUSE:repo-oss-source
Repository 'openSUSE:repo-oss-source' has been successfully disabled.
```
### Enabling / Disabling openSUSE debug repo
```
$ sudo zypper modifyrepo -e openSUSE:repo-oss-debug
Repository 'openSUSE:repo-oss-debug' has been successfully enabled.
$ sudo zypper modifyrepo -d openSUSE:repo-oss-debug
Repository 'openSUSE:repo-oss-debug' has been successfully disabled.
```
### There is a typo in repository definition how can I fix it myself?
```
$ vim /usr/share/zypp/local/service/openSUSE/repo/repoindex.xml
$ zypper --gpg-auto-import-keys ref -s # to refresh services
```
## Restoring original distribution repositories
openSUSE-repos does backup of all existing default distribution repo files under /etc/zypp/repos.d/*.rpmsave
As of today uninstalling openSUSE-repos **will not** restore original distribution repo files.
You can restore original repo files by running following as root.
Note: You should not use rpmconf, as the original file was simply moved under a new name.
```
# zypper remove openSUSE-repos-*
# ls -la /etc/zypp/repos.d/*.rpmsave # review list of repos that will be restored
# for file in /etc/zypp/repos.d/*.rpmsave; do echo mv $file `echo $file | sed -s "s/\.rpmsave//"`; done
# zypper ref
```
## How to contribute?
Package is developed in [GitHub/openSUSE](https://github.com/openSUSE/openSUSE-repos/).
We have a [simple CI](https://github.com/openSUSE/openSUSE-repos/actions) which runs [repo_checks](https://github.com/openSUSE/openSUSE-repos/blob/main/checks/repo_checks) to ensure that paths are correct.
Package needs to be manually updated in [OBS](https://build.opensuse.org/package/show/Base:System/openSUSE-repos) once changes are merged in GitHub.
Make sure to install osc and required obs services by openSUSE-repos package
```
$ sudo zypper in openSUSE-release-tools obs-service-tar
```
Fork the repository in OBS, fetch latest request and make a submit request.
```
$ osc bco Base:System/openSUSE-repos
cd home:i*:branches:Base:System/openSUSE-repos
osc service runall
osc addremove
osc commit # changelog can be reviewed by osc vc
osc sr # submit request back to Base:System
```
Don't forget to send changes back to Tumbleweed and Leap once changes are merged to Base:System.
```
$ osc sr Base:System openSUSE-repos openSUSE:Factory
$ osc sr openSUSE:Factory openSUSE-repos openSUSE:Leap:15.6 # once merged to Factory
$ osc sr openSUSE:Factory openSUSE-repos openSUSE:Leap:16.0 # once merged to Factory
$ osc sr openSUSE:Factory openSUSE-repos openSUSE:Leap:Micro:6.0 # once merged to Factory
```
That's all. Happy Hacking
07070100000005000041ED0000000000000000000000026645FE3900000000000000000000000000000000000000000000002700000000openSUSE-repos-20240516.5431918/checks07070100000006000081ED0000000000000000000000016645FE39000009D4000000000000000000000000000000000000003300000000openSUSE-repos-20240516.5431918/checks/repo_checks#!/bin/bash
set -e
export CURRDIR="$(dirname -- "${BASH_SOURCE[0]}")"
for path in ${CURRDIR}/../*.xml; do
filename=`basename $path`
echo "Checking repo definitions in $filaname"
export disturl=`grep "disturl=" $path | awk -F"=" '{ print $2 }' | sed 's/"//g' | sed "s/'//g"`
export distsub=`grep "distsub=" $path | awk -F"=" '{ print $2 }' | sed 's/"//g' | sed "s/'//g"`
echo "[INFO] $filename disturl=${disturl}"
echo "[INFO] $filename distsub=${distsub}"
export distver="tumbleweed" # Default
export distarch="zsystems" # we expect s390x to be around
# Manually managed in the test
if [ "$distsub" == "leap" ]; then
export distver="15.5" # Should be bumped periodically
export distarch="armv7hl" # we expect s390x to be around
fi
if [ "$distsub" == "leap-micro" ]; then
export distver="5.5" # Should be bumped periodically
export distarch="aarch64" # or x86_64 would work too
fi
echo "[INFO] Using harcoded distver=$distver"
echo "[INFO] Using harcoded distarch=$distarch"
# Expand all variables in url paths and check if they exist
grep '<repo url' ${path} | while read line; do
url=`echo $line | awk -F"=" '{ print $2 }' | sed 's/"//g' | sed "s/'//g"`
#echo "url=${url}"
expanded_url=`echo $url \
| awk -v u="$distver" '{gsub(/%{distver}/,u)}1' \
| awk -v u="$disturl" '{gsub(/%{disturl}/,u)}1' \
| awk -v u="$distsub" '{gsub(/%{distsub}/,u)}1' \
| awk -v u="$distarch" '{gsub(/\\$DIST_ARCH/,u)}1'` # /etc/zypp/vars.d/DIST_ARCH ports and LEAPM are using it
echo "[INFO] expanded_url=$expanded_url"
# Check 1 - unexpanded zypp %{} variables
if [[ $expanded_url = *"%{"* ]]; then
echo "[ERROR] $filename - Unexpanded variable found in $expanded_url"
exit 1
fi
# Check 2 - Custom user variables, as of today we define only "$"
if [[ $expanded_url = *"$"* ]]; then
echo "[ERROR] $filename - Unexpanded shell \$ variable found in $expanded_url"
exit 2
fi
# Check 3 - URL availability
if curl --head --silent --fail "${expanded_url}/repodata/repomd.xml" > /dev/null 2>&1; then
echo "[OK] - $filename - Url "${expanded_url}/repodata/repomd.xml" exists."
else
echo "[ERROR] - $filename - Url "${expanded_url}/repodata/repomd.xml" does not exist."
exit 3
fi
done
done
07070100000007000081A40000000000000000000000016645FE390000014A000000000000000000000000000000000000003A00000000openSUSE-repos-20240516.5431918/nvidia-leap-repoindex.xml<repoindex ttl="0"
disturl="https://download.nvidia.com"
distsub="leap"
distver="${releasever}"
debugenable="false"
sourceenable="false">
<repo url="%{disturl}/opensuse/%{distsub}/%{distver}"
alias="repo-non-free"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
</repoindex>
07070100000008000081A40000000000000000000000016645FE390000011C000000000000000000000000000000000000003D00000000openSUSE-repos-20240516.5431918/nvidia-microos-repoindex.xml<repoindex ttl="0"
disturl="https://download.nvidia.com"
distsub="tumbleweed"
debugenable="false"
sourceenable="false">
<repo url="%{disturl}/opensuse/%{distsub}"
alias="repo-non-free"
name="%{alias}"
enabled="true"
autorefresh="true"/>
</repoindex>
07070100000009000081A40000000000000000000000016645FE390000011C000000000000000000000000000000000000003E00000000openSUSE-repos-20240516.5431918/nvidia-slowroll-repoindex.xml<repoindex ttl="0"
disturl="https://download.nvidia.com"
distsub="tumbleweed"
debugenable="false"
sourceenable="false">
<repo url="%{disturl}/opensuse/%{distsub}"
alias="repo-non-free"
name="%{alias}"
enabled="true"
autorefresh="true"/>
</repoindex>
0707010000000A000081A40000000000000000000000016645FE390000011C000000000000000000000000000000000000004000000000openSUSE-repos-20240516.5431918/nvidia-tumbleweed-repoindex.xml<repoindex ttl="0"
disturl="https://download.nvidia.com"
distsub="tumbleweed"
debugenable="false"
sourceenable="false">
<repo url="%{disturl}/opensuse/%{distsub}"
alias="repo-non-free"
name="%{alias}"
enabled="true"
autorefresh="true"/>
</repoindex>
0707010000000B000081A40000000000000000000000016645FE39000003CF000000000000000000000000000000000000004200000000openSUSE-repos-20240516.5431918/opensuse-leap-micro-repoindex.xml<repoindex ttl="0"
disturl="http://cdn.opensuse.org"
distsub="leap-micro"
distver="${releasever}"
debugenable="false"
sourceenable="false">
<repo url="%{disturl}/distribution/%{distsub}/%{distver}/product/repo/Leap-Micro-%{distver}-$DIST_ARCH-Media1"
alias="repo-main"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/distribution/%{distsub}/%{distver}/product/repo/Leap-Micro-%{distver}-$DIST_ARCH-Media2"
alias="repo-debug"
name="%{alias} (%{distver})"
enabled="false"
autorefresh="true"/>
<repo url="%{disturl}/distribution/%{distsub}/%{distver}/product/repo/Leap-Micro-%{distver}-$DIST_ARCH-Media3"
alias="repo-source"
name="%{alias} (%{distver})"
enabled="false"
autorefresh="true"/>
<repo url="%{disturl}/update/%{distsub}/%{distver}/sle"
alias="repo-sle-update"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
</repoindex>
0707010000000C000081A40000000000000000000000016645FE39000002BB000000000000000000000000000000000000004200000000openSUSE-repos-20240516.5431918/opensuse-leap-ports-repoindex.xml<repoindex ttl="0"
disturl="http://cdn.opensuse.org"
distsub="leap"
distver="${releasever}"
debugenable="false"
sourceenable="false">
<repo url="%{disturl}/ports/$DIST_ARCH/distribution/%{distsub}/%{distver}/repo/oss"
alias="repo-oss"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/source/distribution/%{distsub}/%{distver}/repo/oss"
alias="repo-oss-source"
name="%{alias} (%{distver})"
enabled="false"
autorefresh="true"/>
<repo url="http://codecs.opensuse.org/openh264/openSUSE_Leap"
alias="repo-openh264"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
</repoindex>
0707010000000D000081A40000000000000000000000016645FE3900000A09000000000000000000000000000000000000003C00000000openSUSE-repos-20240516.5431918/opensuse-leap-repoindex.xml<repoindex ttl="0"
disturl="http://cdn.opensuse.org"
distsub="leap"
distver="${releasever}"
debugenable="false"
sourceenable="false">
<repo url="%{disturl}/distribution/%{distsub}/%{distver}/repo/oss"
alias="repo-oss"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/debug/distribution/%{distsub}/%{distver}/repo/oss"
alias="repo-oss-debug"
name="%{alias} (%{distver})"
enabled="false"
autorefresh="true"/>
<repo url="%{disturl}/source/distribution/%{distsub}/%{distver}/repo/oss"
alias="repo-oss-source"
name="%{alias} (%{distver})"
enabled="false"
autorefresh="true"/>
<repo url="%{disturl}/distribution/%{distsub}/%{distver}/repo/non-oss"
alias="repo-non-oss"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/debug/distribution/%{distsub}/%{distver}/repo/non-oss"
alias="repo-non-oss-debug"
name="%{alias} (%{distver})"
enabled="false"
autorefresh="true"/>
<repo url="http://codecs.opensuse.org/openh264/openSUSE_Leap"
alias="repo-openh264"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/update/%{distsub}/%{distver}/oss"
alias="update-oss"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/debug/update/%{distsub}/%{distver}/oss"
alias="update-oss-debug"
name="%{alias} (%{distver})"
enabled="false"
autorefresh="true"/>
<repo url="%{disturl}/update/%{distsub}/%{distver}/non-oss"
alias="update-non-oss"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/debug/update/%{distsub}/%{distver}/non-oss"
alias="update-non-oss-debug"
name="%{alias} (%{distver})"
enabled="false"
autorefresh="true"/>
<repo url="%{disturl}/update/%{distsub}/%{distver}/backports"
alias="update-backports"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/update/%{distsub}/%{distver}/backports_debug"
alias="update-backports-debug"
name="%{alias} (%{distver})"
enabled="false"
autorefresh="true"/>
<repo url="%{disturl}/update/%{distsub}/%{distver}/sle"
alias="update-sle"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/debug/update/%{distsub}/%{distver}/sle"
alias="update-sle-debug"
name="%{alias} (%{distver})"
enabled="false"
autorefresh="true"/>
</repoindex>
0707010000000E000081A40000000000000000000000016645FE39000003E1000000000000000000000000000000000000003F00000000openSUSE-repos-20240516.5431918/opensuse-microos-repoindex.xml<repoindex ttl="0"
disturl="http://cdn.opensuse.org"
distsub="tumbleweed"
debugenable="false"
sourceenable="false">
<repo url="%{disturl}/%{distsub}/repo/oss"
alias="repo-oss"
name="%{alias}"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/debug/%{distsub}/repo/oss"
alias="repo-oss-debug"
name="%{alias}"
enabled="false"
autorefresh="true"/>
<repo url="%{disturl}/source/%{distsub}/repo/oss"
alias="repo-oss-source"
name="%{alias}"
enabled="false"
autorefresh="true"/>
<repo url="%{disturl}/%{distsub}/repo/non-oss"
alias="repo-non-oss"
name="%{alias}"
enabled="true"
autorefresh="true"/>
<repo url="http://codecs.opensuse.org/openh264/openSUSE_Tumbleweed"
alias="repo-openh264"
name="%{alias}"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/update/%{distsub}"
alias="update-tumbleweed"
name="%{alias}"
enabled="true"
autorefresh="true"/>
</repoindex>
0707010000000F000081A40000000000000000000000016645FE39000003FD000000000000000000000000000000000000004000000000openSUSE-repos-20240516.5431918/opensuse-slowroll-repoindex.xml<repoindex ttl="0"
disturl="http://download.opensuse.org"
distsub="slowroll"
debugenable="false"
sourceenable="false">
<repo url="%{disturl}/%{distsub}/repo/oss"
alias="repo-oss"
name="%{alias}"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/debug/%{distsub}/repo/oss"
alias="repo-oss-debug"
name="%{alias}"
enabled="false"
autorefresh="true"/>
<repo url="%{disturl}/source/%{distsub}/repo/oss"
alias="repo-oss-source"
name="%{alias}"
enabled="false"
autorefresh="true"/>
<repo url="%{disturl}/%{distsub}/repo/non-oss"
alias="repo-non-oss"
name="%{alias}"
enabled="true"
autorefresh="true"/>
<repo url="http://codecs.opensuse.org/openh264/openSUSE_Tumbleweed"
alias="repo-openh264"
name="%{alias}"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/update/%{distsub}/repo/oss"
alias="update-slowroll"
name="%{alias}"
enabled="true"
priority="80"
autorefresh="true"/>
</repoindex>
07070100000010000081A40000000000000000000000016645FE39000003D4000000000000000000000000000000000000004800000000openSUSE-repos-20240516.5431918/opensuse-tumbleweed-ports-repoindex.xml<repoindex ttl="0"
disturl="https://download.opensuse.org"
distsub="tumbleweed"
debugenable="false"
sourceenable="false">
<repo url="%{disturl}/ports/$DIST_ARCH/%{distsub}/repo/oss"
alias="repo-oss"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/ports/$DIST_ARCH/debug/%{distsub}/repo/oss"
alias="repo-oss-debug"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/ports/$DIST_ARCH/source/%{distsub}/repo/oss"
alias="repo-oss-source"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
<repo url="http://codecs.opensuse.org/openh264/openSUSE_Tumbleweed"
alias="repo-openh264"
name="%{alias} (%{distver})"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/ports/$DIST_ARCH/update/%{distsub}"
alias="update-tumbleweed"
name="%{alias}"
enabled="true"
autorefresh="true"/>
</repoindex>
07070100000011000081A40000000000000000000000016645FE39000003E1000000000000000000000000000000000000004200000000openSUSE-repos-20240516.5431918/opensuse-tumbleweed-repoindex.xml<repoindex ttl="0"
disturl="http://cdn.opensuse.org"
distsub="tumbleweed"
debugenable="false"
sourceenable="false">
<repo url="%{disturl}/%{distsub}/repo/oss"
alias="repo-oss"
name="%{alias}"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/debug/%{distsub}/repo/oss"
alias="repo-oss-debug"
name="%{alias}"
enabled="false"
autorefresh="true"/>
<repo url="%{disturl}/source/%{distsub}/repo/oss"
alias="repo-oss-source"
name="%{alias}"
enabled="false"
autorefresh="true"/>
<repo url="%{disturl}/%{distsub}/repo/non-oss"
alias="repo-non-oss"
name="%{alias}"
enabled="true"
autorefresh="true"/>
<repo url="http://codecs.opensuse.org/openh264/openSUSE_Tumbleweed"
alias="repo-openh264"
name="%{alias}"
enabled="true"
autorefresh="true"/>
<repo url="%{disturl}/update/%{distsub}"
alias="update-tumbleweed"
name="%{alias}"
enabled="true"
autorefresh="true"/>
</repoindex>
07070100000012000041ED0000000000000000000000026645FE3900000000000000000000000000000000000000000000002200000000openSUSE-repos-20240516.5431918/t07070100000013000081ED0000000000000000000000016645FE39000001E9000000000000000000000000000000000000003300000000openSUSE-repos-20240516.5431918/t/01-tumbleweed.sh#!lib/test-in-container-systemd.sh tumbleweed
set -e
mkdir -p /usr/share/zypp/local/service/openSUSE/repo/
ln -sf /opt/project/opensuse-tumbleweed-repoindex.xml /usr/share/zypp/local/service/openSUSE/repo/repoindex.xml
zypper addservice /usr/share/zypp/local/service/openSUSE/ openSUSE
zypper -vvv ref -s
grep -r baseurl /etc/zypp/repos.d
grep -r baseurl /etc/zypp/repos.d | grep -q cdn.opensuse.org
# make sure we can install a random package
zypper -vvvn in vim-small
echo success
07070100000014000081ED0000000000000000000000016645FE39000004AC000000000000000000000000000000000000002D00000000openSUSE-repos-20240516.5431918/t/02-leap.sh#!lib/test-in-container-systemd.sh leap
set -e
mkdir -p /usr/share/zypp/local/service/openSUSE/repo/
ln -sf /opt/project/opensuse-leap-repoindex.xml /usr/share/zypp/local/service/openSUSE/repo/repoindex.xml
zypper addservice /usr/share/zypp/local/service/openSUSE/ openSUSE
echo =======================
curl -is https://cdn.opensuse.org/update/leap/15.5/sle/repodata/repomd.xml
curl -is https://download.opensuse.org/update/leap/15.5/sle/repodata/repomd.xml
echo =======================
curl -is https://cdn.opensuse.org/update/leap/15.5/sle/repodata/repomd.xml.key
curl -is https://download.opensuse.org/update/leap/15.5/sle/repodata/repomd.xml.key
echo =======================
curl -is https://cdn.opensuse.org/update/leap/15.5/sle/repodata/repomd.xml.asc
curl -is https://download.opensuse.org/update/leap/15.5/sle/repodata/repomd.xml.asc
echo =======================
echo =======================
zypper -vvv ref -s || ( tail -n 200 /var/log/zypper.log && ( sleep 1; exit 1 ) )
echo =======================
grep -r baseurl /etc/zypp/repos.d
grep -r baseurl /etc/zypp/repos.d | grep -q cdn.opensuse.org
# make sure we can install a random package
zypper -vvvn in vim-small
echo success
07070100000015000081A40000000000000000000000016645FE390000005A000000000000000000000000000000000000002B00000000openSUSE-repos-20240516.5431918/t/Makefile
test_container:
( for f in *.sh; do ./$$f && continue; echo FAIL $$f; exit 1 ; done )
07070100000016000081A40000000000000000000000016645FE3900000464000000000000000000000000000000000000002C00000000openSUSE-repos-20240516.5431918/t/README.mdScripts to test using podman containers
-------------------
The goal is to cover following workflow:
* Change xml files.
* Spawn a container, add zypper service.
* Check basic installation of a package to verify outcome.
The test is set of bash commands.
The script relies on shebang to prepare an image and spawn a container.
###### Example: Run test for mysql states:
```bash
cd t
./01-tumbleweed.sh
```
#### By default, a container is destroyed when the test finishes.
This is to simplify re-run of tests and do not flood machine with leftover containers after tests.
To make sure container stays around after faiure - set environment variable *T_PAUSE_ON_FAILURE* to 1
###### Example: Connect to the container after test failure
```bash
> # terminal 1
> echo fail >> 01-tumbleweed.sh
> T_PAUSE_ON_FAILURE=1 ./01-tumbleweed.sh
...
bash: line 18: fail: command not found
Test failed, press any key to finish
```
The terminal will wait for any input to finish the test and clean up the container.
Now use another terminal window to check the running podman container and get into it for eventual troubleshooting:
07070100000017000041ED0000000000000000000000026645FE3900000000000000000000000000000000000000000000002600000000openSUSE-repos-20240516.5431918/t/lib07070100000018000081ED0000000000000000000000016645FE39000009E1000000000000000000000000000000000000004300000000openSUSE-repos-20240516.5431918/t/lib/test-in-container-systemd.sh#!/bin/bash
#
# Copyright (C) 2024 SUSE LLC
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.
last=${@:$#} # last parameter
other=${*%${!#}} # all parameters except the last
other=$(echo $other) # remove trailing space
image="${other##* }"
set -euo pipefail
test "$image" != "" || (echo empty image, exiting; exit 1)
testcase=$last
PODMAN=podman
(
PODMAN_info="$($PODMAN info >/dev/null 2>&1)" || $PODMAN info
[ -n "$testcase" ] || (echo No testcase provided; exit 1)
[ -f "$testcase" ] || (echo Cannot find file "$testcase"; exit 1 )
) >&2
thisdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
basename=$(basename "$testcase")
basename=${basename,,}
basename=${basename//:/_}
ident=opensuse.repo.t.$image
containername="$ident.${basename,,}"
echo image=$image
(
echo image2=$image
)
(
echo FROM registry.opensuse.org/opensuse/$image
cat << EOF
ENV container podman
ENV LANG en_US.UTF-8
RUN zypper -vvvn install systemd
WORKDIR /opt/project
# ENTRYPOINT ["tail", "-f", "/dev/null"]
ENTRYPOINT ["/usr/lib/systemd/systemd"]
EOF
) | $PODMAN build -t $ident.image -f - $thisdir/../..
$PODMAN run --privileged --rm --name "$containername" -d -v"$thisdir/../..":/opt/project -- $ident.image
in_cleanup=0
ret=111
function cleanup {
[ "$in_cleanup" != 1 ] || return
in_cleanup=1
if [ "$ret" != 0 ] && [ -n "${T_PAUSE_ON_FAILURE-}" ]; then
read -rsn1 -p"Test failed, press any key to finish";echo
fi
[ "$ret" == 0 ] || echo FAIL $basename
$PODMAN stop -t 0 "$containername" >&/dev/null || :
}
trap cleanup INT TERM EXIT
counter=1
# wait container start
until [ $counter -gt 10 ]; do
sleep 0.5
$PODMAN exec "$containername" pwd >& /dev/null && break
((counter++))
done
$PODMAN exec "$containername" pwd >& /dev/null || (echo Cannot start container; exit 1 ) >&2
set +e
$PODMAN exec -e TESTCASE="$testcase" -i "$containername" bash -xe < "$testcase"
ret=$?
( exit $ret )
07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!53 blocks