[PATCH] sysprep: handle distro specific sysv scripts
by Olaf Hering
Currently firstboot would only work on redhat-based images.
Handle redhat-based, suse-based and debian guests, error out in case of an
unknown distro.
Update firstboot.sh:
- make sure scripts exists and can be executed
- add LSB header to avoid insserv warnings later on
- run script only if called with "start"
Update functions, pass only required options.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
diff --git a/sysprep/firstboot.ml b/sysprep/firstboot.ml
index 97cd8a9..c5296a1 100644
--- a/sysprep/firstboot.ml
+++ b/sysprep/firstboot.ml
@@ -28,14 +28,35 @@ let firstboot_dir = "/usr/lib/virt-sysprep"
let firstboot_sh = sprintf "\
#!/bin/sh -
+### BEGIN INIT INFO
+# Provides: virt-sysprep
+# Required-Start: $null
+# Should-Start: $all
+# Required-Stop: $null
+# Should-Stop: $all
+# Default-Start: 2 3 5
+# Default-Stop: 0 1 6
+# Short-Description: Start scripts to run once at next boot
+# Description: Start scripts to run once at next boot
+# These scripts run the first time the guest boots,
+# and then are deleted. Output or errors from the scripts
+# are written to ~root/virt-sysprep-firstboot.log.
+### END INIT INFO
+
d=%s/scripts
logfile=~root/virt-sysprep-firstboot.log
-for f in $d/* ; do
- echo '=== Running' $f '===' >>$logfile
- $f >>$logfile 2>&1
- rm $f
-done
+if test \"$1\" = \"start\"
+then
+ for f in $d/* ; do
+ if test -x \"$f\"
+ then
+ echo '=== Running' $f '===' >>$logfile
+ $f >>$logfile 2>&1
+ rm -f $f
+ fi
+ done
+fi
" firstboot_dir
let firstboot_service = sprintf "\
@@ -56,7 +77,7 @@ WantedBy=default.target
let failed fs =
ksprintf (fun msg -> failwith (s_"firstboot: failed: " ^ msg)) fs
-let rec install_service g root =
+let rec install_service g distro =
g#mkdir_p firstboot_dir;
g#mkdir_p (sprintf "%s/scripts" firstboot_dir);
g#write (sprintf "%s/firstboot.sh" firstboot_dir) firstboot_sh;
@@ -64,18 +85,18 @@ let rec install_service g root =
(* systemd, else assume sysvinit *)
if g#is_dir "/etc/systemd" then
- install_systemd_service g root
+ install_systemd_service g
else
- install_sysvinit_service g root
+ install_sysvinit_service g distro
(* Install the systemd firstboot service, if not installed already. *)
-and install_systemd_service g root =
+and install_systemd_service g =
g#write (sprintf "%s/firstboot.service" firstboot_dir) firstboot_service;
g#mkdir_p "/etc/systemd/system/default.target.wants";
g#ln_sf (sprintf "%s/firstboot.service" firstboot_dir)
"/etc/systemd/system/default.target.wants"
-and install_sysvinit_service g root =
+and install_sysvinit_redhat g =
g#mkdir_p "/etc/rc.d/rc2.d";
g#mkdir_p "/etc/rc.d/rc3.d";
g#mkdir_p "/etc/rc.d/rc5.d";
@@ -86,12 +107,51 @@ and install_sysvinit_service g root =
g#ln_sf (sprintf "%s/firstboot.sh" firstboot_dir)
"/etc/rc.d/rc5.d/99virt-sysprep-firstboot"
+(* Make firstboot.sh look like a runlevel script to avoid insserv warnings. *)
+and install_sysvinit_suse g =
+ g#mkdir_p "/etc/init.d/rc2.d";
+ g#mkdir_p "/etc/init.d/rc3.d";
+ g#mkdir_p "/etc/init.d/rc5.d";
+ g#ln_sf (sprintf "%s/firstboot.sh" firstboot_dir)
+ "/etc/init.d/virt-sysprep-firstboot";
+ g#ln_sf "../virt-sysprep-firstboot"
+ "/etc/init.d/rc2.d/S99virt-sysprep-firstboot";
+ g#ln_sf "../virt-sysprep-firstboot"
+ "/etc/init.d/rc3.d/S99virt-sysprep-firstboot";
+ g#ln_sf "../virt-sysprep-firstboot"
+ "/etc/init.d/rc5.d/S99virt-sysprep-firstboot"
+
+and install_sysvinit_debian g =
+ g#mkdir_p "/etc/init.d";
+ g#mkdir_p "/etc/rc2.d";
+ g#mkdir_p "/etc/rc3.d";
+ g#mkdir_p "/etc/rc5.d";
+ g#ln_sf (sprintf "%s/firstboot.sh" firstboot_dir)
+ "/etc/init.d/virt-sysprep-firstboot";
+ g#ln_sf "/etc/init.d/virt-sysprep-firstboot"
+ "/etc/rc2.d/S99virt-sysprep-firstboot";
+ g#ln_sf "/etc/init.d/virt-sysprep-firstboot"
+ "/etc/rc3.d/S99virt-sysprep-firstboot";
+ g#ln_sf "/etc/init.d/virt-sysprep-firstboot"
+ "/etc/rc5.d/S99virt-sysprep-firstboot"
+
+and install_sysvinit_service g distro =
+ match distro with
+ | ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based") ->
+ install_sysvinit_redhat g
+ | ("opensuse"|"sles"|"suse-based") ->
+ install_sysvinit_suse g
+ | "debian" ->
+ install_sysvinit_debian g
+ | _ ->
+ failed "guest type %s is not supported" distro
+
let add_firstboot_script g root id content =
let typ = g#inspect_get_type root in
let distro = g#inspect_get_distro root in
match typ, distro with
| "linux", _ ->
- install_service g root;
+ install_service g distro;
let t = Int64.of_float (Unix.time ()) in
let r = string_random8 () in
let filename = sprintf "%s/scripts/%Ld-%s-%s" firstboot_dir t r id in
--
1.7.12
10 years, 11 months
libguestfs 1.18.11 build error
by Evaggelos Balaskas
I am trying to build libguestfs version libguestfs-1.18.11 in my archlinux box
i am getting this error:
febootstrap: error: /lib appears as both directory and ordinary file
(glibc, ntfs-3g)
make[2]: *** [stamp-supermin] Error 1
make[2]: Leaving directory
`/mnt/downloads/dnl/PKGBUILDs/kvm/libguestfs/src/libguestfs-1.18.11/appliance'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory
`/mnt/downloads/dnl/PKGBUILDs/kvm/libguestfs/src/libguestfs-1.18.11'
make: *** [all] Error 2
==> ERROR: A failure occurred in build().
Aborting...
any pointers ?
--
Evaggelos Balaskas - Unix System Engineer
http://gr.linkedin.com/in/evaggelosbalaskas
11 years, 11 months
The road to libguestfs 1.20
by Richard W.M. Jones
I've got some bad news: libvirt remote support is probably not going
to make libguestfs 1.20. John Eckersberg is diligently working on
this, but I don't want to hold up the release of the next stable
libguestfs for this, particularly since it needs dependent changes in
libvirt.
The last stable branch of libguestfs (1.18) happened in the middle of
May. That's 7 months ago, making this the longest cycle we've ever
had by a large margin. Therefore it is time to start thinking about
the next stable version, 1.20.
As usual, bugs that need to be fixed for 1.20 should have "1.20"
(without quotes) placed in the Devel Whiteboard field in Bugzilla.
(There are currently none, but I plan to mark some). You can get a
list of these bugs using this link:
https://bugzilla.redhat.com/buglist.cgi?query_format=advanced&field0-0-0=...
( http://tinyurl.com/bx8kter )
or all bugs here:
https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virt...
The draft release notes (not quite up to date) are here so you can get
an idea of the new features:
http://libguestfs.org/guestfs-release-notes.1.html#release-notes-for-libg...
I'm planning to spend at least the next 3 weeks making the libvirt
backend stable, so that we can use this as the default in Fedora 18,
but I'm quite prepared to pull this and go with the ordinary backend
if I cannot do this. Note that the default upstream is the
non-libvirt appliance backend, and this will remain so.
If there are any other problems, please let me know.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
11 years, 12 months
febootstrap and zypper
by Olaf Hering
On Mon, Oct 08, Richard W.M. Jones wrote:
> On Mon, Oct 08, 2012 at 08:50:47PM +0200, Olaf Hering wrote:
> > On Mon, Oct 08, Richard W.M. Jones wrote:
> >
> > > But out of interest, how are you creating this appliance? I thought
> > > we'd ripped out support for old-style appliances from the rest of the
> > > toolchain ...
> >
> > I use mkinitrd to pull in all tools and run guestfsd instead of
> > /sysroot/sbin/init. This allows me to build the package automated as
> > unprivileged user in the buildsystem. Creating a loop file requires
> > root, which is cumbersome in the openSuSE buildservice.
>
> BTW, febootstrap (which is what we use) runs unprivileged and should
> be able to process SuSE rpms. However it does require yum, not
> zypper, but that's probably easy to fix if zypper has a way to take a
> list of package names and resolve all the dependencies without needing
> root and without needing to install any packages.
I just looked at this.
Does febootstrap do some sort of unrpm? Does it call %pre/%post install
scripts?
zypper alone can not be used because it calls rpm, which does chroot.
It can however download the required rpms and place them into a
directory:
zypper \
--verbose \
--verbose \
--gpg-auto-import-keys \
--root /dev/shm/${LOGNAME} \
--reposd-dir /etc/zypp/repos.d \
--pkg-cache-dir /dev/shm/${LOGNAME}--pkg-cache-dir \
--non-interactive \
install \
--auto-agree-with-licenses \
--no-recommends \
--download-only \
kernel-default
So what do you suggest to do on a system with zypper/libzypp?
Olaf
11 years, 12 months
[PATCH] Add the .mailmap and change the method to generate AUTHORS
by Wanlong Gao
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
.mailmap | 13 +++++++++++++
AUTHORS | 4 ++--
Makefile.am | 5 +----
3 files changed, 16 insertions(+), 6 deletions(-)
create mode 100644 .mailmap
diff --git a/.mailmap b/.mailmap
new file mode 100644
index 0000000..504fd79
--- /dev/null
+++ b/.mailmap
@@ -0,0 +1,13 @@
+Jim Meyering <meyering(a)redhat.com> <jim(a)meyering.net>
+Jim Meyering <meyering(a)redhat.com> <meyering(a)vv.meyering.net.meyering.net>
+Richard W.M. Jones <rjones(a)redhat.com> Richard Jones <rich(a)hakodate.home.annexia.org>
+Richard W.M. Jones <rjones(a)redhat.com> Richard Jones <rich(a)koneko.home.annexia.org>
+Richard W.M. Jones <rjones(a)redhat.com> Richard Jones <rich(a)koneko.local>
+Richard W.M. Jones <rjones(a)redhat.com> Richard Jones <rjones(a)centos5x32.home.annexia.org>
+Richard W.M. Jones <rjones(a)redhat.com> Richard Jones <rjones(a)debian5x64.home.annexia.org>
+Richard W.M. Jones <rjones(a)redhat.com> Richard Jones <rjones(a)redhat.com>
+Richard W.M. Jones <rjones(a)redhat.com> Richard Jones <rjones(a)trick.home.annexia.org>
+Richard W.M. Jones <rjones(a)redhat.com> Richard Jones <rjones(a)ubuntu910x64.home.annexia.org>
+Richard W.M. Jones <rjones(a)redhat.com> <rich(a)annexia.org>
+Richard W.M. Jones <rjones(a)redhat.com> rjones <rjones>
+Wanlong Gao <gaowanlong(a)cn.fujitsu.com> <wanlong.gao(a)gmail.com>
diff --git a/AUTHORS b/AUTHORS
index 6588c61..eb1e296 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -10,7 +10,7 @@ Geert Warrink <geert.warrink(a)onsnet.nu>
Guido Günther <agx(a)sigxcpu.org>
Hilko Bengen <bengen(a)hilluzination.de>
Jaswinder Singh <jsingh(a)redhat.com>
-Jim Meyering <jim(a)meyering.net>
+Jim Meyering <meyering(a)redhat.com>
Jiri Popelka <jpopelka(a)redhat.com>
John Eckersberg <jeckersb(a)redhat.com>
Karel Klíč <kklic(a)redhat.com>
@@ -25,7 +25,7 @@ Olaf Hering <olaf(a)aepfle.de>
Piotr Drąg <piotrdrag(a)gmail.com>
Qin Guan <qguan(a)redhat.com>
Rajesh Ranjan <rranjan(a)redhat.com>
-Richard W.M. Jones <rich(a)annexia.org>
+Richard W.M. Jones <rjones(a)redhat.com>
Sandeep Shedmake <sshedmak(a)redhat.com>
Shankar Prasad <svenkate(a)redhat.com>
Thomas S Hatch <thatch45(a)gmail.com>
diff --git a/Makefile.am b/Makefile.am
index 1ae7849..9b307b0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -240,10 +240,7 @@ dist-hook:
$(top_srcdir)/update-bugs.sh > BUGS-t
mv BUGS-t BUGS
cp BUGS $(distdir)/BUGS
- git log --pretty="format:%an <%ae>" | sort -u | uniq -w 10 | \
- grep -v rjones | \
- grep -v "Richard Jones" \
- > AUTHORS-t
+ git shortlog -se | awk -F'\t' '{print $$2}' > AUTHORS-t
mv AUTHORS-t AUTHORS
cp AUTHORS $(distdir)/AUTHORS
--
1.8.0
11 years, 12 months
lpj= handling
by Olaf Hering
Richard,
the newly added code to read lpj= does not consider /var/log/boot.msg,
which is used in SuSE based systems.
Olaf
12 years
[PATCH] lua: fix build error due to LUA_GLOBALSINDEX usage
by Olaf Hering
lua 5.2 changed API, LUA_GLOBALSINDEX is no longer available.
http://www.lua.org/manual/5.2/manual.html#8.3
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
---
Fix is only compile tested.
generator/lua.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/generator/lua.ml b/generator/lua.ml
index 88748ae..7461cbd 100644
--- a/generator/lua.ml
+++ b/generator/lua.ml
@@ -723,7 +723,7 @@ push_int64_array (lua_State *L, const int64_t *array, size_t len)
static void
print_any (lua_State *L, int index, FILE *out)
{
- lua_getfield (L, LUA_GLOBALSINDEX, \"tostring\");
+ lua_getglobal(L, \"tostring\");
lua_pushvalue (L, index >= 0 ? index : index-1);
lua_call (L, 1, 1);
fprintf (out, \"%%s\", luaL_checkstring (L, -1));
--
1.8.0
12 years
install errors for libguestfs-1.19.60
by Skippy VonDrake
I've been using libguestfs-1.18.9 but decided to "upgrade" to 1.19.60.
Using Ubuntu 12.04 with the older version installed via source.
So I went through the same process with the new version of guestfs sources
and got the following errors on 'make install':
make[2]: Nothing to be done for `install-exec-am'.
make install-data-hook
make[3]: Entering directory `/home/skippy/libguestfs/libguestfs-1.19.60/ocaml'
mkdir -p /usr/lib/ocaml
mkdir -p /usr/lib/ocaml/stublibs
ocamlfind install \
-ldconf ignore -destdir /usr/lib/ocaml \
guestfs \
META *.so *.a *.cma *.cmx *.cmxa *.cmi ./*.mli
ocamlfind: Package guestfs is already installed
- (file /usr/lib/ocaml/guestfs/META already exists)
make[3]: *** [install-data-hook] Error 2
make[3]: Leaving directory `/home/skippy/libguestfs/libguestfs-1.19.60/ocaml'
make[2]: *** [install-data-am] Error 2
make[2]: Leaving directory `/home/skippy/libguestfs/libguestfs-1.19.60/ocaml'
make[1]: *** [install-am] Error 2
make[1]: Leaving directory `/home/skippy/libguestfs/libguestfs-1.19.60/ocaml'
make: *** [install-recursive] Error 1
Was I supposed to remove the older version first? And if so - how?
12 years