From 8cc83aaa274e1be055096d1f2b4da0ee0d9c37d4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 6 Dec 2012 16:48:10 +0000 Subject: [PATCH] * Add a script to delete old NixOS/Nixpkgs releases. git-svn-id: https://nixos.org/repos/nix/release/trunk/channels@34655 70bd8c7a-acb8-0310-9f0d-9cc1c95dcdbb --- delete-old-releases.sh | 35 +++++++++++++++++++++++++++++++++++ remove-dead-files.sh | 4 ---- 2 files changed, 35 insertions(+), 4 deletions(-) create mode 100755 delete-old-releases.sh delete mode 100644 remove-dead-files.sh diff --git a/delete-old-releases.sh b/delete-old-releases.sh new file mode 100755 index 0000000..95ae781 --- /dev/null +++ b/delete-old-releases.sh @@ -0,0 +1,35 @@ +#! /bin/sh + +trash=/data/releases/.trash +mkdir -p $trash + +# Remove garbage temporary directories. +find /data/releases/nixos/ /data/releases/nixpkgs/ -maxdepth 1 -name ".tmp*" -mtime +7 | while read rel; do + echo "removing temporary directory $rel" + mv $rel $trash/ +done + +# Remove old NixOS releases. +find /data/releases/nixos/ -maxdepth 1 -name "nixos-*pre*" -mtime +30 | sort | while read rel; do + if [ -e $rel/keep ]; then + echo "keeping NixOS release $rel" + continue + fi + echo "removing old NixOS release $rel" + mv $rel $trash/ +done + +# Remove old Nixpkgs releases. +find /data/releases/nixpkgs/ -maxdepth 1 -name "nixpkgs-*pre*" -mtime +30 | sort | while read rel; do + if [ -e $rel/keep ]; then + echo "keeping Nixpkgs release $rel" + continue + fi + echo "removing old Nixpkgs release $rel" + mv $rel $trash/ +done + +# Remove unreferenced NARs/patches. +./print-dead-files.pl /data/releases/patches/all-patches $(find /data/releases -name MANIFEST | grep -v '\.trash' | grep -v '\.tmp') \ +| xargs -d '\n' sh -c 'find "$@" -mtime +50 -print' \ +| xargs -d '\n' mv -v --target-directory=$trash diff --git a/remove-dead-files.sh b/remove-dead-files.sh deleted file mode 100644 index 69e4a19..0000000 --- a/remove-dead-files.sh +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/sh -./print-dead-files.pl /data/releases/patches/all-patches $(find /data/releases -name MANIFEST | grep -v '\.trash' | grep -v '\.tmp') | sort > /tmp/dead -mkdir -p /data/releases/.trash/ -xargs -d '\n' sh -c 'find "$@" -mtime +50 -print' < /tmp/dead | xargs -d '\n' mv -v --target-directory=/data/releases/.trash/