mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-05 12:40:16 +01:00
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).
This commit is contained in:
parent
2469601a0e
commit
39fdae3799
5 changed files with 177 additions and 0 deletions
20
contrib/fedora/nm-live-vm/README
Normal file
20
contrib/fedora/nm-live-vm/README
Normal file
|
|
@ -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
|
||||
88
contrib/fedora/nm-live-vm/build.sh
Executable file
88
contrib/fedora/nm-live-vm/build.sh
Executable file
|
|
@ -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
|
||||
17
contrib/fedora/nm-live-vm/nm-make-script.sh
Executable file
17
contrib/fedora/nm-live-vm/nm-make-script.sh
Executable file
|
|
@ -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
|
||||
33
contrib/fedora/nm-live-vm/run.sh
Executable file
33
contrib/fedora/nm-live-vm/run.sh
Executable file
|
|
@ -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
|
||||
19
contrib/fedora/nm-live-vm/self-extract.sh
Normal file
19
contrib/fedora/nm-live-vm/self-extract.sh
Normal file
|
|
@ -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__
|
||||
Loading…
Add table
Reference in a new issue