summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehoon Chung <jh80.chung@samsung.com>2021-06-03 11:22:01 +0900
committerJaehoon Chung <jh80.chung@samsung.com>2021-06-09 15:23:19 +0900
commit8fbcc2b8e3bf8c9b8623abf417062b129c8cd918 (patch)
treee16d79c7777f7617375e8e06fc3af141bde6cde4
parentdf5ff0e73c404319a0d7c5720645637478876716 (diff)
downloadmeta-8fbcc2b8e3bf8c9b8623abf417062b129c8cd918.tar.gz
meta-8fbcc2b8e3bf8c9b8623abf417062b129c8cd918.tar.bz2
meta-8fbcc2b8e3bf8c9b8623abf417062b129c8cd918.zip
[TRE-2699] scripts: add new scripts relevant to HAL
Add new scripts relevant to HAL. - Supported RPI3, ARTIK530 *common-hal-directory-check.post - check the packages to install to wrong path. * iot-hal-backend.post - Setup hal rpmdb and dependency files. Change-Id: I59fb13be99c8aef26322100d8d363df4cad5d916 Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
-rw-r--r--scripts/common-hal-directory-check.post20
-rw-r--r--scripts/iot-hal-backend.post160
2 files changed, 180 insertions, 0 deletions
diff --git a/scripts/common-hal-directory-check.post b/scripts/common-hal-directory-check.post
new file mode 100644
index 0000000..3366867
--- /dev/null
+++ b/scripts/common-hal-directory-check.post
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+echo "#################### common-hal-directory-check.post ####################"
+if [ -d /hal ]; then
+ VALUE=`/usr/bin/ls -R /hal | /usr/bin/grep -v "hal\:"`
+ if [ "$VALUE" ]; then
+ echo "WARNING!! There are some files to install to wrong path (/hal)"
+ echo "WARNING!! It has to be nothing under hal directory."
+ FILES=`/usr/bin/ls -R /hal`
+ for file in $FILES; do
+ if [[ $file =~ ":" ]]; then
+ echo $file
+ DIR=`echo $file | /usr/bin/awk -F ":" '{print $1}'`
+ fi
+ if [ -f $DIR/$file ]; then
+ echo $file
+ fi
+ done
+ fi
+fi
diff --git a/scripts/iot-hal-backend.post b/scripts/iot-hal-backend.post
new file mode 100644
index 0000000..a111a50
--- /dev/null
+++ b/scripts/iot-hal-backend.post
@@ -0,0 +1,160 @@
+#!/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" "ARTIK530");
+
+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`
+ ;;
+ ARTIK530)
+ BACKEND=`/usr/bin/xmlstarlet sel -t -v '//group[name = "IoT Hal Backend ARTIK530"]/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/tizen-build.conf
+
+TYPE=$(echo $TZ_BUILD_RELEASE_TYPE | /usr/bin/tr '[:upper:]' '[:lower:]')
+
+DATE=$(echo $TZ_BUILD_DATE | /usr/bin/awk -F"[-_.]" '{ print $1 }')
+
+RELEASE=$(echo $TZ_BUILD_ID | /bin/sed "s/.*$DATE/$DATE/")
+RELEASE=$(echo $RELEASE | /usr/bin/awk -F"[-_]" '{ print $1 }')
+
+ID=$(echo $TZ_BUILD_ID | /bin/sed "s/$DATE.*//")
+ID=$(echo $ID | /bin/sed "s/[-_.]*$//")
+
+
+/bin/cat <<EOF > /hal/etc/hal-info.ini
+[Version]
+Model=$TZ_BUILD_RELEASE_NAME;
+Build=$TZ_BUILD_ID;
+Release=$RELEASE;
+[Build]
+Type=$TYPE;
+Date=$TZ_BUILD_DATE;
+Time=$TZ_BUILD_TIME;
+Variant=$TZ_BUILD_VARIANT;
+ID=$ID;
+EOF