test/remove.sh
author J. Ali Harlow <ali@juiblex.co.uk>
Thu Feb 09 20:45:27 2012 +0000 (2012-02-09)
changeset 418 33b825d3128d
parent 372 6e93e5485947
child 456 bae5adee8c8c
permissions -rwxr-xr-x
Add transaction barriers
These allow packages to be installed and removed which have scripts
that depend on each other when atomic transactions are involved.
Note that yum supports pre, but not other requires flags. post will
need similar support to the post scripts themselves pulling in the
requires flags from the rpms. Likewise preun and postun will need
similar handling to those scrips since the requires flags will need
to be stored in the razor database.
ali@363
     1
#!/bin/sh
ali@369
     2
fs_check_file()
ali@369
     3
{
ali@369
     4
    if [ ! -e "$RAZOR_ROOT$1" ]; then 
ali@369
     5
	echo $1: Not in filesystem >&2
ali@369
     6
	ls -R "$RAZOR_ROOT" >&2
ali@369
     7
	exit 1
ali@369
     8
    fi
ali@369
     9
}
ali@369
    10
fs_check_no_file()
ali@369
    11
{
ali@369
    12
    if [ -e "$RAZOR_ROOT$1" ]; then 
ali@369
    13
	echo $1: Still in filesystem >&2
ali@369
    14
	exit 1
ali@369
    15
    fi
ali@369
    16
}
ali@363
    17
check_file()
ali@363
    18
{
ali@363
    19
    ../src/razor list-files | grep -x "$1" > /dev/null
ali@363
    20
    if [ $? -ne 0 ]; then
ali@363
    21
	echo $1: Not in database >&2
ali@363
    22
	../src/razor list-files >&2
ali@363
    23
	exit 1
ali@363
    24
    fi
ali@363
    25
    ../src/razor list-files "$1" | grep -x "$1" > /dev/null
ali@363
    26
    if [ $? -ne 0 ]; then
ali@363
    27
	echo $1: Not seen by patterned list >&2
ali@363
    28
	../src/razor list-files "$1" >&2
ali@363
    29
	exit 1
ali@363
    30
    fi
ali@363
    31
    pkgs=`../src/razor list-file-packages "$1"`
ali@363
    32
    if [ -z "$pkgs" ]; then
ali@363
    33
	echo $1: Not owned by any package >&2
ali@363
    34
	../src/razor list-file-packages "$1"
ali@363
    35
	exit 1
ali@363
    36
    fi
ali@363
    37
    for nevra in "$pkgs"; do
ali@363
    38
	name=`echo $nevra | sed 's/\-.*$//'`
ali@363
    39
	../src/razor list-package-files "$name" | grep -x "$1" > /dev/null
ali@363
    40
	if [ $? -ne 0 ]; then
ali@363
    41
	    echo $1: Not in database for package $name >&2
ali@363
    42
	    ../src/razor list-package-files "$name"
ali@363
    43
	    exit 1
ali@363
    44
	fi
ali@363
    45
    done
ali@369
    46
    fs_check_file $1
ali@363
    47
}
ali@363
    48
check_no_file()
ali@363
    49
{
ali@363
    50
    ../src/razor list-files | grep -x "$1" > /dev/null
ali@363
    51
    if [ $? -eq 0 ]; then
ali@363
    52
	echo $1: Still in database >&2
ali@363
    53
	exit 1
ali@363
    54
    fi
ali@369
    55
    fs_check_no_file $1
ali@363
    56
}
ali@363
    57
export RAZOR_ROOT=`mktemp -dt` || exit 1
ali@363
    58
../src/razor init || exit 1
ali@363
    59
export YUM_URL="file://localhost/`pwd`"
ali@363
    60
../src/razor import-yum || exit 1
ali@372
    61
../src/razor install --relocate /usr=/opt zip || exit 1
ali@372
    62
fs_check_file /opt/var/lib/zip/data.zap
ali@363
    63
../src/razor remove zip || exit 1
ali@372
    64
check_file /opt/bin/zap
ali@372
    65
check_no_file /opt/bin/zip
ali@372
    66
fs_check_no_file /opt/var/lib/zip/data.zap
ali@372
    67
../src/razor install --relocate /usr=/opt zsh || exit 1
ali@372
    68
../src/razor install --relocate /usr=/opt zsh2 || exit 1
ali@363
    69
../src/razor remove zsh || exit 1
ali@363
    70
check_file /etc/zsh.conf
ali@372
    71
check_no_file /opt/bin/zsh
ali@372
    72
check_no_file /opt/var/lib/zsh/data.zip
ali@410
    73
# Installing a package twice isn't handled very well at present
ali@410
    74
# so just don't do it for now.
ali@410
    75
#../src/razor install --relocate /usr=/opt zsh2 || exit 1
ali@372
    76
fs_check_file /opt/var/lib/zip/data.zap
ali@371
    77
../src/razor remove zsh2 zip || exit 1
ali@372
    78
fs_check_no_file /opt/var/lib/zip/data.zap
ali@363
    79
rm -rf "$RAZOR_ROOT"