debugreport functional
This commit is contained in:
parent
08a2121ffe
commit
986f7ed645
|
@ -1 +1,2 @@
|
|||
build_logs
|
||||
*.cast
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
{"version": 2, "width": 207, "height": 25, "timestamp": 1718750280, "env": {"SHELL": "/bin/zsh", "TERM": "xterm-256color"}}
|
||||
[0.256711, "o", "\u001b[1m\u001b[7m%\u001b[27m\u001b[1m\u001b[0m \r \r\u001b]2;aedev@computers-iMac:~/dev/debugreport\u0007\u001b]1;..v/debugreport\u0007"]
|
||||
[0.261332, "o", "\u001b]7;file://computers-iMac.localdomain/Users/aedev/dev/debugreport\u001b\\"]
|
||||
[0.276765, "o", "\r\u001b[0m\u001b[27m\u001b[24m\u001b[J\u001b[35maedev\u001b[00m\u001b[36m@\u001b[00m\u001b[33mcomputers-iMac\u001b[00m\u001b[31m:\u001b[00m\u001b[36m~/dev/debugreport\u001b[00m\u001b[31m|\u001b[00m\u001b[36m⇒\u001b[00m \u001b[K"]
|
||||
[0.276846, "o", "\u001b[?1h\u001b=\u001b[?2004h"]
|
||||
[1.569833, "o", "l"]
|
||||
[1.585655, "o", "\b\u001b[32ml\u001b[39m"]
|
||||
[1.586509, "o", "\b\u001b[32ml\u001b[39m\u001b[90ms\u001b[39m\b"]
|
||||
[1.704188, "o", "\b\u001b[32ml\u001b[32ms\u001b[39m"]
|
||||
[1.841041, "o", "\u001b[?1l\u001b>"]
|
||||
[1.841212, "o", "\u001b[?2004l"]
|
||||
[1.844016, "o", "\r\r\n"]
|
||||
[1.84507, "o", "\u001b]2;ls -G\u0007\u001b]1;ls\u0007"]
|
||||
[1.862516, "o", "README.md \u001b[31mbuild.sh\u001b[39;49m\u001b[0m \u001b[1m\u001b[36mdist\u001b[39;49m\u001b[0m install.sh\r\nasciinema-20240618183800.cast \u001b[1m\u001b[36mbuild_logs\u001b[39;49m\u001b[0m go.mod main.go\r\n"]
|
||||
[1.862743, "o", "\u001b[1m\u001b[7m%\u001b[27m\u001b[1m\u001b[0m \r \r"]
|
||||
[1.862912, "o", "\u001b]2;aedev@computers-iMac:~/dev/debugreport\u0007\u001b]1;..v/debugreport\u0007"]
|
||||
[1.86532, "o", "\u001b]7;file://computers-iMac.localdomain/Users/aedev/dev/debugreport\u001b\\"]
|
||||
[1.885521, "o", "\r\u001b[0m\u001b[27m\u001b[24m\u001b[J\u001b[35maedev\u001b[00m\u001b[36m@\u001b[00m\u001b[33mcomputers-iMac\u001b[00m\u001b[31m:\u001b[00m\u001b[36m~/dev/debugreport\u001b[00m\u001b[31m|\u001b[00m\u001b[36m⇒\u001b[00m \u001b[K"]
|
||||
[1.885742, "o", "\u001b[?1h\u001b=\u001b[?2004h"]
|
||||
[3.353476, "o", "o"]
|
||||
[3.359874, "o", "\b\u001b[1m\u001b[31mo\u001b[0m\u001b[39m"]
|
||||
[3.360155, "o", "\b\u001b[1m\u001b[31mo\u001b[0m\u001b[39m\u001b[90mpen Sandsara-tracks\u001b[39m\u001b[19D"]
|
||||
[4.076455, "o", "\b\u001b[1m\u001b[31mo\u001b[1m\u001b[31mk\u001b[0m\u001b[39m\u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[18D"]
|
||||
[4.195769, "o", "\b\b\u001b[1m\u001b[31mo\u001b[1m\u001b[31mk\u001b[1m\u001b[31ma\u001b[0m\u001b[39m"]
|
||||
[4.451507, "o", "\b\u001b[1m\u001b[31ma\u001b[1m\u001b[31my\u001b[0m\u001b[39m"]
|
||||
[4.616607, "o", "\b\u001b[1m\u001b[31my\u001b[1m\u001b[31m \u001b[0m\u001b[39m"]
|
||||
[4.619412, "o", "\b\b\u001b[1m\u001b[31my\u001b[0m\u001b[39m\u001b[0m\u001b[39m "]
|
||||
[5.413241, "o", "\b\b\b\b\b"]
|
||||
[5.998918, "o", "\u001b[0m\u001b[39me\u001b[1m\u001b[31mo\u001b[1m\u001b[31mk\u001b[1m\u001b[31ma\u001b[1m\u001b[31my\u001b[0m\u001b[39m \b\b\b\b\b"]
|
||||
[6.005631, "o", "\b\u001b[1m\u001b[31me"]
|
||||
[6.235222, "o", "\b\u001b[1m\u001b[31me\u001b[1m\u001b[31mc\u001b[1m\u001b[31mo\u001b[1m\u001b[31mk\u001b[1m\u001b[31ma\u001b[1m\u001b[31my\u001b[0m\u001b[39m \b\b\b\b\b"]
|
||||
[6.331374, "o", "\u001b[1m\u001b[31mh\u001b[1m\u001b[31mo\u001b[1m\u001b[31mk\u001b[1m\u001b[31ma\u001b[1m\u001b[31my\u001b[0m\u001b[39m \b\b\b\b\b"]
|
||||
[6.417782, "o", "\u001b[1C\u001b[1m\u001b[31mo\u001b[1m\u001b[31mk\u001b[1m\u001b[31ma\u001b[1m\u001b[31my\u001b[0m\u001b[39m \b\b\b\b\b"]
|
||||
[6.52071, "o", "\u001b[1m\u001b[31m \u001b[1m\u001b[31mo\u001b[1m\u001b[31mk\u001b[1m\u001b[31ma\u001b[1m\u001b[31my\u001b[0m\u001b[39m \b\b\b\b\b"]
|
||||
[6.535294, "o", "\b\b\b\b\b\u001b[0m\u001b[32me\u001b[0m\u001b[32mc\u001b[0m\u001b[32mh\u001b[0m\u001b[32mo\u001b[39m\u001b[0m\u001b[39m \u001b[0m\u001b[39mo\u001b[0m\u001b[39mk\u001b[0m\u001b[39ma\u001b[0m\u001b[39my\b\b\b\b"]
|
||||
[6.986127, "o", "\u001b[?1l\u001b>"]
|
||||
[6.986177, "o", "\u001b[?2004l"]
|
||||
[6.989743, "o", "\r\r\n"]
|
||||
[6.991177, "o", "\u001b]2;echo okay\u0007\u001b]1;echo\u0007"]
|
||||
[7.024897, "o", "okay\r\n"]
|
||||
[7.024932, "o", "\u001b[1m\u001b[7m%\u001b[27m\u001b[1m\u001b[0m \r \r"]
|
||||
[7.02502, "o", "\u001b]2;aedev@computers-iMac:~/dev/debugreport\u0007\u001b]1;..v/debugreport\u0007"]
|
||||
[7.027346, "o", "\u001b]7;file://computers-iMac.localdomain/Users/aedev/dev/debugreport\u001b\\"]
|
||||
[7.040054, "o", "\r\u001b[0m\u001b[27m\u001b[24m\u001b[J\u001b[35maedev\u001b[00m\u001b[36m@\u001b[00m\u001b[33mcomputers-iMac\u001b[00m\u001b[31m:\u001b[00m\u001b[36m~/dev/debugreport\u001b[00m\u001b[31m|\u001b[00m\u001b[36m⇒\u001b[00m \u001b[K"]
|
||||
[7.040286, "o", "\u001b[?1h\u001b=\u001b[?2004h"]
|
||||
[8.494716, "o", "\u001b[?2004l\r\r\n"]
|
33
build.sh
33
build.sh
|
@ -1,41 +1,46 @@
|
|||
#!/bin/bash
|
||||
|
||||
ARCHITECTURES=("linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64" "windows/amd64")
|
||||
PROJECT_NAME=$(basename "$(pwd)")
|
||||
PROJECTS=("main.go:debugreport" "decodereport.go:decodereport")
|
||||
|
||||
prepare_build() {
|
||||
mkdir -p dist build_logs
|
||||
if [ ! -f go.mod ]; then
|
||||
go mod init "$PROJECT_NAME"
|
||||
go mod init "$(basename "$(pwd)")"
|
||||
fi
|
||||
go mod tidy
|
||||
}
|
||||
|
||||
build_binary() {
|
||||
local os=$1
|
||||
local arch=$2
|
||||
local output="dist/${PROJECT_NAME}_${os}_${arch}"
|
||||
env GOOS=$os GOARCH=$arch go build -o $output . &> "build_logs/${os}_${arch}.log"
|
||||
local source_file=$1
|
||||
local project_name=$2
|
||||
local os=$3
|
||||
local arch=$4
|
||||
local output="dist/${project_name}_${os}_${arch}"
|
||||
env GOOS=$os GOARCH=$arch go build -o $output $source_file &> "build_logs/${project_name}_${os}_${arch}.log"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Build failed for $os/$arch" >> "build_logs/error.log"
|
||||
echo "Build failed for $project_name on $os/$arch" >> "build_logs/error.log"
|
||||
else
|
||||
echo "Build succeeded for $os/$arch"
|
||||
echo "Build succeeded for $project_name on $os/$arch"
|
||||
fi
|
||||
if [ "$os" == "linux" ]; then
|
||||
env GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o "${output}_static" . &> "build_logs/${os}_${arch}_static.log"
|
||||
env GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o "${output}_static" $source_file &> "build_logs/${project_name}_${os}_${arch}_static.log"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Static build failed for $os/$arch" >> "build_logs/error.log"
|
||||
echo "Static build failed for $project_name on $os/$arch" >> "build_logs/error.log"
|
||||
else
|
||||
echo "Static build succeeded for $os/$arch"
|
||||
echo "Static build succeeded for $project_name on $os/$arch"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
prepare_build
|
||||
for arch in "${ARCHITECTURES[@]}"; do
|
||||
IFS="/" read -r os arch <<< "$arch"
|
||||
build_binary $os $arch
|
||||
for project in "${PROJECTS[@]}"; do
|
||||
IFS=":" read -r source_file project_name <<< "$project"
|
||||
for arch in "${ARCHITECTURES[@]}"; do
|
||||
IFS="/" read -r os arch <<< "$arch"
|
||||
build_binary $source_file $project_name $os $arch
|
||||
done
|
||||
done
|
||||
echo "Build process completed."
|
||||
}
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Function to download a file from a URL and save it locally
|
||||
func downloadFile(url string, fileName string) error {
|
||||
// Get the data
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
// Create the file
|
||||
out, err := os.Create(fileName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
// Write the body to file
|
||||
_, err = io.Copy(out, resp.Body)
|
||||
return err
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) != 2 {
|
||||
fmt.Println("Usage: ./downloadcast <hastebin-url>")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
hastebinURL := os.Args[1]
|
||||
if !strings.HasPrefix(hastebinURL, "https://haste.nixc.us/") {
|
||||
fmt.Println("Invalid Hastebin URL. Please provide a valid URL from haste.nixc.us")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Get the key from the URL
|
||||
parts := strings.Split(hastebinURL, "/")
|
||||
if len(parts) < 4 {
|
||||
fmt.Println("Invalid Hastebin URL format")
|
||||
os.Exit(1)
|
||||
}
|
||||
key := parts[len(parts)-1]
|
||||
|
||||
// Build the raw URL for downloading the content
|
||||
rawURL := fmt.Sprintf("https://haste.nixc.us/raw/%s", key)
|
||||
fileName := fmt.Sprintf("%s.cast", key)
|
||||
|
||||
fmt.Printf("Downloading from %s to %s\n", rawURL, fileName)
|
||||
|
||||
// Download the file
|
||||
err := downloadFile(rawURL, fileName)
|
||||
if err != nil {
|
||||
fmt.Printf("Error downloading the file: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Downloaded file saved as %s\n", fileName)
|
||||
|
||||
// Optional: Play the downloaded cast file using asciinema
|
||||
playCmd := exec.Command("asciinema", "play", fileName)
|
||||
playCmd.Stdout = os.Stdout
|
||||
playCmd.Stderr = os.Stderr
|
||||
err = playCmd.Run()
|
||||
if err != nil {
|
||||
fmt.Printf("Error playing the cast file: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Println("Playback finished.")
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
29
install.sh
29
install.sh
|
@ -1,13 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
INSTALL_DIR="/usr/local/bin"
|
||||
BINARY_NAME="debugreport"
|
||||
BASE_URL="https://git.nixc.us/colin/debugreport/raw/branch/master/dist"
|
||||
|
||||
|
||||
# Supported architectures
|
||||
ARCHITECTURES=("linux/amd64" "linux/arm64" "linux/arm/v7" "darwin/amd64" "darwin/arm64")
|
||||
|
||||
# Determine the OS and architecture
|
||||
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
||||
ARCH="$(uname -m)"
|
||||
|
||||
|
@ -18,17 +17,21 @@ case $ARCH in
|
|||
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
|
||||
esac
|
||||
|
||||
BINARY_URL="${BASE_URL}/${BINARY_NAME}_${OS}_${ARCH}"
|
||||
BINARIES=("debugreport" "decodereport")
|
||||
|
||||
echo "Downloading and installing $BINARY_NAME from $BINARY_URL..."
|
||||
for BINARY_NAME in "${BINARIES[@]}"; do
|
||||
BINARY_URL="${BASE_URL}/${BINARY_NAME}_${OS}_${ARCH}"
|
||||
|
||||
# Check if we have write permission to the install directory
|
||||
if [ -w "${INSTALL_DIR}" ]; then
|
||||
curl -sSL "$BINARY_URL" -o "${INSTALL_DIR}/${BINARY_NAME}"
|
||||
chmod +x "${INSTALL_DIR}/${BINARY_NAME}"
|
||||
else
|
||||
sudo curl -sSL "$BINARY_URL" -o "${INSTALL_DIR}/${BINARY_NAME}"
|
||||
sudo chmod +x "${INSTALL_DIR}/${BINARY_NAME}"
|
||||
fi
|
||||
echo "Downloading and installing $BINARY_NAME from $BINARY_URL..."
|
||||
|
||||
echo "Installed $BINARY_NAME to $INSTALL_DIR"
|
||||
# Check if we have write permission to the install directory
|
||||
if [ -w "${INSTALL_DIR}" ]; then
|
||||
curl -sSL "$BINARY_URL" -o "${INSTALL_DIR}/${BINARY_NAME}"
|
||||
chmod +x "${INSTALL_DIR}/${BINARY_NAME}"
|
||||
else
|
||||
sudo curl -sSL "$BINARY_URL" -o "${INSTALL_DIR}/${BINARY_NAME}"
|
||||
sudo chmod +x "${INSTALL_DIR}/${BINARY_NAME}"
|
||||
fi
|
||||
|
||||
echo "Installed $BINARY_NAME to $INSTALL_DIR"
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue