Opened 8 years ago

Closed 4 years ago

#1979 closed enhancement (invalid)

Make utility functions for finding common resources

Reported by: muks Owned by: UnAssigned
Priority: medium Milestone: Remaining BIND10 tickets
Component: build system Version: git
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: N/A
Sub-Project: Core Feature Depending on Ticket:
Estimated Difficulty: 0 Add Hours to Ticket: 0
Total Hours: 0 Internal?: no

Description

This bug comes from #1628. Currently, a lot of the components have code like this:

# If B10_FROM_SOURCE is set in the environment, we use data files
# from a directory relative to that, otherwise we use the ones
# installed on the system
if "B10_FROM_SOURCE" in os.environ:
    SPECFILE_LOCATION = os.environ["B10_FROM_SOURCE"] + os.sep + \
        "src" + os.sep + "bin" + os.sep + "ddns" + os.sep + "ddns.spec"
else:
    PREFIX = "@prefix@"
    DATAROOTDIR = "@datarootdir@"
    SPECFILE_LOCATION = "@datadir@" + os.sep + "@PACKAGE@" + os.sep + "ddns.spec"
    SPECFILE_LOCATION = SPECFILE_LOCATION.replace("${datarootdir}", DATAROOTDIR)\
        .replace("${prefix}", PREFIX)

SOCKET_FILE = bind10_config.DATA_PATH + '/ddns_socket'
if "B10_FROM_BUILD" in os.environ:
    if "B10_FROM_SOURCE_LOCALSTATEDIR" in os.environ:
        SOCKET_FILE = os.environ["B10_FROM_SOURCE_LOCALSTATEDIR"] + \
            "/ddns_socket"
    else:
        SOCKET_FILE = os.environ["B10_FROM_BUILD"] + "/ddns_socket"

It is duplicated code, which is inconsistent in the various copies. Any change in our process (where we install things, or the env variable we use to override settings) would mean editing many files. We should ideally have utility functions such as one that returns a path to the spec file when passed the name of the component.

Subtickets

Change History (4)

comment:1 Changed 8 years ago by jelte

BTW, I once added the src/lib/python/bind10_config.py[.in] file, with the intent to start using that for configure-time variables (instead of generating other python files). We never really gotten around to start using that for most of the currently generated files, and I'm not suggesting we do so in this ticket, but perhaps this would be a good place for such shared path derivation code.

comment:2 Changed 8 years ago by shane

  • Component changed from Unclassified to build system
  • Milestone changed from New Tasks to Non-Development-2012Q2
  • Owner set to UnAssigned
  • Sub-Project changed from DNS to Core

comment:3 Changed 6 years ago by tomek

  • Milestone set to Remaining BIND10 tickets

comment:4 Changed 4 years ago by tomek

  • Resolution set to invalid
  • Status changed from new to closed
  • Version set to git

We don't have any python code in Kea anymore. No longer applicable, closing ticket.

Note: See TracTickets for help on using tickets.