summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoseph DiGiovanni2023-11-25 14:34:03 -0500
committerJoseph DiGiovanni2023-11-25 14:34:03 -0500
commit7ee1ae4939517e97a3ec5d7e714b7af08ef8f5da (patch)
treeaed2df801a5047480df46d86af9df038f1fb9c04
downloadaur-7ee1ae4939517e97a3ec5d7e714b7af08ef8f5da.tar.gz
Initial commit
-rw-r--r--.SRCINFO11
-rw-r--r--.gitignore3
-rw-r--r--PKGBUILD16
-rwxr-xr-xpacdate.sh87
4 files changed, 117 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..f1b6478fe730
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,11 @@
+pkgbase = pacdate
+ pkgdesc = Automates downgrading packages to a specific date
+ pkgver = 1.0.0
+ pkgrel = 1
+ arch = any
+ license = none
+ depends = pacman
+ source = pacdate.sh
+ sha256sums = SKIP
+
+pkgname = pacdate
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..cdd6b0f23e74
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.tar.*
+/pkg
+/src
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..b6ce58e14144
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,16 @@
+# Maintainer: jdigi78 <jdigiovanni78@gmail.com>
+
+pkgname=pacdate
+pkgver=1.0.0
+pkgrel=1
+pkgdesc='Automates downgrading packages to a specific date'
+arch=('any')
+license=('none')
+depends=('pacman')
+source=("pacdate.sh")
+
+sha256sums=('SKIP')
+
+package() {
+ install -Dm755 "pacdate.sh" "${pkgdir}/usr/bin/pacdate"
+}
diff --git a/pacdate.sh b/pacdate.sh
new file mode 100755
index 000000000000..df53be2e87c7
--- /dev/null
+++ b/pacdate.sh
@@ -0,0 +1,87 @@
+#!/bin/bash
+
+PACDATE=""
+PACDATE_LIST=""
+PACDATE_DEPS=""
+
+# Function to display help/usage information
+function show_usage() {
+ echo ""
+ echo "Usage: $0 <YYYY/MM/DD> <package package2 ...>"
+ echo ""
+}
+
+# Function to check the input date format is correct
+function is_valid_date_format() {
+ local regex="^[0-9]{4}/(0[1-9]|1[0-2])/(0[1-9]|[1-2][0-9]|3[0-1])$"
+
+ if [[ $1 =~ $regex ]]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+if ! is_valid_date_format "$1"; then
+ echo "Date is invalid: $1"
+else
+ PACDATE=$1
+ PACDATE_LIST="${*:2}"
+fi
+
+if [ -z $PACDATE ]; then
+ echo "No date option provided."
+ show_usage
+ exit 1
+fi
+
+echo "Packages will be updated to the archived version from $PACDATE."
+echo " "
+
+if [ -f /etc/pacman.d/mirrorlist.pacdate_backup ]; then
+ echo "Mirrorlist already backed up."
+else
+ echo "Backing up mirrorlist..."
+ # Make backup of mirror list
+ sudo mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.pacdate_backup
+ # Create new mirror list
+ sudo sh -c "echo 'Server=https://archive.archlinux.org/repos/$PACDATE/\$repo/os/\$arch' > /etc/pacman.d/mirrorlist"
+ echo "Done."
+fi
+
+echo " "
+
+if [ -z "$PACDATE_LIST" ]; then
+ # Update all
+ sudo pacman -Syyuu
+else
+ # Update selected packages
+ sudo pacman -Syy $PACDATE_LIST
+
+ # Create dependency list
+ IFS=' ' read -ra PACKAGE_ARRAY <<< "$PACDATE_LIST"
+ for CURRENT_PKG in "${PACKAGE_ARRAY[@]}"; do
+ PACDATE_DEPS="$PACDATE_DEPS $(pacman -Qi $CURRENT_PKG|grep "Depends On"|cut -d: -f2|awk '{$1=$1};1'|tr -s ' '|tr -d '\n')"
+ done
+
+ if [ -n "$PACDATE_DEPS" ]; then
+ # List dependencies
+ echo " "
+ echo "The downgraded packages have these dependencies:"
+ echo $PACDATE_DEPS
+ echo " "
+ read -p "Do you want to downgrade these as well? (y/N) " choice
+ if [[ "$choice" =~ ^[Yy]$ ]]; then
+ $0 "$PACDATE" "$PACDATE_DEPS"
+ fi
+ fi
+fi
+
+if [ -f /etc/pacman.d/mirrorlist.pacdate_backup ]; then
+ echo " "
+ echo "Restoring mirrorlist from backup..."
+ sudo cp /etc/pacman.d/mirrorlist.pacdate_backup /etc/pacman.d/mirrorlist
+ sudo rm /etc/pacman.d/mirrorlist.pacdate_backup
+ echo "Done."
+fi
+exit 0