#!/bin/bash

# Dracut is bash too, and it doesn't play nicely with our usual sets
# dib-lint: disable=setu sete setpipefail dibdebugtrace

check() {
    return 0
}

depends() {
    return 0
}

install() {
    inst /bin/targetcli
    inst "$moddir/targetcli-wrapper" /targetcli-wrapper
    inst "$moddir/iscsi-func" /iscsi-func
    # Install all of Python
    # TODO(bnemec): At some point this will need to be extended to support
    # Python 3, but for the moment we aren't using that anyway.
    inst /usr/bin/python
    while IFS='' read -r -d '' i; do
        inst "$i"
    done < <(find /usr/lib64/python2.7/ /usr/lib/python2.7/ -type f -print0)
}

#!/bin/bash

# Dracut is bash too, and it doesn't play nicely with our usual sets
# dib-lint: disable=setu sete setpipefail dibdebugtrace

check() {
    return 0
}

depends() {
    return 0
}

install() {
    inst /bin/targetcli
    inst "$moddir/targetcli-wrapper" /targetcli-wrapper
    inst "$moddir/iscsi-func" /iscsi-func
    # Install all of Python
    # TODO(bnemec): At some point this will need to be extended to support
    # Python 3, but for the moment we aren't using that anyway.
    inst /usr/bin/python
    local all_of_python=()
    while IFS='' read -r -d '' i; do
        all_of_python+=("$i")
    done < <(find /usr/lib64/python2.7/ /usr/lib/python2.7/ -type f -not -name "*.pyc" -not -name "*.pyo" -print0)
    inst_multiple "${all_of_python[@]}"
}

Optimize Python install in deploy-targetcli
Optimize Python install in deploy-targetcli

Installing Python to a ramdisk takes quite a long time because of
the way dracut checks for dependencies of every single file
installed.  We could avoid that, but then we might miss a required
library file.

This change alters the installation method to speed up
the process.  First, it creates a list of files that are needed and
then installs them all at once using inst_multiple instead of calling
inst on each file separately.  This doesn't make a huge difference,
but in my testing it is marginally faster.

Second, and more significantly, we don't need the *.pyo and *.pyc
files as those are simply an optimization to speed up module
loading.  Because the deploy ramdisk is a short-lived operation,
we probably lose more time transferring those extra files to the
target system than we save in improved load times.

In my testing, these two changes netted about a 20% improvement
in build times, and about 13% decrease in image size.

Change-Id: Ibc2b778c28fc9fb7177380dffe8dbce5722d0733
