diff --git a/README b/README
index c7241ca..5459fce 100644
--- a/README
+++ b/README
@@ -2,7 +2,44 @@ obs-service-docker_label_helper
===============================
This service can be enabled to run during buildtime, when it will edit the
-Dockerfile to expand the PREFIXEDLABEL instruction.
+Dockerfile to expand the LABEL instruction.
+
+A new syntax using entry/exit flags has been introduced to provide
+compatibility with stock docker build command while allowing OBS
+to add its prefix to existing LABEL instructions values.
+
+Both new and old syntax are supported, but you should not mix both in the
+same Dockerfile.
+
+1 - New syntax using entry/exit flags
+
+Only LABEL between # labelprefix and # endlabelprefix will be considered
+
+Example:
+
+```
+FROM opensuse/tumbleweed
+# labelprefix=org.opensuse.nano
+LABEL org.opencontainers.image.title="Example container"
+LABEL org.opencontainers.image.description="This contains nano"
+# endlabelprefix
+LABEL not.expanded.label="example
+```
+
+expands to
+
+```
+FROM opensuse/tumbleweed
+LABEL org.opensuse.nano.title="Example container"
+LABEL org.opencontainers.image.title="Example container"
+LABEL org.opensuse.nano.description="This contains nano"
+LABEL org.opencontainers.image.description="This contains nano"
+LABEL not.expanded.label="example"
+```
+
+2 - Old syntax
+
+Expand the PREFIXEDLABEL instruction.
Example:
diff --git a/docker_label_helper b/docker_label_helper
index f0cae5b..03e5af1 100644
--- a/docker_label_helper
+++ b/docker_label_helper
@@ -20,6 +20,7 @@ if [ -e "${BUILD_DATA}" ]; then
fi
gawk -i inplace '
- match($0, /^# labelprefix=(.*)$/, m) { labelprefix=m[1]; next }
- labelprefix != "" && match($0, /^PREFIXEDLABEL .*\.([^.]*)=(.*)$/, m) { printf "LABEL %s.%s=%s\n", labelprefix, m[1], m[2]; $1 = "LABEL" }
- 1' Dockerfile
+ match($0, /^# labelprefix=(.*)$/, m) { labelprefix=m[1]; next }
+ labelprefix != "" && match($0, /^(PREFIXED)?LABEL .*\.([^.]*)=(.*)$/, m) { printf "LABEL %s.%s=%s\n", labelprefix, m[2], m[3]; $1 = "LABEL" }
+ match($0, /^# endlabelprefix/) { labelprefix=""; next }
+ 1' Dockerfile
diff --git a/docker_label_helper.service b/docker_label_helper.service
index 29af0f5..68aa4e9 100644
--- a/docker_label_helper.service
+++ b/docker_label_helper.service
@@ -1,4 +1,4 @@
Allows automatic duplication of labels with a custom prefix.
- Implements the PREFIXEDLABEL pseudo command for Dockerfile.
+ Expand LABEL instructions with mandatory openSUSE prefixes for Dockerfile.
diff --git a/obs-service-docker_label_helper.changes b/obs-service-docker_label_helper.changes
index bb6f82e..6663c54 100644
--- a/obs-service-docker_label_helper.changes
+++ b/obs-service-docker_label_helper.changes
@@ -1,3 +1,20 @@
+-------------------------------------------------------------------
+Fri Jul 23 08:50:08 UTC 2021 - Bruno Leon
+
+- Improve regexp instead of having two as proposed by Fabian Vogt
+
+-------------------------------------------------------------------
+Wed Jul 21 10:38:53 UTC 2021 - Bruno Leon
+
+- Retain compatibility with old syntax. Update documentation.
+
+-------------------------------------------------------------------
+Tue Jul 20 14:28:28 UTC 2021 - Bruno Leon
+
+- Use entry/exit point to determine whether labels should be expanded.
+ Doing so makes the Dockerfile compatible with standard
+ docker build command.
+
-------------------------------------------------------------------
Fri Sep 11 10:07:44 UTC 2020 - Fabian Vogt
diff --git a/obs-service-docker_label_helper.spec b/obs-service-docker_label_helper.spec
index 7e8d43c..3ca00b8 100644
--- a/obs-service-docker_label_helper.spec
+++ b/obs-service-docker_label_helper.spec
@@ -1,7 +1,7 @@
#
# spec file for package obs-service-docker_label_helper
#
-# Copyright (c) 2020 SUSE LLC
+# 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
@@ -33,8 +33,8 @@ BuildArch: noarch
BuildRequires: diffutils
%description
-This service can be used during buildtime to implement the
-PREFIXEDLABEL instruction useful for building containers.
+This service can be used during buildtime to expand LABEL
+instructions with mandatory openSUSE prefixes.
%prep
%setup -q -D -T -n .
diff --git a/test.sh b/test.sh
index f6ba6e0..ff57c61 100644
--- a/test.sh
+++ b/test.sh
@@ -7,6 +7,7 @@ script="$(realpath "$(dirname $0)")/docker_label_helper"
cd $tmpdir
+# Test old syntax
cat >Dockerfile <Dockerfile <