summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Holman2017-05-30 21:23:51 -0500
committerDaniel Holman2017-05-30 21:23:51 -0500
commit3d07bf4e2e96ad34e921e1f39ad116844fd5234d (patch)
tree81da40369618531ef6a2758c0014c8e6140a100d
downloadaur-3d07bf4e2e96ad34e921e1f39ad116844fd5234d.tar.gz
Initial commit
-rw-r--r--.SRCINFO17
-rw-r--r--LICENSE19
-rw-r--r--PKGBUILD27
-rw-r--r--orphan-manager15
-rw-r--r--orphan-manager.service6
-rw-r--r--orphan-manager.timer9
6 files changed, 93 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..ef4ace04fd1a
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,17 @@
+pkgbase = orphan-manager
+ pkgdesc = Systemd timer to automatically remove orphaned packages
+ pkgver = 1.0
+ pkgrel = 1
+ arch = any
+ license = MIT
+ depends = coreutils
+ depends = systemd
+ source = orphan-manager
+ source = orphan-manager.service
+ source = orphan-manager.timer
+ sha256sums = 32af05fcbee78a58ce8026fc42abf04286dd9e568eedb4343bcbae97de8803ca
+ sha256sums = 822c5314564143815bc2765cb3e7d33ca21ca2c17c0752eae34fc5e8610d17b6
+ sha256sums = 4c2c3936aca97ccf8269e8756a304a66743938d69337c3b097b0b92fc8a13855
+
+pkgname = orphan-manager
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000000000000..cc86bf9420ce
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,19 @@
+Copyright 2017 Daniel Holman <dholman@gymli.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..e826e62eba1b
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,27 @@
+# Maintainer: Daniel Holman <dholman@gymli.org>
+pkgname=orphan-manager
+pkgver=1.0
+pkgrel=1
+pkgdesc="Systemd timer to automatically remove orphaned packages"
+arch=('any')
+license=('MIT')
+depends=('coreutils' 'systemd')
+source=("orphan-manager"
+ "orphan-manager.service"
+ "orphan-manager.timer")
+sha256sums=('32af05fcbee78a58ce8026fc42abf04286dd9e568eedb4343bcbae97de8803ca'
+ '822c5314564143815bc2765cb3e7d33ca21ca2c17c0752eae34fc5e8610d17b6'
+ '4c2c3936aca97ccf8269e8756a304a66743938d69337c3b097b0b92fc8a13855')
+
+package() {
+ mkdir -p "${pkgdir}/usr/lib/systemd/system/"
+ mkdir -p "${pkgdir}/usr/bin/"
+
+ cp "orphan-manager.service" "${pkgdir}/usr/lib/systemd/system/"
+ cp "orphan-manager.timer" "${pkgdir}/usr/lib/systemd/system"
+ chmod 644 "${pkgdir}/usr/lib/systemd/system/orphan-manager.service"
+ chmod 644 "${pkgdir}/usr/lib/systemd/system/orphan-manager.timer"
+
+ cp "orphan-manager" "${pkgdir}/usr/bin"
+ chmod 755 "${pkgdir}/usr/bin/orphan-manager"
+}
diff --git a/orphan-manager b/orphan-manager
new file mode 100644
index 000000000000..c08e64951062
--- /dev/null
+++ b/orphan-manager
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# Cleans up orphaned packages on an Arch Linux system
+
+if [[ $EUID -ne 0 ]]; then
+ echo "You must be root to run this program"
+ exit
+fi
+
+ORPHANS=$(pacman -Qdtq)
+if [[ -z $ORPHANS ]]; then
+ echo "No orphans present. Stopping."
+else
+ pacman -Rns --noconfirm $ORPHANS
+fi
diff --git a/orphan-manager.service b/orphan-manager.service
new file mode 100644
index 000000000000..aded94e5696e
--- /dev/null
+++ b/orphan-manager.service
@@ -0,0 +1,6 @@
+[Unit]
+Description=Removes orphaned packages
+
+[Service]
+Type=simple
+ExecStart=/usr/local/bin/orphans
diff --git a/orphan-manager.timer b/orphan-manager.timer
new file mode 100644
index 000000000000..640e45ca3ab0
--- /dev/null
+++ b/orphan-manager.timer
@@ -0,0 +1,9 @@
+[Unit]
+Description=Remove orphaned packages
+
+[Timer]
+OnBootSec=15min
+OnUnitActiveSec=1w
+
+[Install]
+WantedBy=timers.target