osc copypac from project:home:vulyanov package:obs-service-replace_using_env revision:2
OBS-URL: https://build.opensuse.org/package/show/Virtualization/obs-service-replace_using_env?expand=0&rev=1
This commit is contained in:
commit
e338628f5a
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
## Default LFS
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.osc
|
7
README
Normal file
7
README
Normal file
@ -0,0 +1,7 @@
|
||||
obs-service-replace_using_env
|
||||
=============================
|
||||
|
||||
This service can be enabled to run during buildtime, when it will replace the
|
||||
specified placeholders in the given files with the values obtained from the
|
||||
build environment. Additionally it will eval all the bash commands that are
|
||||
provided before doing the substitution.
|
9
obs-service-replace_using_env.changes
Normal file
9
obs-service-replace_using_env.changes
Normal file
@ -0,0 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 16 08:33:01 UTC 2021 - Vasily Ulyanov <vasily.ulyanov@suse.com>
|
||||
|
||||
- Add meta info for virt-containers
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Mar 15 06:27:20 UTC 2021 - Vasily Ulyanov <vasily.ulyanov@suse.com>
|
||||
|
||||
- Initial commit
|
53
obs-service-replace_using_env.spec
Normal file
53
obs-service-replace_using_env.spec
Normal file
@ -0,0 +1,53 @@
|
||||
#
|
||||
# spec file for package obs-service-replace_using_env
|
||||
#
|
||||
# Copyright (c) 2021 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
# upon. The license for this file, and modifications and additions to the
|
||||
# file, is the same license as for the pristine package itself (unless the
|
||||
# license for the pristine package is not an Open Source License, in which
|
||||
# case the license is the MIT License). An "Open Source License" is a
|
||||
# license that conforms to the Open Source Definition (Version 1.9)
|
||||
# published by the Open Source Initiative.
|
||||
|
||||
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
|
||||
Name: obs-service-replace_using_env
|
||||
Version: 0.1
|
||||
Release: 0
|
||||
Summary: Service for variables substitution
|
||||
License: GPL-2.0-or-later
|
||||
URL: https://build.opensuse.org/
|
||||
Source0: replace_using_env
|
||||
Source1: replace_using_env.service
|
||||
Source2: README
|
||||
Source3: virt-containers-meta
|
||||
Requires: bash
|
||||
Requires: sed
|
||||
BuildArch: noarch
|
||||
|
||||
%description
|
||||
This service can be enabled to run during buildtime to replace the placeholders
|
||||
in the specified files with the values from the build environment.
|
||||
|
||||
%prep
|
||||
cp %{SOURCE2} .
|
||||
|
||||
%build
|
||||
|
||||
%install
|
||||
mkdir -p %{buildroot}%{_prefix}/lib/obs/service/meta
|
||||
install -m 0755 %{SOURCE0} %{buildroot}%{_prefix}/lib/obs/service
|
||||
install -m 0644 %{SOURCE1} %{buildroot}%{_prefix}/lib/obs/service
|
||||
install -m 0755 %{SOURCE3} %{buildroot}%{_prefix}/lib/obs/service/meta
|
||||
|
||||
%files
|
||||
%doc README
|
||||
%dir %{_prefix}/lib/obs
|
||||
%{_prefix}/lib/obs/service
|
||||
|
||||
%changelog
|
50
replace_using_env
Normal file
50
replace_using_env
Normal file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
VARS=()
|
||||
FILES=()
|
||||
VERBOSE=
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
param="$1"
|
||||
arg="$2"
|
||||
|
||||
case "${param}" in
|
||||
--eval)
|
||||
eval "${arg}"
|
||||
shift 2
|
||||
;;
|
||||
--var)
|
||||
VARS+=(${arg})
|
||||
shift 2
|
||||
;;
|
||||
--file)
|
||||
FILES+=(${arg})
|
||||
shift 2
|
||||
;;
|
||||
--verbose)
|
||||
VERBOSE=1
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
echo "Ignoring unknown parameter: ${param}"
|
||||
shift
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ${#FILES[@]} -eq 0 ]; then
|
||||
echo "No input files"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for var in ${VARS[@]}; do
|
||||
echo "Replacing '${var}' with '${!var}'"
|
||||
sed -i"" \
|
||||
-e "s#%%${var}%%#${!var}#g" \
|
||||
"${FILES[@]}"
|
||||
done
|
||||
|
||||
if [ -n "${VERBOSE}" ]; then
|
||||
cat ${FILES[@]}
|
||||
fi
|
5
replace_using_env.service
Normal file
5
replace_using_env.service
Normal file
@ -0,0 +1,5 @@
|
||||
<service name="replace_using_env">
|
||||
<summary>Replace placeholder variables</summary>
|
||||
<description>Replaces placeholders %%VAR%% in specified files with the
|
||||
values from the build environment ${VAR}.</description>
|
||||
</service>
|
17
virt-containers-meta
Normal file
17
virt-containers-meta
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
distro=$(rpm --eval '%{?sle_version}:%{?is_opensuse}%{!?is_opensuse:0}')
|
||||
case "${distro}" in
|
||||
150200:0)
|
||||
TAGPREFIX=suse/sles/15.2
|
||||
LABELPREFIX=com.suse.kubevirt
|
||||
;;
|
||||
150300:0)
|
||||
TAGPREFIX=suse/sles/15.3
|
||||
LABELPREFIX=com.suse.kubevirt
|
||||
;;
|
||||
*)
|
||||
TAGPREFIX=opensuse/tumbleweed
|
||||
LABELPREFIX=org.opensuse.kubevirt
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue
Block a user