summaryrefslogtreecommitdiffstats
path: root/build/install/install.sh
blob: 6155a41629e83a8cf5e23cadbba37553a0c570ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape */
.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
.highlight .sx { color: #e6db74 } /* Literal.String.Other */
.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #a6e22e } /* Name.Function.Magic */
.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
}
@media (prefers-color-scheme: light) {
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
}
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. SPDX-License-Identifier: CC-BY-4.0
.. (c) 2018 Ericsson AB, Mirantis Inc., Enea AB and others.

:orphan:

Image Editor
============

All files in this directory have been created using `draw.io`_.

Image Sources
=============

Image sources are embedded in each ``png`` file.
To edit an image, import the ``png`` file using `draw.io`_.

.. _`draw.io`: https://draw.io
a id='n359' href='#n359'>359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481
#!/bin/bash -e
##############################################################################
# Copyright (c) 2015 Ericsson AB and others.
# stefan.k.berg@ericsson.com
# jonas.bjurel@ericsson.com
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################


my_exit() {
    rc=$?

    cd /tmp

    if [ -n "$TMP_HOSTMOUNT" ]; then
        if [ -d "$TMP_HOSTMOUNT" ]; then
            fusermount -u $TMP_HOSTMOUNT
            rmdir $TMP_HOSTMOUNT
        fi
    fi

    if [ -d "$TMP_OLDISO" ]; then
        fusermount -u $TMP_OLDISO
        rmdir $TMP_OLDISO
    fi

    if [ -f "$CONF" ]; then
        rm $CONF
    fi

    if [ -d "$TMP_ISOPUPPET" ]; then
        rm -Rf $TMP_ISOPUPPET
    fi
}

get_deb_name() {
    ar p $1 control.tar.gz | tar xzO ./control | grep "^Package:.* " | sed 's/.* //'
    if [ $PIPESTATUS -ne 0 ]; then
        echo "Error in get_deb_name($1)"
        exit 1
    fi
}

get_deb_rev() {
    ar p $1 control.tar.gz | tar xzO ./control | grep "^Version:.* " | sed 's/.* //'
    if [ $PIPESTATUS -ne 0 ]; then
        echo "Error in get_deb_rev($1)"
        exit 1
    fi
}


# Added logic for ".orig" files:
#   1. Is there an .orig file for the new file?
#   2. If the file is not present in base ISO -> Error!
#   3. If the file is changed i base ISO -> Error!  (need manual rebase)
#   4. If there is no .orig file, but file is present in base ISO: Error!
verify_orig_files() {
    OLDDIR=$1
    NEWDIR=$2

    pushd $NEWDIR >/dev/null
    for f in $(find * -type f -name '*.orig')
    do
        origfile=$NEWDIR/$f
        oldfile=$OLDDIR/$(echo $f | sed 's/.orig$//')
        newfile=$NEWDIR/$(echo $f | sed 's/.orig$//')

        origfile=${newfile}.orig
        # If no corresponding base file, error
        if [ ! -f $oldfile ]; then
            printf "\n\n\n\n"
            echo "Error: found ${newfile} but no"
            echo "Error: ${oldfile}"
            echo "Error: Manual rebase is needed!"
            printf "\n\n\n\n"
            exit 1
        fi

        # If orig file differs from base file, error
        if ! diff -q $origfile $oldfile > /dev/null; then
            printf "\n\n\n\n"
            echo "Error: $origfile differs from"
            echo "Error: $oldfile!"
            echo "Error: Manual rebase is needed!"
            printf "\n\n\n\n"
            exit 1
        fi

    done


    # Check that there we're not overwriting oldfiles without having a ".orig" copy
    for f in $(find * -type f ! -name '*.orig')
    do
        newfile=$NEWDIR/$(echo $f | sed 's/.orig$//')
        origfile=${newfile}.orig
        oldfile=$OLDDIR/$f
        if [ -f $oldfile ]; then
            if [ ! -f $origfile ]; then
                printf "\n\n\n\n"
                echo "Error: Will overwrite $oldfile, but there is no"
                echo "Error: $origfile!"
                echo "Error: You need to create the `basename $origfile`!"
                printf "\n\n\n\n"
                exit 1
            fi
        fi
    done


    popd >/dev/null
}

prep_make_live() {
    DEST=$TMP_HOSTMOUNT
    REPO=$DEST/var/www/nailgun/ubuntu/fuelweb/x86_64
    echo "Live install"
    ssh-copy-id root@$FUELHOST
    sshfs root@1${FUELHOST}:/ $TMP_HOSTMOUNT

    if [ -f  $REPO/dists/trusty/main/binary-amd64/Packages.backup ]; then
        echo "Error - found backup file for Packages!"
        exit 1
    fi

    if [ -f  $REPO/dists/trusty/main/binary-amd64/Packages.gz.backup ]; then
        echo "Error - found backup file for Packages.gz!"
        exit 1
    fi

    if [ -f  $REPO/dists/trusty/Release.backup ]; then
        echo "Error - found backup file for Release!"
        exit 1
    fi

    if [ -d  $DEST/etc/puppet.backup ]; then
        echo "Error - found backup file for Puppet!"
        exit 1
    fi

    cp $REPO/dists/trusty/main/binary-amd64/Packages $REPO/dists/trusty/main/binary-amd64/Packages.backup
    cp $REPO/dists/trusty/main/binary-amd64/Packages.gz $REPO/dists/trusty/main/binary-amd64/Packages.gz.backup
    cp $REPO/dists/trusty/Release $REPO/dists/trusty/Release.backup
    cp -Rvp $DEST/etc/puppet $DEST/etc/puppet.backup
}

post_make_live() {
    if [ -d $TOP/release/puppet/modules ]; then
        echo "Installing into Puppet:"
        cd $TOP/release/puppet/modules
        if [ `ls -1 | wc -l` -gt 0 ]; then
            for dir in *
            do
                echo "   $dir"
                cp -Rp $dir $DEST/etc/puppet/modules
            done
        fi
    fi
}

make_live() {
    prep_make_live
    copy_packages
    post_make_live
}


prep_make_iso() {
    DEST=$TOP/newiso
    REPO=$DEST/ubuntu
    echo "Making ISO..."
    echo "Unpack of old ISO..."
    if [ -d newiso ]; then
        chmod -R 755 newiso
        rm -rf newiso
    fi
    mkdir newiso
    fusermount -u $TMP_OLDISO 2>/dev/null || cat /dev/null
    fuseiso -p $ORIGISO $TMP_OLDISO
    sleep 1
    cd $TMP_OLDISO
    find . | cpio -pd $TOP/newiso
    cd ..
    fusermount -u $TMP_OLDISO
    rm -Rf $TMP_OLDISO
    chmod -R 755 $TOP/newiso
}

make_iso_image() {
    echo "Making ISO..."
    cd $DEST
    find . -name TRANS.TBL -exec rm {} \;
    rm -rf rr_moved

    mkisofs --quiet -r -V "$VOLUMEID" -publisher "$PUBLISHER" \
        -p `git rev-parse --verify HEAD` -J -R -b isolinux/isolinux.bin \
        -no-emul-boot \
        -boot-load-size 4 -boot-info-table \
        --hide-rr-moved \
        -x "lost+found" -o $NEWISO .

    isoinfo -d -i $NEWISO
}

# iso_copy_puppet: Create a new puppet-slave.tgz for the iso
iso_copy_puppet() {
    echo "Installing into Puppet..."
    mkdir -p $TMP_ISOPUPPET/release/puppet
    cd $TMP_ISOPUPPET/release/puppet
    tar xzf $DEST/puppet-slave.tgz
    cd $TOP/release/puppet/modules

    # Remove all .orig files before copying as they now have been verfied

    if [ -d $TOP/release/puppet/modules ]; then
        if [ `ls -1 | wc -l` -gt 0 ]; then
            verify_orig_files $TMP_ISOPUPPET/release/puppet $TOP/release/puppet/modules
            find $TOP/release/puppet/modules -type f -name '*.orig' -exec rm {} \;
            for dir in $TOP/release/puppet/modules/*
            do
                echo "   $dir"
                cp -Rp $dir $TMP_ISOPUPPET/release/puppet
            done
        fi
    fi

    cd $TMP_ISOPUPPET/release/puppet
    tar czf $DEST/puppet-slave.tgz .
    cd $TOP
    rm -Rf $TMP_ISOPUPPET
}

# iso_modify_image: Add/patch files in the ISO root
iso_modify_image () {
    # TODO: Add logic for ".orig" files (hey! make a function!), which would look
    # something like:
    #   1. Is there an .orig file?
    #   2. If the file is not present in origiso -> Error exit
    #   3. If the file is changed in origiso -> Error exit (need manual rebase)
    #   4. Otherwise continue, but don't copy orig file (or maybe we should?)
    # ... and corresponding reverse logic:
    #   1. If there is no .orig file, but file is present in origiso -> Error exit
    echo "Modify ISO files (wild copy)..."

    verify_orig_files $DEST $TOP/release/isoroot
    # Remove all .orig files before copying as they now have been verfied
    find $TOP/release/isoroot -type f -name '*.orig' -exec rm {} \;

    cd $TOP/release/isoroot
    cp -Rvp . $DEST

    # Add all Git info files
    sort $TOP/gitinfo*.txt > $DEST/gitinfo.txt
    cp $DEST/gitinfo.txt $REPORTFILE
}

make_iso() {
    prep_make_iso
    copy_packages
    #iso_copy_puppet
    iso_modify_image
    make_iso_image
}

copy_packages() {
    echo "Copying Debian packages..."
    cd $TOP/release/packages/ubuntu/pool/debian-installer

    for udeb in `ls -1 | grep '\.udeb$'`
    do
        echo "   $udeb"
        cp $udeb $REPO/pool/debian-installer
	echo "Did not expect a package here, not supported"
	exit 1
    done

    cd $TOP/release/packages/ubuntu/pool/main
    for deb in `ls -1 | grep '\.deb$'`
    do
        echo "   $deb"
        cp $deb $REPO/pool/main
	echo "Did not expect a package here, not supported"
	exit 1
    done

    echo "Running Fuel package patch file"
    pushd $REPO/pool/main > /dev/null

    for line in `cat $TOP/apply_patches | grep -v "^#" | grep -v "^$"`; do
        echo "Line is $line"
        echo "Did not expect a line here, not supported"
        exit 1
        ref=`echo $line | cut -d '>' -f 1`
        origpkg=`echo $line| cut -d '>' -f 2`
        url=`echo $line | cut -d '>' -f 3`

        if [ -z "$origpkg" ]; then
            echo "Error: No origpkg for patching"
            exit 1
        fi

        if [ -z "$url" ]; then
            echo "Error: No url for patching"
            exit 1
        fi

        if [ -z "$ref" ]; then
            echo "Error: No reference text for patching"
            exit 1
        fi

        echo "CM: Patching Fuel package for $ref" | tee -a $REPORTFILE
        echo "CM: Replacing package $origpkg with $url" | tee -a $REPORTFILE
        oldrev=`get_deb_rev $origpkg`
        rm $origpkg
        wget --quiet $url
        topkg=`basename $url`
        echo "CM: MD5 of new package:" | tee -a $REPORTFILE
        md5sum $topkg | tee -a $REPORTFILE

        patchname=`get_deb_name $topkg`
        patchrev=`get_deb_rev $topkg`
        echo "Correcting dependencies towards $patchname rev $patchrev - old rev $oldrev" | tee -a $REPORTFILE
        $TOP/patch-packages/tools/correct_deps $patchname $oldrev $patchrev | tee -a $REPORTFILE
        if [ $PIPESTATUS -ne 0 ]; then
            exit 1
        fi
    done

    printf "Done running Fuel patch file\n\n"
    echo "Running add packages file"
    for line in `cat $TOP/add_opnfv_packages | grep -v "^#" | grep -v "^$"`; do
        echo "Line is $line"
        echo "Did not expect a line here, not supported"
        exit 1
        ref=`echo $line | cut -d '>' -f 1`
        origpkg=`echo $line| cut -d '>' -f 2`
        url=`echo $line | cut -d '>' -f 3`

        if [ -z "$origpkg" ]; then
            echo "Error: No origpkg for patching"
            exit 1
        fi

        if [ -z "$url" ]; then
            echo "Error: No url for patching"
            exit 1
        fi

        if [ -z "$ref" ]; then
            echo "Error: No reference text for patching"
            exit 1
        fi

        if [ "$origpkg" != "NONE" ]; then
            echo "CM: Patching added package for $ref" | tee -a $REPORTFILE
            echo "CM: Replacing package $origpkg with $url" | tee -a $REPORTFILE
            oldrev=`get_deb_rev $origpkg`
            rm $origpkg
        else
            echo "CM: Adding previoulsy uninstalled package for $ref" tee -a $REPORTFILE
        fi
        wget --quiet $url
        topkg=`basename $url`
        echo "CM: MD5 of new package:" | tee -a $REPORTFILE
        md5sum $topkg | tee -a $REPORTFILE
        if [ "$origpkg" != "NONE" ]; then
            patchname=`get_deb_name $topkg`
            patchrev=`get_deb_rev $topkg`
            echo "Correcting dependencies towards $patchname rev $patchrev - old rev $oldrev" | tee -a $REPORTFILE
            $TOP/patch-packages/tools/correct_deps $patchname $oldrev $patchrev | tee -a $REPORTFILE
            if [ $PIPESTATUS -ne 0 ]; then
                exit 1
            fi
        fi
    done
    printf "Done running add packages file\n\n"

    popd > /dev/null

    if [ -f $TOP/patch-packages/release/patch-replacements ]; then
        echo "Applying package patches" | tee -a $REPORTFILE
        pushd $REPO/pool/main > /dev/null
        printf "\n\n" | tee -a  $REPORTFILE
        for line in `cat $TOP/patch-packages/release/patch-replacements`
        do
            echo "Did not expect a line here, not supported"
       	    exit 1
            frompkg=`echo $line | cut -d ">" -f 1`
            topkg=`echo $line | cut -d ">" -f 2`
            echo "CM: Applying patch to $frompkg" | tee -a $REPORTFILE
            echo "CM: New package rev after patch: $topkg" | tee -a $REPORTFILE

            if [ ! -f $frompkg ]; then
                echo "Error: Can't find $frompkg in repo"
                exit 1
            else
                oldrev=`get_deb_rev $frompkg`
                echo "Removing $frompkg from repo"
                rm $frompkg
            fi

            if [ ! -f $TOP/patch-packages/release/packages/$topkg ]; then
                echo "Error: Can't find $topkg in patch release"
                exit 1
            else
                echo "Adding $topkg to repo"
                cp $TOP/patch-packages/release/packages/$topkg .
            fi

            patchname=`get_deb_name $topkg`
            patchrev=`get_deb_rev $topkg`
            echo "Correcting dependencies towards $patchname rev $patchrev - old rev $oldrev" | tee -a $REPORTFILE
            $TOP/patch-packages/tools/correct_deps $patchname $oldrev $patchrev | tee -a $REPORTFILE
            if [ $PIPESTATUS -ne 0 ]; then
                exit 1
            fi
        done
        popd > /dev/null
    fi

    echo "Generating metadata..."
    pushd $REPO > /dev/null

    # The below methods are from 15B
    APT_REL_CONF="$TOP/install/apt-ftparchive-release.conf"
    APT_DEB_CONF="$TOP/install/apt-ftparchive-deb.conf"
    APT_UDEB_CONF="$TOP/install/apt-ftparchive-udeb.conf"

    echo Not running echo apt-ftparchive -c "${APT_REL_CONF}" generate "${APT_DEB_CONF}"
    echo Not running apt-ftparchive -c "${APT_REL_CONF}" generate "${APT_DEB_CONF}"
    echo Not running apt-ftparchive generate "${APT_UDEB_CONF}"
    echo Not running apt-ftparchive generate "${APT_UDEB_CONF}"

    # Fuel also needs this index file
    # cat dists/trusty/main/binary-amd64/Packages | \
    #    awk '/^Package:/{pkg=$2}
    # /^Version:/{print pkg ": \"" $2 "\""}' > ubuntu-versions.yaml
    # cp ubuntu-versions.yaml $DEST

    # apt-ftparchive -c "${APT_REL_CONF}" release dists/trusty/ > dists/trusty/Release
    # gzip -9cf dists/trusty/Release > dists/trusty/Release.gz

    popd > /dev/null

}


#############################################################################

trap my_exit EXIT

CONF=`mktemp /tmp/XXXXXXX`
MODE=$1
TOP=`pwd`

if [ $MODE = "iso" ]; then
    PUBLISHER="OPNFV"
    TMP_OLDISO=`mktemp -d /tmp/XXXXXXX`
    TMP_ISOPUPPET=`mktemp -d /tmp/XXXXXXX`
    ORIGISO=$2
    NEWISO=$3
    VOLUMEID="$4 $5"
    REPORTFILE="${NEWISO}.txt"
    echo "Opening reportfile at $REPORTFILE"
    touch $REPORTFILE
    if [ ! -f $ORIGISO ]; then
        echo "Can't find original iso at $ORIGISO"
        rm $CONF
        exit 1
    fi

    make_iso
else
    echo "Unknown mode: $MODE"
    exit 1
fi