This file is indexed.

/usr/bin/virt-p2v-make-kickstart is in libguestfs-tools 1:1.36.13-1ubuntu3.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#!/bin/bash -
# p2v/virt-p2v-make-kickstart.  Generated from virt-p2v-make-kickstart.in by configure.
# virt-p2v-make-kickstart
# Copyright (C) 2014-2017 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

unset CDPATH

program="virt-p2v-make-kickstart"
version="1.36.13"

# Parse the command line arguments.
shortopts=o:vV
longopts=help,inject-ssh-identity:,install:,long-options,output:,proxy:,short-options,verbose,version
TEMP=`getopt \
        -o "$shortopts" \
        --long "$longopts" \
        -n $program -- "$@"`
if [ $? != 0 ]; then
    echo "$program: problem parsing the command line arguments"
    exit 1
fi
eval set -- "$TEMP"

usage ()
{
    echo "Usage:"
    echo "  $program [--options] [-o p2v.ks] [--proxy=http://...] repo [repo...]"
    echo
    echo "Read $program(1) man page for more information."
    exit $1
}

extra_packages=
output=p2v.ks
proxy=
ssh_identity=
verbose=

while true; do
    case "$1" in
        --inject-ssh-identity)
            ssh_identity="$2"
            shift 2;;
        --install)
            extra_packages="${extra_packages:+${extra_packages},}$2"
            shift 2;;
        -o|--output)
            output="$2"
            shift 2;;
        --proxy)
            proxy="--proxy=$2"
            shift 2;;
        --repo)
            repo="$2"
            shift 2;;
        -v|--verbose)
            set +x
            verbose=1
            shift;;

        # help etc.
        --help)
            usage 0;;
        -V|--version)
            echo "$program $version"
            exit 0;;
        --short-options)
            echo -n "$shortopts" |
                /bin/sed -e 's/://g' -e 's/\(.\)/-\1\n/g'
            exit 0;;
        --long-options)
            echo "$longopts" |
                /bin/sed -e 's/,/\n/g' -e 's/:$//mg' -e 's/\(.*\)/--\1/mg' |
                grep -v -E -- "--(short|long)-options"
            exit 0;;
        --)
            shift
            break;;
        *)
            echo "internal error ($1)"
            exit 1;;
    esac
done

if [ $# -lt 1 ]; then
    echo "$program: Missing repo(s).  See $program(1)."
    exit 1
fi

set -e

if [ -n "$VIRT_P2V_DATA_DIR" ]; then
    datadir="$VIRT_P2V_DATA_DIR"
    libdir="$VIRT_P2V_DATA_DIR"
else
    datadir="${prefix}/share/virt-p2v"
    libdir="${prefix}/lib/x86_64-linux-gnu/virt-p2v"
fi

# Base64-encode the files that we need to embed into the kickstart.
base64_issue="$(base64 $datadir/issue)"
base64_launch_virt_p2v="$(base64 $datadir/launch-virt-p2v)"
base64_p2v_service="$(base64 $datadir/p2v.service)"
if [ -n "$ssh_identity" ]; then
    base64_ssh_identity="$(base64 $ssh_identity)"
else
    base64_ssh_identity=
fi

# virt-p2v binary is too large unless we strip it and recompress it.
tmpfile="$(mktemp -u)"
xzcat $libdir/virt-p2v.xz > $tmpfile
md5sum_virt_p2v="$(md5sum $tmpfile | gawk '{print $1}')"
strip --strip-all $tmpfile
gzip -9 $tmpfile
base64_virt_p2v="$(base64 $tmpfile.gz)"
rm $tmpfile.gz

# Repositories.
repos=
i=0
for repo in "$@"; do
    case "$repo" in
        fedora)
            repos="$repos
repo --name=fedora --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-\$releasever\\\\&arch=\$basearch $proxy
"
            ;;
        rawhide)
            repos="$repos
repo --name=rawhide --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=rawhide\\\\&arch=\$basearch $proxy
"
            ;;
        koji)
            repos="$repos
repo --name=koji --baseurl=http://koji.fedoraproject.org/repos/rawhide/latest/\$basearch/ $proxy
"
            ;;
        rhel-5.*)
            minor=$( echo "$repo" | sed 's/rhel-[0-9]*\.\([0-9]*\)/\1/' )
            arch=`uname -m | sed 's/i[3456]86/i386/g'`
            baseurl=http://download.devel.redhat.com/released/RHEL-5-Server/U$minor/$arch/os/Server/
            # Neither $basearch nor --proxy work in RHEL 5 kickstarts.
            repos="$repos
repo --name=rhel5_${minor}_server --baseurl=$baseurl
"
            ;;
        rhel-6.*)
            minor=$( echo "$repo" | sed 's/rhel-[0-9]*\.\([0-9]*\)/\1/' )
            baseurl=http://download.devel.redhat.com/released/RHEL-6/6.$minor
            # '$basearch' cannot be used in kickstart, so:
            arch=`uname -m`
            repos="$repos
repo --name=rhel6_${minor}_server --baseurl=$baseurl/Server/$arch/os $proxy
repo --name=rhel6_${minor}_server_optional --baseurl=$baseurl/Server/optional/$arch/os $proxy
"
            ;;
        rhel-7.*)
            minor=$( echo "$repo" | sed 's/rhel-[0-9]*\.\([0-9]*\)/\1/' )
            baseurl=http://download.devel.redhat.com/released/RHEL-7/7.$minor
            # '$basearch' cannot be used in kickstart, so:
            arch=`uname -m`
            repos="$repos
repo --name=rhel7_${minor}_server --baseurl=$baseurl/Server/$arch/os $proxy
repo --name=rhel7_${minor}_server_optional --baseurl=$baseurl/Server-optional/$arch/os $proxy
"
            ;;
        *)
            # A custom repo is just a URL.
            ((i++)) ||:
            repos="$repos
repo --name=custom$i --baseurl=$repo $proxy
"
            ;;
    esac
done

# Dependencies.  Since kickstart is Red Hat-specific, only include
# dependencies.redhat here.
depsfile="$datadir/dependencies.redhat"
if [ ! -f "$depsfile" ]; then
    echo "$0: cannot find dependencies file ($depsfile)"
    exit 1
fi
dependencies=
while read line; do
    if [ -n "$line" ]; then
        if [ -z "$dependencies" ]; then
            dependencies="$line"
        else
            dependencies="$dependencies
$line"
        fi
    fi
done < $depsfile

# Now generate the final kickstart, substituting as necessary.
# AWK FTW!
gawk \
  -v "base64_issue=$base64_issue" \
  -v "base64_launch_virt_p2v=$base64_launch_virt_p2v" \
  -v "base64_p2v_service=$base64_p2v_service" \
  -v "base64_ssh_identity=$base64_ssh_identity" \
  -v "base64_virt_p2v=$base64_virt_p2v" \
  -v "dependencies=$dependencies" \
  -v "extra_packages=$extra_packages" \
  -v "md5sum_virt_p2v=$md5sum_virt_p2v" \
  -v "repos=$repos" \
  '{
    gsub (/__PACKAGE_NAME__/, "libguestfs");
    gsub (/__PACKAGE_VERSION__/, "1.36.13");
    gsub (/__PACKAGE_VERSION_FULL__/, "1.36.13");
    gsub (/__BASE64_ISSUE__/, base64_issue);
    gsub (/__BASE64_LAUNCH_VIRT_P2V__/, base64_launch_virt_p2v);
    gsub (/__BASE64_P2V_SERVICE__/, base64_p2v_service);
    gsub (/__BASE64_SSH_IDENTITY__/, base64_ssh_identity);
    gsub (/__BASE64_VIRT_P2V__/, base64_virt_p2v);
    gsub (/__DEPENDENCIES__/, dependencies);
    gsub (/__EXTRA_PACKAGES__/, gensub (/,/, "\n", "g", extra_packages));
    gsub (/__MD5SUM_VIRT_P2V__/, md5sum_virt_p2v);
    gsub (/__REPOS__/, repos);
    print;
  }' \
  $datadir/p2v.ks.in > $output-t
mv $output-t $output

echo "Kickstart file written to $output"