From 39fdae3799744eb64a40616b02ffac89f7391161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Fri, 19 Apr 2013 10:56:11 +0200 Subject: [PATCH 01/27] contrib/nm-live-vm: set of scripts for building a live initramfs for NM testing The scripts use Fedora to build a Fedora 18 (i386) live image, and pack it into a single self-extracting script, that can be easily distributed. $ sudo ./build [-n name] [-b branch/commit] will create name-bundle.sh with NM built of a specified NM branch(commit). (defaults are: name="nm-live-vm"; branch="master") Resulting nm-live-vm-bundle.sh can be run with almost any distro. The only requirement is qemu-kvm (and VNC (tigervnc) on RHEL). --- contrib/fedora/nm-live-vm/README | 20 +++++ contrib/fedora/nm-live-vm/build.sh | 88 +++++++++++++++++++++ contrib/fedora/nm-live-vm/nm-make-script.sh | 17 ++++ contrib/fedora/nm-live-vm/run.sh | 33 ++++++++ contrib/fedora/nm-live-vm/self-extract.sh | 19 +++++ 5 files changed, 177 insertions(+) create mode 100644 contrib/fedora/nm-live-vm/README create mode 100755 contrib/fedora/nm-live-vm/build.sh create mode 100755 contrib/fedora/nm-live-vm/nm-make-script.sh create mode 100755 contrib/fedora/nm-live-vm/run.sh create mode 100644 contrib/fedora/nm-live-vm/self-extract.sh diff --git a/contrib/fedora/nm-live-vm/README b/contrib/fedora/nm-live-vm/README new file mode 100644 index 000000000..c0da9e35b --- /dev/null +++ b/contrib/fedora/nm-live-vm/README @@ -0,0 +1,20 @@ +NetworkManager live VM scripts +------------------------------ + +This set of scripts can be used to build a live initramfs image suitable +for testing NetworkManager in a virtual environment. The scripts themselves +are intended to be used by a power user who can adapt them to their needs. +The result, on the contrary, is intended to be used by anyone who wants to +play with NetworkManager on the command line. + +Building the initramfs image: + +sudo ./build.sh [-n name] [-b branch/commit] + +You may have to update ./build.sh to suit your distribution. The included +is prepared for Fedora 18 and the image is also build using Fedora 18 +repositories. + +Then you can distribute the self-extracting archive and run in on other machines: + +./nm-live-vm-bundle.sh diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh new file mode 100755 index 000000000..ee8f6a551 --- /dev/null +++ b/contrib/fedora/nm-live-vm/build.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +NAME="nm-live-vm" +NM_BRANCH="master" +BUILD_PACKAGES="qemu febootstrap mock rpmdevtools" +ARCH=i386 +ROOT="fedora-18-$ARCH" +TREE="/var/lib/mock/$ROOT/root" +PACKAGES="kernel passwd git autoconf automake libtool intltool gtk-doc libnl3-devel + dbus-glib-devel libgudev1-devel libuuid-devel nss-devel ppp-devel dhclient + bash-completion man-db man-pages vim-minimal" +KERNEL_URL=http://kojipkgs.fedoraproject.org/packages/kernel/3.8.5/201.fc18/i686/kernel-3.8.5-201.fc18.i686.rpm +KERNEL=`basename "${KERNEL_URL%.rpm}"` +#RELEASE="http://kojipkgs.fedoraproject.org/packages/fedora-release/18/1/noarch/fedora-release-18-1.noarch.rpm" +#PACKAGES="systemd bash" + +test "$EUID" -eq 0 || { echo "$0 must be run as root"; exit 1; } + +do_prepare() { + echo "Installing build packages..." + rpm -q $BUILD_PACKAGES || yum install $BUILD_PACKAGES || exit 1 + echo +} + +do_chroot() { + echo "Building the chroot..." + mock -r "$ROOT" --init || exit 1 + mock -r "$ROOT" --install $PACKAGES || exit 1 + #mock -r "$ROOT" --installdeps NetworkManager || exit 1 + mock -r "$ROOT" --chroot cp /sbin/init /init || exit 1 + echo +} + +do_build() { + echo "Building NetworkManager..." + cp nm-make-script.sh $TREE/usr/local/sbin/nm-make-script || exit 1 + mock -r "$ROOT" --chroot "/usr/local/sbin/nm-make-script $NM_BRANCH" || exit 1 + test -f "$TREE/usr/sbin/NetworkManager" || ( echo "NetworkManager binary not found"; exit 1; ) + echo +} + +do_live_vm() { + echo "Preparing kernel and initrd..." || exit 1 + mkdir -p $NAME || exit 1 + cp $TREE/boot/vmlinuz* $NAME/vmlinuz || exit 1 + { ( cd "$TREE" && find -print0 | cpio -o0c ) || exit 1; } | gzip > $NAME/initramfs.img || exit 1 + cp run.sh $NAME/run.sh +} + +do_archive() { + echo "Creating the archive..." + tar -czvf $NAME.tar.gz $NAME || exit 1 + cat self-extract.sh ${NAME}.tar.gz > ${NAME}-bundle.sh || exit 1 + chmod +x ${NAME}-bundle.sh || exit 1 + echo "Successfully completed" + echo + echo "Now you can run and/or distribute: ${NAME}-bundle.sh" +} + + +if [ "$1" = "-n" ]; then + test -n "$2" || { echo "Name for initramfs is expected"; exit 1; } + NAME=$2 + shift 2 +fi + +if [ "$1" = "-b" ]; then + test -n "$2" || { echo "NM branch (commit) is expected"; exit 1; } + NM_BRANCH=$2 + shift 2 +fi + +if [ $# -eq 0 ]; then + do_prepare + do_chroot + do_build + do_live_vm + do_archive + exit 0 +fi + +while [ $# -gt 0 ]; do + do_$1; shift + exit 0 +done + +echo "Wrong number of arguments." +exit 1 diff --git a/contrib/fedora/nm-live-vm/nm-make-script.sh b/contrib/fedora/nm-live-vm/nm-make-script.sh new file mode 100755 index 000000000..39d53f6cf --- /dev/null +++ b/contrib/fedora/nm-live-vm/nm-make-script.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +BRANCH=${1:-"master"} +COMMIT=origin/$BRANCH + +cd / +passwd -d root +test -d NetworkManager || git clone git://anongit.freedesktop.org/NetworkManager/NetworkManager || exit 1 +cd NetworkManager/ || exit 1 +git fetch +git checkout -f $COMMIT || exit 1 +./autogen.sh --prefix=/ --exec-prefix=/usr --libdir=/usr/lib --datadir=/usr/share --mandir=/usr/share/man --enable-doc || exit 1 +make || exit 1 +#make check || exit 1 +make install || exit 1 +echo -e "[main]\nplugins=ifcfg-rh\n" > /etc/NetworkManager/NetworkManager.conf +/bin/systemctl enable NetworkManager.service || exit 1 diff --git a/contrib/fedora/nm-live-vm/run.sh b/contrib/fedora/nm-live-vm/run.sh new file mode 100755 index 000000000..827cd0c1c --- /dev/null +++ b/contrib/fedora/nm-live-vm/run.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +OS="Linux" +if [ -f /etc/redhat-release ]; then + OS=`cat /etc/redhat-release | cut -d" " -f1,2,3,4` +fi + +if [ "$OS" == "Red Hat Enterprise Linux" ]; then + # qemu-kvm is installed in /usr/libexec on RHEL6 + # and redirects its output to VNC server + + rpm -q qemu-kvm tigervnc >&2 || exit 1 + + PATH=$PATH:/usr/libexec + + qemu-kvm -vnc :0 -m 2048 -net nic -net user -net nic -net user -net nic -net user -kernel vmlinuz -append video='1024x768' -initrd initramfs.img & + + sleep 1 + vncviewer localhost + +else + # all other distros + + QEMU="qemu-kvm" + which $QEMU &>2 || { + ARCH=`uname -m` + which qemu-system-$ARCH &>2 || { echo "Neither '$QEMU' nor 'qemu-system-$ARCH' available"; exit 1; } + QEMU="qemu-system-$ARCH -enable-kvm" + } + + $QEMU -m 2048 -net nic -net user -net nic -net user -net nic -net user -kernel vmlinuz -append video='1024x768' -initrd initramfs.img + +fi diff --git a/contrib/fedora/nm-live-vm/self-extract.sh b/contrib/fedora/nm-live-vm/self-extract.sh new file mode 100644 index 000000000..ac84da53d --- /dev/null +++ b/contrib/fedora/nm-live-vm/self-extract.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +SCRIPT_NAME=`basename $0` +NAME=${SCRIPT_NAME%%-bundle.sh} +[ $SCRIPT_NAME = $NAME ] && NAME=nm-live-vm +BUNDLE=`readlink -f "$0"` || exit 1 +TEMP=`mktemp -d "$PWD/$NAME.XXXXXXXXXX"` || exit 1 + +echo "Extracting to: $TEMP" +cd "$TEMP" || exit 1 +sed '1,/^__MARK__$/d' "$BUNDLE" > $NAME.tar.gz || exit 1 +tar -xvf $NAME.tar.gz || exit 1 +cd $NAME || exit 1 + +./run.sh || exit 1 + +rm -rf "$TEMP" +exit 0 +__MARK__ From 514d594e9d247a71872fa7507031d1b4abc55fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Thu, 25 Apr 2013 15:26:47 +0200 Subject: [PATCH 02/27] contrib/nm-live-vm: add 'gdb' to the VM It is very helful for testing the size doesn't hurt (~ 2 MB) --- contrib/fedora/nm-live-vm/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh index ee8f6a551..085d578ad 100755 --- a/contrib/fedora/nm-live-vm/build.sh +++ b/contrib/fedora/nm-live-vm/build.sh @@ -8,7 +8,7 @@ ROOT="fedora-18-$ARCH" TREE="/var/lib/mock/$ROOT/root" PACKAGES="kernel passwd git autoconf automake libtool intltool gtk-doc libnl3-devel dbus-glib-devel libgudev1-devel libuuid-devel nss-devel ppp-devel dhclient - bash-completion man-db man-pages vim-minimal" + bash-completion man-db man-pages vim-minimal gdb" KERNEL_URL=http://kojipkgs.fedoraproject.org/packages/kernel/3.8.5/201.fc18/i686/kernel-3.8.5-201.fc18.i686.rpm KERNEL=`basename "${KERNEL_URL%.rpm}"` #RELEASE="http://kojipkgs.fedoraproject.org/packages/fedora-release/18/1/noarch/fedora-release-18-1.noarch.rpm" From f1c0a1a85ba832e7457af488305474550937610b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Mon, 29 Apr 2013 15:02:51 +0200 Subject: [PATCH 03/27] contrib/nm-live-vm: put the archive name explicitly inside the bundled script Getting the archive name from the bundled script file name is fragile. --- contrib/fedora/nm-live-vm/build.sh | 3 ++- contrib/fedora/nm-live-vm/self-extract.sh | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh index 085d578ad..69ca7741b 100755 --- a/contrib/fedora/nm-live-vm/build.sh +++ b/contrib/fedora/nm-live-vm/build.sh @@ -50,7 +50,8 @@ do_live_vm() { do_archive() { echo "Creating the archive..." tar -czvf $NAME.tar.gz $NAME || exit 1 - cat self-extract.sh ${NAME}.tar.gz > ${NAME}-bundle.sh || exit 1 + EXTRACT_SCRIPT=$(sed -e "s/__NAME_PLACEHOLDER__/$NAME/g" < self-extract.sh) + echo "$EXTRACT_SCRIPT" | cat - ${NAME}.tar.gz > ${NAME}-bundle.sh || exit 1 chmod +x ${NAME}-bundle.sh || exit 1 echo "Successfully completed" echo diff --git a/contrib/fedora/nm-live-vm/self-extract.sh b/contrib/fedora/nm-live-vm/self-extract.sh index ac84da53d..3fa29a6b4 100644 --- a/contrib/fedora/nm-live-vm/self-extract.sh +++ b/contrib/fedora/nm-live-vm/self-extract.sh @@ -1,8 +1,6 @@ #!/bin/sh -SCRIPT_NAME=`basename $0` -NAME=${SCRIPT_NAME%%-bundle.sh} -[ $SCRIPT_NAME = $NAME ] && NAME=nm-live-vm +NAME=__NAME_PLACEHOLDER__ BUNDLE=`readlink -f "$0"` || exit 1 TEMP=`mktemp -d "$PWD/$NAME.XXXXXXXXXX"` || exit 1 From ebc11835429bf7bd949ed4488929dbbd0d75003b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Thu, 16 May 2013 12:18:31 +0200 Subject: [PATCH 04/27] contrib/nm-live-vm: documentation/man pages now depend on '--enable-gtk-doc' --- contrib/fedora/nm-live-vm/nm-make-script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/fedora/nm-live-vm/nm-make-script.sh b/contrib/fedora/nm-live-vm/nm-make-script.sh index 39d53f6cf..d5ffed013 100755 --- a/contrib/fedora/nm-live-vm/nm-make-script.sh +++ b/contrib/fedora/nm-live-vm/nm-make-script.sh @@ -9,7 +9,7 @@ test -d NetworkManager || git clone git://anongit.freedesktop.org/NetworkManager cd NetworkManager/ || exit 1 git fetch git checkout -f $COMMIT || exit 1 -./autogen.sh --prefix=/ --exec-prefix=/usr --libdir=/usr/lib --datadir=/usr/share --mandir=/usr/share/man --enable-doc || exit 1 +./autogen.sh --prefix=/ --exec-prefix=/usr --libdir=/usr/lib --datadir=/usr/share --mandir=/usr/share/man --enable-gtk-doc || exit 1 make || exit 1 #make check || exit 1 make install || exit 1 From c976724571f6f3bab700e99ee7caaa6807110039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Fri, 19 Jul 2013 14:38:07 +0200 Subject: [PATCH 05/27] contrib/nm-live-vm: correct and simplify paths for configure --- contrib/fedora/nm-live-vm/nm-make-script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/fedora/nm-live-vm/nm-make-script.sh b/contrib/fedora/nm-live-vm/nm-make-script.sh index d5ffed013..d96e97030 100755 --- a/contrib/fedora/nm-live-vm/nm-make-script.sh +++ b/contrib/fedora/nm-live-vm/nm-make-script.sh @@ -9,7 +9,7 @@ test -d NetworkManager || git clone git://anongit.freedesktop.org/NetworkManager cd NetworkManager/ || exit 1 git fetch git checkout -f $COMMIT || exit 1 -./autogen.sh --prefix=/ --exec-prefix=/usr --libdir=/usr/lib --datadir=/usr/share --mandir=/usr/share/man --enable-gtk-doc || exit 1 +./autogen.sh --prefix=/usr --exec-prefix=/usr --libdir=/usr/lib --sysconfdir=/etc --localstatedir=/var --enable-gtk-doc || exit 1 make || exit 1 #make check || exit 1 make install || exit 1 From b22b063f97467725e3c2140a3cb66324eb5eda0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Fri, 19 Jul 2013 14:40:12 +0200 Subject: [PATCH 06/27] contrib/nm-live-vm: add some debugging tools and useful utilities --- contrib/fedora/nm-live-vm/build.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh index 69ca7741b..99b5714ad 100755 --- a/contrib/fedora/nm-live-vm/build.sh +++ b/contrib/fedora/nm-live-vm/build.sh @@ -8,7 +8,10 @@ ROOT="fedora-18-$ARCH" TREE="/var/lib/mock/$ROOT/root" PACKAGES="kernel passwd git autoconf automake libtool intltool gtk-doc libnl3-devel dbus-glib-devel libgudev1-devel libuuid-devel nss-devel ppp-devel dhclient - bash-completion man-db man-pages vim-minimal gdb" + bash-completion man-db man-pages vim-minimal + firewald + gdb valgrind lsof strace nmap-ncat tcpdump + net-tools bridge-utils vconfig" KERNEL_URL=http://kojipkgs.fedoraproject.org/packages/kernel/3.8.5/201.fc18/i686/kernel-3.8.5-201.fc18.i686.rpm KERNEL=`basename "${KERNEL_URL%.rpm}"` #RELEASE="http://kojipkgs.fedoraproject.org/packages/fedora-release/18/1/noarch/fedora-release-18-1.noarch.rpm" From b0f9302e1ff529ca84a069d2644f1ac0ed3a412d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Mon, 18 Nov 2013 13:33:53 +0100 Subject: [PATCH 07/27] contrib/nm-live-vm: add 'teamd' and 'libteam' packages to the VM for teaming to work --- contrib/fedora/nm-live-vm/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh index 99b5714ad..d0d071fcb 100755 --- a/contrib/fedora/nm-live-vm/build.sh +++ b/contrib/fedora/nm-live-vm/build.sh @@ -11,7 +11,8 @@ PACKAGES="kernel passwd git autoconf automake libtool intltool gtk-doc libnl3-de bash-completion man-db man-pages vim-minimal firewald gdb valgrind lsof strace nmap-ncat tcpdump - net-tools bridge-utils vconfig" + net-tools bridge-utils vconfig + teamd libteam" KERNEL_URL=http://kojipkgs.fedoraproject.org/packages/kernel/3.8.5/201.fc18/i686/kernel-3.8.5-201.fc18.i686.rpm KERNEL=`basename "${KERNEL_URL%.rpm}"` #RELEASE="http://kojipkgs.fedoraproject.org/packages/fedora-release/18/1/noarch/fedora-release-18-1.noarch.rpm" From 7b43e0526e61232b4262d17404ef2973f1d076c9 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 5 Nov 2013 15:30:36 +0100 Subject: [PATCH 08/27] contrib/nm-live-vm: change scripts to be run by unprevileged user The user must still be member of the 'mock' group though. Also, hack something, that the current git repositoy will be reused, so that we don't have to fetch the entire repositoy from upstream. Signed-off-by: Thomas Haller --- contrib/fedora/nm-live-vm/.gitignore | 4 ++ contrib/fedora/nm-live-vm/build.sh | 63 ++++++++++++++++++--- contrib/fedora/nm-live-vm/nm-make-script.sh | 33 ++++++++--- 3 files changed, 85 insertions(+), 15 deletions(-) create mode 100644 contrib/fedora/nm-live-vm/.gitignore diff --git a/contrib/fedora/nm-live-vm/.gitignore b/contrib/fedora/nm-live-vm/.gitignore new file mode 100644 index 000000000..0f63e25c1 --- /dev/null +++ b/contrib/fedora/nm-live-vm/.gitignore @@ -0,0 +1,4 @@ +.build.log +nm-live-vm/ +nm-live-vm.tar.gz +nm-live-vm-bundle.sh diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh index d0d071fcb..b308076b0 100755 --- a/contrib/fedora/nm-live-vm/build.sh +++ b/contrib/fedora/nm-live-vm/build.sh @@ -1,10 +1,36 @@ #!/bin/bash + +set -vx + +die() { + echo "$@" >&2 + exit 1 +} + +BASEDIR="$(readlink -f "$(dirname "$0")")" +cd "$BASEDIR" || die "Could not switch directory." + +# copy output also to logfile +exec > >(tee ./.build.log) +exec 2>&1 + +if git rev-parse --git-dir 2> /dev/null; then + INSIDE_GIT=1 +else + INSIDE_GIT= +fi + NAME="nm-live-vm" -NM_BRANCH="master" +if [[ $INSIDE_GIT ]]; then + NM_BRANCH="HEAD" +else + NM_BRANCH=master +fi + BUILD_PACKAGES="qemu febootstrap mock rpmdevtools" ARCH=i386 -ROOT="fedora-18-$ARCH" +ROOT="${ROOT:-"fedora-18-$ARCH"}" TREE="/var/lib/mock/$ROOT/root" PACKAGES="kernel passwd git autoconf automake libtool intltool gtk-doc libnl3-devel dbus-glib-devel libgudev1-devel libuuid-devel nss-devel ppp-devel dhclient @@ -18,10 +44,13 @@ KERNEL=`basename "${KERNEL_URL%.rpm}"` #RELEASE="http://kojipkgs.fedoraproject.org/packages/fedora-release/18/1/noarch/fedora-release-18-1.noarch.rpm" #PACKAGES="systemd bash" -test "$EUID" -eq 0 || { echo "$0 must be run as root"; exit 1; } +check_root() { + test "$EUID" -eq 0 +} do_prepare() { echo "Installing build packages..." + check_root || die "$0 must be run as root" rpm -q $BUILD_PACKAGES || yum install $BUILD_PACKAGES || exit 1 echo } @@ -37,9 +66,22 @@ do_chroot() { do_build() { echo "Building NetworkManager..." - cp nm-make-script.sh $TREE/usr/local/sbin/nm-make-script || exit 1 - mock -r "$ROOT" --chroot "/usr/local/sbin/nm-make-script $NM_BRANCH" || exit 1 - test -f "$TREE/usr/sbin/NetworkManager" || ( echo "NetworkManager binary not found"; exit 1; ) + + if [[ $INSIDE_GIT ]]; then + # make first a local, bare clone of our git repository and copy it into the chroot. + # nm-make-script.sh will try to fetch from it first, to save bandwidth + GIT1="`git rev-parse --show-toplevel`" + GIT2="`mktemp --tmpdir -d nm.git-XXXXXXXXX`" + git clone --bare "$GIT1" "$GIT2" || die "Could not make local clone of git dir" + mock -r "$ROOT" --chroot 'rm -rf /NetworkManager-local.git' + mock -r "$ROOT" --copyin "$GIT2" "/NetworkManager-local.git" || die "Could not copy local repositoy" + rm -rf "$GIT2" + fi + + # run the make script in chroot. + mock -r "$ROOT" --copyin nm-make-script.sh "/usr/local/sbin/" || exit 1 + mock -r "$ROOT" --chroot "/usr/local/sbin/nm-make-script.sh \"$NM_BRANCH\"" || exit 1 + test -f "$TREE/usr/sbin/NetworkManager" || die "NetworkManager binary not found" echo } @@ -47,7 +89,8 @@ do_live_vm() { echo "Preparing kernel and initrd..." || exit 1 mkdir -p $NAME || exit 1 cp $TREE/boot/vmlinuz* $NAME/vmlinuz || exit 1 - { ( cd "$TREE" && find -print0 | cpio -o0c ) || exit 1; } | gzip > $NAME/initramfs.img || exit 1 + mock -r "$ROOT" --chroot "{ ( cd / ; find -not \( -path ./tmp/initramfs.img -o -path './var/cache/yum/*' -o -path './boot' -o -path './NetworkManager' \) -xdev -print0 | cpio -o0c ) || exit 1; } | gzip > /tmp/initramfs.img || exit 1" || die "error creating initramfs" + cp "$TREE/tmp/initramfs.img" "$NAME/" || exit 1 cp run.sh $NAME/run.sh } @@ -75,8 +118,12 @@ if [ "$1" = "-b" ]; then shift 2 fi +if [[ $INSIDE_GIT ]]; then + NM_BRANCH="$(git rev-parse -q --verify "$NM_BRANCH")" || die "Could not resolve branch $NM_BRANCH" +fi + if [ $# -eq 0 ]; then - do_prepare + check_root && do_prepare do_chroot do_build do_live_vm diff --git a/contrib/fedora/nm-live-vm/nm-make-script.sh b/contrib/fedora/nm-live-vm/nm-make-script.sh index d96e97030..bdd458db6 100755 --- a/contrib/fedora/nm-live-vm/nm-make-script.sh +++ b/contrib/fedora/nm-live-vm/nm-make-script.sh @@ -1,14 +1,33 @@ #!/bin/bash -BRANCH=${1:-"master"} -COMMIT=origin/$BRANCH +set -vx + +die() { + echo "$@" >&2 + exit 1 +} + +COMMIT=${1:-origin/master} + +URL="${2:-"git://anongit.freedesktop.org/NetworkManager/NetworkManager"}" -cd / passwd -d root -test -d NetworkManager || git clone git://anongit.freedesktop.org/NetworkManager/NetworkManager || exit 1 -cd NetworkManager/ || exit 1 -git fetch -git checkout -f $COMMIT || exit 1 +test -d /NetworkManager || ( + git init /NetworkManager + cd /NetworkManager + + # check if there is a local git repository and fetch from it first (should be faster) + test -d "/NetworkManager-local.git" && ( + git remote add local "/NetworkManager-local.git" + git fetch local + git remote remove local + rm -rf "/NetworkManager-local.git" + ) + git remote add origin "$URL" +) +cd /NetworkManager/ || exit 1 +git fetch origin || die "Could not fetch $URL" +git checkout -f "$COMMIT" || exit 1 ./autogen.sh --prefix=/usr --exec-prefix=/usr --libdir=/usr/lib --sysconfdir=/etc --localstatedir=/var --enable-gtk-doc || exit 1 make || exit 1 #make check || exit 1 From e9ed87a920f57f4c3b8d2f348374c4f2fe1d11e6 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 23 Nov 2013 19:34:30 +0100 Subject: [PATCH 09/27] contrib/nm-live-vm: adjust build script to enable DEBUG logging Enable more logging when starting NM. Signed-off-by: Thomas Haller --- contrib/fedora/nm-live-vm/nm-make-script.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/fedora/nm-live-vm/nm-make-script.sh b/contrib/fedora/nm-live-vm/nm-make-script.sh index bdd458db6..c5c26efe1 100755 --- a/contrib/fedora/nm-live-vm/nm-make-script.sh +++ b/contrib/fedora/nm-live-vm/nm-make-script.sh @@ -32,5 +32,11 @@ git checkout -f "$COMMIT" || exit 1 make || exit 1 #make check || exit 1 make install || exit 1 -echo -e "[main]\nplugins=ifcfg-rh\n" > /etc/NetworkManager/NetworkManager.conf +cat < /etc/NetworkManager/NetworkManager.conf +[main] +plugins=ifcfg-rh +[logging] +level=DEBUG +domains=ALL +EOF /bin/systemctl enable NetworkManager.service || exit 1 From 9b3922390c71842fcda5c66073db4f4491739359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Thu, 30 Jan 2014 13:01:18 +0100 Subject: [PATCH 10/27] contrib/nm-live-vm: update scripts to make VM based on Fedora 20 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jiří Klimeš --- contrib/fedora/nm-live-vm/README | 14 +++++++------- contrib/fedora/nm-live-vm/build.sh | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/contrib/fedora/nm-live-vm/README b/contrib/fedora/nm-live-vm/README index c0da9e35b..75cff68a0 100644 --- a/contrib/fedora/nm-live-vm/README +++ b/contrib/fedora/nm-live-vm/README @@ -1,20 +1,20 @@ NetworkManager live VM scripts ------------------------------ -This set of scripts can be used to build a live initramfs image suitable -for testing NetworkManager in a virtual environment. The scripts themselves -are intended to be used by a power user who can adapt them to their needs. -The result, on the contrary, is intended to be used by anyone who wants to -play with NetworkManager on the command line. +This set of scripts can be used to build a live initramfs image suitable for +testing NetworkManager in a virtual environment. The scripts themselves are +intended to be used by a power user who can adapt them to their needs. The +result, on the contrary, is intended to be used by anyone who wants to play +with NetworkManager on the command line. Building the initramfs image: sudo ./build.sh [-n name] [-b branch/commit] You may have to update ./build.sh to suit your distribution. The included -is prepared for Fedora 18 and the image is also build using Fedora 18 +version is prepared for Fedora 20 and the image is also build using Fedora 20 repositories. -Then you can distribute the self-extracting archive and run in on other machines: +Then you can distribute the self-extracting archive and run it on other machines: ./nm-live-vm-bundle.sh diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh index b308076b0..1a36ba899 100755 --- a/contrib/fedora/nm-live-vm/build.sh +++ b/contrib/fedora/nm-live-vm/build.sh @@ -30,7 +30,7 @@ fi BUILD_PACKAGES="qemu febootstrap mock rpmdevtools" ARCH=i386 -ROOT="${ROOT:-"fedora-18-$ARCH"}" +ROOT="${ROOT:-"fedora-20-$ARCH"}" TREE="/var/lib/mock/$ROOT/root" PACKAGES="kernel passwd git autoconf automake libtool intltool gtk-doc libnl3-devel dbus-glib-devel libgudev1-devel libuuid-devel nss-devel ppp-devel dhclient @@ -39,9 +39,9 @@ PACKAGES="kernel passwd git autoconf automake libtool intltool gtk-doc libnl3-de gdb valgrind lsof strace nmap-ncat tcpdump net-tools bridge-utils vconfig teamd libteam" -KERNEL_URL=http://kojipkgs.fedoraproject.org/packages/kernel/3.8.5/201.fc18/i686/kernel-3.8.5-201.fc18.i686.rpm +KERNEL_URL=http://kojipkgs.fedoraproject.org/packages/kernel/3.12.9/301.fc20/i686/kernel-3.12.9-301.fc20.i686.rpm KERNEL=`basename "${KERNEL_URL%.rpm}"` -#RELEASE="http://kojipkgs.fedoraproject.org/packages/fedora-release/18/1/noarch/fedora-release-18-1.noarch.rpm" +#RELEASE="http://kojipkgs.fedoraproject.org/packages/fedora-release/20/1/noarch/fedora-release-20-1.noarch.rpm" #PACKAGES="systemd bash" check_root() { From 26626c75c3a013a1d82d7ea1586c0a7dbcede101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Thu, 30 Jan 2014 16:26:55 +0100 Subject: [PATCH 11/27] contrib/nm-live-vm: put qemu network-related options into a variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jiří Klimeš --- contrib/fedora/nm-live-vm/run.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/contrib/fedora/nm-live-vm/run.sh b/contrib/fedora/nm-live-vm/run.sh index 827cd0c1c..fb018da26 100755 --- a/contrib/fedora/nm-live-vm/run.sh +++ b/contrib/fedora/nm-live-vm/run.sh @@ -1,5 +1,8 @@ #!/bin/sh +# Three network interfaces +NET_OPTIONS="-net nic -net user -net nic -net user -net nic -net user" + OS="Linux" if [ -f /etc/redhat-release ]; then OS=`cat /etc/redhat-release | cut -d" " -f1,2,3,4` @@ -13,7 +16,7 @@ if [ "$OS" == "Red Hat Enterprise Linux" ]; then PATH=$PATH:/usr/libexec - qemu-kvm -vnc :0 -m 2048 -net nic -net user -net nic -net user -net nic -net user -kernel vmlinuz -append video='1024x768' -initrd initramfs.img & + qemu-kvm -vnc :0 -m 2048 $NET_OPTIONS -kernel vmlinuz -append video='1024x768' -initrd initramfs.img & sleep 1 vncviewer localhost @@ -28,6 +31,6 @@ else QEMU="qemu-system-$ARCH -enable-kvm" } - $QEMU -m 2048 -net nic -net user -net nic -net user -net nic -net user -kernel vmlinuz -append video='1024x768' -initrd initramfs.img + $QEMU -m 2048 -net nic $NET_OPTIONS -kernel vmlinuz -append video='1024x768' -initrd initramfs.img fi From dc872b7e52e111c26011ab674b40d6348776b250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Thu, 30 Jan 2014 17:08:02 +0100 Subject: [PATCH 12/27] contrib/nm-live-vm: add rootfstype=ramfs kernel parameter to run.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kernel changed default filesystem for roots from ramfs to tmpfs. See http://lwn.net/Articles/559176/ for more information. The change caused our initramfs to be mounted with size= parameter that equals to the actual size of unpacked initramfs. That's why mounted / was full and no space was available (without manual remounting: mount -o remount,size=100% /). So we explicitly require usage of ramfs to have all RAM of the virtual machine available for /. Signed-off-by: Jiří Klimeš --- contrib/fedora/nm-live-vm/run.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contrib/fedora/nm-live-vm/run.sh b/contrib/fedora/nm-live-vm/run.sh index fb018da26..7a5acbb7c 100755 --- a/contrib/fedora/nm-live-vm/run.sh +++ b/contrib/fedora/nm-live-vm/run.sh @@ -16,7 +16,7 @@ if [ "$OS" == "Red Hat Enterprise Linux" ]; then PATH=$PATH:/usr/libexec - qemu-kvm -vnc :0 -m 2048 $NET_OPTIONS -kernel vmlinuz -append video='1024x768' -initrd initramfs.img & + qemu-kvm -vnc :0 -m 2048 $NET_OPTIONS -kernel vmlinuz -append "video=1024x768 rootfstype=ramfs" -initrd initramfs.img & sleep 1 vncviewer localhost @@ -31,6 +31,5 @@ else QEMU="qemu-system-$ARCH -enable-kvm" } - $QEMU -m 2048 -net nic $NET_OPTIONS -kernel vmlinuz -append video='1024x768' -initrd initramfs.img - + $QEMU -m 2048 -net nic $NET_OPTIONS -kernel vmlinuz -append "video=1024x768 rootfstype=ramfs" -initrd initramfs.img fi From f20f706d341c4d3d369a0a1453e2ca2ca4ceac31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Thu, 30 Jan 2014 16:23:12 +0100 Subject: [PATCH 13/27] contrib/nm-live-vm: also build nmtui --- contrib/fedora/nm-live-vm/build.sh | 2 +- contrib/fedora/nm-live-vm/nm-make-script.sh | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh index 1a36ba899..9c30ef59a 100755 --- a/contrib/fedora/nm-live-vm/build.sh +++ b/contrib/fedora/nm-live-vm/build.sh @@ -33,7 +33,7 @@ ARCH=i386 ROOT="${ROOT:-"fedora-20-$ARCH"}" TREE="/var/lib/mock/$ROOT/root" PACKAGES="kernel passwd git autoconf automake libtool intltool gtk-doc libnl3-devel - dbus-glib-devel libgudev1-devel libuuid-devel nss-devel ppp-devel dhclient + dbus-glib-devel libgudev1-devel libuuid-devel nss-devel ppp-devel newt-devel dhclient bash-completion man-db man-pages vim-minimal firewald gdb valgrind lsof strace nmap-ncat tcpdump diff --git a/contrib/fedora/nm-live-vm/nm-make-script.sh b/contrib/fedora/nm-live-vm/nm-make-script.sh index c5c26efe1..9c519bd75 100755 --- a/contrib/fedora/nm-live-vm/nm-make-script.sh +++ b/contrib/fedora/nm-live-vm/nm-make-script.sh @@ -28,7 +28,13 @@ test -d /NetworkManager || ( cd /NetworkManager/ || exit 1 git fetch origin || die "Could not fetch $URL" git checkout -f "$COMMIT" || exit 1 -./autogen.sh --prefix=/usr --exec-prefix=/usr --libdir=/usr/lib --sysconfdir=/etc --localstatedir=/var --enable-gtk-doc || exit 1 +./autogen.sh --prefix=/usr \ + --exec-prefix=/usr \ + --libdir=/usr/lib \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --with-nmtui=yes \ + --enable-gtk-doc || exit 1 make || exit 1 #make check || exit 1 make install || exit 1 From 84b3e924df36ff93b73ffc642ea1aa8ac187b20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Mon, 10 Feb 2014 16:19:39 +0100 Subject: [PATCH 14/27] contrib/nm-live-vm: fix build - libndp-devel is now required --- contrib/fedora/nm-live-vm/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh index 9c30ef59a..d88c0c6f1 100755 --- a/contrib/fedora/nm-live-vm/build.sh +++ b/contrib/fedora/nm-live-vm/build.sh @@ -33,7 +33,8 @@ ARCH=i386 ROOT="${ROOT:-"fedora-20-$ARCH"}" TREE="/var/lib/mock/$ROOT/root" PACKAGES="kernel passwd git autoconf automake libtool intltool gtk-doc libnl3-devel - dbus-glib-devel libgudev1-devel libuuid-devel nss-devel ppp-devel newt-devel dhclient + dbus-glib-devel libgudev1-devel libuuid-devel nss-devel ppp-devel newt-devel libndp-devel + dhclient bash-completion man-db man-pages vim-minimal firewald gdb valgrind lsof strace nmap-ncat tcpdump From ef052ead888de8a9f71a6c21e902e8b872989ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Mon, 10 Feb 2014 16:21:18 +0100 Subject: [PATCH 15/27] contrib/nm-live-vm: add dnsmasq to the VM --- contrib/fedora/nm-live-vm/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh index d88c0c6f1..c74e775a2 100755 --- a/contrib/fedora/nm-live-vm/build.sh +++ b/contrib/fedora/nm-live-vm/build.sh @@ -34,7 +34,7 @@ ROOT="${ROOT:-"fedora-20-$ARCH"}" TREE="/var/lib/mock/$ROOT/root" PACKAGES="kernel passwd git autoconf automake libtool intltool gtk-doc libnl3-devel dbus-glib-devel libgudev1-devel libuuid-devel nss-devel ppp-devel newt-devel libndp-devel - dhclient + dhclient dnsmasq bash-completion man-db man-pages vim-minimal firewald gdb valgrind lsof strace nmap-ncat tcpdump From f2878b76333984ffda9189828f78b11faa07c568 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 27 Feb 2014 18:16:33 +0100 Subject: [PATCH 16/27] contrib/nm-live-vm: compile live-vm build without compiler optimization Signed-off-by: Thomas Haller --- contrib/fedora/nm-live-vm/nm-make-script.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/fedora/nm-live-vm/nm-make-script.sh b/contrib/fedora/nm-live-vm/nm-make-script.sh index 9c519bd75..adbb4848f 100755 --- a/contrib/fedora/nm-live-vm/nm-make-script.sh +++ b/contrib/fedora/nm-live-vm/nm-make-script.sh @@ -28,6 +28,9 @@ test -d /NetworkManager || ( cd /NetworkManager/ || exit 1 git fetch origin || die "Could not fetch $URL" git checkout -f "$COMMIT" || exit 1 +git clean -fdx +export CFLAGS='-g -Og' +export CXXFLAGS='-g -Og' ./autogen.sh --prefix=/usr \ --exec-prefix=/usr \ --libdir=/usr/lib \ From fbc9c41e96b07798d08bba355dea8985d1b9c2f2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 27 Feb 2014 18:55:59 +0100 Subject: [PATCH 17/27] contrib/nm-live-vm: include the NetworkManager source in the live-mv file for debugging Signed-off-by: Thomas Haller --- contrib/fedora/nm-live-vm/build.sh | 3 ++- contrib/fedora/nm-live-vm/nm-make-script.sh | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh index c74e775a2..8cf734795 100755 --- a/contrib/fedora/nm-live-vm/build.sh +++ b/contrib/fedora/nm-live-vm/build.sh @@ -37,6 +37,7 @@ PACKAGES="kernel passwd git autoconf automake libtool intltool gtk-doc libnl3-de dhclient dnsmasq bash-completion man-db man-pages vim-minimal firewald + vim gdb valgrind lsof strace nmap-ncat tcpdump net-tools bridge-utils vconfig teamd libteam" @@ -90,7 +91,7 @@ do_live_vm() { echo "Preparing kernel and initrd..." || exit 1 mkdir -p $NAME || exit 1 cp $TREE/boot/vmlinuz* $NAME/vmlinuz || exit 1 - mock -r "$ROOT" --chroot "{ ( cd / ; find -not \( -path ./tmp/initramfs.img -o -path './var/cache/yum/*' -o -path './boot' -o -path './NetworkManager' \) -xdev -print0 | cpio -o0c ) || exit 1; } | gzip > /tmp/initramfs.img || exit 1" || die "error creating initramfs" + mock -r "$ROOT" --chroot "{ ( cd / ; find -not \( -path ./tmp/initramfs.img -o -path './var/cache/yum/*' -o -path './boot' \) -xdev -print0 | cpio -o0c ) || exit 1; } | gzip > /tmp/initramfs.img || exit 1" || die "error creating initramfs" cp "$TREE/tmp/initramfs.img" "$NAME/" || exit 1 cp run.sh $NAME/run.sh } diff --git a/contrib/fedora/nm-live-vm/nm-make-script.sh b/contrib/fedora/nm-live-vm/nm-make-script.sh index adbb4848f..34ee49cd7 100755 --- a/contrib/fedora/nm-live-vm/nm-make-script.sh +++ b/contrib/fedora/nm-live-vm/nm-make-script.sh @@ -49,3 +49,5 @@ level=DEBUG domains=ALL EOF /bin/systemctl enable NetworkManager.service || exit 1 + +git gc From 78f94726a7e6063921cc05325519eb09c421c40b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 5 Mar 2014 18:52:19 +0100 Subject: [PATCH 18/27] contrib/nm-live-vm: share a directory with the live-vm Signed-off-by: Thomas Haller --- contrib/fedora/nm-live-vm/nm-make-script.sh | 3 +++ contrib/fedora/nm-live-vm/run.sh | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/contrib/fedora/nm-live-vm/nm-make-script.sh b/contrib/fedora/nm-live-vm/nm-make-script.sh index 34ee49cd7..79e1dff86 100755 --- a/contrib/fedora/nm-live-vm/nm-make-script.sh +++ b/contrib/fedora/nm-live-vm/nm-make-script.sh @@ -50,4 +50,7 @@ domains=ALL EOF /bin/systemctl enable NetworkManager.service || exit 1 +mkdir /mnt/sda1 +echo "/dev/sda1 /mnt/sda1 vfat defaults 1 2" >> /etc/fstab + git gc diff --git a/contrib/fedora/nm-live-vm/run.sh b/contrib/fedora/nm-live-vm/run.sh index 7a5acbb7c..cb8b6db7c 100755 --- a/contrib/fedora/nm-live-vm/run.sh +++ b/contrib/fedora/nm-live-vm/run.sh @@ -8,6 +8,11 @@ if [ -f /etc/redhat-release ]; then OS=`cat /etc/redhat-release | cut -d" " -f1,2,3,4` fi +DIR="$(dirname "$(readlink -f "$0")")" +SDIR="$DIR/share" + +mkdir "$SDIR" + if [ "$OS" == "Red Hat Enterprise Linux" ]; then # qemu-kvm is installed in /usr/libexec on RHEL6 # and redirects its output to VNC server @@ -31,5 +36,5 @@ else QEMU="qemu-system-$ARCH -enable-kvm" } - $QEMU -m 2048 -net nic $NET_OPTIONS -kernel vmlinuz -append "video=1024x768 rootfstype=ramfs" -initrd initramfs.img + $QEMU -m 2048 -net nic $NET_OPTIONS -drive "file=fat:rw:$SDIR,cache=none" -kernel vmlinuz -append "video=1024x768 rootfstype=ramfs" -initrd initramfs.img fi From fe267b0fd2fb31884aeab91cd4b6de9a8d1bc42c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 5 Mar 2014 17:03:48 +0100 Subject: [PATCH 19/27] contrib/nm-live-vm: enable ssh server and add port forward from localhost:10022 Signed-off-by: Thomas Haller --- contrib/fedora/nm-live-vm/build.sh | 1 + contrib/fedora/nm-live-vm/nm-make-script.sh | 5 +++++ contrib/fedora/nm-live-vm/run.sh | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh index 8cf734795..bc1f06f24 100755 --- a/contrib/fedora/nm-live-vm/build.sh +++ b/contrib/fedora/nm-live-vm/build.sh @@ -40,6 +40,7 @@ PACKAGES="kernel passwd git autoconf automake libtool intltool gtk-doc libnl3-de vim gdb valgrind lsof strace nmap-ncat tcpdump net-tools bridge-utils vconfig + openssh-server teamd libteam" KERNEL_URL=http://kojipkgs.fedoraproject.org/packages/kernel/3.12.9/301.fc20/i686/kernel-3.12.9-301.fc20.i686.rpm KERNEL=`basename "${KERNEL_URL%.rpm}"` diff --git a/contrib/fedora/nm-live-vm/nm-make-script.sh b/contrib/fedora/nm-live-vm/nm-make-script.sh index 79e1dff86..86ac67fe0 100755 --- a/contrib/fedora/nm-live-vm/nm-make-script.sh +++ b/contrib/fedora/nm-live-vm/nm-make-script.sh @@ -49,6 +49,11 @@ level=DEBUG domains=ALL EOF /bin/systemctl enable NetworkManager.service || exit 1 +/bin/systemctl enable sshd.service || exit 1 + +sed -e 's/^#\?\(PermitRootLogin *\).*/\1yes/' \ + -e 's/^#\?\(PermitEmptyPasswords *\).*/\1yes/' \ + -i /etc/ssh/sshd_config mkdir /mnt/sda1 echo "/dev/sda1 /mnt/sda1 vfat defaults 1 2" >> /etc/fstab diff --git a/contrib/fedora/nm-live-vm/run.sh b/contrib/fedora/nm-live-vm/run.sh index cb8b6db7c..d0f1ed2f2 100755 --- a/contrib/fedora/nm-live-vm/run.sh +++ b/contrib/fedora/nm-live-vm/run.sh @@ -1,7 +1,7 @@ #!/bin/sh # Three network interfaces -NET_OPTIONS="-net nic -net user -net nic -net user -net nic -net user" +NET_OPTIONS="-net nic -net user,hostfwd=tcp:127.0.0.1:10022-:22 -net nic -net user -net nic -net user" OS="Linux" if [ -f /etc/redhat-release ]; then From 0689efc7689bb7da808e0848fd855dd084b64c9d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 5 Mar 2014 19:35:03 +0100 Subject: [PATCH 20/27] contrib/nm-live-vm: don't remove the temporary directory with the extracted VM image Signed-off-by: Thomas Haller --- contrib/fedora/nm-live-vm/self-extract.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/fedora/nm-live-vm/self-extract.sh b/contrib/fedora/nm-live-vm/self-extract.sh index 3fa29a6b4..754e98337 100644 --- a/contrib/fedora/nm-live-vm/self-extract.sh +++ b/contrib/fedora/nm-live-vm/self-extract.sh @@ -12,6 +12,6 @@ cd $NAME || exit 1 ./run.sh || exit 1 -rm -rf "$TEMP" +#rm -rf "$TEMP" exit 0 __MARK__ From 0178d73699b95ca7ce78d457145f0c63e8191188 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 6 Mar 2014 11:58:33 +0100 Subject: [PATCH 21/27] contrib/nm-live-vm: disable rate limiting in the journal of the VM Signed-off-by: Thomas Haller --- contrib/fedora/nm-live-vm/nm-make-script.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/fedora/nm-live-vm/nm-make-script.sh b/contrib/fedora/nm-live-vm/nm-make-script.sh index 86ac67fe0..ed3e7c910 100755 --- a/contrib/fedora/nm-live-vm/nm-make-script.sh +++ b/contrib/fedora/nm-live-vm/nm-make-script.sh @@ -51,11 +51,17 @@ EOF /bin/systemctl enable NetworkManager.service || exit 1 /bin/systemctl enable sshd.service || exit 1 +# allow login for root via SSH, without password!! sed -e 's/^#\?\(PermitRootLogin *\).*/\1yes/' \ -e 's/^#\?\(PermitEmptyPasswords *\).*/\1yes/' \ -i /etc/ssh/sshd_config +# disable rate limiting of the journal +sed -e 's/^#\?\(RateLimitInterval *= *\).*/\10/' \ + -e 's/^#\?\(RateLimitBurst *= *\).*/\10/' \ + -i /etc/systemd/journald.conf + mkdir /mnt/sda1 -echo "/dev/sda1 /mnt/sda1 vfat defaults 1 2" >> /etc/fstab +echo "/dev/sda1 /mnt/sda1 vfat defaults 0 0" >> /etc/fstab git gc From cd7c97eb1d97f80cb6971e9a6b63c0be789e5f5f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 6 Mar 2014 15:58:12 +0100 Subject: [PATCH 22/27] contrib/nm-live-vm: write /etc/fstab Everytime you call mock again, the fstab file will be reset. So, we have to write it shortly before creating the image. Signed-off-by: Thomas Haller --- contrib/fedora/nm-live-vm/build.sh | 9 ++++++++- contrib/fedora/nm-live-vm/nm-make-script.sh | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh index bc1f06f24..eb2c07044 100755 --- a/contrib/fedora/nm-live-vm/build.sh +++ b/contrib/fedora/nm-live-vm/build.sh @@ -92,7 +92,14 @@ do_live_vm() { echo "Preparing kernel and initrd..." || exit 1 mkdir -p $NAME || exit 1 cp $TREE/boot/vmlinuz* $NAME/vmlinuz || exit 1 - mock -r "$ROOT" --chroot "{ ( cd / ; find -not \( -path ./tmp/initramfs.img -o -path './var/cache/yum/*' -o -path './boot' \) -xdev -print0 | cpio -o0c ) || exit 1; } | gzip > /tmp/initramfs.img || exit 1" || die "error creating initramfs" + mock -r "$ROOT" --chroot "{ ( cd / ; \ + echo '/dev/sda1 /mnt/sda1 vfat defaults 0 0' >> /etc/fstab ; \ + find -not \( \ + -path ./tmp/initramfs.img -o \ + -path './var/cache/yum/*' -o \ + -path './boot' \ + \) -xdev -print0 | \ + cpio -o0c ) || exit 1; } | gzip > /tmp/initramfs.img || exit 1" || die "error creating initramfs" cp "$TREE/tmp/initramfs.img" "$NAME/" || exit 1 cp run.sh $NAME/run.sh } diff --git a/contrib/fedora/nm-live-vm/nm-make-script.sh b/contrib/fedora/nm-live-vm/nm-make-script.sh index ed3e7c910..4717600a5 100755 --- a/contrib/fedora/nm-live-vm/nm-make-script.sh +++ b/contrib/fedora/nm-live-vm/nm-make-script.sh @@ -62,6 +62,5 @@ sed -e 's/^#\?\(RateLimitInterval *= *\).*/\10/' \ -i /etc/systemd/journald.conf mkdir /mnt/sda1 -echo "/dev/sda1 /mnt/sda1 vfat defaults 0 0" >> /etc/fstab git gc From acfb0b1bbf876da2038aee38b27917760b4fd8e7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 7 Mar 2014 11:11:55 +0100 Subject: [PATCH 23/27] contrib/nm-live-vm: enable option main.debug for NM in VM Signed-off-by: Thomas Haller --- contrib/fedora/nm-live-vm/nm-make-script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/fedora/nm-live-vm/nm-make-script.sh b/contrib/fedora/nm-live-vm/nm-make-script.sh index 4717600a5..131e8f36a 100755 --- a/contrib/fedora/nm-live-vm/nm-make-script.sh +++ b/contrib/fedora/nm-live-vm/nm-make-script.sh @@ -44,6 +44,7 @@ make install || exit 1 cat < /etc/NetworkManager/NetworkManager.conf [main] plugins=ifcfg-rh +debug=RLIMIT_CORE [logging] level=DEBUG domains=ALL From 6a5c05e61a8808c935e71735687e7e88507982e5 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 7 Mar 2014 13:56:55 +0100 Subject: [PATCH 24/27] contrib/nm-live-vm: install wget and setup bashrc and git Signed-off-by: Thomas Haller --- contrib/fedora/nm-live-vm/build.sh | 1 + contrib/fedora/nm-live-vm/nm-make-script.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh index eb2c07044..ab2227105 100755 --- a/contrib/fedora/nm-live-vm/build.sh +++ b/contrib/fedora/nm-live-vm/build.sh @@ -38,6 +38,7 @@ PACKAGES="kernel passwd git autoconf automake libtool intltool gtk-doc libnl3-de bash-completion man-db man-pages vim-minimal firewald vim + wget gdb valgrind lsof strace nmap-ncat tcpdump net-tools bridge-utils vconfig openssh-server diff --git a/contrib/fedora/nm-live-vm/nm-make-script.sh b/contrib/fedora/nm-live-vm/nm-make-script.sh index 131e8f36a..f987842ef 100755 --- a/contrib/fedora/nm-live-vm/nm-make-script.sh +++ b/contrib/fedora/nm-live-vm/nm-make-script.sh @@ -52,6 +52,18 @@ EOF /bin/systemctl enable NetworkManager.service || exit 1 /bin/systemctl enable sshd.service || exit 1 +git config --global user.name "NetworkManager Test VM" +git config --global user.email "networkmanager-maint@gnome.bugs" + +cat < /root/.vimrc +EOF + +cat < /root/.bashrc +LS_OPTIONS='--color=auto -Q' +alias l='ls \$LS_OPTIONS -la' +alias ll='ls \$LS_OPTIONS -l' +EOF + # allow login for root via SSH, without password!! sed -e 's/^#\?\(PermitRootLogin *\).*/\1yes/' \ -e 's/^#\?\(PermitEmptyPasswords *\).*/\1yes/' \ From c274725dc3f19dc718db87a8b5a6e04d816d8a65 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 7 Mar 2014 13:58:23 +0100 Subject: [PATCH 25/27] contrib/nm-live-vm: start the VM with less memory (1024 mb) Signed-off-by: Thomas Haller --- contrib/fedora/nm-live-vm/run.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/fedora/nm-live-vm/run.sh b/contrib/fedora/nm-live-vm/run.sh index d0f1ed2f2..189650b84 100755 --- a/contrib/fedora/nm-live-vm/run.sh +++ b/contrib/fedora/nm-live-vm/run.sh @@ -10,6 +10,7 @@ fi DIR="$(dirname "$(readlink -f "$0")")" SDIR="$DIR/share" +MEMORY=$((3*1024)) mkdir "$SDIR" @@ -21,7 +22,7 @@ if [ "$OS" == "Red Hat Enterprise Linux" ]; then PATH=$PATH:/usr/libexec - qemu-kvm -vnc :0 -m 2048 $NET_OPTIONS -kernel vmlinuz -append "video=1024x768 rootfstype=ramfs" -initrd initramfs.img & + qemu-kvm -vnc :0 -m $MEMORY $NET_OPTIONS -kernel vmlinuz -append "video=1024x768 rootfstype=ramfs" -initrd initramfs.img & sleep 1 vncviewer localhost @@ -36,5 +37,5 @@ else QEMU="qemu-system-$ARCH -enable-kvm" } - $QEMU -m 2048 -net nic $NET_OPTIONS -drive "file=fat:rw:$SDIR,cache=none" -kernel vmlinuz -append "video=1024x768 rootfstype=ramfs" -initrd initramfs.img + $QEMU -m $MEMORY -net nic $NET_OPTIONS -drive "file=fat:rw:$SDIR,cache=none" -kernel vmlinuz -append "video=1024x768 rootfstype=ramfs" -initrd initramfs.img fi From 04591cfa2e91fbf2d125f692c5a06ff677cfb40f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 21 May 2014 10:05:08 +0200 Subject: [PATCH 26/27] contrib/nm-live-vm: fix run.sh script to into script directory run.sh refers to the image file via relative path. Signed-off-by: Thomas Haller --- contrib/fedora/nm-live-vm/run.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/fedora/nm-live-vm/run.sh b/contrib/fedora/nm-live-vm/run.sh index 189650b84..cd9f7c238 100755 --- a/contrib/fedora/nm-live-vm/run.sh +++ b/contrib/fedora/nm-live-vm/run.sh @@ -14,6 +14,8 @@ MEMORY=$((3*1024)) mkdir "$SDIR" +cd "$DIR" + if [ "$OS" == "Red Hat Enterprise Linux" ]; then # qemu-kvm is installed in /usr/libexec on RHEL6 # and redirects its output to VNC server From 031142000a7b1861043c44972e8c81f714dc6fef Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 27 Jun 2014 13:02:42 +0200 Subject: [PATCH 27/27] contrib/nm-live-vm: install required packages readline, gobject-introspection, and pygobject3 Signed-off-by: Thomas Haller --- contrib/fedora/nm-live-vm/build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/fedora/nm-live-vm/build.sh b/contrib/fedora/nm-live-vm/build.sh index ab2227105..e31d021b9 100755 --- a/contrib/fedora/nm-live-vm/build.sh +++ b/contrib/fedora/nm-live-vm/build.sh @@ -34,6 +34,9 @@ ROOT="${ROOT:-"fedora-20-$ARCH"}" TREE="/var/lib/mock/$ROOT/root" PACKAGES="kernel passwd git autoconf automake libtool intltool gtk-doc libnl3-devel dbus-glib-devel libgudev1-devel libuuid-devel nss-devel ppp-devel newt-devel libndp-devel + readline-devel + gobject-introspection-devel + pygobject3 dhclient dnsmasq bash-completion man-db man-pages vim-minimal firewald