#9 Read in values from os-release if present.
Opened 7 years ago by jcpunk. Modified 7 years ago
jcpunk/install-guide from-os-release  into  master

@@ -1,9 +1,3 @@ 

- <!ENTITY PRODUCT "Fedora">

- <!ENTITY NEXTVER "26">

- <!ENTITY PRODVER "25">

- <!ENTITY PREVVER "24">

  <!ENTITY BOOKID "install-guide">

- <!ENTITY YEAR "2016">

  <!ENTITY HOLDER "Red Hat, Inc. and others">

- <!ENTITY BZURL "<ulink url='https://bugzilla.redhat.com/enter_bug.cgi?product=&PRODUCT;&amp;component=&BOOKID;'>https://bugzilla.redhat.com</ulink>" >

  <!ENTITY IGURL '<ulink url="http://docs.fedoraproject.org/" />'>

@@ -5,6 +5,9 @@ 

  import shutil

  import glob

  import subprocess

+ import platform

+ import datetime

+ 

  # we are using lxml as unlike in the Python built-in ElementTree elements

  # in the lxml tree know their parents - this is handy when removing the figure tags

  from lxml import etree as ET
@@ -12,6 +15,7 @@ 

  PLACEHOLDERS = ["FedoraPlaceholderWithLinks.html", "FedoraPlaceholder.html", "FedoraPlaceholder.txt"]

  INPUT_FOLDER = "en-US"

  OUTPUT_FOLDER = "anaconda_help_content/en-US"

+ XML_DEFINES = "Installation_Guide.ent"

  

  # list of the XML help content & supporting files Anaconda currently cares about

  ANACONDA_HELP_FILES = [
@@ -79,6 +83,27 @@ 

          print("WARNING: required file %s is missing" % origin)

      shutil.copy(origin, destination)

  

+ print("setting platform specifics")

+ linux_distribution = platform.linux_distribution()

+ with open(OUTPUT_FOLDER + '/' + XML_DEFINES, 'a') as custom_settings:

+     custom_settings.write('<!ENTITY YEAR "%s">\n' % datetime.datetime.now().year)

+ 

+     custom_settings.write('<!ENTITY PRODUCT "%s">\n' % linux_distribution[0])

+     if int(float(linux_distribution[1])) == linux_distribution[1]:

+         nextver = int(linux_distribution[1]) + 1

+         prevver = int(linux_distribution[1]) - 1

+     else:

+         nextver = float(linux_distribution[1]) + 0.1

+         prevver = float(linux_distribution[1]) - 0.1

+     custom_settings.write('<!ENTITY NEXTVER "%s">\n' % nextver)

+     custom_settings.write('<!ENTITY PRODVER "%s">\n' % linux_distribution[1])

+     custom_settings.write('<!ENTITY PREVVER "%s">\n' % prevver)

+ 

+     if 'BUG_REPORT_URL' in os.environ:

+         if 'REDHAT_BUGZILLA_PRODUCT' in os.environ:

+             if os.environ['BUG_REPORT_URL'].startswith('http'):

+                 custom_settings.write('<!ENTITY url="%s/enter_bug.cgi?product=%s;&amp;component=&BOOKID;">%s</ulink>\n' % (os.environ['BUG_REPORT_URL'], os.environ['REDHAT_BUGZILLA_PRODUCT'], os.environ['BUG_REPORT_URL']))

+ 

  print("removing non breakable spaces")

  for path in glob.glob(os.path.join(OUTPUT_FOLDER, "*.ent")):

      os.system("sed 's/&nbsp;/ /g' -i %s %s" % (path, path))

This automatically pulls in values from /etc/os-release (if souced). It should reduce the need to constantly update en-US/Installation_Guide.ent for just version number bumps. It is also compatible with RHEL versioning strings.

Must add source /etc/os-release to spec before running prepare_anaconda_help_content.py

This presumes that the builder has the proper /etc/os-release file for the version of the documentation being built. I am not sure I see how this adds significant value. I am saying this in part because of the current desire to move away from publican and DocBook which means this would have to be ported to any newer system as well.

Excluding RHEL6, all current RH releases are systemd based. If the system is missing /etc/os-release, something is wrong with the builder.

The two big gains I see here are in the automatic version numbers and the debranding.

From the rebuild community side, having the code able to track against the OS branding would be instantly helpful to me.

For the version numbers, if nothing has chanced in the guide, the auto spec bump script would be sufficient to move from Fedora 27 to Fedora 28 without any maintenance.

Is there a proposal out there for a switch from publican and DockBook?

Is there a proposal out there for a switch from publican and DockBook?

There is work being done at https://pagure.io/docs-fp-o

@jcpunk Can we close this? Do you want to propose this toward the new builder? If so, please open a ticket in pagure.io/docs-fp-o with a statement of benefits.