integrate-distro.sh: Replace option -c copy-source-dir by -k hook

Signed-off-by: Jan Lindemann <jan@jannet.de>
This commit is contained in:
Jan Lindemann 2013-04-09 13:36:40 +00:00 committed by Jan Lindemann
commit 77f7912c3f

View file

@ -6,6 +6,7 @@ arch=`uname -m`
suse_version=12.3
o_name=suse-$suse_version
cmd=install
cwd=`pwd`
initrd_modules="
via-rhine
@ -243,15 +244,27 @@ usage()
-n target-name
-p file with root password
-a architecture
-c copy-source-dir
-k hook=command
-u user (for source-code-management login)
known hooks are:
o fs-ready
o pkg-installed
during hook execution the following variables are filled
o \$hook : the name of the hook
o \$root : path to the root directory of the
distribution being integrated
"
[ "$1" ] && exit $1
}
get_opts()
{
set -- `getopt 'hd:n:a:p:c:u:' $*`
set -- `getopt 'hd:n:a:p:k:u:w:' $*`
while [ "$1" != -- ] ; do
case "$1" in
-h)
@ -273,14 +286,18 @@ get_opts()
root_password_file=$2
shift
;;
-c)
copy_source_dir=$2
-k)
hooks[${2%%=*}]="${2#*=}"
shift
;;
-u)
scm_user=$2
shift
;;
-w)
cwd=$2
shift
;;
*)
usage 1
;;
@ -365,6 +382,15 @@ run_chroot()
}
}
run_hook()
{
hook="$1"
local cmd="${hooks[$hook]}"
[ "$cmd" ] || return
[ "${cmd:0:2}" = "./" ] && cmd=$cwd/${cmd:2}
. $cmd
}
run_parted()
{
while read cmd; do
@ -934,13 +960,7 @@ cmd_install()
make_home_ssh_conf > $root/root/.ssh/config
chmod 600 $root/root/.ssh/config
[ "$copy_source_dir" ] && {
echo "=== copying over dir $copy_source_dir"
cp -rLp $copy_source_dir/* $root/
chroot $root /sbin/mkinitrd_setup # TODO: remove this
touch $root/opt/ytools/bin/jcs # TODO: remove this
chroot $root /opt/ytools/bin/jcs init # TODO: remove this
}
run_hook pkg-installed
export CVSROOT=:ext:$scm_user@cvs.jannet.de:/home/jannet/arc/cvs
if [ "$SSH_AUTH_SOCK" ]; then
@ -996,7 +1016,7 @@ myname=`basename $0`
zypper_global_opts="--non-interactive --gpg-auto-import-keys --no-gpg-checks"
date=`date`
host_files=""
declare -A hooks
get_opts "$@"
init_root_password_file
@ -1025,7 +1045,7 @@ if [ `whoami` != root -o "$l32" ]; then
# preferring "ssh -l root localhost" over "sudo" to keep ssh-agent environment
#sudo -i $exe $@ -p $root_password_file
ssh -l root localhost $l32 $exe $@ -p $root_password_file -u $scm_user
ssh -l root localhost $l32 $exe $@ -p $root_password_file -u $scm_user -w $cwd
exit $?
fi