diff options
author | MyungJoo Ham <myungjoo.ham@samsung.com> | 2017-04-11 17:03:44 +0900 |
---|---|---|
committer | MyungJoo Ham <myungjoo.ham@samsung.com> | 2017-04-11 19:42:17 +0900 |
commit | b1922df9d039f4da447122e98804fcf97128ab3f (patch) | |
tree | 78f2edd54bf79b296df003fa9ec82fe8e51ccc92 | |
parent | 87d69766932a90d0eccb68a5eb24ed9199e84ec2 (diff) | |
download | building-blocks-b1922df9d039f4da447122e98804fcf97128ab3f.tar.gz building-blocks-b1922df9d039f4da447122e98804fcf97128ab3f.tar.bz2 building-blocks-b1922df9d039f4da447122e98804fcf97128ab3f.zip |
Preset: auto-generate preset/zblocks from yaml filessubmit/tizen/20170411.104924
From Idea of YD Seo.
Change-Id: I83e208d661bd5cb0fff96b3d4fbab3533c81dbc9
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
-rw-r--r-- | packaging/building-blocks.spec | 80 | ||||
-rw-r--r-- | packaging/platform-preset-common.inc | 5 | ||||
-rw-r--r-- | packaging/platform-preset-ivi.inc | 5 | ||||
-rw-r--r-- | packaging/platform-preset-mobile.inc | 4 | ||||
-rw-r--r-- | packaging/platform-preset-tv.inc | 3 | ||||
-rw-r--r-- | packaging/platform-preset-wearable.inc | 2 | ||||
-rwxr-xr-x | rule_checker.py | 2 |
7 files changed, 97 insertions, 4 deletions
diff --git a/packaging/building-blocks.spec b/packaging/building-blocks.spec index f799940..991c1ae 100644 --- a/packaging/building-blocks.spec +++ b/packaging/building-blocks.spec @@ -41,6 +41,13 @@ Source3900: platform-preset-smart.inc # To get .ks files BuildRequires: image-configurations +# To get blocked .yaml files, idea from YD Seo. +BuildRequires: meta-common +BuildRequires: meta-mobile +BuildRequires: meta-wearable +BuildRequires: meta-tv +BuildRequires: meta-ivi + # To check the rules BuildRequires: python @@ -116,9 +123,6 @@ presets describing specific products. # This script writes build-spec when building the build-spec itself. :) # Importing .kg file with list_with_require() based on image-configuration will work # after Tizen:Unified starts to generate its own platform images. - -# TODO1: How to interpret "- pkg"? just skip? or make it conflicted? -# TODO2: How to handle "no file error"? %define list_with_require() %{expand:%{lua:if posix.access(rpm.expand("%{SOURCE1001}"), "f") then \ local start = 0 \ if posix.access(rpm.expand("%{1}")) then \ @@ -143,6 +147,76 @@ presets describing specific products. end \ end}} +# Create Suggests List of blocks with yaml file list +# DIRECTORY, Prefix-To-Be-Removed, Prefix-for-block-name +%define list_suggest() %{expand:%{lua:if posix.access(rpm.expand("%{SOURCE1001}"), "f") then \ + for f in posix.files(rpm.expand("%{1}")) do \ + local line = string.sub(f, string.len(rpm.expand("%{2}"))+2) \ + local prefix = string.sub(f, 1, string.len(rpm.expand("%{2}"))) \ + if (string.sub(line, 1, 10) == 'adaptation') then \ + elseif (string.sub(line, 1, 4) == 'boot') then \ + elseif (prefix == rpm.expand("%{2}")) then \ + print("Suggests: "..rpm.expand("%{3}").."zblock_"..line) \ + print("\\n") \ + end \ + end \ +end}} + + +# Create Requires List of packages for all blocks with yaml file list +# DIRECTORY, Prefix-To-Be-Removed, Prefix-for-block-name +%define list_require() %{expand:%{lua:if posix.access(rpm.expand("%{SOURCE1001}"), "f") then \ + for f in posix.files(rpm.expand("%{1}")) do \ + local line = string.sub(f, string.len(rpm.expand("%{2}"))+2) \ + local prefix = string.sub(f, 1, string.len(rpm.expand("%{2}"))) \ + if (string.sub(line, 1, 10) == 'adaptation') then \ + elseif (string.sub(line, 1, 4) == 'boot') then \ + elseif (prefix == rpm.expand("%{2}")) then \ + local pkg = rpm.expand("%{3}").."zblock_"..line \ + local summary_available = 0 \ + local filename = rpm.expand("%{1}").."/"..f \ + print("\\n") \ + print("%%package "..pkg.."\\n") \ + if posix.access(filename) then \ + for tag in io.lines(filename) do \ + if (string.sub(tag, 1, 8) == "Summary:") then \ + print(tag) \ + print("\\n") \ + summary_available = 1 \ + break \ + end \ + end \ + end \ + if (summary_available == 0) then \ + print("Summary: "..f) \ + print("\\n") \ + end \ + if posix.access(filename) then \ + for line in io.lines(rpm.expand("%{1}").."/"..f) do \ + if (string.match(line, 'Packages:')) then \ + start = 1 \ + elseif (string.sub(line, 1, 2) == '- ') then \ + if (start == 1) then \ + print("Requires: "..string.sub(line, 3)) \ + print("\\n") \ + end \ + elseif (string.sub(line, 1, 1) == '#') then \ + elseif (string.len(line) == 0) then \ + else \ + start = 0 + end \ + end \ + else \ + print("Requires: CANNOT_FIND_REQUIRED_FILES\\n") \ + end \ + print("%%description "..pkg.."\\n") \ + print("Auto Generated Block (zblock) of "..f.."\\n") \ + print("%%files "..pkg.."\\n") \ + print("\\n\\n\\n") \ + end \ + end \ +end}} + %prep %setup diff --git a/packaging/platform-preset-common.inc b/packaging/platform-preset-common.inc index e1f7e6a..7d9a9b5 100644 --- a/packaging/platform-preset-common.inc +++ b/packaging/platform-preset-common.inc @@ -10,6 +10,11 @@ Conflicts: %{name}-sub1-Preset_sd-wearable Conflicts: %{name}-sub1-Preset_sd-home_appliance Conflicts: %{name}-root-Preset-iot Conflicts: %{name}-sub1-Preset_sd-ivi + +%list_suggest /usr/share/package-groups/common/ common sub2-Preset_sd-common- + %description sub1-Preset_sd-common Tizen Platform Presets for "Common Profile" %files sub1-Preset_sd-common + +%list_require %{_datadir}/package-groups/common/ common sub2-Preset_sd-common- diff --git a/packaging/platform-preset-ivi.inc b/packaging/platform-preset-ivi.inc index c5ac5d1..8b070e8 100644 --- a/packaging/platform-preset-ivi.inc +++ b/packaging/platform-preset-ivi.inc @@ -9,10 +9,12 @@ Conflicts: %{name}-sub1-Preset_sd-wearable Conflicts: %{name}-sub1-Preset_sd-home_appliance Conflicts: %{name}-root-Preset-iot Suggests: %{name}-sub2-Preset_sd-ivi-proto +%list_suggest /usr/share/package-groups/ivi/ ivi sub2-Preset_sd-ivi- %description sub1-Preset_sd-ivi Tizen IVI Platform Presets %files sub1-Preset_sd-ivi + %package sub2-Preset_sd-ivi-proto Summary: IVI OdroidXU3 Prototype # image-configuration must have this file supplied. @@ -21,3 +23,6 @@ Summary: IVI OdroidXU3 Prototype Tizen IVI Prototype Preset from OdroidXU3 as an example %files sub2-Preset_sd-ivi-proto + +%list_require /usr/share/package-groups/ivi/ ivi sub2-Preset_sd-ivi- + diff --git a/packaging/platform-preset-mobile.inc b/packaging/platform-preset-mobile.inc index 23eab09..1a83d2a 100644 --- a/packaging/platform-preset-mobile.inc +++ b/packaging/platform-preset-mobile.inc @@ -11,6 +11,7 @@ Suggests: %{name}-sub2-Preset_sd-mobile-tm1 Suggests: %{name}-sub2-Preset_sd-mobile-tm2_aarch64 Suggests: %{name}-sub2-Preset_sd-mobile-tm2_armv7l Suggests: %{name}-sub2-Preset_sd-mobile-minimal +%list_suggest /usr/share/package-groups/mobile/ mobile sub2-Preset_sd-mobile- %description sub1-Preset_sd-mobile Tizen Mobile Platform Presets %files sub1-Preset_sd-mobile @@ -68,3 +69,6 @@ Tizen Mobile Minimal Platform Preset Mobile-PM: fill in minimal API sets for mobile profile. %files sub2-Preset_sd-mobile-minimal + + +%list_require /usr/share/package-groups/mobile/ mobile sub2-Preset_sd-mobile- diff --git a/packaging/platform-preset-tv.inc b/packaging/platform-preset-tv.inc index c580193..55796d9 100644 --- a/packaging/platform-preset-tv.inc +++ b/packaging/platform-preset-tv.inc @@ -9,6 +9,7 @@ Conflicts: %{name}-sub1-Preset_sd-ivi Conflicts: %{name}-sub1-Preset_sd-home_appliance Conflicts: %{name}-root-Preset-iot Suggests: %{name}-sub2-Preset_sd-tv-odroid +%list_suggest /usr/share/package-groups/tv/ tv sub2-Preset_sd-tv- %description sub1-Preset_sd-tv Tizen TV Platform Presets %files sub1-Preset_sd-tv @@ -22,3 +23,5 @@ Summary: TV-Odroid Tizen TV Odroid Preset %files sub2-Preset_sd-tv-odroid + +%list_require /usr/share/package-groups/tv/ tv sub2-Preset_sd-tv- diff --git a/packaging/platform-preset-wearable.inc b/packaging/platform-preset-wearable.inc index 1a580e3..7e9aab8 100644 --- a/packaging/platform-preset-wearable.inc +++ b/packaging/platform-preset-wearable.inc @@ -9,6 +9,7 @@ Conflicts: %{name}-sub1-Preset_sd-ivi Conflicts: %{name}-sub1-Preset_sd-home_appliance Conflicts: %{name}-root-Preset-iot Suggests: %{name}-sub2-Preset_sd-wearable-tw2 +%list_suggest /usr/share/package-groups/wearable/ wearable sub2-Preset_sd-wearable- %description sub1-Preset_sd-wearable Tizen Wearable Platform Presets %files sub1-Preset_sd-wearable @@ -22,3 +23,4 @@ Summary: Wearable-TW2 Tizen Wearable TW1 (Gear 2) Preset %files sub2-Preset_sd-wearable-tw2 +%list_require /usr/share/package-groups/wearable/ wearable sub2-Preset_sd-wearable- diff --git a/rule_checker.py b/rule_checker.py index 2578d5f..c29e116 100755 --- a/rule_checker.py +++ b/rule_checker.py @@ -115,7 +115,7 @@ def ruleCheckInc(file): files = 0 else: if re.search(r'^\s*[^#\s]+', line) and \ - not re.search(r'^\s*(%include)|(%endif)|(%ifarch)', line): + not re.search(r'^\s*(%include)|(%endif)|(%ifarch)|(%list_require)', line): error += 1 print("ERROR: RULE 5.3 a block must not have a file included (%files section must be empty)") report(file, lc, line) |