#
# Synchronise Nokia 770 filesystem                      (c) Andrew Flegg 2005
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        Released under the Artistic Licence
#                                                      mailto:andrew@bleb.org
#                                                        http://www.bleb.org/
# Available targets:
#     push       Push local files to 770 file system
#     pull       Backup 770 to local file system
#     bootstrap  Use scp to install a fresh version of this file system
#
# Note, all options require SSH[1] and rsync[2] to be installed on your 770. If
# you want to maintain modifications to /etc (for example), then R&D mode
# will have to be enabled[3].
#
# Usage:
#   (1) Modify the REMOTE_DEVICE variable to contain the IP address
#       of your 770. Should be of the form: [user@]host:[port]/
#       For example:
#           user@192.168.1.42:2222/
#           user@my770:/
#           root@my770:/
#   (2) Create local files and directories next to this makefile that
#       you would like to put on the 770. For example:
#           $ mkdir -p etc/rc2.d
#           $ ln -s /var/lib/install/etc/init.d/dropbear-server \
#                    etc/rc2.d/S90dropbear-server
#   (3) Run `make <target>':
#        a/ `make push' to push local changes to the 770/restore from backup.
#        b/ `make pull' to back up the 770.
#        c/ `make bootstrap' to copy the local changes to the 770 using SCP.
#   
#
# Links:
#   [1] Such as Dropbear: http://maemo.org/maemowiki/InstallSsh
#   [2] http://www.bleb.org/software/770/#rsync
#   [3] http://maemo.org/maemowiki/HowDoiBecomeRoot

# -- Change this line to your device ----------------------------------
#  
REMOTE_DEVICE=root@770:/

# -- Only change below here if you know wat you're doing --------------
# 
RSYNC_OPTS=rlptvogH --rsync-path=/usr/bin/rsync
RSYNC_RSH=ssh
INCLUDES=var/lib/gconf           \
	 etc                     \
	 boot                    \
	 bin                     \
	 lib                     \
	 root                    \
	 var/lib                 \
	 var/mail                \
	 usr                     \
         home
EXCLUDES=--exclude home/user/.opera/cache*                 \
         --exclude home/user/.thumbnails/osso/*            \
	 --exclude home/user/.osso_rss_feed_reader/cache/* \
	 --exclude home/user/.gaim/icons/*                 \
	 --exclude etc/mtab                                \
	 --exclude usr/var/*                               \
         --exclude Makefile
TEMP_FILE=/tmp/770-sync.filelist

push:
	rsync -${RSYNC_OPTS} . ${REMOTE_DEVICE}

pull:
	find . -type f | sed -e 's/^.\///' >${TEMP_FILE}       ; \
	for i in ${INCLUDES}; do echo $$i >>${TEMP_FILE}; done ; \
	rsync -${RSYNC_OPTS}                                     \
	      --delete-after --ignore-errors                     \
	      ${EXCLUDES} --files-from=${TEMP_FILE}              \
	      ${REMOTE_DEVICE} .                               ; \
	rm ${TEMP_FILE}

bootstrap:
	scp -pr . ${REMOTE_DEVICE}
