sync-complete.sh 1.89 KB
Newer Older
Jan Mette's avatar
Jan Mette committed
1
#!/bin/bash
Jan Mette's avatar
Jan Mette committed
2 3 4 5 6 7 8 9 10 11 12 13 14

#   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, see <http://www.gnu.org/licenses/>
Jan Mette's avatar
Jan Mette committed
15 16 17 18

#
# setup
#
Jan Mette's avatar
Jan Mette committed
19
_script_name="sync complete"
Jan Mette's avatar
Jan Mette committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33
_build_arch="$_arch"
_cur_repo=`pwd | awk -F '/' '{print $NF}'`
_needed_functions="config_handling helpers messages"
# load functions
for subroutine in ${_needed_functions}
do
    source _buildscripts/functions/${subroutine}
done

#
# main
#
sync_complete()
{
Jan Mette's avatar
Jan Mette committed
34
	title2 "syncing down"
Jan Mette's avatar
Jan Mette committed
35
        export RSYNC_PASSWORD=`echo $_rsync_pass`
Jan Mette's avatar
Jan Mette committed
36
        rsync -avh --progress $_rsync_user@$_rsync_server::$_rsync_dir/* _repo/remote/
Jan Mette's avatar
Jan Mette committed
37 38 39
	
	# move new packages from $ROOT/repos/$REPO/build into thr repo dir 
        title2 "adding new packages"
Jan Mette's avatar
Jan Mette committed
40
        mv -v _repo/local/*.pkg.* _repo/remote/
Jan Mette's avatar
Jan Mette committed
41 42 43

        # run repo-clean on it
        title2 "running repo-clean"
Jan Mette's avatar
Jan Mette committed
44
        repo-clean -m c -s _repo/remote/
Jan Mette's avatar
Jan Mette committed
45 46 47

        # create new pacman database
        title2 "creating pacman database"
Jan Mette's avatar
Jan Mette committed
48 49
	rm -rf _repo/remote/*.db.tar.gz
        pushd _repo/remote/
Jan Mette's avatar
Jan Mette committed
50
        repo-add $_cur_repo.db.tar.gz *.pkg.*
Jan Mette's avatar
Jan Mette committed
51 52 53
        popd

        # sync local -> server
Jan Mette's avatar
Jan Mette committed
54
        title2 "syncing up"
Jan Mette's avatar
Jan Mette committed
55
        rsync -avh --progress --delay-updates --delete-after _repo/remote/ $_rsync_user@$_rsync_server::$_rsync_dir
Jan Mette's avatar
Jan Mette committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69
}

#
# startup
#
title "${_script_name} - $_cur_repo"

check_configs
load_configs

check_rsync
check_accounts

time sync_complete
Jan Mette's avatar
Jan Mette committed
70
newline
Jan Mette's avatar
Jan Mette committed
71 72 73

title "All done"
newline