#!/bin/sh echo "############### iot-hal-backend.post ################" if [ -d /hal ]; then echo "Initialize rpmdb for HaL Backend" mkdir -p /hal/lib/rpm cp /var/lib/rpm/Packages /hal/lib/rpm/ rpm --rebuilddb --dbpath=/hal/lib/rpm fi check_building_block() { PKG=`/usr/bin/rpm -qR $1 | /usr/bin/uniq | /bin/grep -v "^rpmlib" | /bin/grep -v ".\+\.so\..\+" | /bin/grep -v "^\/" | /bin/grep -v "=" | /bin/grep -v "(.\+)"` for pkgs in ${PKG}; do INSTALLED=`/usr/bin/rpm -q $pkgs` RET=$? if [[ $pkgs =~ "building-blocks" ]]; then check_building_block $pkgs elif [ $RET -eq 0 ]; then PATH=`/usr/bin/rpm -ql $INSTALLED | /bin/grep -v "^\/hal\/"` if [ "$PATH" ]; then echo "WARNING!!! $INSTALLED packages was installed to wrong path" for wrong_path in $PATH; do echo $wrong_path done fi echo -e $INSTALLED >> /hal/list/hal-backend-list.ini fi done } #FIXME: Need to check how to parse specific package BACKEND_PACKAGE=("hal-backend-device-common"); create_backend_dependency_file() { echo "Creating Backend Dependency List" PKG=`/usr/bin/rpm -qa` /usr/bin/mkdir -p /hal/temp /usr/bin/mkdir -p /hal/etc/rpm/ for packages in ${PKG}; do /usr/bin/rpm -qP $packages > /hal/temp/${packages} done for lists in ${BACKEND_PACKAGE[@]}; do /usr/bin/grep -lr $lists /hal/temp/ | /bin/sed "s/\/hal\/temp\\///" >> /hal/list/hal-backend-list.ini done while read line; do /usr/bin/rpm -qR --qf "%{NAME} [%{REQUIRENAME} %{REQUIREVERSION}] " $line | /bin/grep -v "\/bin\/" | /bin/grep -v "rpmlib" | /bin/grep -v "\/sbin\/" | /bin/grep -v "config(" > /hal/list/${line}.ini done < /hal/list/hal-backend-list.ini LIST=`/usr/bin/ls /hal/list/` for lists in ${LIST}; do while read line; do /usr/bin/grep -lr $line /hal/temp/ | /bin/sed "s/\/hal\/temp\\///" >> /hal/etc/rpm/temp.ini done < /hal/list/$lists if [ -e /hal/etc/rpm/temp.ini ]; then /usr/bin/sort -u /hal/etc/rpm/temp.ini > /hal/etc/rpm/$lists /usr/bin/rm /hal/etc/rpm/temp.ini else /usr/bin/touch /hal/etc/rpm/$lists fi done for packages in ${PKG}; do FOUND=0 while read line; do if [ $line == $packages ]; then FOUND=1 break fi done < /hal/list/hal-backend-list.ini if [ $FOUND -eq 0 ]; then /usr/bin/rpm -e --justdb $packages --nodeps --noscripts --dbpath=/hal/lib/rpm fi done /usr/bin/rm -rf /hal/temp /usr/bin/rm -rf /hal/list /usr/bin/rm -rf /hal/etc/rpm/hal-backend-list.ini echo "Finished to Create Backend Dependency List" } #Supported Target's list TARGET=("RPI3" "RPI4" "ARTIK530" "VIM3" "C4"); PKGGROUP=`/usr/bin/rpm -qa | /bin/grep package-groups` if [ $PKGGROUP ]; then for target in ${TARGET[@]}; do RET=`/usr/bin/rpm -qa | /usr/bin/grep $target` RET=$? if [ $RET -eq 0 ]; then break; fi done case $target in RPI3) BACKEND=`/usr/bin/xmlstarlet sel -t -v '//group[name = "IoT Hal Backend RPI3"]/packagelist/packagereq' -n /usr/share/package-groups/group.xml` ;; RPI4) BACKEND=`/usr/bin/xmlstarlet sel -t -v '//group[name = "IoT Hal Backend RPI4"]/packagelist/packagereq' -n /usr/share/package-groups/group.xml` ;; ARTIK530) BACKEND=`/usr/bin/xmlstarlet sel -t -v '//group[name = "IoT Hal Backend ARTIK530"]/packagelist/packagereq' -n /usr/share/package-groups/group.xml` ;; VIM3) BACKEND=`/usr/bin/xmlstarlet sel -t -v '//group[name = "IoT Hal Backend VIM3"]/packagelist/packagereq' -n /usr/share/package-groups/group.xml` ;; C4) BACKEND=`/usr/bin/xmlstarlet sel -t -v '//group[name = "IoT Hal Backend C4"]/packagelist/packagereq' -n /usr/share/package-groups/group.xml` ;; esac /usr/bin/mkdir -p /hal/list/ #Get HAL Backend Package List# PKG=`/usr/bin/rpm -q $BACKEND` echo "Create Hal Backend Packages List" for packages in ${PKG}; do check_building_block $packages done create_backend_dependency_file #Create exportdb file to update a rpmdb of core image /usr/bin/rpmdb --dbpath=/hal/lib/rpm --exportdb > /hal/etc/hal-rpmdb.ini fi build_ts=$(/bin/date -u +%s) build_date=$(/bin/date -u --date @$build_ts +%Y%m%d_%H%M%S) build_time=$(/bin/date -u --date @$build_ts +%H:%M:%S) /bin/sed -ri \ -e 's|@BUILD_ID[@]|@BUILD_ID@|g' \ -e "s|@BUILD_DATE[@]|$build_date|g" \ -e "s|@BUILD_TIME[@]|$build_time|g" \ -e "s|@BUILD_TS[@]|$build_ts|g" \ /etc/tizen-build.conf /etc/make_info_file.sh hal