summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeongHyun Kang <jhyuni.kang@samsung.com>2016-06-17 14:22:24 +0900
committerJeongHyun Kang <jhyuni.kang@samsung.com>2016-06-17 15:12:04 +0900
commit4cb09bb4240c1e4a00469e08a3ea8c1fb8dda8aa (patch)
treea446921214f4b64070da81425fd67f14499c77eb
parentdeb12cbbb6fcfa42afb8be07e8e2bee89413f3ed (diff)
downloadxkeyboard-config-4cb09bb4240c1e4a00469e08a3ea8c1fb8dda8aa.tar.gz
xkeyboard-config-4cb09bb4240c1e4a00469e08a3ea8c1fb8dda8aa.tar.bz2
xkeyboard-config-4cb09bb4240c1e4a00469e08a3ea8c1fb8dda8aa.zip
Change-Id: If80c074760b5f0c6825620f7445f313d96bde68f
-rw-r--r--packaging/xkeyboard-config.spec4
-rwxr-xr-xremove_symbols.sh305
-rwxr-xr-xremove_unused_files.sh52
3 files changed, 308 insertions, 53 deletions
diff --git a/packaging/xkeyboard-config.spec b/packaging/xkeyboard-config.spec
index 71f482e6..0a7e98e0 100644
--- a/packaging/xkeyboard-config.spec
+++ b/packaging/xkeyboard-config.spec
@@ -80,10 +80,10 @@ mv -f %{buildroot}/%{TZ_SYS_RO_SHARE}/X11/xkb/rules/evdev %{buildroot}/%{TZ_SYS_
sed -i 's/evdev/tizen_%{?profile}/g' %{buildroot}/%{TZ_SYS_RO_SHARE}/X11/xkb/rules/tizen_"%{?profile}"
ln -sf tizen_"%{?profile}" %{buildroot}/%{TZ_SYS_RO_SHARE}/X11/xkb/rules/evdev
export LOCAL_KEYMAP_PATH=%{buildroot}/%{TZ_SYS_RO_SHARE}/X11/xkb
-./remove_unused_files.sh
-
export RULE_FILE_PATH=%{TZ_SYS_RO_SHARE}/X11/xkb/xkb.rule
export KEYMAP_FILE_PATH="%{KEYMAP_FILE_PATH}"
+./remove_unused_files.sh
+
%ifarch aarch64 x86_64
%else
if [ -e %{buildroot}%{_bindir}/cache ]; then
diff --git a/remove_symbols.sh b/remove_symbols.sh
new file mode 100755
index 00000000..6de7651c
--- /dev/null
+++ b/remove_symbols.sh
@@ -0,0 +1,305 @@
+#!/bin/sh
+
+RULE_FILE=${RULE_FILE_PATH}
+XKB_FILES_PATH=${LOCAL_KEYMAP_PATH}"/symbols/"
+TEMP_SAVE_FILE="./tmp.txt"
+TEMP_UNDELETE_LIST_FILE="./tmp_list.txt"
+TEMP_UNDELETE_LIST_FOLDER="./tmp_folder.txt"
+SUPPORTED_LAYOUTS=""
+ALREADY_LAYOUT=0
+LAYOUTS=""
+END_FLAG=0
+UNDELETE_LAYOUTS=""
+
+START_POINT=0
+SECTION_FLAG=0
+DEEP_FIND_COUNT=0
+
+function Add_Layout()
+{
+ NEW_STRING=$1"("$2")"
+
+ [[ "${SUPPORTED_LAYOUTS}" == *"${NEW_STRING}"* ]] && ALREADY_LAYOUT=1
+
+ if [ "$ALREADY_LAYOUT" == "1" ]; then
+ return
+ fi
+
+ SUPPORTED_LAYOUTS=$SUPPORTED_LAYOUTS$NEW_STRING","
+}
+
+function Search_Symbol()
+{
+ STRING=$1
+
+ if [[ "${STRING}" == *"include \""* ]]; then
+ HAVE_SECTION_FLAG=0
+ NEW_STRING=${STRING#include \"}
+ NEW_STRING=${NEW_STRING%\"}
+
+ [[ "${NEW_STRING}" == *"("* ]] && HAVE_SECTION_FLAG=1
+
+ if [ "${HAVE_SECTION_FLAG}" == "1" ]; then
+ NEW_LAYOUT=${NEW_STRING%%(*}
+ SECTION=${NEW_STRING#$NEW_LAYOUT}
+ SECTION=${SECTION#(}
+ SECTION=${SECTION%)}
+
+ Find_Layout $NEW_LAYOUT $SECTION
+ SECTION_FLAG=$DEEP_FIND_COUNT
+ START_POINT=1
+ else
+ NEW_LAYOUT=$NEW_STRING
+ Find_Default_Layout $NEW_LAYOUT
+ SECTION_FLAG=$DEEP_FIND_COUNT
+ START_POINT=1
+ fi
+ fi
+
+}
+
+function Find_Layout()
+{
+ LAYOUT=$1
+ LAYOUT_FILE_PATH=${XKB_FILES_PATH}${LAYOUT}
+
+ DEEP_FIND_COUNT=$(echo $(($DEEP_FIND_COUNT+1)))
+
+ if [ ! -e ${LAYOUT_FILE_PATH} ]; then
+ return
+ fi
+
+ Add_Layout $1 $2
+
+ if [ "$ALREADY_LAYOUT" == "1" ]; then
+ ALREADY_LAYOUT=0
+ DEEP_FIND_COUNT=$(echo $(($DEEP_FIND_COUNT-1)))
+ return
+ fi
+
+ FIND_LAYOUT_FLAG=0
+ SECTION_FLAG=$DEEP_FIND_COUNT
+ START_POINT=0
+
+ while read STRING
+ do
+ [[ "${STRING}" == *"xkb_symbols \"$2\""* ]] && FIND_LAYOUT_FLAG=1
+
+ if [ "$FIND_LAYOUT_FLAG" == "1" ]; then
+ [[ "${STRING}" == *"{"* ]] && START_POINT=$(echo $START_POINT "1" | awk '{print $1 + $2}')
+ [[ "${STRING}" == *"}"* ]] && START_POINT=$(echo $START_POINT "1" | awk '{print $1 - $2}')
+
+ if [ "${SECTION_FLAG}" == $DEEP_FIND_COUNT ]; then
+ if [ "${START_POINT}" == 1 ]; then
+ SECTION_FLAG=$(echo $(($SECTION_FLAG+1)))
+ fi
+ fi
+
+ Search_Symbol "$STRING"
+
+ if [ "${SECTION_FLAG}" != $DEEP_FIND_COUNT ]; then
+ if [ "${START_POINT}" == "0" ]; then
+ break
+ fi
+ fi
+ fi
+ done < ${LAYOUT_FILE_PATH}
+ DEEP_FIND_COUNT=$(echo $(($DEEP_FIND_COUNT-1)))
+}
+
+function Find_Default_Layout()
+{
+ LAYOUT=$1
+ LAYOUT_FILE_PATH=${XKB_FILES_PATH}${LAYOUT}
+ DEEP_FIND_COUNT=$(echo $(($DEEP_FIND_COUNT+1)))
+
+ INCLUDE_CNT=0
+ PREV_INCLUDE_CNT=$INCLUDE_CNT
+
+ STRING_DEFAULT_LINE=0
+ GET_DEFAULT_SYMBOL_LAYOUT_FLAG=0
+
+ START_POINT=0
+ SECTION_FLAG=$DEEP_FIND_COUNT
+
+ while read STRING
+ do
+ [[ "${STRING}" == *"default"* ]] && STRING_DEFAULT_LINE=1
+
+ if [ $STRING_DEFAULT_LINE == 1 ]; then
+ DEFAULT_SYMBOL_LAYOUT="default"
+
+ [[ "${STRING}" == *"{"* ]] && START_POINT=$(echo $START_POINT "1" | awk '{print $1 + $2}')
+ [[ "${STRING}" == *"}"* ]] && START_POINT=$(echo $START_POINT "1" | awk '{print $1 - $2}')
+
+ if [ "${SECTION_FLAG}" == $DEEP_FIND_COUNT ]; then
+ if [ "${START_POINT}" == 1 ]; then
+ SECTION_FLAG=$(echo $(($SECTION_FLAG+1)))
+ fi
+ fi
+
+ if [[ "${STRING}" == *"xkb_symbols"* ]]; then
+ GET_DEFAULT_SYMBOL_LAYOUT_FLAG=1
+ fi
+
+
+ if [ "$GET_DEFAULT_SYMBOL_LAYOUT_FLAG" == "1" ]; then
+ DEFAULT_SYMBOL_LAYOUT=${STRING#xkb_symbols \"}
+ DEFAULT_SYMBOL_LAYOUT=${DEFAULT_SYMBOL_LAYOUT%\"*}
+ Add_Layout $1 $DEFAULT_SYMBOL_LAYOUT
+ if [ "$ALREADY_LAYOUT" == "1" ]; then
+ ALREADY_LAYOUT=0
+ DEEP_FIND_COUNT=$(echo $(($DEEP_FIND_COUNT-1)))
+ return
+ fi
+ GET_DEFAULT_SYMBOL_LAYOUT_FLAG=0
+ fi
+
+ Search_Symbol "$STRING"
+
+ if [ "${SECTION_FLAG}" != $DEEP_FIND_COUNT ]; then
+ if [ "${START_POINT}" == "0" ]; then
+ break
+ fi
+ fi
+ fi
+ done < ${LAYOUT_FILE_PATH}
+ DEEP_FIND_COUNT=$(echo $(($DEEP_FIND_COUNT-1)))
+}
+
+BASE_LAYOUTS=""
+DEFAULT_MODEL=""
+DEFAULT_LAYOUT=""
+
+if [ -e ${RULE_FILE} ]
+then
+ while read STRING
+ do
+ if [[ $STRING == *"model="* ]]; then
+ DEFAULT_MODEL=${STRING#*=}
+ fi
+ if [[ $STRING == *"layout="* ]]; then
+ DEFAULT_LAYOUT=${STRING#*=}
+ fi
+ [[ $STRING != *"supported_layout"* ]] && continue
+ BASE_LAYOUTS=${STRING#supported_layouts=}
+ echo "Support language: "$BASE_LAYOUTS
+ done < ${RULE_FILE}
+
+ echo "Default Model/Layout: "$DEFAULT_MODEL"/"$DEFAULT_LAYOUT
+
+ LAYOUTS=$BASE_LAYOUTS
+ if [[ "$DEFAULT_MODEL" == *"pc"* ]]; then
+ LAYOUTS=$LAYOUTS", pc"
+ fi
+ if [[ "$LAYOUTS" != *$DEFAULT_LAYOUT* ]]; then
+ LAYOUTS=$LAYOUTS", "$DEFAULT_LAYOUT
+ fi
+
+ for ((;;)); do
+ SUB_LAYOUT=${LAYOUTS%%,*}
+ LAYOUTS=${LAYOUTS#$SUB_LAYOUT}
+ LAYOUTS=${LAYOUTS#,}
+
+ START_POINT=0
+ SECTION_FLAG=0
+ DEEP_FIND_COUNT=0
+
+ Find_Default_Layout $SUB_LAYOUT
+
+ echo $SUPPORTED_LAYOUTS
+
+ if [ ! "$LAYOUTS" ]; then
+ break
+ fi
+ done
+
+ echo "Supported layouts: "$SUPPORTED_LAYOUTS
+ if [ -e ${TEMP_UNDELETE_LIST_FILE} ]; then
+ rm $TEMP_UNDELETE_LIST_FILE
+ fi
+
+ for ((;;)); do
+ SUB_LAYOUT=${SUPPORTED_LAYOUTS%%(*}
+
+ HAVE_UNDELETE_LAYOUT_FLAG=0
+
+ [[ $UNDELETE_LAYOUTS == *"$SUB_LAYOUT"* ]] && HAVE_UNDELETE_LAYOUT_FLAG=1
+
+ if [ "$HAVE_UNDELETE_LAYOUT_FLAG" == "0" ]; then
+ UNDELETE_LAYOUTS=$UNDELETE_LAYOUTS$SUB_LAYOUT" "
+ echo $SUB_LAYOUT >> $TEMP_UNDELETE_LIST_FILE
+ fi
+
+ SUPPORTED_LAYOUTS=${SUPPORTED_LAYOUTS#$SUB_LAYOUT}
+ SUPPORTED_LAYOUTS=${SUPPORTED_LAYOUTS#*,}
+ if [ ! "$SUPPORTED_LAYOUTS" ];then
+ break
+ fi
+ done
+fi
+
+touch $TEMP_SAVE_FILE
+touch $TEMP_UNDELETE_LIST_FILE
+touch $TEMP_UNDELETE_LIST_FOLDER
+
+if [[ $UNDELETE_LAYOUTS != *"inet"* ]]; then
+ UNDELETE_LAYOUTS=$UNDELETE_LAYOUTS" inet"
+ echo "inet" >> $TEMP_UNDELETE_LIST_FILE
+fi
+
+while read UNDELETE_LIST
+do
+ if [[ "$UNDELETE_LIST" == *"/"* ]]; then
+ SUB_FOLDER=$UNDELETE_LIST
+ for ((;;)); do
+ SUB_FOLDER=${SUB_FOLDER%/*}
+ echo $XKB_FILES_PATH$SUB_FOLDER >> $TEMP_UNDELETE_LIST_FOLDER
+
+ [[ "$SUB_FOLDER" != *"/"* ]] && break
+ done
+ fi
+done < $TEMP_UNDELETE_LIST_FILE
+
+
+echo "Undeleted layouts: "$UNDELETE_LAYOUTS
+UNDELETE_SYMBOL_FLAG=0
+
+find $XKB_FILES_PATH > $TEMP_SAVE_FILE
+while read SYMBOL_FILES
+do
+ echo "$SYMBOL_FILES"
+ if [ -d $SYMBOL_FILES ]; then
+ if [[ $SYMBOL_FILES == $XKB_FILES_PATH ]]; then
+ continue
+ fi
+ UNDELETE_FOLDER_FLAG=0
+ while read UNDELETE_FOLDER
+ do
+ if [[ $SYMBOL_FILES == $UNDELETE_FOLDER ]]; then
+ UNDELETE_FOLDER_FLAG=1
+ break
+ fi
+ done < $TEMP_UNDELETE_LIST_FOLDER
+ if [[ "$UNDELETE_FOLDER_FLAG" == "1" ]]; then
+ continue
+ fi
+ fi
+ SYMBOL_FILES=${SYMBOL_FILES#$XKB_FILES_PATH}
+ while read UNDELETE_LIST
+ do
+ if [[ "$UNDELETE_LIST" == $SYMBOL_FILES ]]; then
+ UNDELETE_SYMBOL_FLAG=1
+ break
+ fi
+ done < $TEMP_UNDELETE_LIST_FILE
+
+ if [ "$UNDELETE_SYMBOL_FLAG" == "0" ]; then
+ rm -rf $XKB_FILES_PATH$SYMBOL_FILES
+ fi
+ UNDELETE_SYMBOL_FLAG=0
+done < $TEMP_SAVE_FILE
+
+rm $TEMP_SAVE_FILE
+rm $TEMP_UNDELETE_LIST_FILE
+rm $TEMP_UNDELETE_LIST_FOLDER
diff --git a/remove_unused_files.sh b/remove_unused_files.sh
index ad7017e2..d0ab20e3 100755
--- a/remove_unused_files.sh
+++ b/remove_unused_files.sh
@@ -32,57 +32,7 @@ rm -rf ${KEYMAP_PATH}/rules/xfree*
rm -rf ${KEYMAP_PATH}/rules/xkb.dtd
rm -rf ${KEYMAP_PATH}/rules/xorg*
-rm -rf ${KEYMAP_PATH}/symbols/af
-rm -rf ${KEYMAP_PATH}/symbols/al
-rm -rf ${KEYMAP_PATH}/symbols/am
-rm -rf ${KEYMAP_PATH}/symbols/apl
-rm -rf ${KEYMAP_PATH}/symbols/ara
-rm -rf ${KEYMAP_PATH}/symbols/at
-rm -rf ${KEYMAP_PATH}/symbols/az
-rm -rf ${KEYMAP_PATH}/symbols/b*
-rm -rf ${KEYMAP_PATH}/symbols/c*
-rm -rf ${KEYMAP_PATH}/symbols/d*
-rm -rf ${KEYMAP_PATH}/symbols/e*
-rm -rf ${KEYMAP_PATH}/symbols/f*
-rm -rf ${KEYMAP_PATH}/symbols/g*
-rm -rf ${KEYMAP_PATH}/symbols/h*
-rm -rf ${KEYMAP_PATH}/symbols/ie
-rm -rf ${KEYMAP_PATH}/symbols/il
-rm -rf ${KEYMAP_PATH}/symbols/in
-rm -rf ${KEYMAP_PATH}/symbols/iq
-rm -rf ${KEYMAP_PATH}/symbols/ir
-rm -rf ${KEYMAP_PATH}/symbols/is
-rm -rf ${KEYMAP_PATH}/symbols/it
-rm -rf ${KEYMAP_PATH}/symbols/j*
-rm -rf ${KEYMAP_PATH}/symbols/ke
-rm -rf ${KEYMAP_PATH}/symbols/kg
-rm -rf ${KEYMAP_PATH}/symbols/kh
-rm -rf ${KEYMAP_PATH}/symbols/kr
-rm -rf ${KEYMAP_PATH}/symbols/kz
-rm -rf ${KEYMAP_PATH}/symbols/l*
-rm -rf ${KEYMAP_PATH}/symbols/m*
-rm -rf ${KEYMAP_PATH}/symbols/n*
-rm -rf ${KEYMAP_PATH}/symbols/o*
-rm -rf ${KEYMAP_PATH}/symbols/ph
-rm -rf ${KEYMAP_PATH}/symbols/pk
-rm -rf ${KEYMAP_PATH}/symbols/pl
-rm -rf ${KEYMAP_PATH}/symbols/pt
-rm -rf ${KEYMAP_PATH}/symbols/se
-rm -rf ${KEYMAP_PATH}/symbols/sgi_vndr
-rm -rf ${KEYMAP_PATH}/symbols/sharp_vndr
-rm -rf ${KEYMAP_PATH}/symbols/shift
-rm -rf ${KEYMAP_PATH}/symbols/si
-rm -rf ${KEYMAP_PATH}/symbols/sk
-rm -rf ${KEYMAP_PATH}/symbols/sn
-rm -rf ${KEYMAP_PATH}/symbols/sony_vndr
-rm -rf ${KEYMAP_PATH}/symbols/sun_vndr
-rm -rf ${KEYMAP_PATH}/symbols/sy
-rm -rf ${KEYMAP_PATH}/symbols/t*
-rm -rf ${KEYMAP_PATH}/symbols/ua
-rm -rf ${KEYMAP_PATH}/symbols/uz
-rm -rf ${KEYMAP_PATH}/symbols/v*
-rm -rf ${KEYMAP_PATH}/symbols/x*
-rm -rf ${KEYMAP_PATH}/symbols/z*
+./remove_symbols.sh
rm -rf ${KEYMAP_PATH}/types/cancel
rm -rf ${KEYMAP_PATH}/types/caps