[aur-dev] [PATCH] Add a upload directory tranform script
Dan McGee
dan at archlinux.org
Thu Jul 28 15:16:37 EDT 2011
This goes with the previous patch that moves uploads into segmented
subdirectories.
Signed-off-by: Dan McGee <dan at archlinux.org>
---
scripts/uploadbuckets.sh | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
create mode 100755 scripts/uploadbuckets.sh
diff --git a/scripts/uploadbuckets.sh b/scripts/uploadbuckets.sh
new file mode 100755
index 0000000..1bb1a90
--- /dev/null
+++ b/scripts/uploadbuckets.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+DRYRUN=1
+
+source="$1"
+dest="$2"
+
+if [[ -z $source || -z $dest ]]; then
+ echo 'usage: uploadbuckets.sh <source> <dest>'
+ exit 1
+fi
+
+if [[ ! -d $source ]]; then
+ echo 'error: source is not a directory'
+ exit 1
+fi
+
+if [[ -e $dest && ! -d $dest ]]; then
+ echo 'error: dest is not a directory'
+ exit 1
+fi
+
+if [[ ! -d $dest ]]; then
+ mkdir $dest
+fi
+
+for package in "$source"/*; do
+ pkgname="${package##*/}"
+ newfolder="$dest/${pkgname:0:2}"
+ if [[ ! -d "$newfolder" ]]; then
+ if [[ DRYRUN -gt 0 ]]; then
+ echo mkdir -p "$newfolder"
+ else
+ mkdir -p "$newfolder"
+ fi
+ fi
+ if [[ DRYRUN -gt 0 ]]; then
+ echo mv "$source/$pkgname" "$newfolder/$pkgname"
+ else
+ mv "$source/$pkgname" "$newfolder/$pkgname"
+ fi
+done
--
1.7.6
More information about the aur-dev
mailing list