diff options
-rw-r--r-- | .SRCINFO | 15 | ||||
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | PKGBUILD | 30 | ||||
-rw-r--r-- | shellcheck-fixes.patch | 126 |
4 files changed, 155 insertions, 21 deletions
@@ -1,13 +1,14 @@ pkgbase = defrag - pkgdesc = A braindead simple and filesystem agnostic defrag script - pkgver = 0.07 - pkgrel = 1 + pkgdesc = A braindead simple and filesystem agnostic defragmentation script + pkgver = 0.08 + pkgrel = 2 url = http://ck.kolivas.org/apps/defrag/ - arch = i686 - arch = x86_64 + arch = any depends = bash - source = http://ck.kolivas.org/apps/defrag/defrag-0.07/defrag - md5sums = 3a0c4c1278cebe9ddf7741a0c7c6e743 + source = http://ck.kolivas.org/apps/defrag/defrag-0.08/defrag + source = shellcheck-fixes.patch + sha512sums = fa1c9c3a58ec43020a6a1da66bcbf8304e9b2ad1afbd25c0aab0962410e977412954669be2ae2aaaf8b14b2294cad91bbb0143f589688aa684080dff1b2c5316 + sha512sums = bd562680b4c049a1e9b1704b2da2f94f7ba8037625f0a6501d75417d90cce09d10fc59ecd2e0c8f49252d7a7868da36ec2e810a660adefa76b6cc1ce6ecc2f42 pkgname = defrag diff --git a/.gitignore b/.gitignore index e4f398dc5b3a..e2552bd12fcc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ src/ pkg/ -*.pkg.tar.xz -*.pkg.tar -*.src.tar.gz +*.pkg.tar.zst +defrag @@ -1,18 +1,26 @@ -# Contributor: Slash <demodevil5[at]yahoo[dot]com> +# Maintainer: Slash <demodevil5[at]yahoo[dot]com> pkgname=defrag -pkgver=0.07 -pkgrel=1 -pkgdesc="A braindead simple and filesystem agnostic defrag script" +pkgver=0.08 +pkgrel=2 +pkgdesc="A braindead simple and filesystem agnostic defragmentation script" url="http://ck.kolivas.org/apps/defrag/" -license="" +license=() depends=('bash') -arch=('i686' 'x86_64') -source=(http://ck.kolivas.org/apps/defrag/$pkgname-$pkgver/defrag) -md5sums=('3a0c4c1278cebe9ddf7741a0c7c6e743') +arch=('any') +source=("http://ck.kolivas.org/apps/defrag/$pkgname-$pkgver/defrag" 'shellcheck-fixes.patch') +sha512sums=('fa1c9c3a58ec43020a6a1da66bcbf8304e9b2ad1afbd25c0aab0962410e977412954669be2ae2aaaf8b14b2294cad91bbb0143f589688aa684080dff1b2c5316' + 'bd562680b4c049a1e9b1704b2da2f94f7ba8037625f0a6501d75417d90cce09d10fc59ecd2e0c8f49252d7a7868da36ec2e810a660adefa76b6cc1ce6ecc2f42') -build() { - cd $startdir/src/ +prepare() { + cd "${srcdir}" - install -D -m755 defrag $startdir/pkg/usr/bin/defrag + patch --follow-symlinks -p1 -i shellcheck-fixes.patch } + +package() { + cd "${srcdir}" + + install -D -m755 defrag "${pkgdir}/usr/bin/defrag" +} + diff --git a/shellcheck-fixes.patch b/shellcheck-fixes.patch new file mode 100644 index 000000000000..299b86f30b4f --- /dev/null +++ b/shellcheck-fixes.patch @@ -0,0 +1,126 @@ +diff --git a/defrag b/defrag
+index 7210343..a7d91f6 100755
+--- a/defrag
++++ b/defrag
+@@ -27,9 +27,9 @@ fail()
+ declare -i filesize=0
+ declare -i numfiles=0
+
+-#The maximum size of a file we can easily cache in ram
+-declare -i maxsize=$((`awk '/MemTotal/ {print $2}' /proc/meminfo`*1024))
+-(( maxsize-= `awk '/Mapped/ {print $2}' /proc/meminfo` ))
++# The maximum size of a file we can easily cache in ram
++declare -i maxsize=$(($(awk '/MemTotal/ {print $2}' /proc/meminfo)*1024))
++(( maxsize-= $(awk '/^Mapped/ {print $2}' /proc/meminfo)))
+ (( maxsize/= 2))
+
+ if [[ -a tmpfile || -a dirlist ]] ; then
+@@ -45,56 +45,56 @@ fi
+
+ echo "Creating list of files..."
+
+-#stupid script to find max directory depth
+-find -xdev -type d -printf "%d\n" | sort -n | uniq > dirlist
++# stupid script to find max directory depth
++find . -xdev -type d -printf "%d\n" | sort -n | uniq >dirlist
+
+-#sort directories in descending size order
+-cat dirlist | while read d;
++# sort directories in descending size order
++while read -r d;
+ do
+- find -xdev -type d -mindepth $d -maxdepth $d -printf "\"%p\"\n" | \
+- xargs du -bS --max-depth=0 | \
+- sort -k 1,1nr -k 2 |\
+- cut -f2 >> tmpfile
+- if (( $? )) ; then
++ if ! find . -xdev -type d -mindepth "$d" -maxdepth "$d" -printf "\"%p\"\n" | \
++ xargs du -bS --max-depth=0 | \
++ sort -k 1,1nr -k 2 | \
++ cut -f 2 >>tmpfile
++ then
+ fail
+ fi
+
+-done
++done <dirlist
+
+ rm -f dirlist
+
+-#sort files in descending size order
+-cat tmpfile | while read d;
++# sort files in descending size order
++while read -r d;
+ do
+- find "$d" -xdev -type f -maxdepth 1 -printf "%s\t%p\n" | \
+- sort -k 1,1nr | \
+- cut -f2 >> dirlist
+- if (( $? )) ; then
++ if ! find "$d" -xdev -type f -maxdepth 1 -printf "%s\t%p\n" | \
++ sort -k 1,1nr | \
++ cut -f 2 >>dirlist
++ then
+ fail
+ fi
+-done
++done <tmpfile
+
+ rm -f tmpfile
+
+-numfiles=`wc -l dirlist | awk '{print $1}'`
++numfiles=$(wc -l dirlist | awk '{print $1}')
+
+ echo -e "$numfiles files will be reordered\n"
+
+-#copy to temp file, check the file hasn't changed and then overwrite original
+-cat dirlist | while read i;
++# copy to temp file, check the file hasn't changed and then overwrite original
++while read -r i;
+ do
+ (( --numfiles ))
+ if [[ ! -f $i ]]; then
+ continue
+ fi
+
+- #We could be this paranoid but it would slow it down 1000 times
++ # We could be this paranoid but it would slow it down 1000 times
+ #if [[ `lsof -f -- "$i"` ]]; then
+ # echo -e "\n File $i open! Skipping"
+ # continue
+ #fi
+
+- filesize=`find "$i" -printf "%s"`
++ filesize=$(find "$i" -printf "%s")
+ # read the file first to cache it in ram if possible
+ if (( filesize < maxsize ))
+ then
+@@ -104,22 +104,20 @@ do
+ echo -e "\r $numfiles files left - Reordering large file sized $filesize ... \c"
+ fi
+
+- datestamp=`find "$i" -printf "%s"`
+- cp -a -f "$i" tmpfile
+- if (( $? )) ; then
++ datestamp=$(find "$i" -printf "%s")
++ if ! cp -a -f "$i" tmpfile; then
+ fail
+ fi
+ # check the file hasn't been altered since we copied it
+- if [[ `find "$i" -printf "%s"` != $datestamp ]] ; then
++ if [[ $(find "$i" -printf "%s") != "$datestamp" ]] ; then
+ continue
+ fi
+
+- mv -f tmpfile "$i"
+- if (( $? )) ; then
++ if ! mv -f tmpfile "$i"; then
+ fail
+ fi
+-done
+-
+-echo -e "\nSucceeded"
++done <dirlist
+
+ rm -f dirlist
++
++echo -e "\nSucceeded"
|