From: AJ ONeal Date: Sun, 15 Aug 2021 07:10:11 +0000 (+0000) Subject: feature: add Windows installer for gitea X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=22d3602c7d426200e3efe244e27bf15eaf6425da;p=webi-installers%2F.git feature: add Windows installer for gitea --- diff --git a/gitea/README.md b/gitea/README.md index ae9aa91..2283e4f 100644 --- a/gitea/README.md +++ b/gitea/README.md @@ -5,9 +5,11 @@ tagline: | Gitea: Git with a cup of tea, painless self-hosted git service. --- -To update or switch versions, run `webi gitea@stable` (or `@v1.0`, `@beta`, +To update or switch versions, run `webi gitea@stable` (or `@v1.14`, `@beta`, etc). +**Windows users**: You must [install git](/git) first. + ## Cheat Sheet > Gitea is a clean, lightweight self-hosted Github clone. It only uses a few diff --git a/gitea/install.ps1 b/gitea/install.ps1 new file mode 100644 index 0000000..11ca5db --- /dev/null +++ b/gitea/install.ps1 @@ -0,0 +1,55 @@ +#!/usr/bin/env pwsh + +################# +# Install gitea # +################# + +# Every package should define these variables +$pkg_cmd_name = "gitea" + +$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\gitea.exe" +$pkg_dst = "$pkg_dst_cmd" + +$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\gitea-v$Env:WEBI_VERSION\bin\gitea.exe" +$pkg_src_bin = "$Env:USERPROFILE\.local\opt\gitea-v$Env:WEBI_VERSION\bin" +$pkg_src_dir = "$Env:USERPROFILE\.local\opt\gitea-v$Env:WEBI_VERSION" +$pkg_src = "$pkg_src_cmd" + +$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE" + +# Fetch archive +IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE")) +{ + # TODO: arch detection + echo "Downloading gitea from $Env:WEBI_PKG_URL to $pkg_download" + & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" + & move "$pkg_download.part" "$pkg_download" +} + +IF (!(Test-Path -Path "$pkg_src_cmd")) +{ + echo "Installing gitea" + + # TODO: create package-specific temp directory + # Enter tmp + pushd .local\tmp + + # Remove any leftover tmp cruft + Remove-Item -Path ".\gitea-*" -Recurse -ErrorAction Ignore + Remove-Item -Path ".\gitea.exe" -Recurse -ErrorAction Ignore + + # Move single binary into root of temporary folder + & move "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE" "gitea.exe" + + # Settle unpacked archive into place + echo "Install Location: $pkg_src_cmd" + New-Item "$pkg_src_bin" -ItemType Directory -Force | out-null + Move-Item -Path "gitea.exe" -Destination "$pkg_src_bin" + + # Exit tmp + popd +} + +echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'" +Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore | out-null +Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse