diff -Nru ftpsync-1.1/debian/changelog ftpsync-1.3.07/debian/changelog --- ftpsync-1.1/debian/changelog 2015-04-09 07:20:57.000000000 +0000 +++ ftpsync-1.3.07/debian/changelog 2015-04-09 07:40:25.000000000 +0000 @@ -1,5 +1,40 @@ -ftpsync (1.1-1~lffl~trusty) trusty; urgency=low +ftpsync (1.3.07-1~lffl~trusty) trusty; urgency=low - * new package for ubuntu + * Introducing option slowmillis for configurable sleep between PUTs + * Introducing experimental support for FTPSSL, via extra script ftpsync-ssl + + -- lffl Thu, 09 Apr 2015 09:36:53 +0200 + +ftpsync (1.3.07-0) any; urgency=low + + # LICENSE + # + # FTPSync.pl (ftpsync) is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published by + # the Free Software Foundation; either version 2 of the License, or + # (at your option) any later version. + # + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU General Public License for more details. + # + # You should have received a copy of the GNU General Public License + # along with this program; if not, write to the Free Software + # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + -- Ole Tange Mon, 24 Sep 2012 19:21:32 +0200 + +ftpsync (1.3.06-0) any; urgency=low + + * Applying -s to downloads, too. Proposed by Mike Selner + + -- Christoph Lechleitner Mon, 05 Mar 2012 18:43:00 +0100 + +ftpsync (1.3.05-0) any; urgency=low + + * Initial debianization of FTPSync.pl + * For older Changes, see Changes_1.00-1.3.04.txt + + -- Christoph Lechleitner Wed, 15 Jun 2010 13:28:00 +0200 - -- lffl Thu, 09 Apr 2015 09:19:43 +0200 diff -Nru ftpsync-1.1/debian/changelog~ ftpsync-1.3.07/debian/changelog~ --- ftpsync-1.1/debian/changelog~ 2015-04-09 07:19:45.000000000 +0000 +++ ftpsync-1.3.07/debian/changelog~ 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -ftpsync (1.1) unstable; urgency=low - - * Initial Release. - - -- lffl Thu, 09 Apr 2015 09:19:43 +0200 diff -Nru ftpsync-1.1/debian/compat ftpsync-1.3.07/debian/compat --- ftpsync-1.1/debian/compat 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/debian/compat 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1 @@ +6 diff -Nru ftpsync-1.1/debian/control ftpsync-1.3.07/debian/control --- ftpsync-1.1/debian/control 2015-04-09 07:22:17.000000000 +0000 +++ ftpsync-1.3.07/debian/control 2015-04-09 07:40:20.000000000 +0000 @@ -1,14 +1,16 @@ Source: ftpsync -Section: python -Priority: extra +Section: utils +Priority: optional Maintainer: lffl -Build-Depends: debhelper (>= 8.0.0) -Standards-Version: 3.9.4 -Homepage: https://savannah.gnu.org/projects/ftpsync/ +Build-Depends: pba-cbs +XBCS-PBA-Category: ftpsync +XBCS-PBA-Generation: 1 +XBCS-PBA-Distribution: any +XBCS-PBA-Distributions: any +XBCS-PBA-Repositories: deb.clazzes.org Package: ftpsync +Depends: bash, perl-modules, libwww-perl Architecture: all -Depends: ${shlibs:Depends}, ${misc:Depends} -Description: Efficient FTP synchronization - This utility maintains a hashes.txt file in the remote server, and uses it - to recognize which files need to be updated when re-synchronizing. +Description: FTPSync.pl is a Perl script to synchronize a local directory tree and a remote FTP directory tree. + diff -Nru ftpsync-1.1/debian/control~ ftpsync-1.3.07/debian/control~ --- ftpsync-1.1/debian/control~ 2015-04-09 07:19:45.000000000 +0000 +++ ftpsync-1.3.07/debian/control~ 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -Source: ftpsync -Section: unknown -Priority: extra -Maintainer: lffl -Build-Depends: debhelper (>= 8.0.0) -Standards-Version: 3.9.4 -Homepage: -#Vcs-Git: git://git.debian.org/collab-maint/ftpsync.git -#Vcs-Browser: http://git.debian.org/?p=collab-maint/ftpsync.git;a=summary - -Package: ftpsync -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} -Description: - diff -Nru ftpsync-1.1/debian/copyright ftpsync-1.3.07/debian/copyright --- ftpsync-1.1/debian/copyright 2015-04-09 07:19:45.000000000 +0000 +++ ftpsync-1.3.07/debian/copyright 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: ftpsync -Source: - -Files: * -Copyright: - -License: GPL-3.0+ - -Files: debian/* -Copyright: 2015 lffl -License: GPL-3.0+ - -License: GPL-3.0+ - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - . - This package is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - . - You should have received a copy of the GNU General Public License - along with this program. If not, see . - . - On Debian systems, the complete text of the GNU General - Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". - -# Please also look if there are files or directories which have a -# different copyright/license attached and list them here. -# Please avoid to pick license terms that are more restrictive than the -# packaged work, as it may make Debian's contributions unacceptable upstream. diff -Nru ftpsync-1.1/debian/.gitignore ftpsync-1.3.07/debian/.gitignore --- ftpsync-1.1/debian/.gitignore 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/debian/.gitignore 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,5 @@ +*.debhelper.log +*.substvars +devhost.txt.gz +files +ftpsync diff -Nru ftpsync-1.1/debian/rules ftpsync-1.3.07/debian/rules --- ftpsync-1.1/debian/rules 2013-11-07 07:25:58.000000000 +0000 +++ ftpsync-1.3.07/debian/rules 2015-04-09 07:36:44.000000000 +0000 @@ -1,53 +1,44 @@ #!/usr/bin/make -f -# debian/rules for LffL http://www.lffl.org +# +# $Id$ +# -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 +include /usr/share/cdbs/1/rules/debhelper.mk -# Use v4 compatability mode, so ldconfig gets added to maint scripts. -export DH_COMPAT=4 +DEB_DH_ALWAYS_EXCLUDE := .svn:debian/tmp -PACKAGE=$(shell dh_listpackages) +srcname = ftpsync +srcdir = src -build: - dh_testdir +package = ftpsync +target = ftpsync +SRCDIR = $(shell /bin/pwd)/src +DESTDIR = $(shell /bin/pwd)/debian/$(package) -clean: - dh_testdir - dh_testroot - dh_clean -d +DEB_INSTALL_DOCS_ALL := doc/Changes_1.00-1.3.04.txt doc/License.txt doc/ReadMe.txt doc/ToDo.txt -binary-indep: build +# DEB_INSTALL_CHANGELOGS_ALL := doc/Changes.txt -binary-arch: build - dh_testdir - dh_testroot - dh_clean -k -d - dh_installdirs +# satisfied by cdbs +# list of config files +#DH_INSTALLDEBCONF := - dh_installdocs - dh_installchangelogs +INSTALL_PROGRAM = install -# Copy the packages's files. - find . -maxdepth 1 -mindepth 1 -not -name debian -print0 | \ - xargs -0 -r -i cp -a {} debian/$(PACKAGE) -# -# If you need to move files around in debian/$(PACKAGE) or do some -# binary patching, do it here -# +#common-build-indep:: +# touch common-build-indep + +clean:: + cd debian && rm -rf *.subvars *.log ftpsync files tmp + rm -f common-install-indep -# This has been known to break on some wacky binaries. -# dh_strip - dh_compress -# dh_fixperms - dh_makeshlibs - dh_installdeb - -dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb +common-install-indep:: + mkdir -p debian/tmp + mkdir -p $(DESTDIR)/usr/bin + cp $(SRCDIR)/ftpsync $(SRCDIR)/ftpsync-ssl $(DESTDIR)/usr/bin/ + cd $(DESTDIR)/usr/bin/ ; ln -s ftpsync ftpsync.pl + chmod -R 0755 $(DESTDIR) + touch common-install-indep -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary diff -Nru ftpsync-1.1/doc/Changes_1.00-1.3.04.txt ftpsync-1.3.07/doc/Changes_1.00-1.3.04.txt --- ftpsync-1.1/doc/Changes_1.00-1.3.04.txt 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/doc/Changes_1.00-1.3.04.txt 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,270 @@ +# $Id$ + +1.3.04 => later (2011-06-15 and later) +====================================== + +See changelog resp. /usr/share/doc/ftpsync/changelog.Debian.gz. + + +1.3.03 => 1.3.04 (2011-06-15) +============================= + + * Adding timeoffset option + + * Moved from SourceForge to Clazzes.org + + +1.3.02 => 1.3.03 (2009-07-03) +============================= + + * Fixing .netrc support + + * compatibility with historiy MacOS FTP Server + proposed by Brandon Ooi + + * agile mode for rapid pushing + proposed by Jonathan Trachtenberg + + +1.3.01 => 1.3.02 (2009-05-25) +============================= + + * Integrating .netrc support + proposed by Stephan Hoehrmann + + * Documented the ftpuser/ftppasswd=? feature in print_syntax() + + +1.3.00 => 1.3.01 (2009-04-15) +============================= + + * Moving subversion repository to sourceforge + + * Documented the ignoremask feature in print_syntax() + + * Extended detection of trailing / to ftp url parsing. + proposed by https://sourceforge.net/users/djdandman/ + + +1.2.34 => 1.3.00 (2009-04-15) +============================= + + * Put everything under subversion control + + * Fix to allow FTP URL and local directory to be the only command + line options given + + * Integrated option to disable any date check + both by Isak Johnsson + + +1.2.33 => 1.2.34 (2008-06-06) +============================= + + * README enhanced concerinng grammar and style, + by Wolfram Sieber + + * Added Option to disable timestamping for transferred (local) files + * Added reconnect if conncection times out after local file reading + both by by Alexander Klein + + +1.2.32 => 1.2.33 (2006-10-27) +============================= + + Proposed by Jose A. Otero + + * . and : from filetree building only printed when verbosity > 1 + + * New option -f (f for flat) to avoid subdir recursion + + +1.2.31 => 1.2.32 (2006-08-30) +============================= + + Proposed and mostly provided by Brian Drawert + + * Option -L to follow symbolic links on local side + + * Added '-a' to remote listing command to see hidden files+dirs + + +1.2.30 => 1.2.31 (2006-07-29) +============================= + + * Output of -h/-H corrected, on hint + by Ronnie T. Moore http://alwayswebhosting.com/ + + +1.29 => 1.2.30 (2006-07-23) +=========================== + + All proposed by Nikla Therning http://therning.org/niklas + + * added no-delete option --nodel + + * added ability to sync file access modi too, when PUTing + + * version schema changed + + +1.28 => 1.29 (2006-05-22) +========================= + + Proposed by Brian Drawert + + * added param ignoremask to ignore certain directories/files + + +1.27 => 1.28 (2006-03-12) +========================= + + All by Elias Bröms http://www.eliasit.se/ + + * corrected parse of ftp://user:passwd@host/ URLs to accept '-' in hostnames. + + * changed connection mode to passive (PASV). + + * lowered ftp timeout from 120 to 20 seconds. + + +1.26 => 1.27 (2004-08-23) +========================= + + (mostly) by Samuel Marshall + + * enhanced timezone handling, should be perfect now + + * new option -c, like -i but then asks interactively to let do it + + * if FTP user/password are set to ?, they are asked for interactively + + +1.25 => 1.26 (2004-03-31) +========================= + + * fixed "dangerous" algorithm of synchronization direction + + +1.24 => 1.25 (2004-03-20) +========================= + + * fixed some 1.24 bugs + + * clock offset computation now more resistant against very slow connections + + * clock offset computation disabled for GET mode, so mirroring of foreign + stuff is now possible again + + * default localdir of . disabled, therefore + + * using . as localdir parameter does not cause a parsing error any more + + * replaced damn indentation tabs in sourcecode by appropriate number of + spaces, so code is readable independent of tab settings + + * enabled handling of ftpdir / + + * handling of relative ftpdir corrected + + +1.23 => 1.24 (2003-10-11) +========================= + + By Michiel Steltman + + * handle files with blanks etc in names + + * clock offset remote-local to reduce unnecessary transfers + + * error handling + + +1.22 => 1.23 (2003-09-28) +========================= + + * New parameter timeout + + +1.21 => 1.22 (2003-03-24) +========================= + + * Now cuts off / at directory spec's end, to avoid pwd() being different + from target of cwd() (which lead to unneccesarry abortions) + + +1.20 => 1.21 (2003-03-24) +========================= + + * version information in sourcefile and output of -h command + + +1.11 => 1.20 (2003-03-22) +========================= + + * generally, most foreseeable problems are beeing checked, in particular: + + - unability to connect to FTP server + - unability to login into FTP server + - unability to change to local or remote base directory + - unability to change to remote subdirectory + - unability to create local or remote subdirectory + - unability to remove local or remote subdirectory + - unability to put or get a file within 3 trials + + All these errors (except the last one) leads to immediate abortion. + + +1.10 => 1.11 (2002-05-10) +========================= + + * Some optical corrections concerning output + + * Files are now automatically re-transferred until the size on both ends + matches + + * -? now corrrectly recognized + + +1.00 => 1.10 (2001-10-28) +========================= + + * config file support + This is mportant to avoid putting ftp passwords in the process list! + + * much more informative standard and verbose/debug output, including kind + of a advance information + + * better FTP-URL parsing supporting such without user/password + + * much better default values, e.g. ftp://ftp:anonymous@localhost/., ... + + * softlinks are now detected (locally and remote) and treated somewhat + correctly, i.e. they are ignored correctly ;-)) + + + +=> 1.00 (2001-10-26) +==================== + +* 1.0 created 2001-10-20 23:10 by Christoph Lechleitner + +Quite good for a 5 hour hack, isn't it? +O.K., I have already written similar programs for local file systems +in Pascal for DOS, Win3x and OS/2, and in VisualBasic for Win95b. + +# LICENSE +# +# FTPSync.pl (ftpsync) is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Binary files /tmp/cFsGNuFnUW/ftpsync-1.1/doc/ftpsync-logo1000.png and /tmp/yY6AW07JaN/ftpsync-1.3.07/doc/ftpsync-logo1000.png differ Binary files /tmp/cFsGNuFnUW/ftpsync-1.1/doc/ftpsync-logo7000.png and /tmp/yY6AW07JaN/ftpsync-1.3.07/doc/ftpsync-logo7000.png differ Binary files /tmp/cFsGNuFnUW/ftpsync-1.1/doc/ftpsync-logo.png and /tmp/yY6AW07JaN/ftpsync-1.3.07/doc/ftpsync-logo.png differ diff -Nru ftpsync-1.1/doc/ftpsync-logo.svg ftpsync-1.3.07/doc/ftpsync-logo.svg --- ftpsync-1.1/doc/ftpsync-logo.svg 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/doc/ftpsync-logo.svg 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,1248 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + FTP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru ftpsync-1.1/doc/License.txt ftpsync-1.3.07/doc/License.txt --- ftpsync-1.1/doc/License.txt 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/doc/License.txt 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff -Nru ftpsync-1.1/doc/ReadMe.txt ftpsync-1.3.07/doc/ReadMe.txt --- ftpsync-1.1/doc/ReadMe.txt 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/doc/ReadMe.txt 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,185 @@ +# $Id$ + + +Contents: +========= + +- Overview +- Why use ftpsync instead of mirror, sitecopy, ...? +- Why NOT use ftpsync, but rather ... (Security Disclaimer) +- Requirements/restrictions +- Bug reports, contact +- License +- Updates +- Thanks + + +Overview: +--------- + +ftpsync.pl synchronizes a local directory tree and a remote FTP directory tree. + +Initially it was written to automate web publishing, but might be useful for +some other purposes, like mirroring not-too-large public sites, data +replication, and more. + +Call "ftpsync.pl -h" to get a short parameter explanation. + + +Why use ftpsync.pl instead of mirror, sitecopy, ...? +---------------------------------------------------- + +Yes, there are similar projects, hence some comments on them: + +Compared to mirror, ftpsync.pl is capable of PUTting, not only GETting stuff. +(Don't blame me if mirror is able to PUT, I couldn't find a way.) + +Compared to sitecopy, if the remote site was changed by other tools and/or activites since the previous run of the synchronization tool, ftpsync.pl doesn't get a hard time. Unless network problems occur or bugs come into action, ftpsync.pl does a synchronizes reliably. + +Compared to both tools, ftpsync.pl is very lightweight. ;-)) + + +Why NOT use ftpsync, but rather ... (Security Disclaimer) +--------------------------------------------------------- + +FTP is an almost ancient file transport protocol. It has two major flaws: + +1. It is difficult to run FTP through NAT routers, because of the use of session specific ports on which the server wants to connect to the client. +With providers running out of IPv4 addresses and IPv6 growing very slowly, NAT-ing is very common. +Using passive mode (passive FTP) usually works through NAT routers, but it may fail sometimes. + +2. When FTP was born, transport layer security was no issue. Common FTP transfers all data, including passwords (!) in plain text and must therefore be considered VERY INSECURE! +Therefore users are encouraged to use a secure alternative. +Secure alternatives include: +- rsync over SSH (recommended) +- SFTP (FTP over SSH) +- FTPS (FTP with SSL) which is at the top of ftpsync's wish list + + +Requirements / Restrictions: +---------------------------- + +- Perl 5.6+ + ftpsync.pl was initially developed on Perl 5.6.0-81 on SuSE Linux 7.2, + older Perl 5.x version might work. + +- File::Find, IO::Handle, Net::FTP + Usually parts of the basic perl package. + +- File::Listing + Part of the libwww-perl package. + +- UNIX like operating systems on local system + Porting to DOS based systems should be easily done by changing the + directory separator. + +- Perhaps, the script does not work with all FTP servers. + It is being tested only against UNIX based FTP servers. + + +ftpsync-ssl and it's additional requirements: +--------------------------------------------- + +ftpsync-ssl is an experimental ftpsync variant with support for (FTP with SSL). + +For now it lives besides the ftpsync binary because it uses Net::FTPSSL which +- seems to have stopped maturing in 2005, +- can be difficult to install, +- produces weird warning messages when used by an application, +- has an API that is slightly but inconveniently different from Net::FTP's. + +The additional requirements for ftpsync-ssl are: +- Net::Cmd, usually part of the basic perl package. +- Net::SSLeay::Handle, part of the libnet-ssleay-perl package. +- IO::Socket::SSL, part of the libio-socket-ssl-perl package. +- Net::FTPSSL from CPAN, try calling cpan Net::FTPSSL + + +Homepage: +--------------------- + +Old Homepage: + http://www.clazzes.org/ftpsync + +New Homepage (not really complete yet): + https://savannah.gnu.org/projects/ftpsync/ + + +License: +-------- + +FTPSync.pl is GNU/GPL software. + + +FTPSync.pl as GNU/GPL software: +------------------------------- + +FTPSync.pl (ftpsync.pl) is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +See attached file License.txt. + + +Download and Updates +-------------------- + +FTPSync 1.3.06 is available from: + https://download.clazzes.org/ftpsync + https://deb.clazzes.org/ + +Current sourcecode is, and new packages will be available from: + https://savannah.gnu.org/projects/ftpsync/ + + +Thanks +------ + +Thanks to all who have provided comments and enhancements. + +Namely (in order of versions affected): + +- Christoph Lechleitner (Original Author) + +- Michiel Steltman (provided 1.24) + +- Samuel Marshall (provided most of 1.27) + +- Elias Bröms http://www.eliasit.se/ (provided 1.28) + +- Brian Drawert (proposed 1.29) + +- Niklas Therning http://therning.org/niklas (proposed 1.2.30) + +- Ronnie T. Moore http://alwayswebhosting.com/ (typo hint leading to 1.2.31) + +- Brian Drawert (provided 1.2.32) + +- Jose A. Otero (proposed 1.2.33) + +- Wolfram Sieber (enhanced this README, 1.2.34) + +- Peter Bohn (proposed MD5 feature, refused) + +- Alexander Klein (-t feature, 1.2.34) + +- Isak Johnsson (proposed code patches for 1.3.00) + +- Stephan Hoehrmann (proposed .netrc patch for 1.3.02) + +- Brandon Ooi (proposed a patch for 1.3.03) + +- Jonathan Trachtenberg (proposed agile mode for 1.3.03) + +- Ole Tange (project lead since moving ftpsync 1.3.06 to gnu.org) + diff -Nru ftpsync-1.1/doc/ToDo.txt ftpsync-1.3.07/doc/ToDo.txt --- ftpsync-1.1/doc/ToDo.txt 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/doc/ToDo.txt 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,4 @@ +# $Id$ + +Nothing as of now. + diff -Nru ftpsync-1.1/ftpsync ftpsync-1.3.07/ftpsync --- ftpsync-1.1/ftpsync 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/ftpsync 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,1571 @@ +#!/usr/bin/env perl +# +# $Id$ +# +# See attached README file for any details, or call +# ftpsync -h +# for quick start. +# +# LICENSE +# +# FTPSync.pl (ftpsync) is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +################################################################################ + +# +# Options etc. +# +#print "Starting imports.\n"; # For major problem debugging + +use File::Temp qw(tempfile tempdir); +use File::Find; +use File::Basename; +use File::Listing; +use Net::FTP; +use Net::Cmd; +use Net::Netrc; +use strict; +use Getopt::Long; +use URI::Escape; +use File::Path qw(make_path); + +# flushing ... +use IO::Handle; +STDOUT->autoflush(1); +STDERR->autoflush(1); + +# Option Variables +#print "Defining variables.\n"; # For major problem debugging +# meta +my $returncode=0; +my $configfile=$ENV{"HOME"}."/.ftpsync"; +# basics +my $localdir=""; +my $remoteURL=""; +my $syncdirection=""; +my $ftpuser="ftp"; +my $ftppasswd="anonymous"; +my $ftpserver="localhost"; +my $ftpdir=""; +my $ftptimeout=120; +my $syncoff=0; +# verbosity +$opt::verbose=2; +my $doverbose=1; +my $dodebug=0; +my $doquiet=0; +my $doinfoonly=0; +my $infotext=""; +my $docheckfirst=0; +my $ignoremask = undef; +my $nodelete=0; +my $followsymlinks=0; +my $doflat=0; +my $notimestamping=0; +my $notimestampcheck=0; +my $slowmillis=100; + +# Read command line options/parameters +#print "Reading command line options.\n"; # For major problem debugging +my $curopt; +my @cloptions=(); +for $curopt (@ARGV) { + if ($curopt =~ /^cfg=(.*)/) { + $configfile=$1; + if (! -r $configfile) { print "Config file does not exist: ".$configfile."\n"; $returncode+=1; } + } else { + push @cloptions, $curopt; + } +} + +# Read Config File, if given +my @cfgfoptions=(); +if ($configfile ne "") { + if (-r $configfile) { + #print "Reading config file.\n"; # For major problem debugging + open (CONFIGFILE,"<$configfile"); + while () { + $_ =~ s/([ \n\r]*$|\.\.|#.*$)//gs; + if ($_ eq "") { next; } + if ( ($_ =~ /[^=]+=[^=]+/) || ($_ =~ /^-[a-zA-Z]+$/) ) { push @cfgfoptions, $_; } + } + close (CONFIGFILE); + } # else { print "Config file does not exist.\n"; } # For major problem debugging +} # else { print "No config file to read.\n"; } # For major problem debugging + +sub options_hash { + # Returns a hash of the GetOptions config + return + ("debug|d|D" => \$opt::debug, + "verbose|v" => \@opt::verbose, + "version|V" => \$opt::version, + "dry-run|dryrun" => \$opt::dryrun, + "help|h|H" => \$opt::help, + "check|c|C" => \$opt::check, + "flat|f|F" => \$opt::flat, + "get|g|G" => \$opt::get, + "put|p|P" => \$opt::put, + "info|i|I" => \$opt::info, + "links|l|L" => \$opt::links, + "quiet|q|Q" => \$opt::quiet, + "move|remove-source-files" => \$opt::move, + "notimestampcheck|s|S" => \$opt::notimestampcheck, + "notimestamping|t|T" => \$opt::notimestamping, + "nodelete|n|N" => \$opt::nodelete, + "delete" => \$opt::delete, + "cfg=s" => \$opt::cfg, + "ftpserver=s" => \$opt::ftpserver, + "ftpdir=s" => \$opt::ftpdir, + "ftpuser=s" => \$opt::ftpuser, + "ftppasswd|ftppass|ftppassword=s" => \$opt::ftppasswd, + "passiv|passive" => \$opt::passive, + "localdir=s" => \$opt::localdir, + "ignoremask=s" => \$opt::ignoremask, + "size-only|size|sizeonly" => \$opt::sizeonly, + "slowmillis=i" => \$opt::slowmillis, + "timeoffset=i" => \$opt::timeoffset, + "timeout=i" => \$opt::timeout, + # rsync compatibilty + "exclude" => \$opt::exclude, + ); +} + +sub get_options_from_array { + # Run GetOptions on @array + # Returns: + # true if parsing worked + # false if parsing failed + # @array is changed + my $array_ref = shift; + # A bit of shuffling of @ARGV needed as GetOptionsFromArray is not + # supported everywhere + my @save_argv; + my $this_is_ARGV = (\@::ARGV == $array_ref); + if(not $this_is_ARGV) { + @save_argv = @::ARGV; + @::ARGV = @{$array_ref}; + } + my $retval = GetOptions(options_hash()); + if(not $this_is_ARGV) { + @{$array_ref} = @::ARGV; + @::ARGV = @save_argv; + } + return $retval; +} + +sub parse_options { + Getopt::Long::Configure("bundling","require_order"); + get_options_from_array(\@ARGV) || die_usage(); + my @cfgoptions; + if(defined $opt::cfg) { + open(IN,"<",$opt::cfg) || die_usage(); + @cfgoptions = ; + close IN; + get_options_from_array(\@cfgoptions) || die_usage(); + } + if($opt::check) { $docheckfirst=1; } + if($opt::debug) { $dodebug=1; $doverbose=3; $doquiet=0; $opt::verbose = 3; } + if($opt::flat) { $doflat=1; } + if($opt::get) { $syncdirection="get"; } + if($opt::help) { print_syntax(); exit 0; } + if($opt::info) { $doinfoonly=1; } + if($opt::links) { $followsymlinks=1; } + if($opt::put) { $syncdirection="put"; } + if($opt::quiet) { $dodebug=0; $doverbose=0; $doquiet=1; $opt::verbose = 0; } + if($opt::notimestampcheck) { $notimestampcheck=1; } + if($opt::notimestamping) { $notimestamping=1; } + if(@opt::verbose) { $doverbose=@opt::verbose; $opt::verbose=@opt::verbose; } + if($opt::nodelete) { $nodelete=1; } + + for my $arg (@ARGV) { + if($arg =~ /^ftp:\/\/(([^@\/\\\:]+)(:([^@\/\\\:]+))?@)?([a-zA-Z01-9\.\-]+)(\/.*)?/) { + $remoteURL = $arg; + parse_remote_url(); + $syncdirection ||= "get"; + } + } + if(defined $opt::ftpdir) { + $ftpdir = $opt::ftpdir; + if($ftpdir ne "/") { $ftpdir=~s/\/$//; } + $syncdirection ||= "get"; + } + if(defined $opt::ftppasswd) { + $ftppasswd = $opt::ftppasswd; + $syncdirection ||= "get"; + } + if(defined $opt::ftpserver) { + $ftpserver = $opt::ftpserver; + $syncdirection ||= "get"; + } + if(defined $opt::ftpuser) { + $ftpuser = $opt::ftpuser; + $syncdirection ||= "get"; + } + if(defined $opt::localdir) { + $localdir = $opt::localdir; + $localdir=~s/\/$//; + $syncdirection ||= "put"; + } + if($opt::timeout) { + $ftptimeout = $opt::timeout; + } + if(defined $opt::ignoremask) { + $ignoremask = $opt::ignoremask; + } + if(defined $opt::timeoffset) { + $syncoff = $opt::timeoffset; + } + if(defined $opt::slowmillis) { + $slowmillis = $opt::slowmillis; + } + if ($localdir eq "") { + $localdir = shift @ARGV; + $syncdirection ||= "put"; + } else { + error("Unknown parameter: \"".@ARGV."\"\n"); $returncode+=1 + } +} + +sub die_usage { + print STDERR + qq(Usage:\n); + exit(1); +} + +parse_options(); +gnu_main(); +exit(0); + +sub gnu_main { + my @src_urls; + my $dst_url = fill_in_ftpurl(pop @ARGV); + push(@src_urls,fill_in_ftpurl($localdir,@ARGV)); + + my %src_tree = buildtree(@src_urls); + my %dst_tree = buildtree($dst_url); + my @files_to_add = sort(missing(\%src_tree,\%dst_tree)); + my @files_to_delete = sort(missing(\%dst_tree,\%src_tree)); + my @files_to_update = sort(changed(\%src_tree,\%dst_tree)); + my @src_files_to_delete = $opt::move ? sort(keys %src_tree) : (); + + logger("","Files to add: ".($#files_to_add+1)."\n", + "Files to add: @files_to_add\n"); + if($opt::delete) { + logger("","Files to delete: ".($#files_to_delete+1)."\n", + "Files to delete: @files_to_delete\n"); + } + logger("","Files to update: ".($#files_to_update+1)."\n", + "Files to update: @files_to_update\n"); + logger("","Source files to delete: ".($#src_files_to_delete+1)."\n", + "Source files to delete: @src_files_to_delete\n"); + + if($opt::delete) { + # Delete before copy to avoid problems if a src dir is a file on dst + delete_files(\%dst_tree,$dst_url,@files_to_delete,@files_to_update); + } + + copy(\%src_tree,$dst_url,@files_to_add,@files_to_update); + + if($opt::move) { + for my $src_url (@src_urls) { + delete_files(\%src_tree,$src_url,@src_files_to_delete); + } + } + print("FINISHED\n"); + exit(0); +} + +# .netrc support +if ( ($ftpserver ne "") and ($ftppasswd eq "anonymous") ) { + if ($ftpuser eq "ftp") { + my $netrcdata = Net::Netrc->lookup($ftpserver); + if ( defined $netrcdata ) { + $ftpuser = $netrcdata->login; + $ftppasswd = $netrcdata->password; + } + } else { + my $netrcdata = Net::Netrc->lookup($ftpserver,$ftpuser); + if ( defined $netrcdata ) { + $ftppasswd = $netrcdata->password; + } + } +} + +#if($ftpuser eq "?") { print "User: "; $ftpuser=; chomp($ftpuser); } +#if($ftppasswd eq "?") { print "Password: "; $ftppasswd=; chomp($ftppasswd); } + +if ($dodebug) { print_options(); } +# check options +if (not -e $localdir){ + error("Local directory does not exist: ".$localdir."\n"); $returncode+=1; +} +if ($ftpserver eq "") { error("No FTP server given.\n"); $returncode+=1; } +# $ftpdir is allowed to be empty +if ($ftpuser eq "") { error("No FTP user given.\n"); $returncode+=1; } +if ($ftppasswd eq "") { error("No FTP password given.\n"); $returncode+=1; } +if ($returncode > 0) { die "Aborting due to missing or wrong options! Call ftpsync -? for more information.\n"; } + +# Find out if ftp server is online & accessible +my $ftpc = connection(); + +logger("\nDetermine s offset.\n"); +if (($notimestamping+$notimestampcheck) lt 2 && $syncdirection eq "put" && $syncoff == 0) +{ clocksync($ftpc); } + +# local & remote tree vars +#chdir $localdir; +my $ldl=length($localdir) + 1; +my %localfiledates=(); +my %localfilesizes=(); +my %localdirs=(); +my %locallinks=(); + +my %remotefilesizes=(); +my %remotefiledates=(); +my %remotedirs=(); +my %remotelinks=(); +my $curremotesubdir=""; + +# Build local & remote tree + +logger("\nBuilding local file tree.\n"); +buildlocaltree(); + +logger("\nBuilding remote file tree.\n"); + +# Prepend connection time out while file reading takes +# longer than the remote ftp time out +# - 421 Connection timed out. +# - code=421 or CMD_REJECT=4 +if (!$ftpc->pwd()) { + #print "Message: (".$ftpc->code."/".$ftpc->status.") ".$ftpc->message; exit 0; + if ($ftpc->code == 421 or $ftpc->status eq CMD_REJECT) { + logger("\nReconnect to server.\n"); + $ftpc = connection(); + } +} +buildremotetree(); + +listremotedirs(); + +# Work ... +if ($doinfoonly) { $docheckfirst=0; } +if ($docheckfirst) +{ print "Simulating synchronization.\n"; + $doinfoonly=1; + dosync(); + $doinfoonly=0; + print "\nOK to really update files? (y/n) [n] "; + my $yn=; + if ($yn =~ /^y/i) + { print "OK, going to do it.\n"; + } + else + { print "OK, exiting without actions.\n"; + exit 1; + } +} +if ($doinfoonly) { + logger("\nSimulating synchronization.\n"); +} else { + logger("\nStarting synchronization.\n"); +} +dosync(); + +logger("Done.\n"); + +logger("Quitting FTP connection.\n"); +$ftpc->quit(); + +exit 0; + + +# +# Subs +# + +sub copy { + my $src_tree_ref = shift; + my $dst_url = shift; + my @files = @_; + my %src = %$src_tree_ref; + + logger("","Copying\n"); + for my $file (sort @files) { + if(defined $src{$file}{'connection'}) { + # Src file is remote + if($Global::ftpconnections{$dst_url}) { + # Dst is remote + copy_remote_remote($src{$file}{'connection'},$file,$dst_url); + } else { + # Dst is local + copy_remote_local($src{$file}{'connection'},$file,$dst_url); + } + } else { + # Src file is local + if($Global::ftpconnections{$dst_url}) { + # Dst is remote + copy_local_remote($file,$dst_url,%src); + } else { + # Dst is local + copy_local_local($file,$dst_url); + } + } + } + logger("","\n"); + + sub copy_local_local { + die("Not implemented"); + } + + sub copy_local_remote { + my $filepath = shift; + my $dst_url = shift; + my $path = (parse_url($dst_url))[5]; + if($path =~ m:^//:) { + # ftp://user@host//path => /path + $path =~ s:^//:/:; + } elsif($path =~ m:^/:) { + # ftp://user@host/path => ./path + $path =~ s:^:.:; + } + my %src = @_; + my $ftpc = $Global::ftpconnections{$dst_url}; + my $file = $src{$filepath}; + # Make subdirs if needed + $opt::dryrun or ftpmkdirhier($ftpc,$path); + my $would = $opt::dryrun ? "Would " : ""; + if($file->{'size'} == -1) { + my $cpath = clean_dir_name($path); + logger("",":",$would."Make dir $filepath\n",$would."Make dir $dst_url$filepath\n"); + $opt::dryrun or ftpmkdir($ftpc,$cpath.$filepath); + } else { + my $cpath = clean_dir_name($path); + logger("",".",$would."Copy $file->{'abspath'} to $cpath$filepath\n", + $would."Copy $file->{'abspath'} to $dst_url/$filepath\n"); + if(not $opt::dryrun) { + ftpsleep(); + $ftpc->delete($cpath.$filepath); + if(not $ftpc->put($file->{'abspath'},$cpath.$filepath)) { + warning("Cannot write $cpath$filepath\n"); + } + } + } + } + + sub copy_remote_local { + my $ftpc = shift; + my $filepath = shift; + my $path = shift; +# my $ftpc = $Global::ftpconnections{$src_url}; + my $file = $src{$filepath}; + # Make subdirs if needed + make_path($path); + if($file->{'size'} == -1) { + logger("",":","Make dir $filepath\n","Make dir $path/$filepath\n"); + make_path($path."/".$filepath); + } else { + my $cpath = clean_dir_name($path); + logger("",".","Copy $file->{'abspath'} to $cpath$filepath\n","Copy $file->{'abspath'} to $path/$filepath\n"); + ftpsleep(); + if(not $ftpc->get($file->{'abspath'},$cpath.$filepath)) { + die "Cannot write $cpath$filepath"; + } + } + } + + sub copy_remote_remote { + die("Not implemented"); + } +} + +sub delete_files { + my $tree_ref = shift; + my $url = shift; + my @files = @_; + + logger("","Deleting\n","Deleting\n","Deleting from $url\n"); + if($Global::ftpconnections{$url}) { + # Remote url + delete_remote($Global::ftpconnections{$url},$url,$tree_ref,@files); + } else { + delete_local($tree_ref,@files); + } + logger("","\n"); + + sub delete_remote { + my $ftpc = shift; + my $url = shift; + my $tree_ref = shift; + my @files = @_; + my %tree = %$tree_ref; + for my $f (sort { length($b) <=> length($a) } @files) { + # Sort by length to make sure files are deleted before dirs + my $would = $opt::dryrun ? "Would " : ""; + if($tree{$f}{'size'} == -1) { + # This is a dir + logger("",":",$would."Rmdir: $tree{$f}{'abspath'}\n", + $would."Rmdir: $url / $f = $tree{$f}{'abspath'}\n"); + $opt::dryrun or $ftpc->rmdir($tree{$f}{'abspath'}); + } else { + logger("",".",$would."Delete: $tree{$f}{'abspath'}\n", + $would."Delete: $url / $f = $tree{$f}{'abspath'}\n"); + $opt::dryrun or $ftpc->delete($tree{$f}{'abspath'}); + } + } + } + + sub delete_local { + my $tree_ref = shift; + my %tree = %$tree_ref; + my @files = @_; + for my $f (sort { length($b) <=> length($a) } @files) { + # Sort by length to make sure files are deleted before dirs + my $would = $opt::dryrun ? "Would " : ""; + if($tree{$f}{'size'} == -1) { + # This is a dir + logger("",":",$would."Rmdir: $tree{$f}{'abspath'}\n", + $would."Rmdir: $url / $f = $tree{$f}{'abspath'}\n"); + $opt::dryrun or rmdir($tree{$f}{'abspath'}); + } else { + logger("",".",$would."Delete: $tree{$f}{'abspath'}\n", + $would."Delete: $url / $f = $tree{$f}{'abspath'}\n"); + $opt::dryrun or unlink($tree{$f}{'abspath'}); + } + } + } +} + +sub ftpmkdirhier { + my $ftpc = shift; + my $dir = shift; + my @a = split "/", $dir; + my @dir; + while(@a) { + push @dir, shift @a; + ftpmkdir($ftpc,join("/",@dir)); + } +} + +sub ftpmkdir { + my $ftpc = shift; + my $dir = shift; + if($FTPMKDIR::already_done{$dir}++) { + # skip + } else { + ftpsleep(); + if(not $ftpc->mkdir($dir)) { + # Ignore + } + logger("","","","mkdir $dir\n"); + } +} + +sub ftpsleep { + # Sleep for 0.1 sec + usleep($opt::slowmillis || 100); +} + +sub fill_in_ftpurl { + # Fill in ftpurl with missing information + # ftp://?:?@ => Ask for user, pass + # If .netrc exists, use that for missing fields + my @urls = @_; + for my $url (@urls) { + my ($scheme,$user,$pass,$host,$port,$dir) = parse_url($url); + if($scheme =~ /^ftps?$/i) { + if($user eq "?") { + print "User: "; + $user=; + chomp($user); + } + if($pass eq "?") { + print "Password: "; + $pass=; + chomp($pass); + } + if($host eq "?") { + print "Host: "; + $host=; + chomp($host); + } + if($port eq "?") { + print "Port: "; + $port=; + chomp($port); + } + if($dir eq "?") { + print "Dir: "; + $dir=; + chomp($dir); + } + # TODO read from netrc + if(not defined $user) { + } + if(not defined $pass) { + } + if(not defined $host) { + } + if(not defined $port) { + } + if(not defined $dir) { + } + + $url = $scheme . "://" . uri_escape($user) . ":" . uri_escape($pass) . '@' . + $host . ($port ? ":" . $port : "") . "/" . uri_escape($dir); + } + } + return(wantarray() ? @urls : pop @urls); +} + +sub parse_url { + my $url = shift; + if($url =~ m!(ftp|ftps|sftp):// # Scheme ($1) + (?: + ([^:@/][^:@]*|) # Username ($2) + (?: + :([^@]*) # Password ($3) + )? + @)? + ([^:/]*)? # Hostname ($4) + (?: + : + ([^/]*)? # Port ($5) + )? + (?: + / + (.*)? # Dir ($6) + )? + $ + !ix) { + my ($scheme,$user,$pass,$host,$port,$dir) = uri_unescape($1,$2,$3,$4,$5,$6); + return ($scheme,$user,$pass,$host,$port,$dir); + } else { + if($url =~ m{://}) { + error("$url is not an URL\n"); + } else { + # Not ftpurl - return as single string + return $url; + } + } +} + +sub ftpconnect { + # Return ftp connection object + my $url = shift; + if(not defined $Global::ftpconnections{$url}) { + my($scheme,$user,$pass,$host,$port,$dir) = parse_url($url); + my $doftpdebug=($opt::verbose > 4); + my $passive; + if(defined $opt::passive) { + $passive = $opt::passive; + } else { + $passive = autodetect_passive($user,$pass,$host,$doftpdebug); + } + my $ftpc = Net::FTP->new($host, Debug => $doftpdebug, + Timeout => ($opt::timeout || 120), + Passive => $passive) + || die "Could not connect to $host\n"; + logger("","","Logging in as $user.\n","Logging in as $user with password $pass.\n"); + $ftpc->login($user,$pass) || die "Could not login to $host as $user\n"; + $ftpc->binary() + or die "Cannot set binary mode ", $ftpc->message; + $Global::ftpconnections{$url} = $ftpc; + $Global::timeoffset{$url} = timeoffset($url); + } + return $Global::ftpconnections{$url}; +} + +sub autodetect_passive { + my ($user,$pass,$host,$doftpdebug) = @_; + my $passive_pid; + my $active_pid; + $SIG{CHLD} = 'IGNORE'; + if(not $passive_pid = fork()) { + my $ftpc = Net::FTP->new($host, Debug => $doftpdebug, + Timeout => ($opt::timeout || 120), + Passive => 1) + || die "Could not connect to $host\n"; + $ftpc->login($user,$pass) || die "Could not login to $host as $user\n"; + $ftpc->dir("."); + exit(0); + } + if(not $active_pid = fork()) { + my $ftpc = Net::FTP->new($host, Debug => $doftpdebug, + Timeout => ($opt::timeout || 120), + Passive => 0) + || die "Could not connect to $host\n"; + $ftpc->login($user,$pass) || die "Could not login to $host as $user\n"; + $ftpc->dir("."); + sleep(1); + exit(0); + } + my $timeout = ($opt::timeout || 120)*10; + my $auto_passive; + logger("","","Detecting if passive needed"); + while($timeout--) { + if(not kill 0 => $active_pid) { + # $active_pid finished + $auto_passive = 0; + last; + } + if(not kill 0 => $passive_pid) { + # $passive_pid finished + $auto_passive = 1; + last; + } + usleep(100); + logger("","","."); + } + logger("","",$auto_passive ? " Passive\n" : " Active\n"); + return $auto_passive; +} + +sub timeoffset { + my $url = shift; + my $ftpc = ftpconnect($url); + my($scheme,$user,$pass,$host,$port,$dir) = parse_url($url); + my ($outfh, $localfile) = ::tempfile(); + my ($basename) = basename($localfile); + my $remote_file; + if(not -z $localfile) { + die "File $localfile for time sync must be empty."; + } + if(not $ftpc->put($localfile)) { + if(not $ftpc->put($localfile,"$dir/$basename")) { + logger("Cannot send timesync file $localfile. Assuming no time difference.\n", + "Cannot send timesync file $localfile. Assuming no time difference.\n", + "Cannot send timesync file $localfile. Assuming no time difference.\n", + "Cannot send timesync file $url/$basename. Assuming no time difference.\n"); + return 0; + } else { + $remote_file = "$dir/$basename"; + } + } else { + $remote_file = $basename; + } + logger("","","Sync file $localfile => $remote_file\n"); + my $now_here1 = (lstat($localfile))[9]; + unlink($localfile); + my $now_there; + my @rfl = eval { $ftpc->dir($remote_file) }; + for my $curlsline (parse_dir(\@rfl)) { + my ($file,$type,$size,$date,$mode) = @$curlsline; + logger("","","","Mod:".$date." Size:".$size."\t".$file."\n"); + $now_there = $date; + } + if(not $now_there) { + logger("Cannot get mod time of $remote_file. Assuming no time difference.\n", + "Cannot get mod time of $remote_file. Assuming no time difference.\n", + "Cannot get mod time of $remote_file. Assuming no time difference.\n", + "Cannot get mod time of $url/$basename. Assuming no time difference.\n"); + return 0; + } + my $now_here2 = time(); + $ftpc->delete($remote_file); + logger("","","Localtime before $now_here1, Remote $now_there, after $now_here2\n"); + + if ($now_here2 < $now_there) { + # remote is in the future + $syncoff = ($now_there - $now_here1); + $syncoff -= $syncoff % 60; + $syncoff = 0-$syncoff; + } else { + # remote is the past # or equal + $syncoff = ($now_here2 - $now_there); + $syncoff -= $syncoff % 60; + } + + my $hrs = int(abs($syncoff)/3600); + my $mins = int(abs($syncoff)/60) - $hrs*60; + my $secs = abs($syncoff) - $hrs*3600 - $mins*60; + logger("","",sprintf("Clock sync offset: %dh%02dm%02ds\n", $hrs, $mins, $secs)); + return $syncoff; +} + +sub changed { + # Determine if a file is changed: + # * size mismatch + # * dst_date < src_date + # + # Input: + # $src_tree_ref: Reference to %src_tree + # $dst_tree_ref: Reference to %dst_tree + # + # Output: + # list of files changed in %dst_tree + # files that are missing are ignored + my ($src_tree_ref,$dst_tree_ref) = @_; + my %src = %$src_tree_ref; + my %dst = %$dst_tree_ref; + my @common = grep { defined $dst{$_} } keys %src; + my @changed; + for my $file (@common) { + if($src{$file}{'size'} == $dst{$file}{'size'} + and + ($opt::sizeonly or + $src{$file}{'date'} <= $dst{$file}{'date'})) { + # This is a file with: + # size = size + # --size-only or date <= date + # => + # Not changed + next; + } + if($src{$file}{'size'} == -1 and $dst{$file}{'size'} == -1) { + # This is a dir that both have - ignore date + # TODO Can we sync mdate? + next; + } + if(not $opt::delete) { + # If we are not allowed to delete the mismatching filetypes + # we should fail on changed filetype + if($src{$file}{'size'} == -1 and $dst{$file}{'size'} != -1) { + # A src file is a dir in dst + error("$file is a dir on source but a file on destination.\n"); + } + if($src{$file}{'size'} != -1 and $dst{$file}{'size'} == -1) { + # A src dir is a file in dst + error("$file is a file on source but a dir on destination.\n"); + } + } + if($src{$file}{'size'} != $dst{$file}{'size'} + or + $src{$file}{'date'} >= $dst{$file}{'date'}) { + logger("","","Changed ".$src{$file}{'size'}."!=".$dst{$file}{'size'}. + " or ".$src{$file}{'date'}.">=".$dst{$file}{'date'}." $file\n"); + push @changed, $file; + next; + } + die_bug("changed: $file"); + } + return @changed; +} + +sub missing { + # Input: + # $src_tree_ref: Reference to %src_tree + # $dst_tree_ref: Reference to %dst_tree + # Output: + # list of files missing in %dst_tree + my ($src_tree_ref,$dst_tree_ref) = @_; + my %src = %$src_tree_ref; + my %dst = %$dst_tree_ref; + my @missing = grep { not defined $dst{$_} } keys %src; + return @missing; +} + +sub buildtree { + # Build data structure for URLs + # Returns: + # filename is relative to URL + # %tree{filename}{'date'}=$modification_date; + # %tree{filename}{'size'}=$size; + # %tree{filename}{'link'}=$filename; + # %tree{filename}{'parentdir'}=dirname($filename); + # %tree{filename}{'abspath'}=path from url+$filename + my @urls = @_; + my %tree=(); + # For speed first put the full tree in an array before merging + my @tree_arr = (); + for my $url (@urls) { + my ($scheme,$user,$pass,$host,$port,$dir) = parse_url($url); + if($scheme =~ m{^s?ftps?$}i) { + my $url_no_pass = $scheme."://".$user.'@'.$host."/".$dir; + logger("","Building remote tree $url_no_pass\n","Building remote tree $url_no_pass\n","Building remote tree of $url\n"); + push(@tree_arr, remote_tree($url)); + logger("","\n"); + } else { + # Assume local if not starting with ftps?:// + # file:///foo => /foo + $url =~ s{^file://}{}; + logger("","Building local tree of $url\n"); + push(@tree_arr, local_tree($url)); + logger("","\n"); + } + } + %tree = @tree_arr; + return %tree; + + sub remote_tree { + my $url = shift; + my $ftpc = ftpconnect($url); + my $path = (parse_url($url))[5]; + + if($path =~ m:^//:) { + # ftp://user@host//path => /path + $path =~ s:^//:/:; + } elsif($path =~ m:^/:) { + # ftp://user@host/path => ./path + $path =~ s:^:.:; + } + # Single file not implemented => assume dir + #if(-d $path) { + # Dir + my %tree = remote_tree_dir($ftpc,"",$path,$url); + return %tree; + #} else { + # Single file + # return remote_tree_file($path); + #} + + sub remote_tree_dir { + my ($ftpc,$dir,$abs,$url) = @_; + logger("",":","Dir: ".$dir." in $abs\n"); + my %tree = (); + my @tree_arr; + + ftpsleep(); + my $ftpdir; + if($dir eq "") { + $ftpdir = $abs; + } elsif($abs eq "") { + $ftpdir = $dir; + } else { + $ftpdir = $abs."/".$dir; + } + my @rfl = eval { $ftpc->dir($ftpdir) }; +# my %monthtonr; +# @monthtonr{qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)} = 1..12; + for my $curlsline (parse_dir(\@rfl)) { + my ($f,$type,$size,$date,$mode) = @$curlsline; + my $file = clean_dir_name($dir).$f; + my $abspath = clean_dir_name($abs).$file; + if($type eq "d") { + if($file =~ /\/\.\.?$/ or $opt::flat) { + # Ignore . and .. and subdirs if --flat + } else { + push(@tree_arr, remote_tree_dir($ftpc,$file,$abs,$url)); + # Mark directories by setting size to -1 + $tree{$file}{'size'} = -1; + } + } else { + $tree{$file}{'size'} = $size; + } + $tree{$file}{'date'} = $date + $Global::timeoffset{$url}; + $tree{$file}{'abspath'} = $abspath; + $tree{$file}{'connection'} = $ftpc; + $tree{$file}{'parentdir'} = $dir; + logger("",".","Mod:".$tree{$file}{'date'}." Size:".$tree{$file}{'size'}."\t".$file."\n"); + } + %tree = (@tree_arr,%tree); + return %tree; + } + + sub remote_tree_file { + # Not used + } + } + + sub local_tree { + my $path = shift; + my %tree; + my $prefix = $path; + if(not -e $path) { + # Path does not exist => return empty + return %tree + } + my %t2; + if(-d $path) { + # Dir + $path = clean_dir_name($path); + $path =~ s{/$}{}; + %t2 = local_tree_dir($path); + } else { + # $path is a file. $prefix = dirname($prefix) + $prefix = dirname($prefix); + %t2 = local_tree_file($path) + } + # remove the prefix to get relative paths + while(my($k,$v) = each(%t2)) { + if($k eq $prefix) { + # Skip the prefix dir + next; + } + $k =~ s:^$prefix/::; + $tree{$k} = $v; + $tree{$k}{'parentdir'} =~ s:^$prefix/::; + } + return %tree; + + sub local_tree_dir { + my $dir = shift; + logger("",":","Dir: ".$dir."\n"); + my %tree = (); + # For speed first put the full tree in an array before merging + my @tree_arr = (); + push(@tree_arr, local_tree_file($dir)); + opendir(my $dh,$dir) || die; + my @files_in_dir = map { $dir."/".$_ } readdir($dh); + for my $file (@files_in_dir) { + if($opt::exclude) { + $file =~ /$opt::exclude/o and next; + } + if(-d $file) { + if($file =~ /(^|\/)\.\.?$/ or $opt::flat) { + # Ignore . and .. and subdirs if --flat + } else { + push(@tree_arr, local_tree_dir($file)); + } + } else { + push(@tree_arr, local_tree_file($file)); + } + } + # Merge trees + %tree = @tree_arr; + return %tree; + } + + sub local_tree_file { + my $file = shift; + my %tree; + my $dir = $file; + $dir =~ s:/?[^/]+$::; + if($dir eq "") { + $dir = "."; + } + my @stat = lstat($file); + if(-d $file) { + # Mark directories by setting size to -1 + $tree{$file}{'size'} = -1; + } else { + $tree{$file}{'size'} = $stat[7]; + } + $tree{$file}{'date'} = $stat[9]; + $tree{$file}{'abspath'} = $file; + $tree{$file}{'parentdir'} = $dir; + logger("",".","Mod:".$tree{$file}{'date'}." Size:".$tree{$file}{'size'}."\t".$file."\n"); + return %tree; + } + } + + sub clean_dir_name { + my $dir = shift; + # Returns: + # dir/ or "" + + # foo/bar/../ => foo/ + while($dir =~ s:[^/]+/\.\.(/|$ )::x) {} + # ./foo => foo + # bar/./foo => bar/foo + while($dir =~ s:(^|[^/]+/)\./::) {} + # // => / + while($dir =~ s://:/:) {} + if($dir eq "" or $dir eq ".") { + return ""; + } else { + return $dir."/"; + } + } +} + +### + +sub buildlocaltree() { + if ($doflat) { + chdir $localdir; + my @globbed=glob("{*,.*}"); + foreach my $curglobbed (@globbed) { + next if (! -f $curglobbed); + my @curfilestat=lstat $curglobbed; + my $curfilesize=@curfilestat[7]; + my $curfilemdt=@curfilestat[9]; + logger("",".","File: ".$curglobbed."\n"."Modified ".$curfilemdt."\nSize ".$curfilesize." bytes\n"); + my $relfilename=$curglobbed; + $localfiledates{$relfilename}=$curfilemdt; + $localfilesizes{$relfilename}=$curfilesize; + } + } else { + find ({wanted=>\¬icelocalfile,follow_fast => $followsymlinks }, $localdir."/"); + } + sub noticelocalfile { + my $relfilename=substr($File::Find::name,$ldl); + if (length($relfilename) == 0) { return; } + if ($ignoremask ne "") + { + if ($relfilename =~ /$ignoremask/ ) { + logger("","Ignoring ".$relfilename." which matches ".$ignoremask."\n"); + return; + } + } + if (-d $_) { + logger("",":","Directory: ".$File::Find::name."\n"); + $localdirs{$relfilename}="$relfilename"; + } + elsif (-f $_) { + #my @curfilestat=lstat $File::Find::name; + my @curfilestat=lstat $_; + my $curfilesize=@curfilestat[7]; + my $curfilemdt=@curfilestat[9]; + logger("",".","File: ".$File::Find::name."\n"."Modified ".$curfilemdt."\nSize ".$curfilesize." bytes\n"); + $localfiledates{$relfilename}=$curfilemdt; + $localfilesizes{$relfilename}=$curfilesize; + } + elsif (-l $_) { + logger("",",","Link: ".$File::Find::name."\n"); + $locallinks{$relfilename}="$relfilename"; + } else { + logger("Ignoring file of unknown type: ".$File::Find::name."\n"); + } + } + logger("","","Local dirs (relative to ".$localdir."/):\n"); + my $curlocaldir=""; + foreach $curlocaldir (keys(%localdirs)) { + logger("","",$curlocaldir."/\n"); + logger("","","Local files (relative to ".$localdir."/):\n"); + my $curlocalfile=""; + foreach $curlocalfile (keys(%localfiledates)) { + logger("","",$curlocalfile."\n"); + } + } +} + + +sub buildremotetree() { + my @currecursedirs=(); + #$ftpc->ls() + # or die $ftpc->message . "\nCannot ls remote dir " . $ftpc->pwd(); + my @rfl = $ftpc->dir('-a'); + # or @rfl=(); # we have to survive empty remote directories !!! + my $currf=""; + my $curyear = (gmtime(time))[5] + 1900; + my %monthtonr=(); + $monthtonr{"Jan"}=1; $monthtonr{"Feb"}=2; $monthtonr{"Mar"}=3; $monthtonr{"Apr"}=4; $monthtonr{"May"}=5; $monthtonr{"Jun"}=6; + $monthtonr{"Jul"}=7; $monthtonr{"Aug"}=8; $monthtonr{"Sep"}=9; $monthtonr{"Oct"}=10; $monthtonr{"Nov"}=11; $monthtonr{"Dec"}=12; + logger("","","Remote pwd is ".$ftpc->pwd()."\nDIRing.\n"); + my $curlsline; + foreach $curlsline (parse_dir(\@rfl)) { + my ($cfname,$cftype,$cfsize,$cftime,$mode)=@$curlsline; + if ( $cftype ) { + if ($cfname eq ".") { next; } + if ($cfname eq "..") { next; } + if ($ignoremask ne "") + { + my $testpath; + if ($curremotesubdir eq "") { $testpath = $cfname; } + else { $testpath = $curremotesubdir."/".$cfname; } + if ($testpath =~ /$ignoremask/ ) + { + logger("","Ignoring ".$testpath." which matches ".$ignoremask."\n"); + next; + } + } + if (substr($cftype,0,1) eq 'l') { # link, rest of string = linkto + my $curnrl; + if ($curremotesubdir eq "") { $curnrl = $cfname; } + else { $curnrl = $curremotesubdir."/".$cfname; } + $remotelinks{$curnrl}=$cfname; + logger("","","Link: ".$curnrl." -> ".$cfname."\n"); + } + elsif ($cftype eq 'd') { + if (!$doflat) { + my $curnewrsd; + if ($curremotesubdir eq "") { $curnewrsd = $cfname; } + else { $curnewrsd = $curremotesubdir."/".$cfname; } + $remotedirs{$curnewrsd}=$curnewrsd; + logger("",":","Directory: ".$curnewrsd."\n"); + push @currecursedirs, $cfname; + } + } elsif ($cftype eq 'f') { #plain file + my $curnewrf; + if ($curremotesubdir eq "") { $curnewrf = $cfname; } + else { $curnewrf = $curremotesubdir."/".$cfname; } + #$remotefiledates{$curnewrf}=$cftime; + $remotefiledates{$curnewrf}=$ftpc->mdtm($cfname)+$syncoff; + if ($remotefiledates{$curnewrf} le 0) { die "Timeout detecting modification time of $curnewrf\n"; } + $remotefilesizes{$curnewrf}=$cfsize; + if ($remotefilesizes{$curnewrf} lt 0) { die "Timeout detecting size of $curnewrf\n"; } + logger("",".","File: ".$curnewrf."\n"); + } else { + logger("Unkown file: $curlsline\n"); + } + } else { + logger("","","Ignoring.\n"); + } + } + #recurse + #if ($doflat) { @currecursedirs=(); } + my $currecurseddir; + foreach $currecurseddir (@currecursedirs) + { my $oldcurremotesubdir; + $oldcurremotesubdir=$curremotesubdir; + if ($curremotesubdir eq "") { $curremotesubdir = $currecurseddir; } + else { $curremotesubdir .= "/".$currecurseddir; } + my $curcwddir=""; + if ($ftpdir eq "/") + { $curcwddir=$ftpdir.$curremotesubdir; } + else + { $curcwddir=$ftpdir."/".$curremotesubdir; } + logger("","","Change dir: ".$curcwddir."\n"); + $ftpc->cwd($curcwddir) + or die "Cannot cwd to $curcwddir", $ftpc->message ; + my $ftpcurdir=$ftpc->pwd(); + if ($ftpcurdir ne $curcwddir && $ftpcurdir ne "$curcwddir".'/') { + die "Could not cwd to $curcwddir :" . $ftpc->message ; } + buildremotetree(); + $ftpc->cdup(); + $curremotesubdir = $oldcurremotesubdir; + } +} + + +sub dosync() +{ + chdir $localdir || die "Could not change to local base directory $localdir\n"; + if ($syncdirection eq "put") { + # create dirs missing at the target + if ($doinfoonly) { + print "\nWould create new remote directories.\n"; + } else { + logger("\nCreating new remote directories.\n"); + } + my $curlocaldir; + foreach $curlocaldir (sort { return length($a) <=> length($b); } keys(%localdirs)) { + if (! exists $remotedirs{$curlocaldir}) { + logger("d","$curlocaldir\n"); + if ($doinfoonly) { next; } + if ($ftpc->mkdir($curlocaldir) ne $curlocaldir) { die "Could not create remote subdirectory $curlocaldir\n"; } + $ftpc->quot('SITE', sprintf('CHMOD %04o %s', (lstat $curlocaldir)[2] & 07777, $curlocaldir)); + } + } + # copy files missing or too old at the target, synchronize timestamp _after_ copying + if ($doinfoonly) { print "\nWould copy new(er) local files.\n"; } + else { + logger("\nCopying new(er) local files.\n"); + } + my $curlocalfile; + foreach $curlocalfile (sort { return length($b) <=> length($a); } keys(%localfiledates)) + { my $dorefresh=0; + if (! exists $remotefiledates{$curlocalfile}) { + $dorefresh=1; + $infotext="New: ".$curlocalfile." (".$localfilesizes{$curlocalfile}." bytes)\n"; + logger("n",$infotext); + if ($doinfoonly) { next; } + } + elsif ($notimestampcheck == 0 && $remotefiledates{$curlocalfile} < $localfiledates{$curlocalfile}) { + $dorefresh=1; + $infotext="Newer: ".$curlocalfile." (".$localfilesizes{$curlocalfile}." bytes, ".$localfiledates{$curlocalfile}." versus ".$remotefiledates{$curlocalfile}.")\n"; + logger("u",$infotext); + if ($doinfoonly) { next; } + } + elsif ($remotefilesizes{$curlocalfile} != $localfilesizes{$curlocalfile}) { + $dorefresh=1; + $infotext="Changed (different sized): ".$curlocalfile." (".$localfilesizes{$curlocalfile}." versus ".$remotefilesizes{$curlocalfile}." bytes)\n"; + logger("u",$infotext); + if ($doinfoonly) { next; } + } + if (! $dorefresh) { next; } + logger("","","Really PUTting file ".$curlocalfile."\n"); + # Some servers crash if commands are given too fast, so wait a little. + if ($slowmillis gt 0) { + select(undef, undef, undef, $slowmillis/1000); + } + if ($ftpc->put($curlocalfile, $curlocalfile) ne $curlocalfile) + { print STDERR "Could not put localfile $curlocalfile\n"; } + my $retries = 3; + while ( ($ftpc->size($curlocalfile) != (lstat $curlocalfile)[7]) and ($retries-- > 0) ) + { logger("Re-Transfering $curlocalfile\n"); + if ($ftpc->put($curlocalfile, $curlocalfile) ne $curlocalfile) + { warning("Could not re-put localfile $curlocalfile\n"); } + } + my $newremotemdt=$ftpc->mdtm($curlocalfile)+$syncoff; + if ($notimestamping == 0) { + utime ($newremotemdt, $newremotemdt, $curlocalfile); + } + $ftpc->quot('SITE', sprintf('CHMOD %04o %s', (lstat $curlocalfile)[2] & 07777, $curlocalfile)); + } + if (! $nodelete) + { + # delete files too much at the target + if ($doinfoonly) { print "\nWould delete obsolete remote files.\n"; } + else { + logger("\nDeleting obsolete remote files.\n"); + } + my $curremotefile; + foreach $curremotefile (keys(%remotefiledates)) { + if (not exists $localfiledates{$curremotefile}) { + logger("r",$curremotefile."\n"); + if ($doinfoonly) { next; } + } + if ($ftpc->delete($curremotefile) ne 1) { die "Could not delete remote file $curremotefile\n"; } + } + # delete dirs too much at the target + if ($doinfoonly) { print "\nWould delete obsolete remote directories.\n"; } + else { + logger("\nDeleting obsolete remote directories.\n"); + } + my $curremotedir; + foreach $curremotedir (sort { return length($b) <=> length($a); } keys(%remotedirs)) { + if (! exists $localdirs{$curremotedir}) { + logger("R",$curremotedir."\n"); + if ($doinfoonly) { next; } + if ($ftpc->rmdir($curremotedir) ne 1) { die "Could not remove remote subdirectory $curremotedir\n"; } + } + } + } + } else { # $syncdirection eq "GET" + # create dirs missing at the target + if ($doinfoonly) { + logger("\nWould create new local directories.\n"); + } else { + logger("\nCreating new local directories.\n"); + } + my $curremotedir; + foreach $curremotedir (sort { return length($a) <=> length($b); } keys(%remotedirs)) { + if (! exists $localdirs{$curremotedir}) { + logger("d",$curremotedir."\n"); + if ($doinfoonly) { print ; next; } + } + mkdir($curremotedir) || die "Could not create local subdirectory $curremotedir\n"; + } + # copy files missing or too old at the target, synchronize timestamp _after_ copying + if ($doinfoonly) { + logger("\nWould copy new(er) remote files.\n"); + } else { + logger("\nCopying new(er) remote files.\n"); + } + my $curremotefile; + foreach $curremotefile (sort { return length($b) <=> length($a); } keys(%remotefiledates)) + { my $dorefresh=0; + if (! exists $localfiledates{$curremotefile}) { + $dorefresh=1; + $infotext="New: ".$curremotefile." (".$remotefilesizes{$curremotefile}." bytes)\n"; + logger("n",$infotext); + if ($doinfoonly) { next; } + } + elsif ($notimestampcheck == 0 && $remotefiledates{$curremotefile} > $localfiledates{$curremotefile}) { + $dorefresh=1; + $infotext="Newer: ".$curremotefile." (".$remotefilesizes{$curremotefile}." bytes, ".$remotefiledates{$curremotefile}." versus ".$localfiledates{$curremotefile}.")\n"; + logger("u",$infotext); + if ($doinfoonly) { next; } + } + elsif ($remotefilesizes{$curremotefile} != $localfilesizes{$curremotefile}) { + $dorefresh=1; + $infotext="Changed (different sized): ".$curremotefile." (".$remotefilesizes{$curremotefile}." bytes)\n"; + logger("u",$infotext); + if ($doinfoonly) { next; } + } + if (! $dorefresh) { next; } + logger("Really GETting file ".$curremotefile."\n"); + my $rc=$ftpc->get($curremotefile, $curremotefile); + if ( ($rc eq undef) or ($rc ne $curremotefile) ) + { print STDERR "Could not get file ".$curremotefile."\n"; } + my $retries=3; + while ( ($ftpc->size($curremotefile) != (lstat $curremotefile)[7]) and ($retries-- > 0) ) + { + logger("Re-Transfering $curremotefile\n"); + if ( ($rc eq undef) or ($rc ne $curremotefile) ) + { print STDERR "Could not get file ".$curremotefile."\n"; } + } + my $newlocalmdt=$remotefiledates{$curremotefile}; + if ($notimestamping == 0) { + utime ($newlocalmdt, $newlocalmdt, $curremotefile); + } + } + if (! $nodelete) + { + # delete files too much at the target + if ($doinfoonly) { print "\nWould delete obsolete local files.\n"; } + else { + logger("\nDeleting obsolete local files.\n"); + } + my $curlocalfile; + foreach $curlocalfile (sort { return length($b) <=> length($a); } keys(%localfiledates)) + { if (not exists $remotefiledates{$curlocalfile}) + { + logger("r",$curlocalfile."\n"); + + if (unlink($curlocalfile) ne 1) { die "Could not remove local file $curlocalfile\n"; } + } + } + # delete dirs too much at the target + if ($doinfoonly) { logger("\nWould delete obsolete local directories.\n"); } + else { + logger("\nDeleting obsolete local directories.\n"); + } + my $curlocaldir; + foreach $curlocaldir (keys(%localdirs)) + { if (! exists $remotedirs{$curlocaldir}) + { + logger("d",$curlocaldir."\n"); + if ($doinfoonly) { next; } + rmdir($curlocaldir) || die "Could not remove local subdirectory $curlocaldir\n"; + } + } + } + } +} + +sub parse_remote_url() { + if ($remoteURL =~ /^ftp:\/\/(([^@\/\\\:]+)(:([^@\/\\\:]+))?@)?([a-zA-Z01-9\.\-]+)(\/(.*))?/) { + #print "DEBUG: parsing ".$remoteURL."\n"; + #print "match 1 = ".$1."\n"; + #print "match 2 = ".$2."\n"; + #print "match 3 = ".$3."\n"; + #print "match 4 = ".$4."\n"; + #print "match 5 = ".$5."\n"; + #print "match 6 = ".$6."\n"; + #print "match 7 = ".$7."\n"; + if (length($2) > 0) { $ftpuser=$2; } + if (length($4) > 0) { $ftppasswd=$4; } + $ftpserver=$5; + $ftpdir=$7; + if ($ftpdir ne "/") { $ftpdir=~s/\/$//; } + } +} + + +sub print_syntax() { + print "\n"; + print "ftpsync 1.3.07 (2012-01-28)\n"; + print "\n"; + print " ftpsync [ options ] [ localdir remoteURL ]\n"; + print " ftpsync [ options ] [ remoteURL localdir ]\n"; + print " options = [-dfgpqv] [ cfg|ftpuser|ftppasswd|ftpserver|ftpdir=value ... ] \n"; + print " localdir local directory, defaults to \".\".\n"; + print " ftpURL full FTP URL, scheme\n"; + print ' ftp://[ftpuser[:ftppasswd]@]ftpserver/ftpdir'."\n"; + print " ftpdir is relative, so double / for absolute paths as well as /\n"; + print " -c | -C like -i, but then prompts whether to actually do work\n"; + print " -d | -D turns debug output (including verbose output) on\n"; + print " -f | -F flat operation, no subdir recursion\n"; + print " -g | -G forces sync direction to GET (remote to local)\n"; + print " -h | -H prints out this help text\n"; + print " -i | -I forces info mode, only telling what would be done\n"; + print " -n | -N no deletion of obsolete files or directories\n"; + print " -l | -L follow local symbolic links as if they were directories\n"; + print " -p | -P forces sync direction to PUT (local to remote)\n"; + print " -q | -Q turns quiet operation on\n"; + print " -s | -S turns timestamp comparison off (only checks for changes in size)\n"; + print " -t | -T turns timestamp setting for local files off\n"; # backward compatibility + print " -v | -V turnes verbose output on\n"; + print " cfg= read parameters and options from file defined by value.\n"; + print " ftpserver= defines the FTP server, defaults to \"localhost\".\n"; + print " ftpdir= defines the FTP directory, defaults to \".\" (/wo '\"') \n"; + print " ftpuser= defines the FTP user, defaults to \"ftp\".\n"; + print " ftppasswd= defines the FTP password, defaults to \"anonymous\".\n"; + print " ignoremask= defines a regexp to ignore certain files, like .svn"."\n"; + print " slowmillis= sleeps speficed # of ms between PUTs, default 100, 0=off"."\n"; + print " timeoffset= overrules clocksync() detection with given offset in seconds"."\n"; + print "\n"; + print " Later mentioned options and parameters overwrite those mentioned earlier.\n"; + print " Command line options and parameters overwrite those in the config file.\n"; + print " Don't use '\"', although mentioned default values might motiviate you to.\n"; + print "\n"; + print " If ftpuser or ftppasswd resovle to ? (no matter through which options),\n"; + print " ftpsync.pl asks you for those interactively.\n"; + print "\n"; + print " As of 1.3.02 .netrc is used if ftppassword or ftppassword and ftpuser)\n"; + print " are still empty after parsing all options.\n"; + print "\n"; +} + + +sub print_options() { + print "\nPrinting options:\n"; + # meta + print "returncode = ", $returncode , "\n"; + print "configfile = ", $configfile , "\n"; + # basiscs + print "syncdirection = ", $syncdirection , "\n"; + print "localdir = ", $localdir , "\n"; + # FTP stuff + print "remoteURL = ", $remoteURL , "\n"; + print "ftpuser = ", $ftpuser , "\n"; + print "ftppasswd = ", $ftppasswd , "\n"; + print "ftpserver = ", $ftpserver , "\n"; + print "ftpdir = ", $ftpdir , "\n"; + # verbosity + print "doverbose = ", $doverbose , "\n"; + print "dodebug = ", $dodebug , "\n"; + print "doquiet = ", $doquiet , "\n"; + # other + print "doinfoonly = ", $doinfoonly , "\n"; + print "slowmillis = ", $slowmillis , "\n"; + print "\n"; +} + + +sub logger { + # Print out information + # logger("Info_string","Verbose_string","Debug_string") + # Verbose_string defaults to Info_string + # Debug_string defaults to Verbose_string + # + # $opt::verbose = 0 => quiet + # $opt::verbose = 1 => info + # $opt::verbose = 2 => verbose + # $opt::verbose = 3 => debug + # $opt::verbose = 4 => debug with ftp communication + my @w = ("",@_); + # Verbose_string defaults to Info_string + $w[2] ||= $w[1]; + # Debug_string defaults to Verbose_string + $w[3] ||= $w[2]; + # Debug_string defaults to Verbose_string + $w[4] ||= $w[3]; + # FTP Debug_string defaults to Debug_string + $w[5] ||= $w[4]; + print $w[$opt::verbose]; +} + + +sub warning { + my @w = @_; + my $prog = $Global::progname || "ftpsync"; + print STDERR $prog, ": Warning: ", @w; +} + + +sub error { + my @w = @_; + my $prog = $Global::progname || "ftpsync"; + print STDERR $prog, ": Error: ", @w; + exit(1); +} + +sub usleep { + # Sleep this many milliseconds. + my $secs = shift; + select(undef, undef, undef, $secs/1000); +} + +sub my_dump { + # Returns: + # ascii expression of object if Data::Dump(er) is installed + # error code otherwise + my @dump_this = (@_); + eval "use Data::Dump qw(dump);"; + if ($@) { + # Data::Dump not installed + eval "use Data::Dumper;"; + if ($@) { + my $err = "Neither Data::Dump nor Data::Dumper is installed\n". + "Not dumping output\n"; + print $Global::original_stderr $err; + return $err; + } else { + return Dumper(@dump_this); + } + } else { + # Create a dummy Data::Dump:dump as Hans Schou sometimes has + # it undefined + eval "sub Data::Dump:dump {}"; + eval "use Data::Dump qw(dump);"; + return (Data::Dump::dump(@dump_this)); + } +} + diff -Nru ftpsync-1.1/ftpsync.1 ftpsync-1.3.07/ftpsync.1 --- ftpsync-1.1/ftpsync.1 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/ftpsync.1 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,374 @@ +.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is turned on, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.ie \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. nr % 0 +. rr F +.\} +.el \{\ +. de IX +.. +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "FTPSYNC 1" +.TH FTPSYNC 1 "2013-02-06" "perl v5.14.2" "User Contributed Perl Documentation" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +ftpsync \- synchronize a local dir with a dir on an FTP server. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +\&\fBftpsync\fR [ \-cdfghinlpqstv ] localdir remoteURL +.PP +\&\fBftpsync\fR [ \-cdfghinlpqstv ] remoteURL localdir +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\s-1GNU\s0 FTPsync synchronizes a local dir to a remote \s-1URL\s0. +.SH "OPTIONS" +.IX Header "OPTIONS" +.IP "\fIlocaldir\fR" 9 +.IX Item "localdir" +The local dir to synchronize. +.IP "\fIremoteURL\fR" 9 +.IX Item "remoteURL" +The \s-1URL\s0 of the \s-1FTP\s0 server. The \s-1URL\s0 can contain username password: +ftp://username:password@ftpserver/dir +.IP "\fB\-c\fR" 9 +.IX Item "-c" +Prompt the user about whether to run each command line and read a line +from the terminal. Only run the command line if the response starts +with 'y' or 'Y'. +.IP "\fB\-d\fR" 9 +.IX Item "-d" +Turns debug output (including verbose output) on. +.IP "\fB\-f\fR" 9 +.IX Item "-f" +Flat operation, no subdir recursion. +.IP "\fB\-g\fR" 9 +.IX Item "-g" +Forces sync direction to \s-1GET\s0 (remote to local). +.IP "\fB\-h\fR" 9 +.IX Item "-h" +Prints out help text. +.IP "\fB\-i\fR" 9 +.IX Item "-i" +Forces info mode, only telling what would be done. +.IP "\fB\-n\fR" 9 +.IX Item "-n" +No deletion of obsolete files or directories. +.IP "\fB\-l\fR" 9 +.IX Item "-l" +Follow local symbolic links as if they were directories. +.IP "\fB\-p\fR" 9 +.IX Item "-p" +Forces sync direction to \s-1PUT\s0 (local to remote). +.IP "\fB\-q\fR" 9 +.IX Item "-q" +Turns quiet operation on. +.IP "\fB\-s\fR" 9 +.IX Item "-s" +Turns timestamp comparison off (only checks for changes in size). +.IP "\fB\-t\fR" 9 +.IX Item "-t" +Turns timestamp setting for local files off. +.IP "\fB\-v\fR" 9 +.IX Item "-v" +Turns verbose output on. +.IP "\fIcfg=\fR" 9 +.IX Item "cfg=" +Read parameters and options from file defined by value. +.IP "\fIftpserver=\fR" 9 +.IX Item "ftpserver=" +Defines the \s-1FTP\s0 server, defaults to \*(L"localhost\*(R". +.IP "\fIftpdir=\fR" 9 +.IX Item "ftpdir=" +Defines the \s-1FTP\s0 directory, defaults to \*(L".\*(R" (/wo '"'). +.IP "\fIftpuser=\fR" 9 +.IX Item "ftpuser=" +Defines the \s-1FTP\s0 user, defaults to \*(L"ftp\*(R". +.IP "\fIftppasswd=\fR" 9 +.IX Item "ftppasswd=" +Defines the \s-1FTP\s0 password, defaults to \*(L"anonymous\*(R". +.IP "\fIignoremask=\fR" 9 +.IX Item "ignoremask=" +Defines a regexp to ignore certain files, like .svn. +.IP "\fIslowmillis=\fR" 9 +.IX Item "slowmillis=" +Sleeps speficed # of ms between PUTs, default 100, 0=off. +.IP "\fItimeoffset=\fR" 9 +.IX Item "timeoffset=" +Overrules \fIclocksync()\fR detection with given offset in seconds. +.SH "EXAMPLE: Copying a dir to an FTP server" +.IX Header "EXAMPLE: Copying a dir to an FTP server" +\&\s-1GNU\s0 FTPsync can synchronize a local dir to an \s-1FTP\s0 server, +.PP +\&\fBftpsync mydir ftp://user:password@ftp.example.com/remote/dir\fR +.SH "EXAMPLE: Copying an FTP server to a local dir" +.IX Header "EXAMPLE: Copying an FTP server to a local dir" +\&\s-1GNU\s0 FTPsync can synchronize an \s-1FTP\s0 server to a local dir, +.PP +\&\fBftpsync ftp://user:password@ftp.example.com/remote/dir mydir\fR +.SH "ENVIRONMENT VARIABLES" +.IX Header "ENVIRONMENT VARIABLES" +.ie n .IP "$FTPSYNC" 9 +.el .IP "\f(CW$FTPSYNC\fR" 9 +.IX Item "$FTPSYNC" +The environment variable \f(CW$FTPSYNC\fR is used for ??? +.ie n .IP "$TMPDIR" 9 +.el .IP "\f(CW$TMPDIR\fR" 9 +.IX Item "$TMPDIR" +Directory for temporary files used for time synchronization. +.SH "CONFIG FILE" +.IX Header "CONFIG FILE" +The file ~/.ftpsync/config +.SH "EXIT STATUS" +.IX Header "EXIT STATUS" +.IP "0" 6 +Copying finished with no errors. +.IP "1" 6 +.IX Item "1" +Unknown options. +.IP "2" 6 +.IX Item "2" +Some copying failed. +.IP "255" 6 +.IX Item "255" +Other error. +.SH "BUGS" +.IX Header "BUGS" +FTPsync cannot synchronize between two remote FTPURLs. +.SH "REPORTING BUGS" +.IX Header "REPORTING BUGS" +Report bugs to or +https://savannah.gnu.org/bugs/?func=additem&group=ftpsync +.PP +Your bug report should always include: +.IP "\(bu" 2 +The error message you get (if any). +.IP "\(bu" 2 +The output of \fBftpsync \-\-version\fR. If you are not running the latest +released version you should specify why you believe the problem is not +fixed in that version. +.IP "\(bu" 2 +A complete example that others can run that shows the problem. +.IP "\(bu" 2 +The output of your example. If your problem is not easily reproduced +by others, the output might help them figure out the problem. +.PP +If you suspect the error is dependent on your environment or +distribution, please see if you can reproduce the error on one of +these VirtualBox images: +http://sourceforge.net/projects/virtualboximage/files/ +.PP +Specifying the name of your distribution is not enough as you may have +installed software that is not in the VirtualBox images. +.PP +If you cannot reproduce the error on any of the VirtualBox images +above, you should assume the debugging will be done through you. That +will put more burden on you and it is extra important you give any +information that help. +.SH "AUTHOR" +.IX Header "AUTHOR" +Copyright (C) 2009,2010,2011,2012,2013 Christoph Lechleitner +.PP +Copyright (C) 2013 Ole Tange, http://ole.tange.dk and Free Software +Foundation, Inc. +.SH "LICENSE" +.IX Header "LICENSE" +Copyright (C) 2007,2008,2009,2010,2011,2012,2013 Free Software +Foundation, Inc. +.PP +This program is free software; you can redistribute it and/or modify +it under the terms of the \s-1GNU\s0 General Public License as published by +the Free Software Foundation; either version 3 of the License, or +at your option any later version. +.PP +This program is distributed in the hope that it will be useful, +but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of +\&\s-1MERCHANTABILITY\s0 or \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. See the +\&\s-1GNU\s0 General Public License for more details. +.PP +You should have received a copy of the \s-1GNU\s0 General Public License +along with this program. If not, see . +.SS "Documentation license I" +.IX Subsection "Documentation license I" +Permission is granted to copy, distribute and/or modify this documentation +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with no +Invariant Sections, with no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license is included in the file fdl.txt. +.SS "Documentation license \s-1II\s0" +.IX Subsection "Documentation license II" +You are free: +.IP "\fBto Share\fR" 9 +.IX Item "to Share" +to copy, distribute and transmit the work +.IP "\fBto Remix\fR" 9 +.IX Item "to Remix" +to adapt the work +.PP +Under the following conditions: +.IP "\fBAttribution\fR" 9 +.IX Item "Attribution" +You must attribute the work in the manner specified by the author or +licensor (but not in any way that suggests that they endorse you or +your use of the work). +.IP "\fBShare Alike\fR" 9 +.IX Item "Share Alike" +If you alter, transform, or build upon this work, you may distribute +the resulting work only under the same, similar or a compatible +license. +.PP +With the understanding that: +.IP "\fBWaiver\fR" 9 +.IX Item "Waiver" +Any of the above conditions can be waived if you get permission from +the copyright holder. +.IP "\fBPublic Domain\fR" 9 +.IX Item "Public Domain" +Where the work or any of its elements is in the public domain under +applicable law, that status is in no way affected by the license. +.IP "\fBOther Rights\fR" 9 +.IX Item "Other Rights" +In no way are any of the following rights affected by the license: +.RS 9 +.IP "\(bu" 2 +Your fair dealing or fair use rights, or other applicable +copyright exceptions and limitations; +.IP "\(bu" 2 +The author's moral rights; +.IP "\(bu" 2 +Rights other persons may have either in the work itself or in +how the work is used, such as publicity or privacy rights. +.RE +.RS 9 +.RE +.IP "\fBNotice\fR" 9 +.IX Item "Notice" +For any reuse or distribution, you must make clear to others the +license terms of this work. +.PP +A copy of the full license is included in the file as cc\-by\-sa.txt. +.SH "DEPENDENCIES" +.IX Header "DEPENDENCIES" +\&\s-1GNU\s0 FTPsync uses Perl, and the Perl modules Getopt::Long, File::Temp, +File::Find, File::Listing, Net::FTP, Net::Cmd, Net::Netrc, and +IO::Handle. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fBftp\fR(1), \fBrsync\fR(1). diff -Nru ftpsync-1.1/ftpsync.pod ftpsync-1.3.07/ftpsync.pod --- ftpsync-1.1/ftpsync.pod 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/ftpsync.pod 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,382 @@ +#!/usr/bin/perl -w + +=head1 NAME + +ftpsync - synchronize a local dir with a dir on an FTP server. + + +=head1 SYNOPSIS + +B [ -cdfghinlpqstv ] localdir remoteURL + +B [ -cdfghinlpqstv ] remoteURL localdir + + +=head1 DESCRIPTION + +GNU FTPsync synchronizes a local dir to a remote URL. + + +=head1 OPTIONS + +=over 9 + +=item I + +The local dir to synchronize. + + +=item I + +The URL of the FTP server. The URL can contain username password: +ftp://username:password@ftpserver/dir + +If ? is given as username, password, ftpserver, or dir, the user will +be asked for these. + +=item B<-c> + +Prompt the user about whether to run each command line and read a line +from the terminal. Only run the command line if the response starts +with 'y' or 'Y'. + + +=item B<-d> + +Turns debug output (including verbose output) on. + + +=item B<-f> + +Flat operation, no subdir recursion. + + +=item B<-g> + +Forces sync direction to GET (remote to local). + + +=item B<-h> + +Prints out help text. + + +=item B<-i> + +Forces info mode, only telling what would be done. + + +=item B<-n> + +No deletion of obsolete files or directories. + + +=item B<-l> + +Follow local symbolic links as if they were directories. + + +=item B<-p> + +Forces sync direction to PUT (local to remote). + + +=item B<-q> + +Turns quiet operation on. + + +=item B<-s> + +Turns timestamp comparison off (only checks for changes in size). + + +=item B<-t> + +Turns timestamp setting for local files off. + + +=item B<-v> + +Turns verbose output on. + + +=item I + +Read parameters and options from file defined by value. + + +=item I + +Defines the FTP server, defaults to "localhost". + + +=item I + +Defines the FTP directory, defaults to "." (/wo '"'). + + +=item I + +Defines the FTP user, defaults to "ftp". + + +=item I + +Defines the FTP password, defaults to "anonymous". + + +=item I + +Defines a regexp to ignore certain files, like .svn. + + +=item I + +Sleeps speficed # of ms between PUTs, default 100, 0=off. + + +=item I + +Overrules clocksync() detection with given offset in seconds. + + +=back + + +=head1 EXAMPLE: Copying a dir to an FTP server + +GNU FTPsync can synchronize a local dir to an FTP server, + +B + + +=head1 EXAMPLE: Copying an FTP server to a local dir + +GNU FTPsync can synchronize an FTP server to a local dir, + +B + + +=head1 ENVIRONMENT VARIABLES + +=over 9 + +=item $FTPSYNC + +The environment variable $FTPSYNC is used for ??? + +=item $TMPDIR + +Directory for temporary files used for time synchronization. + + +=back + + +=head1 CONFIG FILE + +The file ~/.ftpsync/config + +=head1 EXIT STATUS + +=over 6 + +=item 0 + +Copying finished with no errors. + +=item 1 + +Unknown options. + +=item 2 + +Some copying failed. + +=item 255 + +Other error. + +=back + + +=head1 BUGS + +FTPsync cannot synchronize between two remote FTPURLs. + + +=head1 REPORTING BUGS + +Report bugs to or +https://savannah.gnu.org/bugs/?func=additem&group=ftpsync + +Your bug report should always include: + +=over 2 + +=item * + +The error message you get (if any). + +=item * + +The output of B. If you are not running the latest +released version you should specify why you believe the problem is not +fixed in that version. + +=item * + +A complete example that others can run that shows the problem. + +=item * + +The output of your example. If your problem is not easily reproduced +by others, the output might help them figure out the problem. + +=back + +If you suspect the error is dependent on your environment or +distribution, please see if you can reproduce the error on one of +these VirtualBox images: +http://sourceforge.net/projects/virtualboximage/files/ + +Specifying the name of your distribution is not enough as you may have +installed software that is not in the VirtualBox images. + +If you cannot reproduce the error on any of the VirtualBox images +above, you should assume the debugging will be done through you. That +will put more burden on you and it is extra important you give any +information that help. + + +=head1 AUTHOR + +Copyright (C) 2009,2010,2011,2012,2013 Christoph Lechleitner + +Copyright (C) 2013 Ole Tange, http://ole.tange.dk and Free Software +Foundation, Inc. + + +=head1 LICENSE + +Copyright (C) 2007,2008,2009,2010,2011,2012,2013 Free Software +Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +at your option any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +=head2 Documentation license I + +Permission is granted to copy, distribute and/or modify this documentation +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with no +Invariant Sections, with no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license is included in the file fdl.txt. + +=head2 Documentation license II + +You are free: + +=over 9 + +=item B + +to copy, distribute and transmit the work + +=item B + +to adapt the work + +=back + +Under the following conditions: + +=over 9 + +=item B + +You must attribute the work in the manner specified by the author or +licensor (but not in any way that suggests that they endorse you or +your use of the work). + +=item B + +If you alter, transform, or build upon this work, you may distribute +the resulting work only under the same, similar or a compatible +license. + +=back + +With the understanding that: + +=over 9 + +=item B + +Any of the above conditions can be waived if you get permission from +the copyright holder. + +=item B + +Where the work or any of its elements is in the public domain under +applicable law, that status is in no way affected by the license. + +=item B + +In no way are any of the following rights affected by the license: + +=over 2 + +=item * + +Your fair dealing or fair use rights, or other applicable +copyright exceptions and limitations; + +=item * + +The author's moral rights; + +=item * + +Rights other persons may have either in the work itself or in +how the work is used, such as publicity or privacy rights. + +=back + +=back + +=over 9 + +=item B + +For any reuse or distribution, you must make clear to others the +license terms of this work. + +=back + +A copy of the full license is included in the file as cc-by-sa.txt. + + +=head1 DEPENDENCIES + +GNU FTPsync uses Perl, and the Perl modules Getopt::Long, File::Temp, +File::Find, File::Listing, Net::FTP, Net::Cmd, Net::Netrc, and +IO::Handle. + + +=head1 SEE ALSO + +B(1), B(1). + +=cut diff -Nru ftpsync-1.1/ftpsync-ssl ftpsync-1.3.07/ftpsync-ssl --- ftpsync-1.1/ftpsync-ssl 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/ftpsync-ssl 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,843 @@ +#!/usr/bin/perl +# +# $Id$ +# +# See attached README file for any details, or call +# ftpsync-ssl -h +# for quick start. +# +# LICENSE +# +# FTPSync (ftpsync-ssl) is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +################################################################################ + +# +# Options etc. +# +#print "Starting imports.\n"; # For major problem debugging + +use File::Find; +use File::Listing; +use Net::FTP; +use Net::Cmd; +use Net::Netrc; +use strict; +# flushing ... +use IO::Handle; +STDOUT->autoflush(1); +STDERR->autoflush(1); + +# for FTPS support, FTPSSL: +use Net::FTPSSL; + +# Option Variables +#print "Defining variables.\n"; # For major problem debugging +# meta +my $returncode=0; +my $configfile=$ENV{"HOME"}."/.ftpsync"; +# basics +my $localdir=""; +my $remoteURL=""; +my $syncdirection=""; +my $ftpproto="ftps"; +my $ftpuser="ftp"; +my $ftppasswd="anonymous"; +my $ftpserver="localhost"; +my $ftpdir=""; +my $ftptimeout=120; +my $syncoff=0; +# verbosity +my $doverbose=1; +my $dodebug=0; +my $doquiet=0; +my $doinfoonly=0; +my $infotext=""; +my $docheckfirst=0; +my $ignoremask = undef; +my $nodelete=0; +my $followsymlinks=0; +my $doflat=0; +my $notimestamping=0; +my $notimestampcheck=0; +my $slowmillis=100; + +# Read command line options/parameters +#print "Reading command line options.\n"; # For major problem debugging +my $curopt; +my @cloptions=(); +for $curopt (@ARGV) { + if ($curopt =~ /^cfg=/) { + $configfile=$'; + if (! -r $configfile) { print "Config file does not exist: ".$configfile."\n"; $returncode+=1; } + } else { + push @cloptions, $curopt; + } +} + +# Read Config File, if given +my @cfgfoptions=(); +if ($configfile ne "") { + if (-r $configfile) { + #print "Reading config file.\n"; # For major problem debugging + open (CONFIGFILE,"<$configfile"); + while () { + $_ =~ s/([ \n\r]*$|\.\.|#.*$)//gs; + if ($_ eq "") { next; } + if ( ($_ =~ /[^=]+=[^=]+/) || ($_ =~ /^-[a-zA-Z]+$/) ) { push @cfgfoptions, $_; } + } + close (CONFIGFILE); + } # else { print "Config file does not exist.\n"; } # For major problem debugging +} # else { print "No config file to read.\n"; } # For major problem debugging + +# Parse Options/Parameters +#print "Parsing all options.\n"; # For major problem debugging +my $noofopts=0; +for $curopt (@cfgfoptions, @cloptions) { + if ($curopt =~ /^-[a-zA-Z]/) { + my $i; + for ($i=1; $i0) { $ftptimeout =$fvalue; } } + elsif ($fname eq "ignoremask") { $ignoremask = $fvalue; } + elsif ($fname eq "timeoffset") { $syncoff = $fvalue; } + elsif ($fname eq "slowmillis") { $slowmillis = $fvalue; } + } + else { + if ($localdir eq "") { + $noofopts++; + $localdir = $curopt; + if ( $syncdirection eq "" ) + { $syncdirection="put"; } + } else { + print "ERROR: Unknown parameter: \"".$curopt."\"\n"; $returncode+=1 + } + } +} +if ($noofopts == 0) { print_syntax(); exit 0; } + +# .netrc support +if ( ($ftpserver ne "") and ($ftppasswd eq "anonymous") ) { + if ($ftpuser eq "ftp") { + my $netrcdata = Net::Netrc->lookup($ftpserver); + if ( defined $netrcdata ) { + $ftpuser = $netrcdata->login; + $ftppasswd = $netrcdata->password; + } + } else { + my $netrcdata = Net::Netrc->lookup($ftpserver,$ftpuser); + if ( defined $netrcdata ) { + $ftppasswd = $netrcdata->password; + } + } +} + +if($ftpuser eq "?") { print "User: "; $ftpuser=; chomp($ftpuser); } +if($ftppasswd eq "?") { print "Password: "; $ftppasswd=; chomp($ftppasswd); } + +if ($dodebug) { print_options(); } +# check options +if ( ($localdir eq "") || (! -d $localdir) ) +{ print "ERROR: Local directory does not exist: ".$localdir."\n"; $returncode+=1; } +#if ($localdir eq "") { print "ERROR: No localdir given.\n"; $returncode+=1; } +#if ( ($remoteURL eq "") { print "ERROR: No remoteURL given.\n"; $returncode+=1; } +if ($ftpserver eq "") { print "ERROR: No FTP server given.\n"; $returncode+=1; } +if ($ftpdir eq "") { print "ERROR: No FTP directory given.\n"; $returncode+=1; } +if ($ftpuser eq "") { print "ERROR: No FTP user given.\n"; $returncode+=1; } +if ($ftppasswd eq "") { print "ERROR: No FTP password given.\n"; $returncode+=1; } +if ($returncode > 0) { die "Aborting due to missing or wrong options! Call ftpsync -? for more information.\n"; } + + +#print "Exiting.\n"; exit 0; + +# Find out if ftp server is online & accessible +my $ftpc; +connection(); + +if (! $doquiet) { print "\nDetermine s offset.\n"; } +if (($notimestamping+$notimestampcheck) lt 2 && $syncdirection eq "put" && $syncoff == 0) +{ clocksync($ftpc,"syncfile"); } + +# local & remote tree vars +#chdir $localdir; +my $ldl=length($localdir) + 1; +my %localfiledates=(); +my %localfilesizes=(); +my %localdirs=(); +my %locallinks=(); + +my %remotefilesizes=(); +my %remotefiledates=(); +my %remotedirs=(); +my %remotelinks=(); +my $curremotesubdir=""; + +# Build local & remote tree + +if (! $doquiet) { print "\nBuilding local file tree.\n"; } +buildlocaltree(); + +if (! $doquiet) { print "\nBuilding remote file tree.\n"; } + +# Prepend connection time out while file reading takes +# longer than the remote ftp time out +# - 421 Connection timed out. +# - code=421 or CMD_REJECT=4 +if (!$ftpc->pwd()) { + #print "Message: (".$ftpc->code."/".$ftpc->status.") ".$ftpc->message; exit 0; + if ($ftpc->code == 421 or $ftpc->status eq CMD_REJECT) { + if (! $doquiet) { print "\nReconnect to server.\n"; } + connection(); + } +} +buildremotetree(); + +listremotedirs(); +#if ($dodebug) { print "Quitting FTP connection.\n" } +#$ftpc->quit(); + +#print "Exiting.\n"; exit 0; + +# Work ... +if ($doinfoonly) { $docheckfirst=0; } +if ($docheckfirst) +{ print "Simulating synchronization.\n"; + $doinfoonly=1; + dosync(); + $doinfoonly=0; + print "\nOK to really update files? (y/n) [n] "; + my $yn=; + if ($yn =~ /^y/i) + { print "OK, going to do it.\n"; + } + else + { print "OK, exiting without actions.\n"; + exit 1; + } +} +if ($doinfoonly) { print "\nSimulating synchronization.\n"; } +elsif (! $doquiet) { print "\nStarting synchronization.\n"; } +dosync(); + +if (!$doquiet) { print "Done.\n"; } + +if ($dodebug) { print "Quitting FTP connection.\n" } +$ftpc->quit(); + +exit 0; + + + +# +# Subs +# + +sub connection() { + if ($dodebug) { print "\nFind out if ftp server is online & accessible.\n"; } + my $doftpdebug=($doverbose > 2); + if ($ftpproto eq "ftps") { + $ftpc = Net::FTPSSL->new($ftpserver,Debug=>$doftpdebug,Timeout=>$ftptimeout,Passive=>1,Encryption=>EXP_CRYPT,PreserveTimestamp=>1) || die "Could not connect to $ftpserver\n"; + } else { + $ftpc = Net::FTP->new($ftpserver,Debug=>$doftpdebug,Timeout=>$ftptimeout,Passive=>1) || die "Could not connect to $ftpserver\n"; + } + if ($dodebug) { print "Logging in as $ftpuser with password $ftppasswd.\n" } + $ftpc->login($ftpuser,$ftppasswd) || die "Could not login to $ftpserver as $ftpuser\n"; + my $ftpdefdir=$ftpc->pwd(); + if ($dodebug) { print "Remote directory is now ".$ftpdefdir."\n"; } + if ($ftpdir !~ /^\//) # insert remote login directory into relative ftpdir specification + { if ($ftpdefdir eq "/") + { $ftpdir = $ftpdefdir . $ftpdir; } + else + { $ftpdir = $ftpdefdir . "/" . $ftpdir; } + if (!$doquiet) + { print "Absolute remote directory is $ftpdir\n"; } + } + if ($dodebug) { print "Changing to remote directory $ftpdir.\n" } + $ftpc->binary() + or die "Cannot set binary mode ", $ftpc->message; + # If the destination path does not exist => create it + if(not $ftpc->cwd($ftpdir)) { + my $subpath = ""; + for my $pathpart (split(m:/:, $ftpdir)) { + $subpath .= "/".$pathpart; + if(not $ftpc->cwd($pathpart)) { + $ftpc->mkdir($pathpart) or die "Cannot mkdir $subpath ", $ftpc->message; + $ftpc->cwd($pathpart) or die "Cannot cwd '$pathpart' ", $ftpc->message; + } + } + } + if ($ftpc->pwd() ne $ftpdir) { die "Could not change to remote base directory $ftpdir\n"; } + if ($dodebug) { print "Remote directory is now ".$ftpc->pwd()."\n"; } +} + +sub buildlocaltree() { + if ($doflat) { + chdir $localdir; + my @globbed=glob("{*,.*}"); + foreach my $curglobbed (@globbed) { + next if (! -f $curglobbed); + my @curfilestat=lstat $curglobbed; + my $curfilesize=@curfilestat[7]; + my $curfilemdt=@curfilestat[9]; + if ($dodebug) { print "File: ".$curglobbed."\n"; + print "Modified ".$curfilemdt."\nSize ".$curfilesize." bytes\n"; } + elsif ($doverbose gt 1) { print "."; } + my $relfilename=$curglobbed; + $localfiledates{$relfilename}=$curfilemdt; + $localfilesizes{$relfilename}=$curfilesize; + } + } else { + find ({wanted=>\¬icelocalfile,follow_fast => $followsymlinks }, $localdir."/"); + } + sub noticelocalfile { + my $relfilename=substr($File::Find::name,$ldl); + if (length($relfilename) == 0) { return; } + if ($ignoremask ne "") + { + if ($relfilename =~ /$ignoremask/ ) + { if ($doverbose) { print "Ignoring ".$relfilename." which matches ".$ignoremask."\n"; } + return; + } + } + if (-d $_) { + if ($dodebug) { print "Directory: ".$File::Find::name."\n"; } + elsif ($doverbose gt 1) { print ":"; } + $localdirs{$relfilename}="$relfilename"; + } + elsif (-f $_) { + #my @curfilestat=lstat $File::Find::name; + my @curfilestat=lstat $_; + my $curfilesize=@curfilestat[7]; + my $curfilemdt=@curfilestat[9]; + if ($dodebug) { print "File: ".$File::Find::name."\n"; + print "Modified ".$curfilemdt."\nSize ".$curfilesize." bytes\n"; } + elsif ($doverbose gt 1) { print "."; } + $localfiledates{$relfilename}=$curfilemdt; + $localfilesizes{$relfilename}=$curfilesize; + } + elsif (-l $_) { + if ($dodebug) { print "Link: ".$File::Find::name."\n"; } + elsif ($doverbose gt 1) { print ","; } + $locallinks{$relfilename}="$relfilename"; + } else { + #print "u ".$File::Find::name."\n"; + if (! $doquiet) { print "Ignoring file of unknown type: ".$File::Find::name."\n"; } + } + #if (! ($doquiet || $dodebug)) { print "\n"; } + #print "File mode is ".@curfilestat[2]."\n"; + } + if ($dodebug) { + print "Local dirs (relative to ".$localdir."/):\n"; + my $curlocaldir=""; + foreach $curlocaldir (keys(%localdirs)) + { print $curlocaldir."/\n"; } + print "Local files (relative to ".$localdir."/):\n"; + my $curlocalfile=""; + foreach $curlocalfile (keys(%localfiledates)) + { print $curlocalfile."\n"; } + } +} + + +sub buildremotetree() { + my @currecursedirs=(); + #$ftpc->ls() + # or die $ftpc->message . "\nCannot ls remote dir " . $ftpc->pwd(); + my @rfl; + if ($ftpproto eq "ftps") { + @rfl = $ftpc->list(); + } else { + @rfl = $ftpc->dir('-a'); + } + # or @rfl=(); # we have to survive empty remote directories !!! + my $currf=""; + my $curyear = (gmtime(time))[5] + 1900; + my %monthtonr=(); + $monthtonr{"Jan"}=1; $monthtonr{"Feb"}=2; $monthtonr{"Mar"}=3; $monthtonr{"Apr"}=4; $monthtonr{"May"}=5; $monthtonr{"Jun"}=6; + $monthtonr{"Jul"}=7; $monthtonr{"Aug"}=8; $monthtonr{"Sep"}=9; $monthtonr{"Oct"}=10; $monthtonr{"Nov"}=11; $monthtonr{"Dec"}=12; + if ($dodebug) { print "Remote pwd is ".$ftpc->pwd()."\nDIRing.\n"; } + my $curlsline; + foreach $curlsline (parse_dir(\@rfl)) { + my ($cfname,$cftype,$cfsize,$cftime,$mode)=@$curlsline; + #if ($dodebug) { print "Analysing remote file/dir ".$currf."\n" }; + if ( $cftype ) { + if ($cfname eq ".") { next; } + if ($cfname eq "..") { next; } + if ($ignoremask ne "") + { + my $testpath; + if ($curremotesubdir eq "") { $testpath = $cfname; } + else { $testpath = $curremotesubdir."/".$cfname; } + if ($testpath =~ /$ignoremask/ ) + { + if ($doverbose) { print "Ignoring ".$testpath." which matches ".$ignoremask."\n"; } + next; + } + } + if (substr($cftype,0,1) eq 'l') { # link, rest of string = linkto + my $curnrl; + if ($curremotesubdir eq "") { $curnrl = $cfname; } + else { $curnrl = $curremotesubdir."/".$cfname; } + $remotelinks{$curnrl}=$cfname; + if ($dodebug) { print "Link: ".$curnrl." -> ".$cfname."\n"; } + } + elsif ($cftype eq 'd') { + if (!$doflat) { + my $curnewrsd; + if ($curremotesubdir eq "") { $curnewrsd = $cfname; } + else { $curnewrsd = $curremotesubdir."/".$cfname; } + $remotedirs{$curnewrsd}=$curnewrsd; + if ($dodebug) { print "Directory: ".$curnewrsd."\n"; } + elsif ($doverbose gt 1) { print ":"; } + push @currecursedirs, $cfname; + } + } + elsif ($cftype eq 'f') { #plain file + my $curnewrf; + if ($curremotesubdir eq "") { $curnewrf = $cfname; } + else { $curnewrf = $curremotesubdir."/".$cfname; } + #$remotefiledates{$curnewrf}=$cftime; + if ($ftpproto eq "ftps") { + $remotefiledates{$curnewrf}=$ftpc->_mdtm($cfname)+$syncoff; + } else { + $remotefiledates{$curnewrf}=$ftpc->mdtm($cfname)+$syncoff; + } + if ($remotefiledates{$curnewrf} le 0) { die "Timeout detecting modification time of $curnewrf\n"; } + $remotefilesizes{$curnewrf}=$cfsize; + if ($remotefilesizes{$curnewrf} lt 0) { die "Timeout detecting size of $curnewrf\n"; } + if ($dodebug) { print "File: ".$curnewrf."\n"; } + elsif ($doverbose gt 1) { print "."; } + } + elsif (! $doquiet) { print "Unkown file: $curlsline\n"; } + } + elsif ($dodebug) { print "Ignoring.\n"; } + } + #recurse + #if ($doflat) { @currecursedirs=(); } + my $currecurseddir; + foreach $currecurseddir (@currecursedirs) + { my $oldcurremotesubdir; + $oldcurremotesubdir=$curremotesubdir; + if ($curremotesubdir eq "") { $curremotesubdir = $currecurseddir; } + else { $curremotesubdir .= "/".$currecurseddir; } + my $curcwddir=""; + if ($ftpdir eq "/") + { $curcwddir=$ftpdir.$curremotesubdir; } + else + { $curcwddir=$ftpdir."/".$curremotesubdir; } + if ($dodebug) { print "Change dir: ".$curcwddir."\n"; } + $ftpc->cwd($curcwddir) + or die "Cannot cwd to $curcwddir", $ftpc->message ; + my $ftpcurdir=$ftpc->pwd(); + if ($ftpcurdir ne $curcwddir && $ftpcurdir ne "$curcwddir".'/') { + die "Could not cwd to $curcwddir :" . $ftpc->message ; } + if ($doverbose gt 1) { print "\n"; } + buildremotetree(); + $ftpc->cdup(); + $curremotesubdir = $oldcurremotesubdir; + } +} + + +# Synchronize clocks. +sub clocksync { + my $conn = shift @_; + my $fn = shift @_; + my $fndidexist=1; + + if(! -f $fn) { + open(SF, ">$fn") or die "Cannot create $fn for time sync option"; + close(SF); + $fndidexist=0; + } + -z $fn or + die "File $fn for time sync must be empty."; + my $putsyncok=1; + $conn->put($fn) or $putsyncok=0; + if (!$putsyncok) + { unlink($fn); # cleanup! + die "Cannot send timesync file $fn"; + } + + my $now_here1 = time(); + my $now_there; + if ($ftpproto eq "ftps") { + $now_there = $conn->_mdtm($fn) or die "Cannot get write time of timesync file $fn"; + } else { + $now_there = $conn->mdtm($fn) or die "Cannot get write time of timesync file $fn"; + } + my $now_here2 = time(); + + if ($now_here2 < $now_there) # remote is in the future + { $syncoff=($now_there - $now_here1); + $syncoff -= $syncoff % 60; + $syncoff = 0-$syncoff; + } + else + #if ($now_here1 > $now_there) # remote is the past # or equal + { $syncoff=($now_here2 - $now_there); + $syncoff -= $syncoff % 60; + } + + $conn->delete($fn); + + my $hrs = int(abs($syncoff)/3600); + my $mins = int(abs($syncoff)/60) - $hrs*60; + my $secs = abs($syncoff) - $hrs*3600 - $mins*60; + if (! $doquiet) { + printf("Clock sync offset: %d:%02d:%02d\n", $hrs, $mins, $secs); + } + unlink ($fn) unless $fndidexist; +} + + +sub dosync() +{ + chdir $localdir || die "Could not change to local base directory $localdir\n"; + if ($syncdirection eq "put") { + # create dirs missing at the target + if ($doinfoonly) { print "\nWould create new remote directories.\n"; } + elsif (! $doquiet) { print "\nCreating new remote directories.\n"; } + my $curlocaldir; + foreach $curlocaldir (sort { return length($a) <=> length($b); } keys(%localdirs)) + { if (! exists $remotedirs{$curlocaldir}) + { if ($doinfoonly) { print $curlocaldir."\n"; next; } + if ($doverbose) { print $curlocaldir."\n"; } + elsif (! $doquiet) { print "d"; } + $ftpc->mkdir($curlocaldir) || die "Could not create remote subdirectory $curlocaldir\n"; + $ftpc->quot('SITE', sprintf('CHMOD %04o %s', (lstat $curlocaldir)[2] & 07777, $curlocaldir)); + } + } + # copy files missing or too old at the target, synchronize timestamp _after_ copying + if ($doinfoonly) { print "\nWould copy new(er) local files.\n"; } + elsif (! $doquiet) { print "\nCopying new(er) local files.\n"; } + my $curlocalfile; + foreach $curlocalfile (sort { return length($b) <=> length($a); } keys(%localfiledates)) + { my $dorefresh=0; + if (! exists $remotefiledates{$curlocalfile}) { + $dorefresh=1; + $infotext="New: ".$curlocalfile." (".$localfilesizes{$curlocalfile}." bytes)\n"; + if ($doinfoonly) { print $infotext; next; } + elsif ($doverbose) { print $infotext; } + elsif (! $doquiet) { print "n"; } + } + elsif ($notimestampcheck == 0 && $remotefiledates{$curlocalfile} < $localfiledates{$curlocalfile}) { + $dorefresh=1; + $infotext="Newer: ".$curlocalfile." (".$localfilesizes{$curlocalfile}." bytes, ".$localfiledates{$curlocalfile}." versus ".$remotefiledates{$curlocalfile}.")\n"; + if ($doinfoonly) { print $infotext; next; } + if ($doverbose) { print $infotext; } + elsif (! $doquiet) { print "u"; } + } + elsif ($remotefilesizes{$curlocalfile} != $localfilesizes{$curlocalfile}) { + $dorefresh=1; + $infotext="Changed (different sized): ".$curlocalfile." (".$localfilesizes{$curlocalfile}." versus ".$remotefilesizes{$curlocalfile}." bytes)\n"; + if ($doinfoonly) { print $infotext; next; } + if ($doverbose) { print $infotext; } + elsif (! $doquiet) { print "u"; } + } + if (! $dorefresh) { next; } + if ($dodebug) { print "Really PUTting file ".$curlocalfile."\n"; } + # Some servers crash if commands are given too fast, so wait a little. + if ($slowmillis gt 0) { + select(undef, undef, undef, $slowmillis/1000); + } + if ($ftpc->put($curlocalfile, $curlocalfile) eq undef) + { print STDERR "Could not put localfile $curlocalfile\n"; } + my $retries = 3; + while ( ($ftpc->size($curlocalfile) != (lstat $curlocalfile)[7]) and ($retries-- > 0) ) + { if (! $doquiet) { print "Re-Transfering $curlocalfile\n"; } + if ($ftpc->put($curlocalfile, $curlocalfile) ne $curlocalfile) + { print STDERR "Could not re-put localfile $curlocalfile\n"; } + } + my $newremotemdt; + if ($ftpproto eq "ftps") { + $newremotemdt=$ftpc->_mdtm($curlocalfile)+$syncoff; + } else { + $newremotemdt=$ftpc->mdtm($curlocalfile)+$syncoff; + } + if ($notimestamping == 0) { + utime ($newremotemdt, $newremotemdt, $curlocalfile); + } + $ftpc->quot('SITE', sprintf('CHMOD %04o %s', (lstat $curlocalfile)[2] & 07777, $curlocalfile)); + } + if (! $nodelete) + { + # delete files too much at the target + if ($doinfoonly) { print "\nWould delete obsolete remote files.\n"; } + elsif (! $doquiet) { print "\nDeleting obsolete remote files.\n"; } + my $curremotefile; + foreach $curremotefile (keys(%remotefiledates)) + { if (not exists $localfiledates{$curremotefile}) + { if ($doinfoonly) { print $curremotefile."\n"; next; } + if ($doverbose) { print $curremotefile."\n"; } + elsif (! $doquiet) { print "r"; } + if ($ftpc->delete($curremotefile) ne 1) { die "Could not delete remote file $curremotefile\n"; } + } + } + # delete dirs too much at the target + if ($doinfoonly) { print "\nWould delete obsolete remote directories.\n"; } + elsif (! $doquiet) { print "\nDeleting obsolete remote directories.\n"; } + my $curremotedir; + foreach $curremotedir (sort { return length($b) <=> length($a); } keys(%remotedirs)) + { if (! exists $localdirs{$curremotedir}) + { if ($doinfoonly) { print $curremotedir."\n"; next; } + if ($doverbose) { print $curremotedir."\n"; } + elsif (! $doquiet) { print "R"; } + if ($ftpc->rmdir($curremotedir) ne 1) { die "Could not remove remote subdirectory $curremotedir\n"; } + } + } + } + } else { # $syncdirection eq "GET" + # create dirs missing at the target + if ($doinfoonly) { print "\nWould create new local directories.\n"; } + elsif (! $doquiet) { print "\nCreating new local directories.\n"; } + my $curremotedir; + foreach $curremotedir (sort { return length($a) <=> length($b); } keys(%remotedirs)) + { if (! exists $localdirs{$curremotedir}) + { if ($doinfoonly) { print $curremotedir."\n"; next; } + if ($doverbose) { print $curremotedir."\n"; } + elsif (! $doquiet) { print "d"; } + mkdir($curremotedir) || die "Could not create local subdirectory $curremotedir\n"; + } + } + # copy files missing or too old at the target, synchronize timestamp _after_ copying + if ($doinfoonly) { print "\nWould copy new(er) remote files.\n"; } + elsif (! $doquiet) { print "\nCopying new(er) remote files.\n"; } + my $curremotefile; + foreach $curremotefile (sort { return length($b) <=> length($a); } keys(%remotefiledates)) + { my $dorefresh=0; + if (! exists $localfiledates{$curremotefile}) { + $dorefresh=1; + $infotext="New: ".$curremotefile." (".$remotefilesizes{$curremotefile}." bytes)\n"; + if ($doinfoonly) { print $infotext; next; } + if ($doverbose) { print $infotext; } + elsif (! $doquiet) { print "n"; } + } + elsif ($notimestampcheck == 0 && $remotefiledates{$curremotefile} > $localfiledates{$curremotefile}) { + $dorefresh=1; + $infotext="Newer: ".$curremotefile." (".$remotefilesizes{$curremotefile}." bytes, ".$remotefiledates{$curremotefile}." versus ".$localfiledates{$curremotefile}.")\n"; + if ($doinfoonly) { print $infotext; next; } + if ($doverbose) { print $infotext; } + elsif (! $doquiet) { print "u"; } + } + elsif ($remotefilesizes{$curremotefile} != $localfilesizes{$curremotefile}) { + $dorefresh=1; + $infotext="Changed (different sized): ".$curremotefile." (".$remotefilesizes{$curremotefile}." bytes)\n"; + if ($doinfoonly) { print $infotext; next; } + if ($doverbose) { print $infotext; } + elsif (! $doquiet) { print "c"; } + } + if (! $dorefresh) { next; } + if ($dodebug) { print "Really GETting file ".$curremotefile."\n"; } + my $rc=$ftpc->get($curremotefile, $curremotefile); + if ($rc eq undef) + { print STDERR "Could not get file ".$curremotefile."\n"; } + my $retries=3; + while ( ($ftpc->size($curremotefile) != (lstat $curremotefile)[7]) and ($retries-- > 0) ) + { if (! $doquiet) { print "Re-Transfering $curremotefile\n"; } + if ( ($rc eq undef) or ($rc ne $curremotefile) ) + { print STDERR "Could not get file ".$curremotefile."\n"; } + } + my $newlocalmdt=$remotefiledates{$curremotefile}; + if ($notimestamping == 0) { + utime ($newlocalmdt, $newlocalmdt, $curremotefile); + } + } + if (! $nodelete) + { + # delete files too much at the target + if ($doinfoonly) { print "\nWould delete obsolete local files.\n"; } + elsif (! $doquiet) { print "\nDeleting obsolete local files.\n"; } + my $curlocalfile; + foreach $curlocalfile (sort { return length($b) <=> length($a); } keys(%localfiledates)) + { if (not exists $remotefiledates{$curlocalfile}) + { if ($doinfoonly) { print $curlocalfile."\n"; next; } + if ($doverbose) { print $curlocalfile."\n"; } + elsif (! $doquiet) { print "r"; } + if (unlink($curlocalfile) ne 1) { die "Could not remove local file $curlocalfile\n"; } + } + } + # delete dirs too much at the target + if ($doinfoonly) { print "\nWould delete obsolete local directories.\n"; } + elsif (! $doquiet) { print "\nDeleting obsolete local directories.\n"; } + my $curlocaldir; + foreach $curlocaldir (keys(%localdirs)) + { if (! exists $remotedirs{$curlocaldir}) + { if ($doinfoonly) { print $curlocaldir."\n"; next; } + if ($doverbose) { print $curlocaldir."\n"; } + elsif (! $doquiet) { print "d"; } + rmdir($curlocaldir) || die "Could not remove local subdirectory $curlocaldir\n"; + } + } + } + } +} + + +sub listremotedirs() { + if ($dodebug) { + print "Remote dirs (relative to ".$ftpdir."):\n"; + my $curremotedir=""; + foreach $curremotedir (keys(%remotedirs)) + { print $curremotedir."/\n"; } + print "Remote files (relative to ".$ftpdir."):\n"; + my $curremotefile=""; + foreach $curremotefile (keys(%remotefiledates)) + { print $curremotefile."\n"; } + print "Remote links (relative to ".$ftpdir."):\n"; + my $curremotelink=""; + foreach $curremotelink (keys(%remotelinks)) + { print $curremotelink." -> ".$remotelinks{$curremotelink}."\n"; } + } +} + +sub parseRemoteURL() { + if ($remoteURL =~ /^(ftps?):\/\/(([^@\/\\\:]+)(:([^@\/\\\:]+))?@)?([a-zA-Z01-9\.\-]+)\/(.*)/) { + #print "DEBUG: parsing ".$remoteURL."\n"; + #print "match 1 = ".$1."\n"; + #print "match 2 = ".$2."\n"; + #print "match 3 = ".$3."\n"; + #print "match 4 = ".$4."\n"; + #print "match 5 = ".$5."\n"; + #print "match 6 = ".$6."\n"; + #print "match 7 = ".$7."\n"; + $ftpproto = $1; + if (length($3) > 0) { $ftpuser = $3; } + if (length($5) > 0) { $ftppasswd = $5; } + $ftpserver = $6; + $ftpdir = $7; + if ($ftpdir ne "/") { $ftpdir=~s/\/$//; } + } +} + + +sub print_syntax() { + print "\n"; + print "ftpsync-ssl 1.3.07 (2013-01-28)\n"; + print "\n"; + print " ftpsync-ssl [ options ] [ localdir remoteURL ]\n"; + print " ftpsync-ssl [ options ] [ remoteURL localdir ]\n"; + print " options = [-dfgpqv] [ cfg|ftpuser|ftppasswd|ftpserver|ftpdir=value ... ] \n"; + print " localdir local directory, defaults to \".\".\n"; + print " ftpURL full FTP[S] URL, scheme\n"; + print ' ftp[s]://[ftpuser[:ftppasswd]@]ftpserver/ftpdir'."\n"; + print " ftpdir is relative, so double / for absolute paths as well as /\n"; + print " -c | -C like -i, but then prompts whether to actually do work\n"; + print " -d | -D turns debug output (including verbose output) on\n"; + print " -f | -F flat operation, no subdir recursion\n"; + print " -g | -G forces sync direction to GET (remote to local)\n"; + print " -h | -H prints out this help text\n"; + print " -i | -I forces info mode, only telling what would be done\n"; + print " -n | -N no deletion of obsolete files or directories\n"; + print " -l | -L follow local symbolic links as if they were directories\n"; + print " -p | -P forces sync direction to PUT (local to remote)\n"; + print " -q | -Q turns quiet operation on\n"; + print " -s | -S turns timestamp comparison off (only checks for changes in size)\n"; + print " -t | -T turns timestamp setting for local files off\n"; # backward compatibility + print " -v | -V turnes verbose output on\n"; + print " cfg= read parameters and options from file defined by value.\n"; + print " ftpserver= defines the FTP server, defaults to \"localhost\".\n"; + print " ftpdir= defines the FTP directory, defaults to \".\" (/wo '\"') \n"; + print " ftpuser= defines the FTP user, defaults to \"ftp\".\n"; + print " ftppasswd= defines the FTP password, defaults to \"anonymous\".\n"; + print " ftpproto= defines the FTP protocol, \"ftp\" or \"ftps\".\n"; + print " ignoremask= defines a regexp to ignore certain files, like .svn"."\n"; + print " slowmillis= sleeps speficed # of ms between PUTs, default 100, 0=off"."\n"; + print " timeoffset= overrules clocksync() detection with given offset in seconds"."\n"; + print "\n"; + print " Later mentioned options and parameters overwrite those mentioned earlier.\n"; + print " Command line options and parameters overwrite those in the config file.\n"; + print " Don't use '\"', although mentioned default values might motiviate you to.\n"; + print "\n"; + print " If ftpuser or ftppasswd resovle to ? (no matter through which options),\n"; + print " ftpsync.pl asks you for those interactively.\n"; + print "\n"; + print " As of 1.3.02 .netrc is used if ftppassword or ftppassword and ftpuser)\n"; + print " are still empty after parsing all options.\n"; + print "\n"; +} + + +sub print_options() { + print "\nPrinting options:\n"; + # meta + print "returncode = ", $returncode , "\n"; + print "configfile = ", $configfile , "\n"; + # basiscs + print "syncdirection = ", $syncdirection , "\n"; + print "localdir = ", $localdir , "\n"; + # FTP stuff + print "remoteURL = ", $remoteURL , "\n"; + print "ftpuser = ", $ftpuser , "\n"; + print "ftpproto = ", $ftpproto , "\n"; + print "ftppasswd = ", $ftppasswd , "\n"; + print "ftpserver = ", $ftpserver , "\n"; + print "ftpdir = ", $ftpdir , "\n"; + # verbosity + print "doverbose = ", $doverbose , "\n"; + print "dodebug = ", $dodebug , "\n"; + print "doquiet = ", $doquiet , "\n"; + # other + print "doinfoonly = ", $doinfoonly , "\n"; + print "slowmillis = ", $slowmillis , "\n"; + print "\n"; +} diff -Nru ftpsync-1.1/.git/config ftpsync-1.3.07/.git/config --- ftpsync-1.1/.git/config 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/config 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,11 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true +[remote "origin"] + url = git://git.savannah.gnu.org/ftpsync.git + fetch = +refs/heads/*:refs/remotes/origin/* +[branch "master"] + remote = origin + merge = refs/heads/master diff -Nru ftpsync-1.1/.git/description ftpsync-1.3.07/.git/description --- ftpsync-1.1/.git/description 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/description 2015-04-09 07:36:34.000000000 +0000 @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff -Nru ftpsync-1.1/.git/HEAD ftpsync-1.3.07/.git/HEAD --- ftpsync-1.1/.git/HEAD 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/HEAD 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1 @@ +ref: refs/heads/master diff -Nru ftpsync-1.1/.git/hooks/applypatch-msg.sample ftpsync-1.3.07/.git/hooks/applypatch-msg.sample --- ftpsync-1.1/.git/hooks/applypatch-msg.sample 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/hooks/applypatch-msg.sample 2015-04-09 07:36:34.000000000 +0000 @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +test -x "$GIT_DIR/hooks/commit-msg" && + exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} +: diff -Nru ftpsync-1.1/.git/hooks/commit-msg.sample ftpsync-1.3.07/.git/hooks/commit-msg.sample --- ftpsync-1.1/.git/hooks/commit-msg.sample 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/hooks/commit-msg.sample 2015-04-09 07:36:34.000000000 +0000 @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff -Nru ftpsync-1.1/.git/hooks/post-update.sample ftpsync-1.3.07/.git/hooks/post-update.sample --- ftpsync-1.1/.git/hooks/post-update.sample 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/hooks/post-update.sample 2015-04-09 07:36:34.000000000 +0000 @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff -Nru ftpsync-1.1/.git/hooks/pre-applypatch.sample ftpsync-1.3.07/.git/hooks/pre-applypatch.sample --- ftpsync-1.1/.git/hooks/pre-applypatch.sample 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/hooks/pre-applypatch.sample 2015-04-09 07:36:34.000000000 +0000 @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +test -x "$GIT_DIR/hooks/pre-commit" && + exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"} +: diff -Nru ftpsync-1.1/.git/hooks/pre-commit.sample ftpsync-1.3.07/.git/hooks/pre-commit.sample --- ftpsync-1.1/.git/hooks/pre-commit.sample 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/hooks/pre-commit.sample 2015-04-09 07:36:34.000000000 +0000 @@ -0,0 +1,50 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +# If you want to allow non-ascii filenames set this variable to true. +allownonascii=$(git config hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ascii filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + echo "Error: Attempt to add a non-ascii file name." + echo + echo "This can cause problems if you want to work" + echo "with people on other platforms." + echo + echo "To be portable it is advisable to rename the file ..." + echo + echo "If you know what you are doing you can disable this" + echo "check using:" + echo + echo " git config hooks.allownonascii true" + echo + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff -Nru ftpsync-1.1/.git/hooks/prepare-commit-msg.sample ftpsync-1.3.07/.git/hooks/prepare-commit-msg.sample --- ftpsync-1.1/.git/hooks/prepare-commit-msg.sample 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/hooks/prepare-commit-msg.sample 2015-04-09 07:36:34.000000000 +0000 @@ -0,0 +1,36 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first comments out the +# "Conflicts:" part of a merge commit. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +case "$2,$3" in + merge,) + /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; + +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$1" ;; + + *) ;; +esac + +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" diff -Nru ftpsync-1.1/.git/hooks/pre-rebase.sample ftpsync-1.3.07/.git/hooks/pre-rebase.sample --- ftpsync-1.1/.git/hooks/pre-rebase.sample 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/hooks/pre-rebase.sample 2015-04-09 07:36:34.000000000 +0000 @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up-to-date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff -Nru ftpsync-1.1/.git/hooks/update.sample ftpsync-1.3.07/.git/hooks/update.sample --- ftpsync-1.1/.git/hooks/update.sample 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/hooks/update.sample 2015-04-09 07:36:34.000000000 +0000 @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to blocks unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 Binary files /tmp/cFsGNuFnUW/ftpsync-1.1/.git/index and /tmp/yY6AW07JaN/ftpsync-1.3.07/.git/index differ diff -Nru ftpsync-1.1/.git/info/exclude ftpsync-1.3.07/.git/info/exclude --- ftpsync-1.1/.git/info/exclude 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/info/exclude 2015-04-09 07:36:34.000000000 +0000 @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff -Nru ftpsync-1.1/.git/logs/HEAD ftpsync-1.3.07/.git/logs/HEAD --- ftpsync-1.1/.git/logs/HEAD 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/logs/HEAD 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 a8ad2d6fcba9f4479733089c6075a8931133326c lffl 1428565004 +0200 clone: from git://git.savannah.gnu.org/ftpsync.git diff -Nru ftpsync-1.1/.git/logs/refs/heads/master ftpsync-1.3.07/.git/logs/refs/heads/master --- ftpsync-1.1/.git/logs/refs/heads/master 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/logs/refs/heads/master 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 a8ad2d6fcba9f4479733089c6075a8931133326c lffl 1428565004 +0200 clone: from git://git.savannah.gnu.org/ftpsync.git diff -Nru ftpsync-1.1/.git/logs/refs/remotes/origin/HEAD ftpsync-1.3.07/.git/logs/refs/remotes/origin/HEAD --- ftpsync-1.1/.git/logs/refs/remotes/origin/HEAD 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/logs/refs/remotes/origin/HEAD 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 a8ad2d6fcba9f4479733089c6075a8931133326c lffl 1428565004 +0200 clone: from git://git.savannah.gnu.org/ftpsync.git Binary files /tmp/cFsGNuFnUW/ftpsync-1.1/.git/objects/pack/pack-7649d823cb7167b8ecd239c244d939df4990f85d.idx and /tmp/yY6AW07JaN/ftpsync-1.3.07/.git/objects/pack/pack-7649d823cb7167b8ecd239c244d939df4990f85d.idx differ Binary files /tmp/cFsGNuFnUW/ftpsync-1.1/.git/objects/pack/pack-7649d823cb7167b8ecd239c244d939df4990f85d.pack and /tmp/yY6AW07JaN/ftpsync-1.3.07/.git/objects/pack/pack-7649d823cb7167b8ecd239c244d939df4990f85d.pack differ diff -Nru ftpsync-1.1/.git/packed-refs ftpsync-1.3.07/.git/packed-refs --- ftpsync-1.1/.git/packed-refs 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/packed-refs 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,2 @@ +# pack-refs with: peeled +a8ad2d6fcba9f4479733089c6075a8931133326c refs/remotes/origin/master diff -Nru ftpsync-1.1/.git/refs/heads/master ftpsync-1.3.07/.git/refs/heads/master --- ftpsync-1.1/.git/refs/heads/master 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/refs/heads/master 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1 @@ +a8ad2d6fcba9f4479733089c6075a8931133326c diff -Nru ftpsync-1.1/.git/refs/remotes/origin/HEAD ftpsync-1.3.07/.git/refs/remotes/origin/HEAD --- ftpsync-1.1/.git/refs/remotes/origin/HEAD 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.git/refs/remotes/origin/HEAD 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff -Nru ftpsync-1.1/.gitignore ftpsync-1.3.07/.gitignore --- ftpsync-1.1/.gitignore 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/.gitignore 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,2 @@ +common-install-indep +target diff -Nru ftpsync-1.1/rebuild.sh ftpsync-1.3.07/rebuild.sh --- ftpsync-1.1/rebuild.sh 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/rebuild.sh 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,31 @@ +#!/bin/sh +# +# $Id$ +# +# rebuilds target/ftpsync-1.x.tar.bz2 +# + +MYDIR=$( dirname $( readlink -f $( which $0 ) ) ) +cd $MYDIR/.. + +rm -rf target/ftpsync* +mkdir -pv target + +FSVER=$(/usr/share/pba-cbs/sh/get_deb_version.sh .) +echo "Building FTPSync.pl $FSVER" + +COLLECTDIR="target/ftpsync-$FSVER" +mkdir -pv $COLLECTDIR +cp -avu \ + src/ftpsync \ + src/ftpsync-ssl \ + doc/*.txt \ + debian/changelog \ + $COLLECTDIR/ + +cd $COLLECTDIR/.. +tar -cjvf ftpsync-$FSVER.tar.bz2 ftpsync-$FSVER +rm -rf $COLLECTDIR + +echo "Built target/ftpsync-$FSVER.tar.bz2" + diff -Nru ftpsync-1.1/republish.sh ftpsync-1.3.07/republish.sh --- ftpsync-1.1/republish.sh 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/republish.sh 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,23 @@ +#!/bin/sh +# +# $Id$ +# +# lets rebuild target/ftpsync-1.x.tar.bz2 and deploys it +# as ftpsync-1.x.tar.bz2 and ftpsync-latest.tar.bz2 +# + +MYDIR=$( dirname $( readlink -f $( which $0 ) ) ) +cd $MYDIR/.. + +scripts/rebuild.sh || exit 1 + +FSVER=$(/usr/share/pba-cbs/sh/get_deb_version.sh $PROJECTDIR) +FSTBZ="target/ftpsync-$FSVER.tar.bz2" +echo "Publishing FTPSync.pl $FSVER aka $FSTBZ" + +echo "cp-ing to clazzes.org AKA https://download.clazzes.org/ftpsync/" +chmod 0755 $FSTBZ +scp $FSTBZ ftpsync@clazzes.org:/var/www/htdocs/download.clazzes.org/ftpsync/ + +rm -rf target/ftpsync* + diff -Nru ftpsync-1.1/testsuite/tests-to-run/test01.sh ftpsync-1.3.07/testsuite/tests-to-run/test01.sh --- ftpsync-1.1/testsuite/tests-to-run/test01.sh 1970-01-01 00:00:00.000000000 +0000 +++ ftpsync-1.3.07/testsuite/tests-to-run/test01.sh 2015-04-09 07:36:44.000000000 +0000 @@ -0,0 +1,40 @@ +#!/bin/bash + +# $FTPSYNC must be the binary to test +# $FTPURL must be an upload URL with no subdirs: ftp://ftp_20130204_9627:n93cDqnf2t@ftp.dna.ku.dk/ +# $FTPURL2 must be an upload URL with no subdirs: ftp://ftp_20130204_9627:n93cDqnf2t@ftp.dna.ku.dk/ + +TMP=/tmp/ftpsync-$$ +mkdir -p $TMP + +# Empty remote +$FTPSYNC $TMP $FTPURL + +mkdir -p $TMP/{adir,bdir,cdir} +mkdir -p $TMP/{adir,bdir,cdir}/subdir +parallel 'echo Content_of_{} > {}' ::: $TMP/{adir,bdir,cdir}{/subdir,}/{afile,bfile,cfile} + + +# Symlinks +ln -s /etc/hosts $TMP/symlink-absolute-outside-file-exists +ln -s /no/such/file $TMP/symlink-absolute-outside-no-such-file +ln -s ../../etc/hosts $TMP/symlink-relative-outside-file-exists +ln -s ../../no/such/file $TMP/symlink-relative-outside-no-such-file +ln -s $TMP/adir/afile $TMP/symlink-absolute-inside-file-exists +ln -s $TMP/no/such/file $TMP/symlink-absolute-inside-no-such-file +ln -s adir/afile $TMP/symlink-relative-inside-file-exists +ln -s no/such/file $TMP/symlink-relative-inside-no-such-file + +# Todo: Permissions +#chmod 000 $TMP/adir +#chmod 000 $TMP/bdir/bfile + +$FTPSYNC $TMP $FTPURL + +# Subdirs with new files +parallel 'echo Content_of_{} > {}' ::: $TMP/{adir,bdir,cdir}{/subdir,}/newfile + +$FTPSYNC $TMP $FTPURL + +chmod 777 $TMP/adir +rm -rf $TMP diff -Nru ftpsync-1.1/usr/bin/ftpsync ftpsync-1.3.07/usr/bin/ftpsync --- ftpsync-1.1/usr/bin/ftpsync 2010-01-31 12:14:27.000000000 +0000 +++ ftpsync-1.3.07/usr/bin/ftpsync 1970-01-01 00:00:00.000000000 +0000 @@ -1,334 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -""" A tool to synchronize the current directory remotly using FTP. - -For usage, run ``ftpsync.py --help``. -""" - -import sys -import os -try: - f = open("/home/%s/.netrc" % os.environ['USER']) -except IOError: - try: - import gtk - import gnomekeyring - except ImportError: - print("cannot open /home/%s/.netrc and gnomekeyring isn't available." % os.environ['USER']) - sys.exit(1) - else: - gtkpresence = True -else: - f.close() - -from netrc import netrc -import ftplib -import hashlib -import re -from tempfile import TemporaryFile -import socket -import random -from optparse import OptionParser -from urlparse import urlparse -from getpass import getpass - -PROGRAM_NAME = "ftpsync" -PROGRAM_VERSION = "1.1" - -__version__ = PROGRAM_VERSION - -HASHFILENAME = 'hashes.txt' - -# Useful functions: ########################################################## - -def uptime(): - '''Uptime used as a monotonic clock.''' - uptfile = open('/proc/uptime') - upt = uptfile.read().split('.')[0] - uptfile.close() - return int(upt) - - -class Printer(object): - def __init__(self, enable): - self.enable = enable - def msg(self, str): - if not self.enable: - return - print(str) - -# Main Ftp class: ############################################################ - -class Ftp(): - def __init__(self, user, host, path): - self.user = user - self.host = host - self.path = path - self.hashespending = False - self.connect() - - def connect(self): - try: - auth = netrc().authenticators(self.host) # TODO check if the host exists in netrc - except IOError, msgio: - if gtkpresence: - try: - keyring = gnomekeyring.get_default_keyring_sync() - keyring_info = gnomekeyring.get_info_sync(keyring) - if keyring_info.get_is_locked(): - keyring_pass = getpass('Enter password to unlock your keychain [%s]: ' % (keyring)) - try: - gnomekeyring.unlock_sync( keyring, keyring_pass ) - except Exception, msg: - sys.stderr.write("\nUnable to unlock your keychain: %s" % msg) - else: - print("+ [%s] unlocked." % keyring) - items = gnomekeyring.find_items_sync(gnomekeyring.ITEM_NETWORK_PASSWORD, - {"server": self.host, - "protocol": "ftp", - "user": self.user}) - if len(items) > 0: - ftp = ftplib.FTP(self.host, self.user, items[0].secret) - else: - raise Exception('gnomekeyring','NoMatchError') - except gnomekeyring.DeniedError: - sys.stderr.write("\nGnome keyring error : Access denied ..\nnetrc error: %s\n" % (msgio)) - sys.exit(1) - except gnomekeyring.NoMatchError: - sys.stderr.write("\nGnome keyring error : No credential for %s..\nnetrc error: %s\n" % (self.host, msgio)) - sys.exit(1) - except Exception, msg: - sys.stderr.write("\nGnome keyring error : %s\nnetrc error: %s\n" % (msg, msgio)) - sys.exit(1) - - else: - assert self.user == auth[0] - ftp = ftplib.FTP(self.host, auth[0], auth[2]) - try: - ftp.cwd(self.path) - except ftplib.error_perm: - ftp.mkd(self.path) - ftp.cwd(self.path) - #ftp.set_debuglevel(1) - self.ftp = ftp - self.dirs = set() - - def sendHashes(self, localHashes): - if not self.hashespending: - return - print('+ Sending hashes') - tmpfile = TemporaryFile() - for f in list(localHashes.keys()): - tmpfile.write('%s %s\n' % (f, localHashes[f])) - tmpfile.seek(0) - self.ftp.storlines('STOR %s' % HASHFILENAME + '.tmp', tmpfile) - self.ftp.rename(HASHFILENAME+'.tmp', HASHFILENAME) - self.hashespending = False - - def mkdir(self, dir): - if dir == '' or dir in self.dirs: - return - self.mkdir(os.path.split(dir)[0]) - try: - self.ftp.mkd(dir) - except ftplib.error_perm: - pass - self.dirs.add(dir) - - def filesGet(self): - remoteFiles = set() - remoteHashes = {} - def remoteHashesGet(l): - r = re.compile('^(.+) ([a-f0-9]+)$') - m = r.match(l) - remoteFiles.add(m.group(1)) - remoteHashes[m.group(1)] = m.group(2) - - try: - self.ftp.retrlines('RETR %s' % HASHFILENAME, remoteHashesGet) - except ftplib.error_perm: - pass - - return remoteFiles, remoteHashes - - def fileSend(self, filename): - self.mkdir(os.path.dirname(filename)) - fd = open(filename) - try: - self.ftp.storbinary('STOR %s' % filename, fd) - self.hashespending = True - except socket.error: - self.connect() - return False - except ftplib.error_temp: - self.connect() - return False - return True - - def delete(self, f): - try: - self.ftp.delete(f) - self.hashespending = True - except ftplib.error_perm: - pass - - -# Local files processing: #################################################### - -def filesget(filelist, entry): - assert os.path.exists(entry) - if os.path.isdir(entry): - for e in os.listdir(entry): - filesget(filelist, os.path.join(entry, e)) - else: - filelist.append(os.path.normpath(entry)) - return filelist - - - -def localFilesGet(): - localFiles = set() - localHashes = {} - - filelist = filesget([], '././') - filelist.sort() - - for f in filelist: - fd = open(f, 'r') - h = hashlib.sha1() - h.update(fd.read()) - localHashes[f] = h.hexdigest() - - return set(filelist), localHashes - - -# Core function: ############################################################# - -def doit(cfg): - p = Printer(not cfg.quiet) - - mainRV = 0 - - try: - fd = open('.ftp_upstream') - except IOError: - sys.stderr.write('.ftp_upstream: file not found') - sys.exit(1) - - o = urlparse(fd.read(),'ftp') - if not o.username: - sys.stderr.write('username not given: %s\n' % o.geturl()) - sys.exit(1) - remote_path = os.path.normpath(o[2] or '/') # ensure the remote path contain at least a '/' - if remote_path.startswith('//'): - remote_path = remote_path[1:] - assert remote_path.startswith('/'),repr(remote_path) - - upstreamurl = o.geturl() - if upstreamurl.endswith('\n'): - upstreamurl = upstreamurl[:-1] - - p.msg('+ Upstream is %s' % upstreamurl[:-1]) - # TODO support the port if given - ftp = Ftp(o.username, o.hostname, remote_path) - p.msg('+ Connected') - - localFiles, localHashes = localFilesGet() - p.msg('+ Got %d local hashes' % len(localFiles)) - - remoteFiles, remoteHashes = ftp.filesGet() - p.msg('+ Got %d remote hashes' % len(remoteFiles)) - - p.msg('+ Deleting remote files') - todel = remoteFiles.difference(localFiles) - j = 0 - jtotal = len(todel) - for f in todel: - if f == HASHFILENAME: - continue - ftp.delete(f) - p.msg('+ %4d/%-4d deleted %s' % (j, jtotal, f)) - remoteFiles.discard(f) - del remoteHashes[f] - - tosend = set() - okHashes = {} - - for f in localFiles: - if not f in remoteFiles or localHashes[f] != remoteHashes[f]: - tosend.add(f) - else: - okHashes[f] = remoteHashes[f] - - ftp.sendHashes(okHashes) - - p.msg('+ Sending files') - sentHashes = {} - i = 0 - itotal = len(tosend) - lastupt = uptime() - lastlen = 0 - tosendList = [x for x in tosend] - random.shuffle(tosendList) - for f in tosendList: - i = i + 1 - if f == 'hashes.txt': - p.msg('+ %4d/%-4d skipping %s' % (i, itotal, f)) - continue - p.msg('+ %4d/%-4d sending %s' % (i, itotal, f)) - if ftp.fileSend(f): - sentHashes[f] = localHashes[f] - okHashes[f] = localHashes[f] - else: - p.msg('- ERROR sending %s' % (f)) - mainRV = 1 - ftp.sendHashes(okHashes) - if cfg.safe or (len(okHashes) > lastlen and uptime() - lastupt > 30): - ftp.sendHashes(okHashes) - lastupt = uptime() - lastlen = len(okHashes) - - ftp.sendHashes(okHashes) - - p.msg('+ Summary: sent %d files, deleted %d files, %d files could not be sent' % (len(sentHashes), len(todel), len(tosend) - len(sentHashes))) - - return mainRV - - - -def main(): - parser = OptionParser(usage="Usage: %prog [-h] [-s]", - version="%prog "+__version__, - description='''\ -ftpsync is a program that synchronize all files beneath the -current directory with an FTP host efficiently. - -The destination host is identified by a .ftp_upstream in the -current directory that must have the following line: -upstream=ftp://user@host/path - -The password is found by looking at ~/.netrc, see netrc(5). - -ftpsync sends all files in the current directory to the target host, -and stores the MD5 of the sent files in a hashes.txt files in the -remote host. When syncing again, it checks the MD5 of each file -against the one stored in the remote hashes.txt file, and only sends -the files that are different. This makes ftpsync very efficient -when synchronizing a directory with only a few different files, -as long as they are always sent by ftpsync. -''' - ) - parser.add_option("-s", "--safe", dest="safe", - action="store_true", default=False, - help="Safe mode: sends hashes.txt after every successful file transfer.") - parser.add_option("-q", "--quiet", dest="quiet", - action="store_true", default=False, - help="") - (cfg, args) = parser.parse_args() - - sys.exit(doit(cfg)) - - -if __name__ == '__main__': - main() - Binary files /tmp/cFsGNuFnUW/ftpsync-1.1/usr/share/doc/ftpsync/changelog.Debian.gz and /tmp/yY6AW07JaN/ftpsync-1.3.07/usr/share/doc/ftpsync/changelog.Debian.gz differ diff -Nru ftpsync-1.1/usr/share/doc/ftpsync/copyright ftpsync-1.3.07/usr/share/doc/ftpsync/copyright --- ftpsync-1.1/usr/share/doc/ftpsync/copyright 2010-01-31 12:06:07.000000000 +0000 +++ ftpsync-1.3.07/usr/share/doc/ftpsync/copyright 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -Leandro Lisboa Penz -Copyright (C) 2009 Leandro Penz -http://github.com/lpenz/ftpsync - -License: - - This package is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation. - - This package is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this package; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -On Debian systems, the complete text of the GNU General Public License version -2 can be found in `/usr/share/common-licenses/GPL-2'. - -The Debian packaging is Copyright (C) 2009 Leandro Lisboa Penz - and is licensed under the GPL version 2, see -`/usr/share/common-licenses/GPL-2'. - Binary files /tmp/cFsGNuFnUW/ftpsync-1.1/usr/share/man/man1/ftpsync.1.gz and /tmp/yY6AW07JaN/ftpsync-1.3.07/usr/share/man/man1/ftpsync.1.gz differ