<commit_before>#!/bin/sh
#
# Migration script used to migrate an rBuilder Appliance from version 1.6.3
# to version 2.0.0

# Full install label to builds repository
INSTALL_LABEL_PATH="products.rpath.com@rpath:rba-2"
NEEDED_TROVES_AND_LABELS="group-rbuilder-dist|products.rpath.com@rpath:rba-1.6 group-rbuilder-dist|products.rpath.com@rpath:rba-2 conary|products.rpath.com@rpath:conary-1.1 raaplugins|products.rpath.com@rpath:raa-1"

RBUILDER_ROOT="/srv/rbuilder"
BACKUPDIR="/tmp/rBA-2.0-migration.$$"

# sane path for this script
PATH="/bin:/usr/bin:/sbin:/usr/sbin"

# sanity checks ###############################################################

# Gotta be root
if [ `whoami` != 'root' ]; then
    echo "Migration script must be run as root."
    exit 1
fi

# If rBuilder isn't installed, we can't do very much.
if [ ! -d ${RBUILDER_ROOT} ]; then
    echo "rBuilder is not installed; nothing to migrate."
    exit 1
fi

# Check to see if the installed group-rbuilder-dist is indeed == 1.6.3
curr_ver=`conary q group-rbuilder-dist | cut -d'=' -f2 | cut -d'-' -f1`
case $curr_ver in
    1.6.3)
        echo "Found version 1.6.3 of group-rbuilder-dist."
        ;;
    2.0.0)
        echo "Migration has already taken place. Exiting."
        exit 1
        ;;
    *)
        echo "Migration script will only migrate version 1.6.3 to version 2.0.0."
        echo "Currently installed version: \"${curr_ver}\"."
        exit 1
        ;;
esac

if [ -d ${RBUILDER_ROOT} ]; then
    conary q rbuilder > /dev/null 2>&1
    if [ $? -ne 0 ]; then
        cat - <<EONOTE
Found ${RBUILDER_ROOT}, but rBuilder doesn't appear to be managed
by Conary. You will need to migrate this system manually.
EONOTE
        exit 1
    fi
fi

access_fail=1
for tl in $NEEDED_TROVES_AND_LABELS; do
    t=`echo $tl | cut -d\| -f1`
    l=`echo $tl | cut -d\| -f2`
    echo -n "Checking access to $l... "
    conary rq $t --install-label="$l" >& /dev/null
    if [ $? -ne 0 ]; then
        echo "failed"
        access_fail=0
    else
        echo "passed"
    fi
done

if [ $access_fail -eq 0 ]; then
    echo ""
    echo "It appears that your appliance cannot access this product update."
    echo "Contact a rPath sales engineer for assistance."
    exit 1
else
    echo "Access confirmed to product update. Migration proceeding."
    echo ""
fi

exit 0

# start the migration here ####################################################

# update conary (the old school way)
echo -n "Checking Conary..."
cversion=`conary --version`

case $cversion in
    1.0.*)
        cversion_minor=`echo $cversion | cut -d. -f3`
        if [ $cversion_minor -lt 27 ]; then<commit_msg>remove extraneous exit statement left in during debugging<commit_after>#!/bin/sh
#
# Migration script used to migrate an rBuilder Appliance from version 1.6.3
# to version 2.0.0

# Full install label to builds repository
INSTALL_LABEL_PATH="products.rpath.com@rpath:rba-2"
NEEDED_TROVES_AND_LABELS="group-rbuilder-dist|products.rpath.com@rpath:rba-1.6 group-rbuilder-dist|products.rpath.com@rpath:rba-2 conary|products.rpath.com@rpath:conary-1.1 raaplugins|products.rpath.com@rpath:raa-1"

RBUILDER_ROOT="/srv/rbuilder"
BACKUPDIR="/tmp/rBA-2.0-migration.$$"

# sane path for this script
PATH="/bin:/usr/bin:/sbin:/usr/sbin"

# sanity checks ###############################################################

# Gotta be root
if [ `whoami` != 'root' ]; then
    echo "Migration script must be run as root."
    exit 1
fi

# If rBuilder isn't installed, we can't do very much.
if [ ! -d ${RBUILDER_ROOT} ]; then
    echo "rBuilder is not installed; nothing to migrate."
    exit 1
fi

# Check to see if the installed group-rbuilder-dist is indeed == 1.6.3
curr_ver=`conary q group-rbuilder-dist | cut -d'=' -f2 | cut -d'-' -f1`
case $curr_ver in
    1.6.3)
        echo "Found version 1.6.3 of group-rbuilder-dist."
        ;;
    2.0.0)
        echo "Migration has already taken place. Exiting."
        exit 1
        ;;
    *)
        echo "Migration script will only migrate version 1.6.3 to version 2.0.0."
        echo "Currently installed version: \"${curr_ver}\"."
        exit 1
        ;;
esac

if [ -d ${RBUILDER_ROOT} ]; then
    conary q rbuilder > /dev/null 2>&1
    if [ $? -ne 0 ]; then
        cat - <<EONOTE
Found ${RBUILDER_ROOT}, but rBuilder doesn't appear to be managed
by Conary. You will need to migrate this system manually.
EONOTE
        exit 1
    fi
fi

access_fail=1
for tl in $NEEDED_TROVES_AND_LABELS; do
    t=`echo $tl | cut -d\| -f1`
    l=`echo $tl | cut -d\| -f2`
    echo -n "Checking access to $l... "
    conary rq $t --install-label="$l" >& /dev/null
    if [ $? -ne 0 ]; then
        echo "failed"
        access_fail=0
    else
        echo "passed"
    fi
done

if [ $access_fail -eq 0 ]; then
    echo ""
    echo "It appears that your appliance cannot access this product update."
    echo "Contact a rPath sales engineer for assistance."
    exit 1
else
    echo "Access confirmed to product update. Migration proceeding."
    echo ""
fi

# start the migration here ####################################################

# update conary (the old school way)
echo -n "Checking Conary..."
cversion=`conary --version`

case $cversion in
    1.0.*)
        cversion_minor=`echo $cversion | cut -d. -f3`
        if [ $cversion_minor -lt 27 ]; then
{'fraction_non_alphanumeric': 0.16135084427767354, 'fraction_numerical': 0.020825515947467167, 'mean_word_length': 2.888402625820569, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1374', 'n_tokens_mistral': 1903, 'n_tokens_neox': 1806, 'n_words': 576}