Separate common packages included in both headless and headed image 00/316000/4
authorSangYoun Kwak <sy.kwak@samsung.com>
Mon, 12 Aug 2024 08:00:45 +0000 (17:00 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 12 Aug 2024 11:34:42 +0000 (20:34 +0900)
Since the headless image does not have some packages compared to the
headed image, it is required to separate these packages from hal
rootstrap.

To separate headed-only packages, hal rootstrap will be created like
below:
    * rootstrap for common packages:
        Package name: hal-rootstrap
        Directory: /opt/data/hal-rootstrap/common
    * rootstrap for headed-only packages:
        Package name: hal-rootstrap-headed
        Directory: /opt/data/hal-rootstrap/headed

Speaking of hal backend packages, they should do "BuildRequires" like:
    * If backend package requires headed packages, do "BuildRequires"
      for both hal-rootstrap and hal-rootstrap-headed.
    * If backend package does not use any headed packages, do
      "BuildRequires" for hal-rootstrap only.

Change-Id: I0b0576a73299d3dd92cc404cc547b295ff9a0355
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
CMakeLists.txt
generate_rootstrap.sh
modify_pc.py
packaging/hal-rootstrap-headed.pc.in [new file with mode: 0644]
packaging/hal-rootstrap.pc.in
packaging/hal-rootstrap.spec

index fe9d563a1c1f491d17b094cc61383553e374d2db..2ec8d1fb4b88f477db2dd64139edbe37dfd0046d 100644 (file)
@@ -1,14 +1,23 @@
 PROJECT(hal-rootstrap)
 
+SET(HAL_ROOTSTRAP "${PROJECT_NAME}")
+SET(HAL_ROOTSTRAP_HEADED "${PROJECT_NAME}-headed")
+
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 SET(EXEC_PREFIX "${PREFIX}/bin")
 SET(INCLUDEDIR "${PREFIX}/include")
 SET(LIBDIR ${CMAKE_LIBDIR_PREFIX})
 
-CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/packaging/${PROJECT_NAME}.pc.in
-       ${CMAKE_CURRENT_SOURCE_DIR}/packaging/${PROJECT_NAME}.pc
+CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/packaging/${HAL_ROOTSTRAP}.pc.in
+       ${CMAKE_CURRENT_SOURCE_DIR}/packaging/${HAL_ROOTSTRAP}.pc
+       @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/${HAL_ROOTSTRAP}.pc
+       DESTINATION ${LIBDIR}/pkgconfig)
+
+CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/packaging/${HAL_ROOTSTRAP_HEADED}.pc.in
+       ${CMAKE_CURRENT_SOURCE_DIR}/packaging/${HAL_ROOTSTRAP_HEADED}.pc
        @ONLY)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/${PROJECT_NAME}.pc
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/${HAL_ROOTSTRAP_HEADED}.pc
        DESTINATION ${LIBDIR}/pkgconfig)
 
 ADD_SUBDIRECTORY(script)
index b2ab78a273f9e02c44b742d9828e7f4661264925..69e9b9841dd5bc75dbaaac11e576561e2d9c5314 100755 (executable)
@@ -1,15 +1,16 @@
 #!/bin/bash
 
 function prepare_generation {
-       if [[ ! -f "./rs-config" ]]; then
-               echo "There is no rs-config."
+       local config_file="./rs-config"
+       local copy_dest=$1
+
+       if [[ ! -f "${config_file}" ]]; then
+               echo "There is no config file(${config_file})."
                exit 1
        fi
 
-       local copy_dest=$1
-
-       sed -i 's@^export BUILD_REQUIRED_INSTALLED_PATH=""@export BUILD_REQUIRED_INSTALLED_PATH="/"@' "./rs-config"
-       sed -i 's@^export GBS_BUILDROOT=""@export GBS_BUILDROOT="'${copy_dest}'"@' "./rs-config"
+       sed -i 's@^export BUILD_REQUIRED_INSTALLED_PATH=.*$@export BUILD_REQUIRED_INSTALLED_PATH="/"@' "${config_file}"
+       sed -i 's@^export GBS_BUILDROOT=.*$@export GBS_BUILDROOT="'${copy_dest}'"@' "${config_file}"
 }
 
 function generate_rootstrap_ix86 {
@@ -94,8 +95,11 @@ function generate_rootstrap_riscv64 {
 
 function generate_rootstrap {
        local arch=$1
+       local rootstrap_type=$2
+       local rootstrap_resource_dir="./rs_resource"
 
-       cp -r '/tmp/rs_resource' .
+       rm -rf "${rootstrap_resource_dir}"
+       cp -r "/tmp/rs_resource/${ROOTSTRAP_TYPE}" "${rootstrap_resource_dir}"
 
        case "${arch}" in
                "arm")
@@ -126,12 +130,13 @@ function generate_rootstrap {
 }
 
 ARCH=$1
-COPY_DEST=$2
+ROOTSTRAP_TYPE=$2
+COPY_DEST=$3
 
-if [[ -z "${ARCH}" ]] || [[ -z "${COPY_DEST}" ]]; then
-       echo "2 parameters are required: <architecture> <generate destination>"
+if [[ -z "${ARCH}" ]] || [[ -z "${ROOTSTRAP_TYPE}" ]] || [[ -z "${COPY_DEST}" ]]; then
+       echo "3 parameters are required: <architecture> <rootstrap type> <generate destination>"
        exit 1
 fi
 
 prepare_generation "${COPY_DEST}"
-generate_rootstrap "${ARCH}"
+generate_rootstrap "${ARCH}" "${ROOTSTRAP_TYPE}"
index 771d674dece68f007ef46824e6264bd994327358..adea07c4c4c4f82392f7a3bfcd2b3c89b6420e01 100755 (executable)
@@ -51,11 +51,11 @@ def write_to_pc(fname):
        f.write("CXXflags: {}\n".format(' '.join(cxxflags)))
        f.close()
 
-hal_rootstrap_pc_path = argv[1]
+rootstrap_pc_path = argv[1]
 pc_dir = argv[2]
 pc_files = listdir(pc_dir)
 
 for pc_file in pc_files:
        parse_pc("{}/{}".format(pc_dir, pc_file))
 
-write_to_pc(hal_rootstrap_pc_path)
+write_to_pc(rootstrap_pc_path)
diff --git a/packaging/hal-rootstrap-headed.pc.in b/packaging/hal-rootstrap-headed.pc.in
new file mode 100644 (file)
index 0000000..eb84c3c
--- /dev/null
@@ -0,0 +1,14 @@
+# Package Information for pkg-config
+
+package_name=hal-rootstrap
+prefix=/opt/data/hal-rootstrap@PREFIX@
+exec_prefix=/opt/data/hal-rootstrap@EXEC_PREFIX@
+hal_rootstrap_dir=/opt/data/hal-rootstrap/headed
+hal_rootstrap_libdir=${hal_rootstrap_dir}@LIBDIR@
+hal_rootstrap_include_dir=${hal_rootstrap_dir}@INCLUDEDIR@
+
+Name: ${package_name}
+Description: ${package_name} interface
+Version: @VERSION@
+
+Requires:
index f42c89f72fa25012a0d89b5a9fe90413cd06f788..5ce9317cea9794f590cebd86ffccf1c960b2f878 100644 (file)
@@ -3,7 +3,7 @@
 package_name=hal-rootstrap
 prefix=/opt/data/hal-rootstrap@PREFIX@
 exec_prefix=/opt/data/hal-rootstrap@EXEC_PREFIX@
-hal_rootstrap_dir=/opt/data/hal-rootstrap
+hal_rootstrap_dir=/opt/data/hal-rootstrap/common
 hal_rootstrap_libdir=${hal_rootstrap_dir}@LIBDIR@
 hal_rootstrap_include_dir=${hal_rootstrap_dir}@INCLUDEDIR@
 
index 56ab38d49e1d19e2537d648e5f752a27bb868df7..9d79f300d2efd07fbf1ab40621ce5168c5e3b7d4 100644 (file)
@@ -1,6 +1,10 @@
-%define name           hal-rootstrap
-%define devel_name     hal-rootstrap-devel
-%define hal_rootstrap_install_path /opt/data/hal-rootstrap
+%define name                           hal-rootstrap
+%define devel_name                     hal-rootstrap-devel
+%define hal_rootstrap_install_path     /opt/data/hal-rootstrap/common
+
+%define headed_name                            hal-rootstrap-headed
+%define headed_devel_name                      hal-rootstrap-headed-devel
+%define hal_rootstrap_headed_install_path      /opt/data/hal-rootstrap/headed
 
 Name:          hal-rootstrap
 Summary:       Package for rootstrap of hal
@@ -42,6 +46,22 @@ Group:               System/Base
 %description checker
 Checker for the hal rootstrap
 
+### hal-rootstrap-headed
+%package -n    %{headed_name}
+Summary:       Package for rootstrap of hal, for headed image
+
+%description -n        %{headed_name}
+Package for rootstrap of hal, for headed image
+
+### hal-rootstrap-headed-devel
+%package -n    %{headed_devel_name}
+Summary:       %{headed_name} interface
+Group:         Development/Libraries
+Requires:      %{headed_name} = %{version}-%{release}
+
+%description -n        %{headed_devel_name}
+${headed_name} Interface for product vendor developer
+
 %prep
 %setup -q
 %cmake . -DCMAKE_LIBDIR_PREFIX=%{_libdir}
@@ -52,11 +72,19 @@ make %{?jobs:-j%jobs}
 %install
 rm -rf %{buildroot}
 mkdir %{buildroot}
-./generate_rootstrap.sh "%{_arch}" "%{buildroot}%{hal_rootstrap_install_path}"
-
 mkdir -p %{buildroot}%{_libdir}/pkgconfig/
+
+# hal-rootstrap
+./generate_rootstrap.sh "%{_arch}" "common" "%{buildroot}%{hal_rootstrap_install_path}"
 cp packaging/hal-rootstrap.pc %{buildroot}%{_libdir}/pkgconfig/
 ./modify_pc.py "%{buildroot}%{_libdir}/pkgconfig/hal-rootstrap.pc" "%{buildroot}%{hal_rootstrap_install_path}/%{_libdir}/pkgconfig"
+rm -f "%{buildroot}%{hal_rootstrap_install_path}/%{_libdir}/pkgconfig/*.pc"
+
+# hal-rootstrap-headed
+./generate_rootstrap.sh "%{_arch}" "headed" "%{buildroot}%{hal_rootstrap_headed_install_path}"
+cp packaging/hal-rootstrap-headed.pc %{buildroot}%{_libdir}/pkgconfig/
+./modify_pc.py "%{buildroot}%{_libdir}/pkgconfig/hal-rootstrap-headed.pc" "%{buildroot}%{hal_rootstrap_headed_install_path}/%{_libdir}/pkgconfig"
+rm -f "%{buildroot}%{hal_rootstrap_headed_install_path}/%{_libdir}/pkgconfig/*.pc"
 
 mkdir -p %{buildroot}%{_sysconfdir}/hal/rootstrap
 install -m 755 %{SOURCE1} %{buildroot}%{_sysconfdir}/hal/rootstrap
@@ -70,16 +98,22 @@ ln -sf %{_sysconfdir}/hal/rootstrap/hal-rootstrap-checker-rpmmacros %{_sysconfdi
 rm -f %{_sysconfdir}/rpm/macros.hal-rootstrap-checker
 
 %files
-%{hal_rootstrap_install_path}/etc/*
-%{hal_rootstrap_install_path}/lib*/*
-%{hal_rootstrap_install_path}/usr/share/*
-%{hal_rootstrap_install_path}/usr/lib*/*
+%{hal_rootstrap_install_path}
+%exclude %dir %{hal_rootstrap_install_path}/%{_includedir}
 
 %files -n %{devel_name}
 %defattr(-,root,root,-)
-%{hal_rootstrap_install_path}/%{_includedir}/*
-%{hal_rootstrap_install_path}/%{_libdir}/pkgconfig/*.pc
-%{_libdir}/pkgconfig/*.pc
+%{hal_rootstrap_install_path}/%{_includedir}
+%{_libdir}/pkgconfig/hal-rootstrap.pc
+
+%files -n %{headed_name}
+%{hal_rootstrap_headed_install_path}
+%exclude %dir %{hal_rootstrap_headed_install_path}/%{_includedir}
+
+%files -n %{headed_devel_name}
+%defattr(-,root,root,-)
+%{hal_rootstrap_headed_install_path}/%{_includedir}
+%{_libdir}/pkgconfig/hal-rootstrap-headed.pc
 
 %files checker
 %defattr(-,root,root,-)