Skip to content

Commit

Permalink
ose: lsb-release=webos10
Browse files Browse the repository at this point in the history
:Release Notes:
Modify versioning policy of lsb-release
Upgrade dist-update (v1.0.1)

:Detailed Notes:
Package version is updated according to webos-release
Add opkg update feature in dist-update

:Testing Performed:
Local test suite.

:QA Notes:
N/A

:Issues Addressed:
[WRO-7183] CCC: lsb-release=webos10
[WRO-7182] Modify versioning policy of lsb-release

Change-Id: I1af0e67d5a38216818dc0aa4b23e190d0ea3bf56
  • Loading branch information
mark.yang authored and Hyunjae Shin committed Jul 3, 2022
1 parent e029b39 commit f76b2b8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 70 deletions.
104 changes: 40 additions & 64 deletions meta-webos/recipes-extended/lsb/lsb-release/dist-update
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
#!/usr/bin/env python3

__DIST_UPDATE_VERSION__ = "1.0.0"
__DIST_UPDATE_VERSION__ = "1.0.1"
PACKAGE_FEED_URI = "@PACKAGE_FEED_URI@"
PACKAGE_FEED_BASE_PATH = "@PACKAGE_FEED_BASE_PATH@"
PACKAGE_DISTRO = "@PACKAGE_DISTRO@"
TRIMED_DISTRO_VERSION = "@TRIMED_DISTRO_VERSION@"

from collections import deque
from collections import defaultdict
import errno
import argparse
import subprocess
import os
import sys
import glob

def parse():
parser = argparse.ArgumentParser()
parser.add_argument('-V','--version', help="Show installed distro image version", action="store_true", dest='installed_version')
group = parser.add_mutually_exclusive_group()
group.add_argument('--show_versions', help="Show All Fetchable versions", action="store_true", dest='show_all_versions')
group.add_argument('--show-versions', help="Show All Fetchable versions", action="store_true", dest='show_all_versions')
group.add_argument('--update', help="Update package list", action="store_true", dest='update')
group.add_argument('--upgrade', help="Upgrade package list to <version>", metavar="<version>", default=None)
args = parser.parse_args()
if len(sys.argv) <= 1:
parser.print_help()
exit(0)
if args.installed_version:
os.system('lsb_release -rs')
exit(0)
opkg = Opkg()
if args.show_all_versions:
opkg.show_all_versions = True
elif args.update:
opkg.update = True
elif args.upgrade is None:
print('Specify Upgrade version')
else:
opkg.upgrade = True
opkg.upgrade_version = args.upgrade
return opkg

def bash_cmd(cmd: str):
Expand All @@ -49,29 +41,18 @@ def bash_cmd(cmd: str):

class Opkg():
def __init__(self):
self.installed_version = self.getInstalledVersionString()
self.feed_uri = self.getCorrectURI()
self.support_version = self.getSupportVersions()
self.sysconfdir = '/etc/opkg'
self.upgradable_version = list()
self.installed_pkg_conf = self.getInstalledPkgConf(base_path=self.sysconfdir)
self.show_all_versions = False
self.update = False
self.upgrade = False
self.upgrade_version = None

def getInstalledVersionString(self):
ret = bash_cmd('lsb_release -rs')
if ret[0] != 0:
print('Error: %s' % (ret[1]))
exit(ret[0])
installed_version=ret[1].strip()
return installed_version

def getCorrectURI(self):
return os.path.join(PACKAGE_FEED_URI,PACKAGE_FEED_BASE_PATH,PACKAGE_DISTRO,TRIMED_DISTRO_VERSION)
return os.path.join(PACKAGE_FEED_URI,PACKAGE_FEED_BASE_PATH,PACKAGE_DISTRO)

def getSupportVersions(self):
print("[INFO] fetch : %s" % self.feed_uri)
print("fetch : %s" % self.feed_uri)
ret = bash_cmd('curl -sL %s --list-only | egrep \'\[DIR\]\' | awk -F \'<a |</a>\' \'{print$2}\' | awk -F \'>\' \'{print$NF}\'' % (self.feed_uri))
if ret[0] != 0:
print('Error occured in curl : %s' % (ret[1]))
Expand All @@ -83,51 +64,46 @@ class Opkg():
fetch_dirs.append(var)
del dirs
return fetch_dirs

def showAllVersions(self):
print('show all versions')

def getInstalledPkgConf(self,base_path):
pkg_feed_conf = defaultdict(bool)
for i in glob.iglob(base_path+'/*.conf'):
installed_conf_version=os.path.basename(i).rstrip('.conf')
if not installed_conf_version[0].isdigit():
continue
if installed_conf_version+'/' in self.support_version:
pkg_feed_conf[installed_conf_version]=True
for i in self.support_version:
print(i[:-1])
exit(0)
if pkg_feed_conf[i[:-1]] == False:
pkg_feed_conf[i[:-1]] = False
return pkg_feed_conf

def Update(self, silent=False):
if not silent:
print("Installed image version: %s" % self.installed_version)
def showAllVersions(self,isUpdate=False):
self.installed_pkg_conf = self.getInstalledPkgConf(base_path=self.sysconfdir)
for i in self.support_version:
if self.installed_version < i[:-1]:
self.upgradable_version.append(i[:-1])
if not silent:
print('Upgradable image version')
for i in self.upgradable_version:
print(i)

def Upgrade(self, version: str):
self.Update(silent=True)
if not self.isUpgradable(version):
print('Not Found version : %s' % version)
exit(1)
try:
os.makedirs(self.sysconfdir)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise
os.chdir(self.sysconfdir)
with open('%s.conf' % (version), 'w') as f:
os.fchmod(f.fileno(), 0o644)
f.write('src/gz %s \"%s\"' % (version, os.path.join(self.feed_uri,version)))
print('Add package feed version : %s' % (version))
if self.installed_pkg_conf[i[:-1]] == True:
print(f'{i[:-1]} [Installed]')
else:
print(f'{i[:-1]} [Not Installed]')
if not isUpdate:
exit(0)

def isUpgradable(self, version: str):
for i in self.upgradable_version:
if i == version:
return True
return False
def Update(self):
for k,v in self.installed_pkg_conf.items():
if not v:
os.chdir(self.sysconfdir)
with open('%s.conf' % (k), 'w') as f:
os.fchmod(f.fileno(), 0o644)
f.write('src/gz %s \"%s\"' % (k, os.path.join(self.feed_uri,k)))
print('Add package feed version : %s' % (k))
ret = bash_cmd('opkg update')
print(ret[1])
print("To upgrade platform latest distro version.\nrun '$ opkg upgrade'")

if __name__ == '__main__':
opkg = parse()
if opkg.show_all_versions:
opkg.showAllVersions()
elif opkg.update:
opkg.Update()
elif opkg.upgrade:
opkg.Upgrade(opkg.upgrade_version)
opkg.showAllVersions(isUpdate=True)
opkg.Update()
9 changes: 3 additions & 6 deletions meta-webos/recipes-extended/lsb/lsb-release_%.bbappend
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) 2013-2022 LG Electronics, Inc.

EXTENDPRAUTO:append = "webos9"
EXTENDPRAUTO:append = "webos10.${WEBOS_DISTRO_BUILD_ID}"

FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:"

Expand Down Expand Up @@ -33,14 +33,11 @@ do_install:append() {
sed -i -e 's/^CHECKFIRST=.*/CHECKFIRST="\${sysconfdir}\/${BUILD_INFO_FILE}"/' ${D}${base_bindir}/lsb_release
echo "${BUILD_DISTRIB_ID} release ${DISTRO_VERSION}-${WEBOS_DISTRO_BUILD_ID} (${WEBOS_DISTRO_RELEASE_CODENAME})" > ${D}${sysconfdir}/${BUILD_INFO_FILE}

# install dist-update
if [ ! -z ${PACKAGE_FEED_URI} -a ! -z ${PACKAGE_FEED_BASE_PATH} ]; then
# install dist-update
install -d ${D}${bindir}
install -m 0755 ${S}/dist-update ${D}${bindir}
fi

# install ${TRIMED_DISTRO_VERSION}.conf
if [ ! -z ${PACKAGE_FEED_URI} -a ! -z ${PACKAGE_FEED_BASE_PATH} ]; then
# install ${TRIMED_DISTRO_VERSION}.conf
install -d ${D}${sysconfdir}/opkg
install -m 0644 ${S}/${TRIMED_DISTRO_VERSION}.conf ${D}${sysconfdir}/opkg
fi
Expand Down

0 comments on commit f76b2b8

Please sign in to comment.