Commit eddb4de3 authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

update-linux-headers: copy standard-headers files one by one



cp_virtio is called for both the asm-s390/ and linux/ directories,
so it looks for pci_regs.h and input.h files in asm-s390/ too.  This
makes little sense.  In the next patch we will have the opposite
problem; we want to add asm-x86/hyperv.h, and there's also a
linux/hyperv.h file with unwanted dependencies on additional Linux
uapi headers.  We do not want to copy linux/hyperv.h.

The solution is to make cp_virtio (now renamed to cp_portable) copy
one file only, instead of using the "find" command, and call it multiple
times.  The new function is really just a reindentation of the old one.

Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 120758fb
Loading
Loading
Loading
Loading
+36 −33
Original line number Diff line number Diff line
@@ -28,14 +28,9 @@ if [ -z "$output" ]; then
    output="$PWD"
fi

cp_virtio() {
    from=$1
cp_portable() {
    f=$1
    to=$2
    virtio=$(find "$from" -name '*virtio*h' -o -name "input.h" -o -name "pci_regs.h")
    if [ "$virtio" ]; then
        rm -rf "$to"
        mkdir -p "$to"
        for f in $virtio; do
    if
        grep '#include' "$f" | grep -v -e 'linux/virtio' \
                                     -e 'linux/types' \
@@ -59,8 +54,6 @@ cp_virtio() {
        -e 's/__inline__/inline/' \
        -e '/sys\/ioctl.h/d' \
        "$f" > "$to/$header";
        done
    fi
}

# This will pick up non-directories too (eg "Kconfig") but we will
@@ -93,7 +86,12 @@ for arch in $ARCHLIST; do
        cp "$tmpdir/include/asm/epapr_hcalls.h" "$output/linux-headers/asm-powerpc/"
    fi

    cp_virtio "$tmpdir/include/asm" "$output/include/standard-headers/asm-$arch"
    rm -rf "$output/include/standard-headers/asm-$arch"
    mkdir -p "$output/include/standard-headers/asm-$arch"
    if [ $arch = s390 ]; then
        cp_portable "$tmpdir/include/asm/kvm_virtio.h" "$output/include/standard-headers/asm-s390/"
        cp_portable "$tmpdir/include/asm/virtio-ccw.h" "$output/include/standard-headers/asm-s390/"
    fi
done

rm -rf "$output/linux-headers/linux"
@@ -120,7 +118,12 @@ cat <<EOF >$output/linux-headers/linux/virtio_ring.h
#include "standard-headers/linux/virtio_ring.h"
EOF

cp_virtio "$tmpdir/include/linux/" "$output/include/standard-headers/linux"
rm -rf "$output/include/standard-headers/linux"
mkdir -p "$output/include/standard-headers/linux"
for i in "$tmpdir"/include/linux/*virtio*.h "$tmpdir/include/linux/input.h" \
         "$tmpdir/include/linux/pci_regs.h"; do
    cp_portable "$i" "$output/include/standard-headers/linux"
done

cat <<EOF >$output/include/standard-headers/linux/types.h
#include <stdint.h>