diff --git a/apps/golang/credits b/apps/golang/credits new file mode 100644 index 0000000000..45d5f04648 --- /dev/null +++ b/apps/golang/credits @@ -0,0 +1,4 @@ +(github.com/.../...) +canha/golang-tools-install-script - the install script +golang/go - the language itself +slashtechno - addition to Pi-Apps \ No newline at end of file diff --git a/apps/golang/icon-24.png b/apps/golang/icon-24.png new file mode 100644 index 0000000000..18dab8e31c Binary files /dev/null and b/apps/golang/icon-24.png differ diff --git a/apps/golang/icon-64.png b/apps/golang/icon-64.png new file mode 100644 index 0000000000..6dc0e0ccb7 Binary files /dev/null and b/apps/golang/icon-64.png differ diff --git a/apps/golang/install b/apps/golang/install new file mode 100755 index 0000000000..7fb445e0f7 --- /dev/null +++ b/apps/golang/install @@ -0,0 +1,86 @@ +#!/bin/bash +version=1.19.3 + +[ -z "$GOROOT" ] && GOROOT="$HOME/.go" +[ -z "$GOPATH" ] && GOPATH="$HOME/go" + +case "$arch" in + "64") + PLATFORM="linux-arm64" + ;; + "32") + PLATFORM="linux-armv6l" + ;; + *) + error "arch variable is not set, can not continue" + ;; +esac + +if [ -z "$PLATFORM" ]; then + echo "Your operating system is not supported by the script." + exit 1 +fi + +if [ -n "$($SHELL -c 'echo $ZSH_VERSION')" ]; then + shell_profile="$HOME/.zshrc" +elif [ -n "$($SHELL -c 'echo $BASH_VERSION')" ]; then + shell_profile="$HOME/.bashrc" +elif [ -n "$($SHELL -c 'echo $FISH_VERSION')" ]; then + shell="fish" + if [ -d "$XDG_CONFIG_HOME" ]; then + shell_profile="$XDG_CONFIG_HOME/fish/config.fish" + else + shell_profile="$HOME/.config/fish/config.fish" + fi +fi + +if [ ! -z "$1" ]; then + echo "Unrecognized option: $1" + exit 1 +fi + +if [ -d "$GOROOT" ]; then + echo "The Go install directory ($GOROOT) already exists. Exiting." + exit 1 +fi + +PACKAGE_NAME="go$version.$PLATFORM.tar.gz" +TEMP_DIRECTORY=$(mktemp -d) + +echo "Downloading $PACKAGE_NAME ..." +wget https://storage.googleapis.com/golang/$PACKAGE_NAME -O "$TEMP_DIRECTORY/go.tar.gz" || error "Failed to download" + +if [ $? -ne 0 ]; then + echo "Download failed! Exiting." + exit 1 +fi + +echo "Extracting File..." +mkdir -p "$GOROOT" + +tar -C "$GOROOT" --strip-components=1 -xzf "$TEMP_DIRECTORY/go.tar.gz" || error "Failed to extract" + +echo "Configuring shell profile in: $shell_profile" +touch "$shell_profile" +if [ "$shell" == "fish" ]; then + { + echo '# GoLang' + echo "set GOROOT '${GOROOT}'" + echo "set GOPATH '$GOPATH'" + echo 'set PATH $GOPATH/bin $GOROOT/bin $PATH' + } >> "$shell_profile" +else + { + echo '# GoLang' + echo "export GOROOT=${GOROOT}" + echo 'export PATH=$GOROOT/bin:$PATH' + echo "export GOPATH=$GOPATH" + echo 'export PATH=$GOPATH/bin:$PATH' + } >> "$shell_profile" +fi + +mkdir -p "${GOPATH}/"{src,pkg,bin} +echo -e "\nGo $version was installed into $GOROOT.\nMake sure to relogin into your shell or run:" +echo -e "\n\tsource $shell_profile\n\nto update your environment variables." +echo "Tip: Opening a new terminal window usually just works. :)" +rm -f "$TEMP_DIRECTORY/go.tar.gz" \ No newline at end of file diff --git a/apps/golang/uninstall b/apps/golang/uninstall new file mode 100755 index 0000000000..4da46b8930 --- /dev/null +++ b/apps/golang/uninstall @@ -0,0 +1,30 @@ +#!/bin/bash +[ -z "$GOROOT" ] && GOROOT="$HOME/.go" + +if [ -n "$($SHELL -c 'echo $ZSH_VERSION')" ]; then + shell_profile="$HOME/.zshrc" +elif [ -n "$($SHELL -c 'echo $BASH_VERSION')" ]; then + shell_profile="$HOME/.bashrc" +elif [ -n "$($SHELL -c 'echo $FISH_VERSION')" ]; then + shell="fish" + if [ -d "$XDG_CONFIG_HOME" ]; then + shell_profile="$XDG_CONFIG_HOME/fish/config.fish" + else + shell_profile="$HOME/.config/fish/config.fish" + fi +fi +rm -rf "$GOROOT" + if [ "$shell" == "fish" ]; then + sed -i '/# GoLang/d' "$shell_profile" + sed -i '/set GOROOT/d' "$shell_profile" + sed -i '/set GOPATH/d' "$shell_profile" + sed -i '/set PATH $GOPATH\/bin $GOROOT\/bin $PATH/d' "$shell_profile" + else + sed -i '/# GoLang/d' "$shell_profile" + sed -i '/export GOROOT/d' "$shell_profile" + sed -i '/$GOROOT\/bin/d' "$shell_profile" + sed -i '/export GOPATH/d' "$shell_profile" + sed -i '/$GOPATH\/bin/d' "$shell_profile" + fi +echo "Go removed." +exit 0 \ No newline at end of file diff --git a/apps/golang/website b/apps/golang/website new file mode 100644 index 0000000000..01a885b76c --- /dev/null +++ b/apps/golang/website @@ -0,0 +1 @@ +https://go.dev/ \ No newline at end of file diff --git a/etc/categories b/etc/categories index b38fda07a6..ca0e37c910 100644 --- a/etc/categories +++ b/etc/categories @@ -74,6 +74,7 @@ GIMP|Creative Arts Github-CLI|Programming Github Desktop|Programming Godot|Games +Go|Programming GParted|System Management Guake Terminal|Terminals Heroes 2|Games