forked from iDiamondhunter/More-bows
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathremoveDirectoryEntries.sh
More file actions
26 lines (25 loc) · 838 Bytes
/
Copy pathremoveDirectoryEntries.sh
File metadata and controls
26 lines (25 loc) · 838 Bytes
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
#!/bin/bash
# Rezips all built .jar files, to remove directory entries.
# This reduces the file size by a small amount.
for file in ./build/libs/*.jar
do
unzip "$file" -d ./build/libs/temp
rm "$file"
find ./build/libs/temp/ \( -iname '*.json' -o -iname '*.info' \) -type f -print0 | while IFS= read -r -d $'\0' jsonFile
do
if [[ "$OSTYPE" == "darwin"* ]]; then
if ! command -v gsed &> /dev/null
then
echo "Please install GNU sed as gsed"
else
jq -c . < "$jsonFile" | gsed -z '$ s/\n$//' > "$jsonFile-tempOut"
fi
else
jq -c . < "$jsonFile" | sed -z '$ s/\n$//' > "$jsonFile-tempOut"
fi
mv "$jsonFile-tempOut" "$jsonFile"
done
# TODO replace this with standard zip
advzip "$file" --shrink-store --pedantic -a ./build/libs/temp/**
rm -rf ./build/libs/temp/
done