Skip to content

Commit

Permalink
0.20180525
Browse files Browse the repository at this point in the history
Options Version
  • Loading branch information
zvezdochiot committed May 25, 2018
1 parent c3179f1 commit 6c8d8c8
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 16 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2015 zvezdochiot

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.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# XCopy

Bash-script for copy dir as sort structure.

https://github.com/zvezdochiot/bash-xcopy

## Make deb package

```
du -s
nano config/control #edit config
sudo bash-deb-build lzma
```

## Utilites

For build deb package install bash-deb-build:

https://github.com/zvezdochiot/bash-deb-build
6 changes: 3 additions & 3 deletions config/control
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Package: xcopy
Version: 0.20151118
Version: 0.20180525-wheezy
Architecture: all
Maintainer: zvezdochiot <[email protected]>
Section: utils
Priority: optional
Installed-Size: 12
Installed-Size: 24
Depends: coreutils, findutils, cpio
Homepage: http://mykaralw.narod.ru/
Homepage: https://github.com/zvezdochiot/bash-xcopy
Description: Bash-script for xcopy.
Bash-script for copy dir as sort structure.
21 changes: 21 additions & 0 deletions data/usr/share/doc/xcopy/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2015 zvezdochiot

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.
19 changes: 19 additions & 0 deletions data/usr/share/doc/xcopy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# XCopy

Bash-script for copy dir as sort structure.

https://github.com/zvezdochiot/bash-xcopy

## Make deb package

```
du -s
nano config/control #edit config
sudo bash-deb-build lzma
```

## Utilites

For build deb package install bash-deb-build:

https://github.com/zvezdochiot/bash-deb-build
38 changes: 38 additions & 0 deletions data/usr/share/man/man1/xcopy.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.TH "XCopy User Manual" 0.20180525 "25 May 2018" "XCopy documentation"

.SH NAME
xcopy

.SH DESCRIPTION
Bash-script for copy dir as sort structure.

.SH SYNOPSIS
xcopy [options] srcdir destdir

.SH OPTIONS
.TP
-l
hardlink files
.TP
-n
no copy files (only directory)
.TP
-h
help

.SH EXAMPLE
xcopy /path/to/my/files tmp

.SH COPYRIGHT
Copyright 2015 zvezdochiot.
All rights reserved.

.SH SEE ALSO
cpio,
find,
sort,
ln

.SH CONTACTS
Website: https://github.com/zvezdochiot/bash-xcopy
Email: [email protected]
83 changes: 70 additions & 13 deletions data/usr/share/scripts/bash/xcopy.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,72 @@
#!/bin/sh

#xcopy.sh
#2015-11-18
#2018-05-25

echo "XCopy 0.20180525"

tnocomp=""
tcomp="/bin/cpio"
tdeb="cpio_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/usr/bin/find"
tdeb="findutils_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/usr/bin/sort"
tdeb="coreutils_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/bin/ln"
tdeb="coreutils_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
if [ "x$tnocomp" != "x" ]
then
echo "Not found $tnocomp !"
echo ""
exit 1
fi

fln="false"
fnc="false"
fhlp="false"
while getopts ":lnh" opt
do
case $opt in
l) fln="true"
;;
n) fnc="true"
;;
h) fhlp="true"
;;
*) echo "Unknown option -$OPTARG"
exit 1
;;
esac
done
shift "$(($OPTIND - 1))"
tdir=`pwd`;
srcdir="$1";
dstdir="$2";
flgcp="$3";

if [ "x$srcdir" = "x" -o "x$dstdir" = "x" ]
if [ "x$srcdir" = "x" -o "x$dstdir" = "x" -o "x$fhlp" = "xtrue" ]
then
echo "Usage:"
echo "$0 srcdir destdir [nc|ln]"
echo "$0 [options] srcdir destdir"
echo "Options:"
echo " -l hardlink files"
echo " -n no copy files (only directory)"
echo " -h help"
exit 0
fi

Expand All @@ -29,14 +84,16 @@ fi
# tree dirs
find "$srcdir" -xtype d | sort | cpio -padv "$dstdir" ;

# copy file
if [ "x$flgcp" = "x" ]
then
find "$srcdir" -xtype f | sort | cpio -padv "$dstdir";
elif [ "x$flgcp" = "xln" ]
# copy/link file
if [ "x$fnc" = "xfalse" ]
then
find "$srcdir" -xtype f -printf "%p\n" | sort | while read tfile
do
ln -fv "$tfile" "$dstdir/$tfile"
done
if [ "x$fln" = "xfalse" ]
then
find "$srcdir" -xtype f | sort | cpio -padv "$dstdir";
else
find "$srcdir" -xtype f -printf "%p\n" | sort | while read tfile
do
ln -fv "$tfile" "$dstdir/$tfile"
done
fi
fi

0 comments on commit 6c8d8c8

Please sign in to comment.