Bug 1283017

Summary: [rfe] support braces in variable substitution
Product: [Fedora] Fedora Reporter: Dave Johansen <davejohansen>
Component: dnfAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: jsilhan, mluscon, packaging-team-maint, pnemade, vmukhame
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-1.1.5-1.fc23 dnf-1.1.5-1.fc22 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-12-22 21:59:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dave Johansen 2015-11-18 03:48:13 UTC
Description of problem:
dnf does not allow braces in variable substitution and makes it impossible to use with certain URLs in COPR ( see https://lists.fedoraproject.org/pipermail/devel/2015-October/215924.html ).

Version-Release number of selected component (if applicable):
Version used by COPR (not sure what it is).

How reproducible:
Always

Steps to Reproduce:
1. Use a variable with braces in a URL on COPR
2. Notice that variable is not expanded

Actual results:
Variable is not expanded with braces

Expected results:
Variable should be expanded with braces

Additional info:
Here's a Python script with several attempts at updating the regular expression ( see https://github.com/rpm-software-management/dnf/blob/bcbf36cbf140eb8a2a1e496e294b0c5102294446/dnf/conf/parser.py ) to support braces. My regex skills are pretty weak, so none of them are a the fully solution that I would hope for.

import re

_KEYCRE = re.compile(r"\${?(\w+)}?")
#_KEYCRE = re.compile(r"\$(\w+)|\${(\w+)}")
#_KEYCRE = re.compile(r'\$([{}]?)releasever\1')

def do_test(r, s):
    print s
    m = r.search(s)
    if m:
        print "Found", m.group(1), m.group()
    else:
        print "Negative"

do_test(_KEYCRE, 'this is a test of $releasever with spaces no braces')
do_test(_KEYCRE, 'this is a test of ${releasever} {with} spaces and braces')
do_test(_KEYCRE, 'this is a test of ${releasever}without spaces and braces')
do_test(_KEYCRE, 'this is a test of ${releasever with only left brace')
do_test(_KEYCRE, 'this is a test of $releasever} with only right brace')

Comment 1 Honza Silhan 2015-11-18 14:26:30 UTC
we can support that. (If you wanna speed things up you can send a pull request [1] with tests inside dnf/tests)

[1] https://github.com/rpm-software-management/dnf

Comment 2 Dave Johansen 2015-11-19 03:12:51 UTC
I created a pull request with the change and some added tests:
https://github.com/rpm-software-management/dnf/pull/387

Comment 3 Fedora Update System 2015-12-18 17:47:04 UTC
dnf-plugins-core-0.1.15-1.fc23 dnf-1.1.5-1.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2015-c72cd24fa0

Comment 4 Fedora Update System 2015-12-18 17:48:46 UTC
dnf-plugins-core-0.1.15-1.fc22 dnf-1.1.5-1.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2015-1bb112ccc6

Comment 5 Fedora Update System 2015-12-19 19:59:38 UTC
dnf-1.1.5-1.fc23, dnf-plugins-core-0.1.15-1.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
$ su -c 'dnf --enablerepo=updates-testing update dnf dnf-plugins-core'
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-c72cd24fa0

Comment 6 Fedora Update System 2015-12-22 15:35:20 UTC
dnf-1.1.5-1.fc22, dnf-plugins-core-0.1.15-1.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-1bb112ccc6

Comment 7 Fedora Update System 2015-12-22 21:58:53 UTC
dnf-1.1.5-1.fc23, dnf-plugins-core-0.1.15-1.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Comment 8 Fedora Update System 2016-01-04 19:52:11 UTC
dnf-1.1.5-1.fc22, dnf-plugins-core-0.1.15-1.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.