1- I see the issue! The script has a bug where it's outputting text while trying to parse the URL, causing the download URL to be malformed. Let me fix this script for you:The main issues I fixed:
2-
3- 1. **URL parsing bug**: The script was mixing print statements with the URL extraction, causing malformed URLs like `[INFO] Fetching...` to be passed to curl
4- 2. **Better error handling**: Separated the URL and version into two separate lines
5- 3. **URL validation**: Added a check to ensure the URL starts with `https://`
6- 4. **Debian compatibility**: Prioritized `apt-get` in the package manager detection
7- 5. **Better `grep` compatibility**: Changed from `grep -oP` (Perl regex) to `grep -oE` (extended regex) for better compatibility
8- 6. **Simplified file size display**: Made `numfmt` optional since it might not be available on all systems
9-
10- To use the fixed script on your Debian 13 system:
11-
12- ```bash
13- # First, install jq if you don't have it
14- sudo apt-get update && sudo apt-get install -y jq
15-
16- # Download the fixed script
17- curl -o install-kusl-tsp.sh https://raw.githubusercontent.com/kusl/tsp/refs/heads/master/scripts/install-linux.sh
18-
19- # Or save the fixed version I provided above
20- nano install-kusl-tsp.sh
21- # (paste the fixed script)
22-
23- # Make it executable
24- chmod +x install-kusl-tsp.sh
25-
26- # Run with sudo
27- sudo ./install-kusl-tsp.sh
28- ```
29-
30- The script should now:
31- 1. Properly fetch the latest release info from GitHub
32- 2. Correctly parse the download URL
33- 3. Download the binary without errors
34- 4. Install it to `/opt/kusl-tsp`
35- 5. Create a symlink in `/usr/local/bin` if possible
36-
37- Let me know if you encounter any other issues!
38-
39-
40-
41- ```bash
1+ PowerShell 7.6.0-preview.4
2+ PS C:\Users\kushal>
3+ PS C:\Users\kushal> ssh
[email protected] 4+ 5+ Linux texas 6.12.38+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.38-1 (2025-07-16) x86_64
6+
7+ The programs included with the Debian GNU/Linux system are free software;
8+ the exact distribution terms for each program are described in the
9+ individual files in /usr/share/doc/*/copyright.
10+
11+ Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
12+ permitted by applicable law.
13+ Last login: Thu Aug 14 10:58:39 2025 from 192.168.0.126
14+ kushal@texas:~$
15+ kushal@texas:~$ dotnet
16+ -bash: dotnet: command not found
17+ kushal@texas:~$ curl
18+ curl: try 'curl --help' or 'curl --manual' for more information
19+ kushal@texas:~$ curl --help
20+ Usage: curl [options...] <url>
21+ -d, --data <data> HTTP POST data
22+ -f, --fail Fail fast with no output on HTTP errors
23+ -h, --help <subject> Get help for commands
24+ -o, --output <file> Write to file instead of stdout
25+ -O, --remote-name Write output to file named as remote file
26+ -i, --show-headers Show response headers in output
27+ -s, --silent Silent mode
28+ -T, --upload-file <file> Transfer local FILE to destination
29+ -u, --user <user:password> Server user and password
30+ -A, --user-agent <name> Send User-Agent <name> to server
31+ -v, --verbose Make the operation more talkative
32+ -V, --version Show version number and quit
33+
34+ This is not the full help; this menu is split into categories.
35+ Use "--help category" to get an overview of all categories, which are:
36+ auth, connection, curl, deprecated, dns, file, ftp, global, http, imap, ldap, output, pop3, post, proxy, scp, sftp, smtp, ssh, telnet, tftp, timeout, tls, upload, verbose.
37+ Use "--help all" to list all options
38+ Use "--help [option]" to view documentation for a given option
39+ kushal@texas:~$ curl --version
40+ curl 8.14.1 (x86_64-pc-linux-gnu) libcurl/8.14.1 OpenSSL/3.5.1 zlib/1.3.1 brotli/1.1.0 zstd/1.5.7 libidn2/2.3.8 libpsl/0.21.2 libssh2/1.11.1 nghttp2/1.64.0 nghttp3/1.8.0 librtmp/2.3 OpenLDAP/2.6.10
41+ Release-Date: 2025-06-04, security patched: 8.14.1-2
42+ Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp ws wss
43+ Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd
44+ kushal@texas:~$ cd mybashscripts/
45+ kushal@texas:~/mybashscripts$ time curl -o install-kusl-tsp.sh https://raw.githubusercontent.com/kusl/tsp/master/install-linux.sh
46+ % Total % Received % Xferd Average Speed Time Time Time Current
47+ Dload Upload Total Spent Left Speed
48+ 100 14 100 14 0 0 119 0 --:--:-- --:--:-- --:--:-- 119
49+
50+ real 0m0.136s
51+ user 0m0.039s
52+ sys 0m0.009s
53+ kushal@texas:~/mybashscripts$ cat ~/mybashscripts/install-kusl-tsp.sh
54+ 404: Not Foundkushal@texas:~/mybashscripts$
55+ kushal@texas:~/mybashscripts$ time curl -o install-kusl-tsp.sh https://raw.githubusercontent.com/kusl/tsp/refs/heads/master/scripts/install-linux.sh
56+ % Total % Received % Xferd Average Speed Time Time Time Current
57+ Dload Upload Total Spent Left Speed
58+ 100 9059 100 9059 0 0 120k 0 --:--:-- --:--:-- --:--:-- 122k
59+
60+ real 0m0.091s
61+ user 0m0.038s
62+ sys 0m0.008s
63+ kushal@texas:~/mybashscripts$ cat ~/mybashscripts/install-kusl-tsp.sh
4264#!/bin/bash
4365
4466# TSP Solver Installation Script for Linux
@@ -116,12 +138,12 @@ check_dependencies() {
116138 print_info "Install them with:"
117139
118140 # Detect package manager
119- if command -v apt-get &> /dev/null; then
120- echo " sudo apt-get update && sudo apt-get install -y ${missing[*]}"
121- elif command -v dnf &> /dev/null; then
122- echo " sudo dnf install -y ${missing[*]}"
141+ if command -v dnf &> /dev/null; then
142+ echo " sudo dnf install ${missing[*]}"
123143 elif command -v yum &> /dev/null; then
124- echo " sudo yum install -y ${missing[*]}"
144+ echo " sudo yum install ${missing[*]}"
145+ elif command -v apt-get &> /dev/null; then
146+ echo " sudo apt-get install ${missing[*]}"
125147 else
126148 echo " Please install: ${missing[*]}"
127149 fi
@@ -140,28 +162,27 @@ get_latest_release_info() {
140162 return 1
141163 }
142164
143- # Extract the Linux x64 binary URL from assets
165+ # Extract the Linux x64 binary URL
144166 local download_url
145167 download_url=$(echo "$response" | jq -r '.assets[] | select(.name | contains("linux-x64")) | .browser_download_url' 2>/dev/null | head -n1)
146168
147- # If no asset found, construct URL from tag
148- if [[ -z "$download_url" ]] || [[ "$download_url" == "null" ]]; then
169+ if [[ -z "$download_url" ]]; then
170+ # Try alternative pattern from release body or tag
149171 local tag_name
150172 tag_name=$(echo "$response" | jq -r '.tag_name' 2>/dev/null)
151173
152- if [[ -n "$tag_name" ]] && [[ "$tag_name" != "null" ]] ; then
174+ if [[ -n "$tag_name" ]]; then
153175 # Extract SHA from tag (format: v25.8.18.1138-76e0c299)
154176 local sha
155- sha=$(echo "$tag_name" | grep -oE '[a-f0-9]{8}$' || true)
177+ sha=$(echo "$tag_name" | grep -oP '[a-f0-9]{8}$' || true)
156178
157179 if [[ -n "$sha" ]]; then
158180 download_url="https://github.com/${GITHUB_REPO}/releases/download/${tag_name}/TSP-linux-x64-${sha}"
159- print_info "Constructed download URL from tag: ${tag_name}"
160181 fi
161182 fi
162183 fi
163184
164- if [[ -z "$download_url" ]] || [[ "$download_url" == "null" ]] ; then
185+ if [[ -z "$download_url" ]]; then
165186 print_error "Could not find Linux x64 binary in the latest release"
166187 print_info "Please check: https://github.com/${GITHUB_REPO}/releases"
167188 return 1
@@ -170,9 +191,7 @@ get_latest_release_info() {
170191 local version
171192 version=$(echo "$response" | jq -r '.tag_name' 2>/dev/null || echo "unknown")
172193
173- # Return both URL and version
174- echo "${download_url}"
175- echo "${version}"
194+ echo "$download_url|$version"
176195}
177196
178197# Download the binary
@@ -182,9 +201,8 @@ download_binary() {
182201
183202 print_info "Downloading from: $url"
184203
185- # Use curl with proper error handling
186- if ! curl -L -f -o "$output_file" "$url" --progress-bar 2>/dev/null; then
187- print_error "Failed to download binary from $url"
204+ if ! curl -L -f -o "$output_file" "$url" --progress-bar; then
205+ print_error "Failed to download binary"
188206 return 1
189207 fi
190208
@@ -199,19 +217,10 @@ download_binary() {
199217
200218 if [[ "$file_size" -lt 1000 ]]; then
201219 print_error "Downloaded file seems too small (${file_size} bytes)"
202- print_error "This might indicate a 404 or other download error"
203220 return 1
204221 fi
205222
206- # Use a simpler size display that works on more systems
207- local size_display
208- if command -v numfmt &> /dev/null; then
209- size_display=$(numfmt --to=iec-i --suffix=B "$file_size" 2>/dev/null || echo "${file_size} bytes")
210- else
211- size_display="${file_size} bytes"
212- fi
213-
214- print_success "Download complete (${size_display})"
223+ print_success "Download complete ($(numfmt --to=iec-i --suffix=B "$file_size" 2>/dev/null || echo "${file_size} bytes"))"
215224}
216225
217226# Check if binary is already installed and get its version
@@ -304,21 +313,11 @@ main() {
304313 print_info "No existing installation found"
305314 fi
306315
307- # Get latest release info (now returns two lines)
316+ # Get latest release info
308317 local release_info
309318 release_info=$(get_latest_release_info) || exit 1
310319
311- # Read the two lines
312- local download_url
313- local latest_version
314- download_url=$(echo "$release_info" | head -n1)
315- latest_version=$(echo "$release_info" | tail -n1)
316-
317- # Validate URL
318- if [[ ! "$download_url" =~ ^https:// ]]; then
319- print_error "Invalid download URL: $download_url"
320- exit 1
321- fi
320+ IFS='|' read -r download_url latest_version <<< "$release_info"
322321
323322 print_info "Latest available version: ${latest_version}"
324323
@@ -366,12 +365,55 @@ main() {
366365 print_info "Testing installation..."
367366 if "${INSTALL_PATH}" --version &>/dev/null; then
368367 print_success "Installation test passed!"
369- echo "Version: $("${INSTALL_PATH}" --version 2>/dev/null | head -n1 || echo "unknown")"
370368 else
371369 print_warning "Could not verify installation. Please test manually."
372370 fi
373371}
374372
375373# Run main function
376374main "$@"
377- ```
375+ kushal@texas:~/mybashscripts$ chmod +x install-kusl-tsp.sh
376+ kushal@texas:~/mybashscripts$ sudo date; time sudo ./install-kusl-tsp.sh
377+ [sudo] password for kushal:
378+ Sorry, try again.
379+ [sudo] password for kushal:
380+ Sun Aug 17 09:57:48 PM EDT 2025
381+ =================================================
382+ TSP Solver Installation Script
383+ Repository: https://github.com/kusl/tsp
384+ =================================================
385+
386+ [INFO] No existing installation found
387+ [INFO] Latest available version:
388+ [INFO] Downloading from: [INFO] Fetching latest release information from GitHub...
389+ curl: (3) bad range in URL position 4:
390+ [INFO] Fetching latest release information from GitHub...
391+ ^
392+ [ERROR] Failed to download binary
393+
394+ real 0m0.246s
395+ user 0m0.000s
396+ sys 0m0.017s
397+ kushal@texas:~/mybashscripts$ sudo date; time sudo ./install-kusl-tsp.sh
398+ Sun Aug 17 09:57:59 PM EDT 2025
399+ =================================================
400+ TSP Solver Installation Script
401+ Repository: https://github.com/kusl/tsp
402+ =================================================
403+
404+ [INFO] No existing installation found
405+ [INFO] Latest available version:
406+ [INFO] Downloading from: [INFO] Fetching latest release information from GitHub...
407+ curl: (3) bad range in URL position 4:
408+ [INFO] Fetching latest release information from GitHub...
409+ ^
410+ [ERROR] Failed to download binary
411+
412+ real 0m0.201s
413+ user 0m0.015s
414+ sys 0m0.000s
415+ kushal@texas:~/mybashscripts$
416+ kushal@texas:~/mybashscripts$ exit
417+ logout
418+ Connection to 192.168.0.120 closed.
419+ PS C:\Users\kushal>
0 commit comments