Created
March 19, 2021 14:12
-
-
Save erfanoabdi/47a0de511dc585b93e034f7a5e8c8223 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BASE_ROM=$1 | |
NEW_ROM=$2 | |
PROP_FILES=$3 | |
TMP=/Users/erfanabdi/Desktop/dep_tmp.txt | |
PROP_FILES_ORG=$PROP_FILES.org | |
cp $PROP_FILES $PROP_FILES_ORG | |
MOVE_TO_BLOB_SECTION() | |
{ | |
TARGET=$1 | |
TARGET_FILE=`echo $TARGET | sed "s|.*/||"` | |
while read -r SUB_LINE; do | |
[[ -z "$SUB_LINE" ]] && continue | |
if [[ $SUB_LINE = \#* ]]; then | |
[[ $SUB_LINE =~ "# " ]] && SUB_SECTION=`echo "$SUB_LINE" | cut -c2- | xargs` | |
else | |
[[ "$SUB_SECTION" = "Misc" ]] && continue | |
#[[ -z `file $NEW_ROM/$SUB_LINE | grep "ARM" | grep -v "relocatable"` ]] && continue | |
#BLOB_DEPS=`readelf -d $NEW_ROM/$SUB_LINE | grep NEEDED | awk '{print $5}' | sed -e 's@\[@@g' -e 's@\]@@g'` | |
#for DEP in $BLOB_DEPS; do | |
#if [[ $DEP = $TARGET_FILE ]]; then | |
[[ $SUB_LINE = '-'* ]] && SUB_LINE=`echo "$SUB_LINE" | cut -c2-` | |
SUB_LINE_from_source=`echo "$SUB_LINE" | cut -d ":" -f 1 | cut -d "|" -f 1` | |
#SUB_LINE_from_rom=`echo "$SUB_LINE" | cut -d ":" -f 2 | cut -d "|" -f 1` | |
SUB_LINE_FILE=`echo $SUB_LINE | sed "s|.*/||"` | |
if grep -q "$TARGET_FILE" "$NEW_ROM/$SUB_LINE_from_source" || grep -q "$SUB_LINE_FILE" "$NEW_ROM/$TARGET"; then | |
echo "$SUB_LINE from $SUB_SECTION" | |
sed -i "\|$TARGET|d" $PROP_FILES | |
sed -ie -z "s|$SUB_LINE|$SUB_LINE\n$TARGET|" $PROP_FILES | |
return 1 | |
fi | |
#done | |
fi | |
done < $PROP_FILES_ORG | |
} | |
while read -r line | |
do | |
[[ -z "$line" ]] && continue | |
if [[ $line = \#* ]]; then | |
[[ $line =~ "# " ]] && SECTION=`echo "$line" | cut -c2- | xargs` | |
else | |
if [[ "$SECTION" = "Misc" ]]; then | |
[[ $line = '-'* ]] && line=`echo "$line" | cut -c2-` | |
#from_source=`echo "$line" | cut -d ":" -f 1 | cut -d "|" -f 1` | |
from_rom=`echo "$line" | cut -d ":" -f 2 | cut -d "|" -f 1` | |
#[[ ! $line =~ "vendor/lib" ]] && continue | |
echo $from_rom | |
#[[ -z `file $NEW_ROM/$line | grep "ARM" | grep -v "relocatable"` ]] && continue | |
MOVE_TO_BLOB_SECTION $from_rom | |
fi | |
fi | |
done < $PROP_FILES_ORG | |
exit | |
echo $line | |
echo $line "in $section section" | |
deps=`readelf -d $NEW_ROM/$line | grep NEEDED | awk '{print $5}' | sed -e 's@\[@@g' -e 's@\]@@g'` | |
for w in $deps | |
do | |
if grep -q "$w".txt; then | |
grep -q "$w" $PROP_FILES | |
sed -i `grep -q "$w" $PROP_FILES` $PROP_FILES | |
fi | |
if [[ -z `find $BASE_ROM -name $w` ]] ; then | |
if grep -q "$w" $PROP_FILES; then | |
echo "Found:" `grep "$w" $PROP_FILES` | |
grep "$w" $PROP_FILES | |
echo `grep "$w" $PROP_FILES` | |
else | |
echo "Not found: $w" | |
fi | |
else | |
echo "found: `echo $w`" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment