1inherit allarch 2 3SUMMARY = "Operating system identification" 4DESCRIPTION = "The /usr/lib/os-release file contains operating system identification data." 5LICENSE = "MIT" 6INHIBIT_DEFAULT_DEPS = "1" 7 8do_fetch[noexec] = "1" 9do_unpack[noexec] = "1" 10do_patch[noexec] = "1" 11do_configure[noexec] = "1" 12 13# Other valid fields: BUILD_ID ID_LIKE ANSI_COLOR CPE_NAME 14# HOME_URL SUPPORT_URL BUG_REPORT_URL 15OS_RELEASE_FIELDS = "ID ID_LIKE NAME VERSION VERSION_ID PRETTY_NAME" 16 17ID = "${DISTRO}" 18NAME = "${DISTRO_NAME}" 19VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in d else ''}" 20VERSION_ID = "${DISTRO_VERSION}" 21PRETTY_NAME = "${DISTRO_NAME} ${VERSION}" 22BUILD_ID ?= "${DATETIME}" 23BUILD_ID[vardepsexclude] = "DATETIME" 24 25def sanitise_version(ver): 26 # VERSION_ID should be (from os-release(5)): 27 # lower-case string (mostly numeric, no spaces or other characters 28 # outside of 0-9, a-z, ".", "_" and "-") 29 ret = ver.replace('+', '-').replace(' ','_') 30 return ret.lower() 31 32python do_compile () { 33 with open(d.expand('${B}/os-release'), 'w') as f: 34 for field in d.getVar('OS_RELEASE_FIELDS').split(): 35 value = d.getVar(field) 36 if value and field == 'VERSION_ID': 37 value = sanitise_version(value) 38 if value: 39 f.write('{0}="{1}"\n'.format(field, value)) 40} 41do_compile[vardeps] += "${OS_RELEASE_FIELDS}" 42 43do_install () { 44 install -d ${D}${nonarch_libdir} ${D}${sysconfdir} 45 install -m 0644 os-release ${D}${nonarch_libdir}/ 46 lnr ${D}${nonarch_libdir}/os-release ${D}${sysconfdir}/os-release 47} 48 49FILES_${PN} += "${nonarch_libdir}/os-release" 50