Modify to make rootstrap through make_rootstrap script
authorSangYoun Kwak <sy.kwak@samsung.com>
Mon, 29 Apr 2024 06:51:02 +0000 (15:51 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Thu, 16 May 2024 03:15:02 +0000 (12:15 +0900)
Change-Id: Ided8d2b522d67706c8c14e6932b1d7efb9569a14
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
generate_rootstrap.sh [new file with mode: 0755]
make_rootstrap.sh
packaging/hal-rootstrap.spec
rs-config
script/rootstrap_gen_1.0.sh

diff --git a/generate_rootstrap.sh b/generate_rootstrap.sh
new file mode 100755 (executable)
index 0000000..105134f
--- /dev/null
@@ -0,0 +1,115 @@
+#!/bin/bash
+
+function prepare_generation {
+       if [[ ! -f "./rs-config" ]]; then
+               echo "There is no rs-config."
+               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"
+}
+
+function generate_rootstrap_i586 {
+       ./script/convert32.sh
+       if [[ $? -ne 0 ]]; then
+               echo "Failed to convert .xml files into 32-bit."
+               return $?
+       fi
+
+       ./make_rootstrap.sh -C rs-config ./rs_resource --clean --emulator
+       RET=$?
+       if [[ ${RET} -ne 0 ]]; then
+               echo "Failed to create rootstrap."
+       fi
+
+       return ${RET}
+}
+
+function generate_rootstrap_x86_64 {
+       ./script/convert64.sh
+       if [[ $? -ne 0 ]]; then
+               echo "Failed to convert .xml files into 64-bit"
+               return $?
+       fi
+
+       ./make_rootstrap_64.sh -C rs-config ./rs_resource --clean --emulator
+       RET=$?
+       if [[ ${RET} -ne 0 ]]; then
+               echo "Failed to create rootstrap."
+       fi
+
+       return ${RET}
+}
+
+function generate_rootstrap_arm {
+       ./script/convert32.sh
+       if [[ $? -ne 0 ]]; then
+               echo "Failed to convert .xml files into 32-bit."
+               return $?
+       fi
+
+       ./make_rootstrap.sh -C rs-config ./rs_resource --clean --target
+       RET=$?
+       if [[ ${RET} -ne 0 ]]; then
+               echo "Failed to create rootstrap."
+       fi
+
+       return ${RET}
+}
+
+function generate_rootstrap_aarch64 {
+       ./script/convert64.sh
+       if [[ $? -ne 0 ]]; then
+               echo "Failed to convert .xml files into 64-bit"
+               return $?
+       fi
+
+       ./make_rootstrap_64.sh -C rs-config ./rs_resource --clean --target
+       RET=$?
+       if [[ ${RET} -ne 0 ]]; then
+               echo "Failed to create rootstrap."
+       fi
+
+       return ${RET}
+}
+
+function generate_rootstrap {
+       local arch=$1
+
+       case "${arch}" in
+               "arm")
+                       generate_rootstrap_arm
+                       return $?
+                       ;;
+               "aarch64")
+                       generate_rootstrap_aarch64
+                       return $?
+                       ;;
+               "i586")
+                       generate_rootstrap_i586
+                       return $?
+                       ;;
+               "x86_64")
+                       generate_rootstrap_x86_64
+                       return $?
+                       ;;
+               *)
+                       echo "Architecture not supported: ${arch}"
+                       exit 1
+                       ;;
+       esac
+}
+
+ARCH=$1
+COPY_DEST=$2
+
+if [[ -z "${ARCH}" ]] || [[ -z "${COPY_DEST}" ]]; then
+       echo "2 parameters are required: <architecture> <generate destination>"
+       exit 1
+fi
+
+prepare_generation "${COPY_DEST}"
+generate_rootstrap "${ARCH}"
index c00e403560eb78641ac462abb155ee265b64f378..a64ff5bcbcf4dec5f6b5c366b14fb4b9a1359be3 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+DEBUG_MODE=1
+
 SCRIPT_NAME="$(basename ${BASH_SOURCE[0]})"
 SCRIPT_FULLPATH="$(readlink -f ${BASH_SOURCE[0]})"
 SCRIPT_BASE="$(dirname ${SCRIPT_FULLPATH})"
@@ -75,9 +77,9 @@ function callRootstrapGen () {
 
        if [[ -z ${3} ]]
        then
-               FULL_RS_CMD="${CMD_RS_GEN} -t ${1} -u ${2} ${xmlList}"
+               FULL_RS_CMD="${CMD_RS_GEN} -t ${1} -u ${2} -q ${BUILD_REQUIRED_INSTALLED_PATH} -r ${GBS_BUILDROOT} ${xmlList}"
        else
-               FULL_RS_CMD="${CMD_RS_GEN} -t ${1} -u ${2} -b ${3} ${xmlList}"
+               FULL_RS_CMD="${CMD_RS_GEN} -t ${1} -u ${2} -b ${3} -q ${BUILD_REQUIRED_INSTALLED_PATH} -r ${GBS_BUILDROOT} ${xmlList}"
        fi
 
        FULL_RS_INFO_CMD="${CMD_RS_INFO} -t $1 -l ${xmlList} -p $PLATFORM_PROFILE -v $PLATFORM_VERSION"
index 0cd1aa46cd7c0b2bcfce408aec77503149f4e5ca..f0509783b346ccd8bc6751eaabbccaea82af2044 100644 (file)
@@ -1,5 +1,6 @@
 %define name           hal-rootstrap
 %define devel_name     hal-rootstrap-devel
+%define hal_rootstrap_install_path /opt/data/hal-rootstrap
 
 %global _privatelibs .*\\.so.*
 %global __requires_exclude %{_privatelibs}
@@ -433,16 +434,17 @@ make %{?jobs:-j%jobs}
 %install
 rm -rf %{buildroot}
 mkdir %{buildroot}
-./copy_required_files.sh %{buildroot}
+./generate_rootstrap.sh "%{_arch}" "%{buildroot}%{hal_rootstrap_install_path}"
 
 mkdir -p %{buildroot}%{_libdir}/pkgconfig/
 cp packaging/hal-rootstrap.pc %{buildroot}%{_libdir}/pkgconfig/
 
 %files
-/opt/data/hal-rootstrap/lib/*
-/opt/data/hal-rootstrap/%{_libdir}/*
+%{hal_rootstrap_install_path}/lib/*
+%{hal_rootstrap_install_path}/%{_libdir}/*
 
 %files -n %{devel_name}
 %defattr(-,root,root,-)
-/opt/data/hal-rootstrap/%{_includedir}/*
+%{hal_rootstrap_install_path}/%{_includedir}/*
+%{hal_rootstrap_install_path}/%{_libdir}/pkgconfig/*.pc
 %{_libdir}/pkgconfig/*.pc
index 5f980d3781dced1c93a8b543d3516da3ad050db5..d995d028c3827b7e2942afd874bf09bcf076ac0a 100755 (executable)
--- a/rs-config
+++ b/rs-config
@@ -19,3 +19,6 @@ export RPM_PKG_SVR_TARGET="${SNAPSHOT_URL_PREFIX}${SNAPSHOT_URL_POSTFIX_TARGET}"
 # Wget ID/PW for Local Test
 export ID=
 export PW=
+
+export BUILD_REQUIRED_INSTALLED_PATH=""
+export GBS_BUILDROOT=""
index 79499d91def1004524c39da06e9a6ea483810cc5..a5f002f4a46bb7b5e750f11bc2d294c78ec7871c 100755 (executable)
@@ -176,58 +176,67 @@ function unnecessary_files()
 
 }
 
-function copy_header_and_so() # $1 : SRCDIR, $2 : DESTDIR, $3 xml
+function copy_header_and_so()
 {
-    log "***************** $FUNCNAME *****************"
-    ALL=$(xmlstarlet sel -t -m "//necessary[count(file)=1]" -v "./file/text()" ${3})
-    log "+ source directory : $1"
-    log "+ destination directory : $2"
-    log "+ xml source file : $3"
-
-    TEMP_SRC_DIR="${1}";
-    TEMP_DEST_DIR="${2}";
-    COPY_ERROR=0;
-    if [[ "${ALL}" == "*" ]] || [ "$INTERNAL" = true ]
-    then
-        (
-        log "+ copy ALL file (h, a, o, so)"
-        cd ${1}
-        find . \( -name "*.h" -o -name "*.a" -o -name "*.o" -o -name "*.so" -o -name "*.so\.[0-9]*" -o -name "*.hpp" -o -name "*.ipp" -o -name "*.x" -o -name "*.def" -o -name "*.so.*" \) \
-            -exec echo "+ copy file [{}]" \; \
-            -exec cp -L -R --parents {} ${2} \;
-        )
-    else
-        log "+ copy necessary files .."
-        for i in $(xmlstarlet sel -t -m "//necessary/file" -o "." -v "text()" -o " " -n  ${3})
-        do
-            #(
-            cd ${1}
-            log "+ copy file from [${i}]"
-            cp -L -R --parents ${i} ${2}
-            if [ "$?" -ne "0" ]; then
-                get_author "../${3}"
-                let "COPY_ERROR+=1"
-            fi
-           cd -
-            #)
-        done
-    fi
-
-    if [ "$COPY_ERROR" -ne "0" ]; then
-        log "Error Occurred Copy file .... "  1>&2
-        exit $ERROR_NOT_EXIST_FILE
-    fi
-#######
-# Pc
-#######
-    if [ -d "${TEMP_SRC_DIR}/usr/lib/pkgconfig" ]
-    then
-    (
-        cd ${TEMP_SRC_DIR}
-        cp -P -R --parents "./usr/lib/pkgconfig"  "${TEMP_DEST_DIR}" ;
-    )
-    fi
+       local src_dir=$1
+       local dest_dir=$2
+       local xml_file=$3
+       local copy_error=0
+       local files=()
+       local dest_path=""
+
+       log "***************** $FUNCNAME *****************"
+       ALL=$(xmlstarlet sel -t -m "//necessary[count(file)=1]" -v "./file/text()" ${xml_file})
+       log "+ source directory : ${src_dir}"
+       log "+ destination directory : ${dest_dir}"
+       log "+ xml source file : ${xml_file}"
+
+       if [[ "${ALL}" == "*" ]] || [[ "${INTERNAL}" == true ]]; then
+               log "ALL(*) and internal is not supported"
+       else
+               log "+ copy necessary files .."
+               for i in $(xmlstarlet sel -t -m "//necessary/file" -o "." -v "text()" -o " " -n  ${xml_file}); do
+                       cd ${src_dir}
+                       log "+ copy file from [${i}]"
+                       files=($(ls ${i}))
+                       for file in ${files[@]}; do
+                               dest_path="${dest_dir}/$(dirname ${file})"
+                               mkdir -p ${dest_path}
+                               cp -L -R ${file} "${dest_path}/."
+                               if [[ "$?" -ne "0" ]]; then
+                                       get_author "../${xml_file}"
+                                       let "COPY_ERROR+=1"
+                               fi
+                       done
+                       cd -
+               done
+       fi
+
+       if [[ "${copy_error}" -ne 0 ]]; then
+               log "Error Occurred Copy file .... "  1>&2
+               exit $ERROR_NOT_EXIST_FILE
+       fi
+}
 
+function copy_package_config()
+{
+       local src_dir=$1
+       local dest_dir=$2
+
+       log "***************** $FUNCNAME *****************"
+       log "+ source directory : ${src_dir}"
+       log "+ destination dierctory : ${dest_dir}"
+
+       if [[ ! -d "${src_dir}/usr/lib/pkgconfig" ]]; then
+               log "+ no pkgconfig directory(${src_dir}/usr/lib/pkgconfig)"
+               return 1
+       fi
+
+       cd ${src_dir}
+       local dest_path="${dest_dir}/usr/lib/pkgconfig"
+       mkdir -p ${dest_path}
+       cp -P -R ./usr/lib/pkgconfig/* "${dest_path}"
+       cd -
 }
 
 function check_prerequisite()
@@ -244,7 +253,7 @@ function check_prerequisite()
 #script start
 check_prerequisite
 
-OPTS=`getopt -o -t:u:b:l:i:p:wh --long type:,url:,base:,list:,id:,pw:,withlogin,help,internal,log: -n 'rootstrap_gen_1.0' -- "$@"`
+OPTS=`getopt -o -t:u:b:l:i:p:whq:r: --long type:,url:,base:,list:,id:,pw:,withlogin,help,internal,log: -n 'rootstrap_gen_1.0' -- "$@"`
 if [ $? != 0 ] ; then log "Failed parsing options." >&2 ; exit 1 ; fi
 
 log ""
@@ -259,6 +268,8 @@ INTERNAL=false
 
 while true; do
   case "$1" in
+    -q ) BUILD_REQUIRED_INSTALLED_PATH="$2"; shift;shift ;;
+    -r ) GBS_BUILDROOT="$2"; shift;shift ;;
     -t | --type ) ROOTSTRAP_TYPE="$2"; shift;shift ;;
     -u | --url ) RPM_PKG_URL="$2"; shift;shift ;;
     -b | --base ) BASE_PKG_URL="$2"; shift;shift ;;
@@ -404,25 +415,13 @@ do
         continue;
     fi
 
-    #download rpm
-    download_rpm $item
-    if [ "$?" -ne "0" ]
-    then
-        continue;
-    fi
-    #unpack rpm
-    unpack_rpm $item
-
-    #remove unnessary header, so
-    unnecessary_files $item
-
     #copy only header & so to dest
-    copy_header_and_so ${TMP} ${DEST} ${item}
+    copy_header_and_so ${BUILD_REQUIRED_INSTALLED_PATH} ${GBS_BUILDROOT} ${item}
 
     #get build option from xml
     #get_build_option $item
 done #finish copy header & library
+copy_package_config ${BUILD_REQUIRED_INSTALLED_PATH} ${GBS_BUILDROOT}
 
 ##################################################################
 #postlink for delete needed field from Library