forked from PhantomZone54/twrp_sources_norepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.sh
executable file
·138 lines (108 loc) · 4.11 KB
/
script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
# Authors - Neil "regalstreak" Agarwal, Harsh "MSF Jarvis" Shandilya, Tarang "DigiGoon" Kagathara
# 2017
# -----------------------------------------------------
# Modified by - Rokib Hasan Sagar @rokibhasansagar
# To be used to Release on AndroidFileHost and GitHub
# -----------------------------------------------------
# Definitions
DIR=$(pwd)
RecName=$1
LINK=$2
BRANCH=$3
# Some Machine Info
lscpu
df -hlT
echo -e "Github Authorization"
git config --global user.email $GitHubMail
git config --global user.name $GitHubName
git config --global color.ui true
git clone -q "https://[email protected]/rokibhasansagar/google-git-cookies.git" &> /dev/null
if [ -e google-git-cookies ]; then
bash google-git-cookies/setup_cookies.sh
rm -rf google-git-cookies
fi
echo -e "Main Function Starts HERE"
cd $DIR; mkdir $RecName; cd $RecName
echo -e "Initialize the repo data fetching"
repo init -q -u $LINK -b $BRANCH --depth 1 || repo init -q -u $LINK --depth 1
echo -e "Removing Unimportant Darwin-specific Files from syncing"
cd .repo/manifests
sed -i '/darwin/d' default.xml
( find . -type f -name '*.xml' | xargs sed -i '/darwin/d' ) || true
git commit -a -m "Magic" || true
cd ../
sed -i '/darwin/d' manifest.xml
cd ../
echo -e "Sync it up"
repo sync -c -q --force-sync --no-clone-bundle --optimized-fetch --prune --no-tags -j$(nproc --all)
echo -e "\nSHALLOW Source Syncing done\n"
echo -e "Remove all the .git folders from withing every Repositories"
find . \( -name ".git" -o -name ".gitignore" -o -name ".gitmodules" -o -name ".gitattributes" \) -exec rm -rf -- {} +
echo -e "Remove the .repo chunks"
rm -rf .repo/
echo -e "Show and Record Total Sizes of the checked-out non-repo files"
cd $DIR
echo -en "The total size of the checked-out files is --- "
du -sh $RecName
DDF=$(du -sh -BM $RecName | awk '{print $1}' | sed 's/M//')
echo -en "Value of DDF is --- " && echo $DDF
echo -e "Disc Usage After Repo Sync and Clear Stuffs ..."
df -hlT
cd $RecName
# Get the Version
export version=$(cat bootable/recovery/variables.h | grep "define TW_MAIN_VERSION_STR" | cut -d '"' -f2)
echo -en "The Recovery Version is -- " && echo $version
# Compress non-repo folder in one piece
echo -e "Compressing files --- "
echo -e "Please be patient, this will take time"
# Take a break
sleep 3s
mkdir -p ~/project/files/
datetime=$(date +%Y%m%d)
# Compression quality
export XZ_OPT="-9"
if [ $DDF -gt 6912 ]; then
mkdir $DIR/parts
echo -e "Compressing and Making 1.2GB parts Because of Huge Data Amount \nBe Patient..."
tar -cJf - * | split -b 1228M - ~/project/files/$RecName-$BRANCH-norepo-$datetime.tar.xz.
# Show Total Sizes of the compressed .repo
echo -en "Final Compressed size of the consolidated checked-out files is --- "
du -sh ~/project/files/
else
tar -cJf ~/project/files/$RecName-$BRANCH-norepo-$datetime.tar.xz *
echo -en "Final Compressed size of the consolidated checked-out archive is --- "
du -sh ~/project/files/$RecName-$BRANCH-norepo*.tar.xz
fi
echo -e "Compression Done"
echo -e "Final Disc Usage After Compression ..."
df -hlT
cd ~/project/files
echo -e "Taking md5 Hash"
md5sum * > $RecName-$BRANCH-norepo-$datetime.md5sum
cat $RecName-$BRANCH-norepo-$datetime.md5sum
# Show Total Sizes of the compressed files
echo -en "Final Compressed size of the checked-out files is --- "
du -sh ~/project/files/*
# Make a Compressed file list for future reference
cd ~/project/$RecName
ls -AhxcRis . >> $RecName-$BRANCH-*.file.log || echo "filelist generation error"
echo -en "Size of filelist text is -- " && du -sh *.file.log
tar -cJf ~/project/files/$RecName-$BRANCH-norepo.filelist.tar.xz *.file.log
rm *.file.log
cd $DIR
echo -e "Basic Cleanup"
rm -rf $RecName
echo -e "Preparing for Upload"
cd ~/project/files/
for file in $RecName-$BRANCH*; do
echo -e "\nUploading $file ...\n"
wput $file ftp://"$FTPUser":"$FTPPass"@"$FTPHost"//$RecName-NoRepo/
sleep 2s
done
echo -e " Done uploading to AFH"
cd ~/project/
rm -f files/core* || true
ghr -u $GitHubName -t $GITHUB_TOKEN -b "Releasing Latest TWRP Sources using OmniROM's Minimal-Manifest" v$version-$datetime files/
echo -e "\nCongratulations! Job Done!"
rm -rf files/