-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
139 lines (123 loc) · 5.67 KB
/
release.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
139
#!/bin/bash
# Prerequisites
## git
## aria2c or wget
## curl
## 7z
## internet access
downloader="null"
init_downloader() {
if which aria2c; then
downloader=(aria2c -s16 -x16 -k1M -c --file-allocation=falloc)
elif which wget; then
downloader=(wget -t3 -c)
else
echo 'fatal: cannot find a downloader'
fi
}
fetch() {
if [[ "${downloader}" = "null" ]]; then
init_downloader
fi
"${downloader[@]}" -o "$2" "$1"
}
update_ffmpeg() {
local b='64'
if [[ "$1" = "32" ]]; then
b='32'
fi
local filename=$(eval echo "\${ffmpeg_version_remote_${b}}")
local url="$(eval echo "\${ffmpeg_url_${b}}")${filename}"
local path="$(echo "${filename}" | sed 's/\.zip$//')"
echo Downloading "${filename}" ...
fetch "${url}" "${filename}"
echo Unpacking "${filename}" ...
unzip -qo "${filename}"
echo Updating ffmpeg "${b}-bit" ...
mv -f "${path}/bin/ffmpeg.exe" "bin${b}/"
echo Cleaning up ffmpeg "${b}-bit" files...
rm -rf "./${path}/presets" "./${path}/doc"
rm -f "./${path}/bin/ffplay.exe" "./${path}/bin/ffprobe.exe" "./${path}/LICENSE.txt" "./${path}/README.txt" "${filename}"
rm -d "${path}/bin" "${path}"
}
echo Fetching remote ffmpeg info...
ffmpeg_regex='ffmpeg-\d+-[\da-f]+-win\d\d-.+?\.zip'
ffmpeg_url_64='https://ffmpeg.zeranoe.com/builds/win64/static/'
ffmpeg_url_32='https://ffmpeg.zeranoe.com/builds/win32/static/'
ffmpeg_version_remote_64="$(curl -L -s "${ffmpeg_url_64}" | grep -ioP "${ffmpeg_regex}" | uniq | sort -r | head -1)"
ffmpeg_version_remote_32="$(curl -L -s "${ffmpeg_url_32}" | grep -ioP "${ffmpeg_regex}" | uniq | sort -r | head -1)"
ffmpeg_date_remote_64="$(echo "${ffmpeg_version_remote_64}" | grep -ioP '\d{8}')"
ffmpeg_date_remote_32="$(echo "${ffmpeg_version_remote_32}" | grep -ioP '\d{8}')"
ffmpeg_date_64="$(stat -c %Y bin64/ffmpeg | xargs -I '*' date -d@'*' '+%0000Y%00m%00d')"
ffmpeg_date_32="$(stat -c %Y bin32/ffmpeg | xargs -I '*' date -d@'*' '+%0000Y%00m%00d')"
echo Remote 64-bit ffmpeg date: $ffmpeg_date_remote_64
echo Local 64-bit ffmpeg date: $ffmpeg_date_64
echo Remote 32-bit ffmpeg date: $ffmpeg_date_remote_32
echo Local 32-bit ffmpeg date: $ffmpeg_date_32
if [[ $ffmpeg_date_remote_64 > $ffmpeg_date_64 ]]; then
update_ffmpeg 64
fi
if [[ $ffmpeg_date_remote_32 > $ffmpeg_date_32 ]]; then
update_ffmpeg 32
fi
echo Fetching remote busybox info...
busybox_info_url='https://frippery.org/busybox/'
busybox_bin_url='https://frippery.org/files/busybox/'
busybox_version_64="$("./bin64/busybox64.exe" | head -1 | grep -ioP '\d+-g[\da-z]+' | grep -ioP '\d+' | head -1)"
busybox_version_32="$("./bin32/busybox.exe" | head -1 | grep -ioP '\d+-g[\da-z]+' | grep -ioP '\d+' | head -1)"
busybox_version_remote="$(curl -k -s -L --retry 5 --retry-connrefused "${busybox_info_url}" | grep -ioP '\d+-g[\da-z]+' | uniq | grep -ioP '\d+' | head -1)"
echo Remote busybox version: $busybox_version_remote
echo Local 64-bit busybox version: $busybox_version_64
echo Local 32-bit busybox version: $busybox_version_32
if [[ $busybox_version_64 < $busybox_version_remote ]]; then
echo Updating busybox 64-bit...
fetch "${busybox_bin_url}busybox64.exe" "busybox64_${busybox_version_remote}.exe"
"./busybox64_${busybox_version_remote}" && mv -f "busybox64_${busybox_version_remote}.exe" "./bin64/busybox64.exe"
fi
if [[ $busybox_version_32 < $busybox_version_remote ]]; then
echo Updating busybox 32-bit...
fetch "${busybox_bin_url}busybox.exe" "busybox_${busybox_version_remote}.exe"
"./busybox_${busybox_version_remote}" && mv -f "busybox_${busybox_version_remote}.exe" "./bin32/busybox.exe"
fi
echo Downloading mujs if not exist...
mujs_url='https://ci.appveyor.com/api/projects/myfreeer/mujs/artifacts/'
[[ ! -e bin64/mujs.exe ]] && fetch "${mujs_url}mujs_x64.7z" mujs_x64.7z && 7z x mujs_x64.7z && mv -f mujs.exe bin64/ && rm -f mujs_x64.7z
[[ ! -e bin32/mujs.exe ]] && fetch "${mujs_url}mujs_x86.7z" mujs_x86.7z && 7z x mujs_x86.7z && mv -f mujs.exe bin32/ && rm -f mujs_x86.7z
echo Fetching remote MediaInfo info...
mediainfo_url='https://mediaarea.net/download/binary/mediainfo'
update_mediainfo() {
local b='64'
local v='x64'
if [[ "$1" = "32" ]]; then
b='32'
v='i386'
fi
local filename="MediaInfo_CLI_${mediainfo_version_remote}_Windows_${v}.zip"
local url="${mediainfo_url}/${mediainfo_version_remote}/${filename}"
local path="$(echo "${filename}" | sed 's/\.zip$//')"
mkdir -p "${path}"
cd "${path}"
echo Downloading "${filename}" ...
fetch "${url}" "${filename}"
echo Unpacking "${filename}" ...
unzip -qo "${filename}"
echo Updating MediaInfo "${b}-bit" ...
mv -f "MediaInfo.exe" "../bin${b}/"
cd ..
echo Cleaning up MediaInfo "${b}-bit" files...
rm -rf "./${path}"
}
mediainfo_version_remote="$(curl -k -s -L --retry 5 --retry-connrefused "${mediainfo_url}" | grep -ioP '(\d+\.)+\d+' | uniq | sort -uVr | head -1)"
mediainfo_version_32="$(bin32/MediaInfo --Version | grep -ioP '(\d+\.)+\d+' | head -1)"
mediainfo_version_64="$(bin64/MediaInfo --Version | grep -ioP '(\d+\.)+\d+' | head -1)"
if [[ $mediainfo_version_remote > $mediainfo_version_64 ]]; then
update_mediainfo 64
fi
if [[ $mediainfo_version_remote > $mediainfo_version_32 ]]; then
update_mediainfo 32
fi
echo Packaging nogui...
nogui_date="$(git log -n1 --date=short --pretty=format:'%ad' | sed 's/-//g')"
nogui_ver="$(git describe --tags)"
package_name="nogui-${nogui_date}-${nogui_ver}.7z"
[[ ! -e "${package_name}" ]] && 7z a -mx9 -myx9 "${package_name}" "*" -xr!"*.7z" -xr!".git" -xr!".gitignore" -xr!"tmp"