diff options
author | Markdols | 2023-12-13 17:25:31 -0600 |
---|---|---|
committer | Markdols | 2023-12-13 17:25:31 -0600 |
commit | fcf935a9bf44b874c4d5840e05e9a3df814b8954 (patch) | |
tree | 0edfdac0ef06d656ae30902bf1babbf86913f771 | |
parent | 8bb5aad2b83007af038d6df85fa9a8b909da8f82 (diff) | |
download | aur-fcf935a9bf44b874c4d5840e05e9a3df814b8954.tar.gz |
Added install script that cleans up toolchains and symlinks when removing the package
-rw-r--r-- | .SRCINFO | 3 | ||||
-rwxr-xr-x | PKGBUILD | 5 | ||||
-rw-r--r-- | swiftly-bin.install | 18 |
3 files changed, 23 insertions, 3 deletions
@@ -1,8 +1,9 @@ pkgbase = swiftly-bin pkgdesc = A Swift toolchain installer and manager, written in Swift. pkgver = 0.1.0 - pkgrel = 1 + pkgrel = 2 url = https://swift-server.github.io/swiftly/ + install = swiftly-bin.install arch = x86_64 license = apache depends = libutil-linux @@ -3,7 +3,7 @@ _pkgname=swiftly pkgname=swiftly-bin pkgver=0.1.0 -pkgrel=1 +pkgrel=2 pkgdesc="A Swift toolchain installer and manager, written in Swift." arch=('x86_64') url="https://swift-server.github.io/swiftly/" @@ -15,6 +15,7 @@ provides=(swift-language) conflicts=(swift-language) source=("https://github.com/swift-server/${_pkgname}/releases/download/${pkgver}/${_pkgname}-x86_64-unknown-linux-gnu") sha256sums=('b3ef4e3d652a622af8f5ec54c1264e0ad9de37fa26e81cfe70649833c0039e45') +install='swiftly-bin.install' package() { mkdir -p ~/.local/share/${_pkgname}/toolchains @@ -23,5 +24,5 @@ package() { fi install -D -m 0755 ${_pkgname}-x86_64-unknown-linux-gnu ${pkgdir}/usr/bin/${_pkgname} echo "Config and toolchains can be found in ~/.local/share/swiftly. Toolchains are installed to ~/.local/bin." - echo "If you decide to uninstall, be sure to remove all toolchains first with \"swiftly uninstall (toolchain)\"." + echo "Please do not modify ~/.local/share/swiftly/toolchains. That directory should only be managed by swiftly itself." } diff --git a/swiftly-bin.install b/swiftly-bin.install new file mode 100644 index 000000000000..33a64d8f2eb7 --- /dev/null +++ b/swiftly-bin.install @@ -0,0 +1,18 @@ +pre_remove() { + echo "Removing all Swift installations..." + echo "IF THERE ARE ANY FILES IN ~/.local/share/swiftly/toolchains THAT ARE NOT MANAGED BY SWIFTLY, PLEASE INTERRUPT THIS AND REMOVE THEM. IT WILL CAUSE AN INFINITE LOOP OTHERWISE." + while true + do + if [ "$(ls -A /home/$SUDO_USER/.local/share/swiftly/toolchains)" ]; then + runuser -l $SUDO_USER -c 'swiftly uninstall latest -y' + else + break + fi + done +} + +post_remove() { + if [ -d /home/$SUDO_USER/.local/share/swiftly ]; then + rm -rf /home/$SUDO_USER/.local/share/swiftly + fi +} |