@@ -31,7 +31,7 @@ has() {
31
31
command -v " $1 " 1> /dev/null 2>&1
32
32
}
33
33
34
- SUPPORTED_TARGETS=" linux_amd64 linux_arm64 windows_amd64 darwin_amd64 darwin_arm64 "
34
+ SUPPORTED_TARGETS=" Linux_x86_64 Linux_arm64 Windows_x86_64 Darwin_x86_64 Darwin_arm64 "
35
35
36
36
get_latest_release () {
37
37
curl --silent " https://api.github.com/repos/mr-karan/doggo/releases/latest" |
@@ -40,11 +40,11 @@ get_latest_release() {
40
40
}
41
41
42
42
detect_platform () {
43
- platform=" $( uname -s | tr ' [:upper:] ' ' [:lower:] ' ) "
43
+ platform=" $( uname -s) "
44
44
case " ${platform} " in
45
- linux ) platform=" linux " ;;
46
- darwin ) platform=" darwin " ;;
47
- msys * |mingw * ) platform=" windows " ;;
45
+ Linux * ) platform=" Linux " ;;
46
+ Darwin * ) platform=" Darwin " ;;
47
+ MINGW * |MSYS * |CYGWIN * ) platform=" Windows " ;;
48
48
* )
49
49
error " Unsupported platform: ${platform} "
50
50
exit 1
@@ -56,7 +56,7 @@ detect_platform() {
56
56
detect_arch () {
57
57
arch=" $( uname -m) "
58
58
case " ${arch} " in
59
- x86_64) arch=" amd64 " ;;
59
+ x86_64) arch=" x86_64 " ;;
60
60
aarch64|arm64) arch=" arm64" ;;
61
61
* )
62
62
error " Unsupported architecture: ${arch} "
@@ -73,7 +73,11 @@ download_and_install() {
73
73
74
74
# Remove 'v' prefix from version for filename
75
75
version_no_v=" ${version# v} "
76
- filename=" doggo_${version_no_v} _${platform} _${arch} .tar.gz"
76
+ if [ " ${platform} " = " Windows" ]; then
77
+ filename=" doggo_${version_no_v} _${platform} _${arch} .zip"
78
+ else
79
+ filename=" doggo_${version_no_v} _${platform} _${arch} .tar.gz"
80
+ fi
77
81
url=" https://github.com/mr-karan/doggo/releases/download/${version} /${filename} "
78
82
79
83
info " Downloading doggo ${version} for ${platform} _${arch} ..."
@@ -99,39 +103,67 @@ download_and_install() {
99
103
fi
100
104
101
105
info " Verifying downloaded file..."
102
- if ! file " ${filename} " | grep -q " gzip compressed data" ; then
103
- error " Downloaded file is not in gzip format. Installation failed."
104
- error " File type:"
105
- file " ${filename} "
106
- rm -f " ${filename} "
107
- exit 1
106
+ if [ " ${platform} " = " Windows" ]; then
107
+ if ! file " ${filename} " | grep -q " Zip archive data" ; then
108
+ error " Downloaded file is not in zip format. Installation failed."
109
+ error " File type:"
110
+ file " ${filename} "
111
+ rm -f " ${filename} "
112
+ exit 1
113
+ fi
114
+ else
115
+ if ! file " ${filename} " | grep -q " gzip compressed data" ; then
116
+ error " Downloaded file is not in gzip format. Installation failed."
117
+ error " File type:"
118
+ file " ${filename} "
119
+ rm -f " ${filename} "
120
+ exit 1
121
+ fi
108
122
fi
109
123
110
124
info " Extracting ${filename} ..."
111
- if ! tar -xzvf " ${filename} " ; then
112
- error " Failed to extract ${filename} "
113
- rm -f " ${filename} "
114
- exit 1
125
+ extract_dir=" doggo_extract"
126
+ mkdir -p " ${extract_dir} "
127
+ if [ " ${platform} " = " Windows" ]; then
128
+ if ! unzip -q " ${filename} " -d " ${extract_dir} " ; then
129
+ error " Failed to extract ${filename} "
130
+ rm -rf " ${filename} " " ${extract_dir} "
131
+ exit 1
132
+ fi
133
+ else
134
+ if ! tar -xzvf " ${filename} " -C " ${extract_dir} " ; then
135
+ error " Failed to extract ${filename} "
136
+ rm -rf " ${filename} " " ${extract_dir} "
137
+ exit 1
138
+ fi
115
139
fi
116
140
117
141
info " Installing doggo..."
118
- if [ ! -f " doggo" ]; then
119
- error " doggo binary not found in the extracted files"
142
+ binary_name=" doggo"
143
+ if [ " ${platform} " = " Windows" ]; then
144
+ binary_name=" doggo.exe"
145
+ fi
146
+
147
+ # Find the doggo binary in the extracted directory
148
+ binary_path=$( find " ${extract_dir} " -name " ${binary_name} " -type f)
149
+
150
+ if [ -z " ${binary_path} " ]; then
151
+ error " ${binary_name} not found in the extracted files"
120
152
error " Extracted files:"
121
- ls -la
122
- rm -f " ${filename} "
153
+ ls -R " ${extract_dir} "
154
+ rm -rf " ${filename} " " ${extract_dir }"
123
155
exit 1
124
156
fi
125
157
126
- chmod +x doggo
127
- if ! sudo mv doggo /usr/local/bin/; then
158
+ chmod +x " ${binary_path} "
159
+ if ! sudo mv " ${binary_path} " /usr/local/bin/doggo ; then
128
160
error " Failed to move doggo to /usr/local/bin/"
129
- rm -f " ${filename} " " doggo "
161
+ rm -rf " ${filename} " " ${extract_dir} "
130
162
exit 1
131
163
fi
132
164
133
165
info " Cleaning up..."
134
- rm -f " ${filename} "
166
+ rm -rf " ${filename} " " ${extract_dir }"
135
167
136
168
completed " doggo ${version} has been installed to /usr/local/bin/doggo"
137
169
}
0 commit comments