Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15:Update
obs-service-kiwi_metainfo_helper.32498
kiwi_metainfo_helper
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File kiwi_metainfo_helper of Package obs-service-kiwi_metainfo_helper.32498
#!/bin/bash # Not using -o pipefail, as SIGPIPE is annoying to deal with set -eu shopt -s nullglob if [ "${BUILD_DIST+x}" != "x" ]; then echo "Not running in an OBS build container" exit 1 fi BUILD_DATA="${BUILD_DIST/.dist/.data}" if [ -e "${BUILD_DATA}" ]; then . "${BUILD_DATA}" BUILD_ARCH="${BUILD_ARCH%%:*}" # The build script renames the recipe (to strip _service:foo:), but doesn't update .data RECIPEFILE="${RECIPEFILE##*:}" if [ "${RECIPEFILE##*.}" != "kiwi" ] && [ "${RECIPEFILE}" != "Dockerfile" ] && [ "${RECIPEFILE}" != "Chart.yaml" ]; then echo "Recipe is neither Dockerfile, kiwi recipe nor helm chart - exiting" exit 0 fi files=("${RECIPEFILE}") else echo "Warning: No build data found - chroot build?" DISTURL="local" RELEASE=0 BUILD_ARCH="noarch" # Guess the build recipe files=(*.kiwi Dockerfile* Chart.yaml*) if [ "${#files}" -eq 0 ]; then echo "No kiwi recipe, Dockerfile or helm chart found - exiting" exit 0 fi fi # generate %SOURCEURL% based on DISTURL with a special case for build.suse.de prj=$(echo ${DISTURL} | cut -d/ -f4) localpath=$(echo ${DISTURL} | cut -d/ -f6-) rev=$(echo ${localpath} | cut -d- -f1) packagename=$(echo ${localpath} | cut -d- -f2- | cut -d: -f1) if [[ "${DISTURL}" == obs://build.suse.de/* ]]; then SOURCEURL="https://sources.suse.com/${prj}/${packagename}/${rev}/" else SOURCEURL="https://$(echo ${DISTURL} | cut -d/ -f3)/package/show/${prj}/${packagename}?rev=${rev}" fi # Print all rpm files which contain os-release find_release_rpms() { find ./repos -name \*-release\*.rpm | while read rpm; do if rpm -qlp "${rpm}" | grep -qE '^(/etc/os-release|/usr/lib/os-release)$'; then echo "${rpm}" fi done } if grep -q "%OS_" ${files[@]}; then # Needs os-release, search for RPMs relpkgs=($(find_release_rpms)) if [ ${#relpkgs[@]} -lt 1 ]; then echo "No release package found, but recipe uses %OS_*% placeholders" exit 1 fi if [ ${#relpkgs[@]} -gt 1 ]; then echo "Multiple release packages found, don't know which os-release to use" exit 1 fi # Extract the content tempdir=$(mktemp -d) trap "rm -r ${tempdir}" EXIT rpm2cpio "${relpkgs[0]}" | (cd "${tempdir}" && cpio -id) # And source it [ -f "${tempdir}/usr/lib/os-release" ] && . "${tempdir}/usr/lib/os-release" [ -f "${tempdir}/etc/os-release" ] && . "${tempdir}/etc/os-release" VERSION="${VERSION:-}" VERSION_NO_DASH="${VERSION/-/ }" # Special case for SLE X "SP 0", make sure it has .0 VERSION_ID_SP="${VERSION_ID}" [[ "${VERSION_ID_SP%}" == *"."* ]] || VERSION_ID_SP="${VERSION_ID}.0" # Provide various modified spellings of PRETTY_NAME useful for writing # KIWI image definitions with reduced diff between SLE, Leap and Tumbleweed: # # VENDOR: openSUSE # PRETTY_NAME_DASHED: openSUSE-Leap-15.3 # PRETTY_NAME_BEFORE_PAREN: openSUSE Leap 15.3 # PRETTY_NAME_BEFORE_PAREN_DASHED: openSUSE-Leap-15.3 # # VENDOR: SUSE # PRETTY_NAME_DASHED: SUSE-Linux-Enterprise-Server-15-SP3-Snapshot-16 # PRETTY_NAME_BEFORE_PAREN: SUSE Linux Enterprise Server 15 SP3 # PRETTY_NAME_BEFORE_PAREN_DASHED: SUSE-Linux-Enterprise-Server-15-SP3 # First word of PRETTY_NAME, typically used as vendor name e.g. SUSE or openSUSE. VENDOR="${PRETTY_NAME%% *}" # KIWI image name attribute must not contain spaces, replace with dash PRETTY_NAME_DASHED="${PRETTY_NAME//[^[:alnum:].]/-}" # Remove repeated dashes from parentheses surrounding SLE release labels PRETTY_NAME_DASHED="${PRETTY_NAME_DASHED//--/-}" # Remove dash at end from parentheses surrounding SLE release labels PRETTY_NAME_DASHED="${PRETTY_NAME_DASHED%%-}" # Special case for SLE release labels e.g. RC1. Keep only up to (space) open paren. # Provides a stable project name for third-party integrations e.g. app store submissions PRETTY_NAME_BEFORE_PAREN="${PRETTY_NAME// (*/}" # KIWI image name attribute must not contain spaces, replace with dash PRETTY_NAME_BEFORE_PAREN_DASHED="${PRETTY_NAME_BEFORE_PAREN//[^[:alnum:].]/-}" sed -i"" \ -e "s/%OS_VERSION_ID%/${VERSION_ID}/g" \ -e "s/%OS_PRETTY_NAME%/${PRETTY_NAME}/g" \ -e "s/%OS_VENDOR%/${VENDOR}/g" \ -e "s/%OS_PRETTY_NAME_DASHED%/${PRETTY_NAME_DASHED}/g" \ -e "s/%OS_PRETTY_NAME_BEFORE_PAREN%/${PRETTY_NAME_BEFORE_PAREN}/g" \ -e "s/%OS_PRETTY_NAME_BEFORE_PAREN_DASHED%/${PRETTY_NAME_BEFORE_PAREN_DASHED}/g" \ -e "s/%OS_VERSION%/${VERSION}/g" \ -e "s/%OS_VERSION_NO_DASH%/${VERSION_NO_DASH}/g" \ -e "s/%OS_VERSION_ID_SP%/${VERSION_ID_SP}/g" "${files[@]}" fi sed -i"" \ -e "s#%DISTURL%#${DISTURL}#g" \ -e "s#%SOURCEURL%#${SOURCEURL}#g" \ -e "s/%RELEASE%/${RELEASE}/g" \ -e "s/%ARCH%/${BUILD_ARCH}/g" \ -e "s/%BUILDTIME%/$(date --utc +%FT%T.%NZ)/g" "${files[@]}"
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor