Compare commits

...

26 Commits

Author SHA1 Message Date
Brian C. Lane
ba531e97a0 livemedia-creator: Make sure make-iso kickstart includes dracut-live
iso creation requires the dracut-live package, otherwise rebuilding the
initrd will crash. Since it takes a long time to discover let's fail
early.

(cherry picked from commit 607d7c1eeb)
2016-04-06 17:11:52 -07:00
Brian C. Lane
372ba1ed16 livemedia-creator: Simplify cleanup for no-virt
If an anaconda no-virt run crashes it can leave things mounted under
/mnt/sysimage. Previously anaconda-cleanup was used to handle this, but
it will also try to cleanup host mountpoints which isn't desired.

(cherry picked from commit bae111d5a3)
2016-04-06 17:08:49 -07:00
Brian C. Lane
631daa0178 Automatic commit of package [lorax] release [22.14-1]. 2016-03-29 17:42:39 -07:00
Will Woods
160be350fb don't build upgrade.img anymore
fedup is deprecated and abandoned. Let's save time and disk by not
building `upgrade.img` when nothing is going to use it anymore.

For the record, performing upgrades using an initramfs from the new
system turns out to be fragile and hard to support:

* dracut initramfs isn't generic enough to handle booting all systems
  (e.g. missing vconsole.conf means you get keymaps wrong, so users
  can't unlock encrypted disks)

* The ABI differences between the two versions of plymouth, systemd,
  etc. requires nasty workarounds at best and causes nightmarish
  systemd crashes at worst

This patch removes all the code that built and installed `upgrade.img`.

For backwards compatibility, the API retains the `doupgrade` keyword
argument, and the `--noupgrade` flag is still accepted.

(cherry picked from commit d9c23d1bce)
2016-03-29 17:14:18 -07:00
Brian C. Lane
0274b91a14 templates: On 32 bit systems limit the amount of memory xz uses
This uses --memlimit-compress=3700MiB on i386 and arm when building the
product and updates images.

(cherry picked from commit eb59bc4fab)
2016-03-29 17:14:15 -07:00
Brian C. Lane
863039555d ltmpl: Add compressor selection and argument passing to installimg
Allow the template to select a different compression type or arguments
for the installimg command.

On 32bit builds running inside a mock xz sees the full amount of system
memory which can result in xz failing with a memory error. This allows
the template to limit the amount of memory it tries to use.

(cherry picked from commit 07dca74c06)
2016-03-29 17:14:12 -07:00
Brian C. Lane
620849968f Automatic commit of package [lorax] release [22.13-1]. 2015-10-30 11:51:41 -07:00
Will Woods
85d3652af5 drop fedup-dracut and friends
This package will not exist soon. Don't bother trying to install it.

(cherry picked from commit 52171ecf23)
2015-10-30 11:49:13 -07:00
Brian C. Lane
4a4a62ce1b Automatic commit of package [lorax] release [22.12-1]. 2015-05-27 17:49:58 -07:00
Brian C. Lane
8e2556474d Use imgutils.copytree instead of shutil (#1221878)
Sometimes the directory is already there, we just want to copy things
into it, so use our copytree.
2015-05-26 13:50:33 -07:00
Brian C. Lane
8619ec59cc Automatic commit of package [lorax] release [22.11-1]. 2015-05-07 16:48:28 -07:00
Brian C. Lane
240f688fb3 Make sure openssh-clients is installed (#1219398)
It used to be pulled in by a dependency, which went away. It should be
explicitly installed.
2015-05-07 08:53:08 -07:00
Brian C. Lane
bf620f9662 Automatic commit of package [lorax] release [22.10-1]. 2015-04-29 16:53:39 -07:00
Dan Horák
0f65bc4a31 Add product.img support for s390 templates
(cherry picked from commit a2c2a4be28)
2015-04-29 11:41:03 -07:00
Brian C. Lane
e76a4ea15c Automatic commit of package [lorax] release [22.9-1]. 2015-04-02 13:31:59 -07:00
Brian C. Lane
92808bcbe6 Include cryptsetup in the image (#1208214)
blivet dropped its requirement on cryptsetup, but fedup needs it in the
upgrade.img and it is useful for rescue mode so add it back.
2015-04-02 11:52:00 -07:00
Brian C. Lane
c45255b666 Automatic commit of package [lorax] release [22.8-1]. 2015-03-27 17:32:16 -07:00
Brian C. Lane
229759f411 livemedia-creator: Clean up resultdir handling
(cherry picked from commit 3148a2b215)
2015-03-24 14:22:44 -07:00
Colin Walters
5155ff65ac Add ability for external templates to graft content into boot.iso
I originally added --add-template to support doing something similar
to pungi, which injects content into the system to be used by default.
However, this causes the content to be part of the squashfs, which
means PXE installations have to download significantly more data that
they may not need (if they actually want to pull the tree data from
the network, which is not an unusual case).

What I actually need is to be able to modify *both* the runtime image
and the arch-specific content.  For the runtime, I need to change
/usr/share/anaconda/interactive-defaults.ks to point to the new
content.  (Although, potentially we could patch Anaconda itself to
auto-detect an ostree repository configured in disk image, similar to
what it does for yum repositories)

For the arch-specfic image, I want to drop my content into the ISO
root.

So this patch adds --add-arch-template and --add-arch-template-var
in order to do the latter, while preserving the --add-template
to affect the runtime image.

Further, the templates will automatically graft in a directory named
"iso-graft/" from the working directory (if it exists).

(I suggest that external templates create a subdirectory named
 "content" to avoid clashes with any future lorax work)

Thus, this will be used by the Atomic Host lorax templates to inject
content/repo, but could be used by e.g. pungi to add content/rpms as
well.

I tried to avoid code deduplication by creating a new template for the
product.img bits and this, but that broke because the parent boot.iso
code needs access to the `${imggraft}` variable.  I think a real fix
here would involve turning the product.img, content/, *and* boot.iso
into a new template.

Conflicts:
	src/sbin/lorax
2015-03-22 08:48:07 -04:00
Brian C. Lane
ebf107a28e Automatic commit of package [lorax] release [22.7-1]. 2015-03-20 18:12:53 -07:00
Brian C. Lane
0f79920957 Include ld.so.conf (#1204031)
ldconfig runs at boot time, and some libraries apparently aren't setup
properly, so the config is needed to point to their directories.

(cherry picked from commit f130efdbc2)
2015-03-20 18:12:07 -07:00
Brian C. Lane
a0e35dbbe0 Keep logitech hid drivers (#1199770)
Some logitech mice need a driver.
2015-03-20 09:16:25 -07:00
Brian C. Lane
68656592e2 Automatic commit of package [lorax] release [22.6-1]. 2015-03-16 17:05:00 -07:00
Stephen Gallagher
c0b1063397 Don't erase /usr/lib/os.release.d
This directory now contains the standard and productized
/etc/os-release feeder files.
2015-03-16 15:34:14 -04:00
Brian C. Lane
a612c1ebd0 Fix Source0 for use with github 2015-02-12 17:06:42 -08:00
Brian C. Lane
281218b258 Automatic commit of package [lorax] release [22.5-1]. 2015-02-12 16:42:03 -08:00
19 changed files with 243 additions and 126 deletions

View File

@ -78,9 +78,6 @@ volume id
.TP
\fB\-\-nomacboot\fR
.TP
\fB\-\-noupgrade\fR
.TP
\fB\-\-logfile=LOGFILE\fR
Path to logfile
@ -95,4 +92,3 @@ Martin Gracik
Will Woods
Brian C. Lane
.fi

View File

@ -1,14 +1,18 @@
%define debug_package %{nil}
Name: lorax
Version: 22.4
Version: 22.14
Release: 1%{?dist}
Summary: Tool for creating the anaconda install images
Group: Applications/System
License: GPLv2+
URL: https://github.com/rhinstaller/lorax
Source0: https://github.com/rhinstaller/%{name}/archive/%{name}-${version}-%{release}.tar.gz
# To generate Source0 do:
# git clone https://github.com/rhinstaller/lorax
# git checkout -b archive-branch lorax-%%{version}-%%{release}
# tito build --tgz
Source0: %{name}-%{version}.tar.gz
BuildRequires: python2-devel
@ -39,8 +43,6 @@ Requires: dracut >= 030
%if 0%{?fedora}
# Fedora specific deps
Requires: fedup-dracut
Requires: fedup-dracut-plymouth
%ifarch x86_64
Requires: hfsplus-tools
%endif
@ -76,7 +78,7 @@ including live isos and disk images. It can use libvirtd for the install, or
Anaconda's image install feature.
%prep
%setup -q
%setup -q -n %{name}-%{version}
%build
@ -102,6 +104,46 @@ make DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} install
%{_mandir}/man1/*.1*
%changelog
* Tue Mar 29 2016 Brian C. Lane <bcl@redhat.com> 22.14-1
- don't build upgrade.img anymore (wwoods@redhat.com)
- templates: On 32 bit systems limit the amount of memory xz uses
(bcl@redhat.com)
- ltmpl: Add compressor selection and argument passing to installimg
(bcl@redhat.com)
* Fri Oct 30 2015 Brian C. Lane <bcl@redhat.com> 22.13-1
- drop fedup-dracut and friends (wwoods@redhat.com)
* Wed May 27 2015 Brian C. Lane <bcl@redhat.com> 22.12-1
- Use imgutils.copytree instead of shutil (#1221878) (bcl@redhat.com)
* Thu May 07 2015 Brian C. Lane <bcl@redhat.com> 22.11-1
- Make sure openssh-clients is installed (#1219398) (bcl@redhat.com)
* Wed Apr 29 2015 Brian C. Lane <bcl@redhat.com> 22.10-1
- Add product.img support for s390 templates (dan@danny.cz)
* Thu Apr 02 2015 Brian C. Lane <bcl@redhat.com> 22.9-1
- Include cryptsetup in the image (#1208214) (bcl@redhat.com)
* Fri Mar 27 2015 Brian C. Lane <bcl@redhat.com> 22.8-1
- livemedia-creator: Clean up resultdir handling (bcl@redhat.com)
- Add ability for external templates to graft content into boot.iso
(walters@verbum.org)
* Fri Mar 20 2015 Brian C. Lane <bcl@redhat.com> 22.7-1
- Include ld.so.conf (#1204031) (bcl@redhat.com)
- Keep logitech hid drivers (#1199770) (bcl@redhat.com)
* Mon Mar 16 2015 Brian C. Lane <bcl@redhat.com> 22.6-1
- Don't erase /usr/lib/os.release.d (sgallagh@redhat.com)
- Fix Source0 for use with github (bcl@redhat.com)
* Thu Feb 12 2015 Brian C. Lane <bcl@redhat.com> 22.5-1
- os-release moved to /usr/lib (#1191713) (bcl@redhat.com)
- Use /usr/bin/python2 in scripts (bcl@redhat.com)
- Add bridge-utils (#1188812) (bcl@redhat.com)
* Fri Feb 06 2015 Brian C. Lane <bcl@redhat.com> 22.4-1
- livemedia-creator: Add --timeout option to cancel install after X minutes
(bcl@redhat.com)

View File

@ -1 +1 @@
22.4-1 ./
22.14-1 ./

View File

@ -17,9 +17,6 @@ mkdir ${KERNELDIR}
## normal aarch64
installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/vmlinuz
installinitrd images-${basearch} ${kernel.initrd.path} ${KERNELDIR}/initrd.img
%if doupgrade:
installupgradeinitrd images-${basearch} ${kernel.upgrade.path} ${KERNELDIR}/upgrade.img
%endif
%endfor
#FIXME: this will need adjusted when we have a real bootloader.
@ -47,6 +44,13 @@ mkdir ${KERNELDIR}
%endif
%endfor
# Inherit iso-graft/ if it exists from external templates
<%
import os
if os.path.exists(workdir + "/iso-graft"):
imggraft += " " + workdir + "/iso-graft"
%>
%if exists("boot/efi/EFI/*/gcdaa64.efi"):
## make boot.iso
runcmd mkisofs -o ${outroot}/images/boot.iso \

View File

@ -36,22 +36,6 @@ mkdir ${KERNELDIR}
platforms = platforms + delimiter + kernel.flavor
delimiter = ','
%>
%if doupgrade:
## install upgrade image
installupgradeinitrd images-${kernel.flavor}-${basearch} ${kernel.upgrade.path} ${KERNELDIR}/upgrade-${kernel.flavor}.img
runcmd mkimage \
-A arm -O linux -T ramdisk -C none \
-a 0 -e 0 \
-n "${product.name} ${product.version} ${kernel.flavor} ${kernel.arch}" \
-d ${outroot}/${KERNELDIR}/upgrade-${kernel.flavor}.img \
${outroot}/${KERNELDIR}/uUpgrade-${kernel.flavor}
treeinfo images-${kernel.flavor}-${basearch} uupgrade ${KERNELDIR}/uUpgrade-${kernel.flavor}
%endif
## create U-Boot wrapped images
runcmd mkimage \
@ -75,21 +59,6 @@ mkdir ${KERNELDIR}
installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/vmlinuz
installinitrd images-${basearch} ${kernel.initrd.path} ${KERNELDIR}/initrd.img
%if doupgrade:
## install upgrade image
installupgradeinitrd images-${basearch} ${kernel.upgrade.path} ${KERNELDIR}/upgrade.img
runcmd mkimage \
-A arm -O linux -T ramdisk -C none \
-a 0 -e 0 \
-n "${product.name} ${product.version} ${kernel.flavor} ${kernel.arch}" \
-d ${outroot}/${KERNELDIR}/upgrade.img \
${outroot}/${KERNELDIR}/uUpgrade
treeinfo images-${basearch} uupgrade ${KERNELDIR}/uUpgrade
%endif
## create U-Boot wrapped images
runcmd mkimage \
@ -119,9 +88,15 @@ treeinfo ${basearch} platforms ${platforms}
<% images=["product", "updates"] %>
%for img in images:
%if exists("%s/%s/" % (LORAXDIR, img)):
installimg ${LORAXDIR}/${img}/ images/${img}.img
installimg --xz -9 --memlimit-compress=3700MiB ${LORAXDIR}/${img}/ images/${img}.img
%endif
%endfor
## FIXME: ARM may need some extra boot config
# Inherit iso-graft/ if it exists from external templates
<%
import os
if os.path.exists(workdir + "/iso-graft"):
imggraft += " " + workdir + "/iso-graft"
%>
## FIXME: ARM may need some extra boot config

View File

@ -74,7 +74,7 @@ mkdir ${KERNELDIR}
<% images=["product", "updates"] %>
%for img in images:
%if exists("%s/%s/" % (LORAXDIR, img)):
installimg ${LORAXDIR}/${img}/ images/${img}.img
installimg --xz -9 --memlimit-compress=3700MiB ${LORAXDIR}/${img}/ images/${img}.img
%endif
%endfor

View File

@ -4,6 +4,7 @@ configdir="tmp/config_files/s390"
BOOTDIR="images"
KERNELDIR=BOOTDIR
INITRD_ADDRESS="0x02000000"
LORAXDIR="usr/share/lorax/"
# The assumption seems to be that there is only one s390 kernel, ever
kernel = kernels[0]
%>
@ -31,3 +32,12 @@ createaddrsize ${INITRD_ADDRESS} ${outroot}/${BOOTDIR}/initrd.img ${outroot}/${B
treeinfo images-${basearch} initrd.addrsize ${BOOTDIR}/initrd.addrsize
treeinfo images-${basearch} generic.prm ${BOOTDIR}/generic.prm
treeinfo images-${basearch} generic.ins generic.ins
# Create optional product.img and updates.img
<% imggraft=""; images=["product", "updates"] %>
%for img in images:
%if exists("%s/%s/" % (LORAXDIR, img)):
installimg ${LORAXDIR}/${img}/ images/${img}.img
<% imggraft += " images/{0}.img={1}/images/{0}.img".format(img, outroot) %>
%endif
%endfor

View File

@ -75,10 +75,14 @@ hardlink ${KERNELDIR}/initrd.img ${BOOTDIR}
%endif
# Create optional product.img and updates.img
<% imggraft=""; images=["product", "updates"] %>
<% imggraft=""; images=["product", "updates"]; compressargs=None; %>
%if basearch == 'i386':
# Limit the amount of memory xz uses on i386
<% compressargs="--xz -9 --memlimit-compress=3700MiB" %>
%endif
%for img in images:
%if exists("%s/%s/" % (LORAXDIR, img)):
installimg ${LORAXDIR}/${img}/ images/${img}.img
installimg ${compressargs} ${LORAXDIR}/${img}/ images/${img}.img
<% imggraft += " images/{0}.img={1}/images/{0}.img".format(img, outroot) %>
%endif
%endfor

View File

@ -68,11 +68,6 @@ install ${configdir}/mapping ${BOOTDIR}
installkernel images-${kernel.arch} ${kernel.path} ${KERNELDIR}/vmlinuz
installinitrd images-${kernel.arch} ${kernel.initrd.path} ${KERNELDIR}/initrd.img
%if doupgrade:
## upgrade image
installupgradeinitrd images-${kernel.arch} ${kernel.upgrade.path} ${KERNELDIR}/upgrade.img
%endif
## kernel-wrapper magic that makes the netboot combined ppc{32,64}.img
runcmd ${inroot}/${WRAPPER} -p of \
-D ${inroot}/${WRAPPER_DATA} \
@ -96,6 +91,13 @@ install ${configdir}/mapping ${BOOTDIR}
%endif
%endfor
# Inherit iso-graft/ if it exists from external templates
<%
import os
if os.path.exists(workdir + "/iso-graft"):
imggraft += " " + workdir + "/iso-graft"
%>
## make boot.iso
runcmd mkisofs -o ${outroot}/images/boot.iso -chrp-boot -U \
${prepboot} -part -hfs -T -r -l -J \

View File

@ -54,11 +54,6 @@ install ${configdir}/mapping ${BOOTDIR}
installkernel images-${kernel.arch} ${kernel.path} ${KERNELDIR}/vmlinuz
installinitrd images-${kernel.arch} ${kernel.initrd.path} ${KERNELDIR}/initrd.img
%if doupgrade:
## upgrade image
installupgradeinitrd images-${kernel.arch} ${kernel.upgrade.path} ${KERNELDIR}/upgrade.img
%endif
treeinfo images-${kernel.arch} zimage
%endfor
@ -72,6 +67,13 @@ mkdir images/
%endif
%endfor
# Inherit iso-graft/ if it exists from external templates
<%
import os
if os.path.exists(workdir + "/iso-graft"):
imggraft += " " + workdir + "/iso-graft"
%>
## make boot.iso
runcmd mkisofs -v -U -J -R -T \
-o ${outroot}/images/boot.iso \

View File

@ -27,7 +27,8 @@ removefrom dracut --allbut /usr/lib/dracut/modules.d/30convertfs/convertfs.sh \
## we don't run SELinux (not in enforcing, anyway)
removepkg checkpolicy selinux-policy libselinux-utils
## anaconda has its own repo files
removefrom fedora-release --allbut /etc/os-release /usr/lib/os-release
removefrom fedora-release --allbut /etc/os-release /usr/lib/os-release \
/usr/lib/os.release.d/*
removepkg fedora-release-rawhide
## no user accounts = no account management
removepkg usermode usermode-gtk passwd shadow-utils
@ -81,7 +82,7 @@ sound drivers/media drivers/hwmon drivers/video
net/atm net/bluetooth net/sched net/sctp
net/rds net/l2tp net/decnet net/netfilter net/ipv4 net/ipv6
drivers/watchdog drivers/target drivers/rtc drivers/input/joystick
drivers/bluetooth drivers/hid drivers/edac drivers/staging
drivers/bluetooth drivers/edac drivers/staging
drivers/usb/serial drivers/usb/host drivers/usb/misc
fs/ocfs2 fs/ceph fs/nfsd fs/ubifs fs/nilfs2
arch/x86/kvm
@ -101,6 +102,12 @@ runcmd chroot ${root} find /lib/modules \
\! -name virtio-rng.ko\* \
\! -name ipmi\* \
-delete
# Remove all of drivers/hid except for logitech modules.
runcmd chroot ${root} find /lib/modules \
-regex ".*/kernel/drivers/hid/.*" \
\! -name hid-logitech-hidpp.ko\* \
\! -name hid-logitech-dj.ko\* \
-delete
## NOTE: depmod gets re-run after cleanup finishes
## remove unused themes, theme engines, icons, etc.
@ -184,7 +191,7 @@ removefrom gdisk /usr/share/*
removefrom gdk-pixbuf2 /usr/share/locale*
removefrom gfs2-utils /usr/sbin/*
removefrom glib2 /etc/* /usr/bin/* /usr/share/locale/*
removefrom glibc /etc/gai.conf /etc/ld.so.conf /etc/localtime /etc/rpc
removefrom glibc /etc/gai.conf /etc/localtime /etc/rpc
removefrom glibc /lib/*/nosegneg/* /${libdir}/libBrokenLocale*
removefrom glibc /${libdir}/libSegFault* /${libdir}/libanl*
removefrom glibc /${libdir}/libcidn* /${libdir}/libnss_compat*

View File

@ -51,11 +51,8 @@ installpkg plymouth
## extra dracut modules
installpkg anaconda-dracut dracut-network dracut-config-generic
## fedup-dracut handles upgrades
installpkg fedup-dracut fedup-dracut-plymouth
## install other fedup scripts, if there are any. It's OK if there aren't.
log "Looking for extra fedup-dracut packages..."
-installpkg *-fedup-dracut
## rescue needs this
installpkg cryptsetup
## rpcbind or portmap needed by dracut nfs module
installpkg rpcbind
@ -96,7 +93,7 @@ installpkg python-nss
installpkg selinux-policy-targeted audit libsemanage-python
## network tools/servers
installpkg python-ethtool ethtool openssh-server nfs-utils
installpkg python-ethtool ethtool openssh-server nfs-utils openssh-clients
installpkg tigervnc-server-minimal
%if basearch != "s390x":
installpkg tigervnc-server-module

View File

@ -4,6 +4,7 @@ configdir="tmp/config_files/s390"
BOOTDIR="images"
KERNELDIR=BOOTDIR
INITRD_ADDRESS="0x02000000"
LORAXDIR="usr/share/lorax/"
# The assumption seems to be that there is only one s390 kernel, ever
kernel = kernels[0]
%>
@ -25,11 +26,6 @@ replace @INITRD_LOAD_ADDRESS@ ${INITRD_ADDRESS} generic.ins
installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/kernel.img
installinitrd images-${basearch} ${kernel.initrd.path} ${KERNELDIR}/initrd.img
%if doupgrade:
## upgrader image
installupgradeinitrd images-${basearch} ${kernel.upgrade.path} ${KERNELDIR}/upgrade.img
%endif
## s390 needs some extra boot config
createaddrsize ${INITRD_ADDRESS} ${outroot}/${BOOTDIR}/initrd.img ${outroot}/${BOOTDIR}/initrd.addrsize
@ -38,3 +34,19 @@ treeinfo images-${basearch} initrd.addrsize ${BOOTDIR}/initrd.addrsize
treeinfo images-${basearch} generic.prm ${BOOTDIR}/generic.prm
treeinfo images-${basearch} genericdvd.prm ${BOOTDIR}/genericdvd.prm
treeinfo images-${basearch} generic.ins generic.ins
# Create optional product.img and updates.img
<% imggraft=""; images=["product", "updates"] %>
%for img in images:
%if exists("%s/%s/" % (LORAXDIR, img)):
installimg ${LORAXDIR}/${img}/ images/${img}.img
<% imggraft += " images/{0}.img={1}/images/{0}.img".format(img, outroot) %>
%endif
%endfor
# Inherit iso-graft/ if it exists from external templates
<%
import os
if os.path.exists(workdir + "/iso-graft"):
imggraft += " " + workdir + "/iso-graft"
%>

View File

@ -44,30 +44,18 @@ mkdir ${KERNELDIR}
## i386 PAE
installkernel images-xen ${kernel.path} ${KERNELDIR}/vmlinuz-${kernel.flavor}
installinitrd images-xen ${kernel.initrd.path} ${KERNELDIR}/initrd-${kernel.flavor}.img
%if doupgrade:
installupgradeinitrd images-xen ${kernel.upgrade.path} ${KERNELDIR}/upgrade-${kernel.flavor}.img
%endif
%else:
## normal i386, x86_64
installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/vmlinuz
installinitrd images-${basearch} ${kernel.initrd.path} ${KERNELDIR}/initrd.img
%if doupgrade:
installupgradeinitrd images-${basearch} ${kernel.upgrade.path} ${KERNELDIR}/upgrade.img
%endif
%endif
%endfor
hardlink ${KERNELDIR}/vmlinuz ${BOOTDIR}
hardlink ${KERNELDIR}/initrd.img ${BOOTDIR}
%if doupgrade:
hardlink ${KERNELDIR}/upgrade.img ${BOOTDIR}
%endif
%if basearch == 'x86_64':
treeinfo images-xen kernel ${KERNELDIR}/vmlinuz
treeinfo images-xen initrd ${KERNELDIR}/initrd.img
%if doupgrade:
treeinfo images-xen upgrade ${KERNELDIR}/upgrade.img
%endif
%endif
## WHeeeeeeee, EFI.
@ -89,14 +77,25 @@ hardlink ${KERNELDIR}/initrd.img ${BOOTDIR}
%endif
# Create optional product.img and updates.img
<% imggraft=""; images=["product", "updates"] %>
<% imggraft=""; images=["product", "updates"]; compressargs=None; %>
%if basearch == 'i386':
# Limit the amount of memory xz uses on i386
<% compressargs="--xz -9 --memlimit-compress=3700MiB" %>
%endif
%for img in images:
%if exists("%s/%s/" % (LORAXDIR, img)):
installimg ${LORAXDIR}/${img}/ images/${img}.img
installimg ${compressargs} ${LORAXDIR}/${img}/ images/${img}.img
<% imggraft += " images/{0}.img={1}/images/{0}.img".format(img, outroot) %>
%endif
%endfor
# Inherit iso-graft/ if it exists from external templates
<%
import os
if os.path.exists(workdir + "/iso-graft"):
imggraft += " " + workdir + "/iso-graft"
%>
## make boot.iso
runcmd mkisofs -o ${outroot}/images/boot.iso \
-b ${BOOTDIR}/isolinux.bin -c ${BOOTDIR}/boot.cat \

View File

@ -155,7 +155,10 @@ class Lorax(BaseLoraxClass):
installpkgs=None,
size=2,
add_templates=None,
add_template_vars=None):
add_template_vars=None,
add_arch_templates=None,
add_arch_template_vars=None,
template_tempdir=None):
assert self._configured
@ -312,7 +315,10 @@ class Lorax(BaseLoraxClass):
inroot=installroot, outroot=self.outputdir,
runtime=runtime, isolabel=isolabel,
domacboot=domacboot, doupgrade=doupgrade,
templatedir=templatedir)
templatedir=templatedir,
add_templates=add_arch_templates,
add_template_vars=add_arch_template_vars,
workdir=self.workdir)
logger.info("rebuilding initramfs images")
dracut_args = ["--xz", "--install", "/.buildstamp"]
@ -328,21 +334,6 @@ class Lorax(BaseLoraxClass):
treebuilder.rebuild_initrds(add_args=anaconda_args)
if doupgrade:
# Build upgrade.img. It'd be nice if these could coexist in the same
# image, but that would increase the size of the anaconda initramfs,
# which worries some people (esp. PPC tftpboot). So they're separate.
try:
# If possible, use the 'fedup' plymouth theme
themes = runcmd_output(['plymouth-set-default-theme', '--list'],
root=installroot)
if 'fedup' in themes.splitlines():
os.environ['PLYMOUTH_THEME_NAME'] = 'fedup'
except RuntimeError:
pass
upgrade_args = dracut_args + ["--add", "system-upgrade"]
treebuilder.rebuild_initrds(add_args=upgrade_args, prefix="upgrade")
logger.info("populating output tree and building boot images")
treebuilder.build()

View File

@ -175,7 +175,7 @@ class LoraxTemplateRunner(object):
def run(self, templatefile, **variables):
for k,v in self.defaults.items() + self.builtins.items():
variables.setdefault(k,v)
logger.debug("parsing %s", templatefile)
logger.debug("executing {0} with variables={1}".format(templatefile, variables))
self.templatefile = templatefile
t = LoraxTemplate(directories=[self.templatedir])
commands = t.parse(templatefile, variables)
@ -234,9 +234,9 @@ class LoraxTemplateRunner(object):
for src in rglob(self._in(srcglob), fatal=True):
cpfile(src, self._out(dest))
def installimg(self, srcdir, destfile):
def installimg(self, *args):
'''
installimg SRCDIR DESTFILE
installimg [--xz|--gzip|--bzip2|--lzma] [-ARG|--ARG=OPTION] SRCDIR DESTFILE
Create a compressed cpio archive of the contents of SRCDIR and place
it in DESTFILE.
@ -245,11 +245,35 @@ class LoraxTemplateRunner(object):
Examples:
installimg ${LORAXDIR}/product/ images/product.img
installimg ${LORAXDIR}/updates/ images/updates.img
installimg --xz -6 ${LORAXDIR}/updates/ images/updates.img
installimg --xz -9 --memlimit-compress=3700MiB ${LORAXDIR}/updates/ images/updates.img
Optionally use a different compression type and override the default args
passed to it. The default is xz -9
'''
COMPRESSORS = ("--xz", "--gzip", "--bzip2", "--lzma")
if len(args) < 2:
raise ValueError("Not enough args for installimg.")
srcdir = args[-2]
destfile = args[-1]
if not os.path.isdir(self._in(srcdir)) or not os.listdir(self._in(srcdir)):
return
compression = "xz"
compressargs = []
if args[0] in COMPRESSORS:
compression = args[0][2:]
for arg in args[1:-2]:
if arg.startswith('-'):
compressargs.append(arg)
else:
raise ValueError("Argument is missing -")
logger.info("Creating image file %s from contents of %s", self._out(destfile), self._in(srcdir))
mkcpio(self._in(srcdir), self._out(destfile))
logger.debug("Using %s %s compression", compression, compressargs or "")
mkcpio(self._in(srcdir), self._out(destfile), compression=compression, compressargs=compressargs)
def mkdir(self, *dirs):
'''

View File

@ -172,16 +172,20 @@ class RuntimeBuilder(object):
class TreeBuilder(object):
'''Builds the arch-specific boot images.
inroot should be the installtree root (the newly-built runtime dir)'''
def __init__(self, product, arch, inroot, outroot, runtime, isolabel, domacboot=True, doupgrade=True, templatedir=None):
def __init__(self, product, arch, inroot, outroot, runtime, isolabel, domacboot=True, doupgrade=True, templatedir=None, add_templates=None, add_template_vars=None, workdir=None):
# NOTE: if you pass an arg named "runtime" to a mako template it'll
# clobber some mako internal variables - hence "runtime_img".
self.vars = DataHolder(arch=arch, product=product, runtime_img=runtime,
runtime_base=basename(runtime),
inroot=inroot, outroot=outroot,
basearch=arch.basearch, libdir=arch.libdir,
isolabel=isolabel, udev=udev_escape, domacboot=domacboot, doupgrade=doupgrade)
isolabel=isolabel, udev=udev_escape, domacboot=domacboot, doupgrade=doupgrade,
workdir=workdir)
self._runner = LoraxTemplateRunner(inroot, outroot, templatedir=templatedir)
self._runner.defaults = self.vars
self.add_templates = add_templates or []
self.add_template_vars = add_template_vars or {}
self.templatedir = templatedir
self.treeinfo_data = None
@ -230,6 +234,8 @@ class TreeBuilder(object):
def build(self):
templatefile = templatemap[self.vars.arch.basearch]
for tmpl in self.add_templates:
self._runner.run(tmpl, **self.add_template_vars)
self._runner.run(templatefile, kernels=self.kernels)
self.treeinfo_data = self._runner.results.treeinfo
self.implantisomd5()

View File

@ -56,7 +56,7 @@ from pylorax.treebuilder import findkernels
from pylorax.sysutils import joinpaths, remove
from pylorax.imgutils import PartitionMount, mksparse, mkext4img, loop_detach
from pylorax.imgutils import get_loop_name, dm_detach, mount, umount, Mount
from pylorax.imgutils import mksquashfs, mkqcow2, mktar, mkrootfsimg
from pylorax.imgutils import mksquashfs, mkqcow2, mktar, mkrootfsimg, copytree
from pylorax.executils import execWithRedirect, execWithCapture, runcmd
# no-virt mode doesn't need libvirt, so make it optional
@ -693,7 +693,7 @@ def make_livecd(opts, mount_dir, work_dir):
fullpath = joinpaths(mount_dir, configdir_path)
if os.path.exists(fullpath):
remove(fullpath)
shutil.copytree(configdir, fullpath)
copytree(configdir, fullpath)
isolabel = opts.volid or "{0.name}-{0.version}-{1.basearch}".format(product, arch)
if len(isolabel) > 32:
@ -766,6 +766,23 @@ def novirt_log_check(log_check, proc):
return False
def anaconda_cleanup(dirinstall_path):
"""
Cleanup any leftover mounts from anaconda
:param str dirinstall_path: Path where anaconda mounts things
If anaconda crashes it may leave things mounted under this path. It will
typically be set to /mnt/sysimage/
"""
dirinstall_path = os.path.abspath(dirinstall_path)
# unmount filesystems
for mounted in reversed(open("/proc/mounts").readlines()):
(_device, mountpoint, _rest) = mounted.split(" ", 2)
if mountpoint.startswith(dirinstall_path):
umount(mountpoint)
def novirt_install(opts, disk_img, disk_size, repo_url):
"""
Use Anaconda to install to a disk image
@ -850,6 +867,9 @@ def novirt_install(opts, disk_img, disk_size, repo_url):
finally:
log_monitor.shutdown()
# Make sure any leftover anaconda mounts have been cleaned up
anaconda_cleanup(ROOT_PATH)
# Move the anaconda logs over to a log directory
log_dir = os.path.abspath(os.path.dirname(opts.logfile))
log_anaconda = joinpaths(log_dir, "anaconda")
@ -882,7 +902,7 @@ def novirt_install(opts, disk_img, disk_size, repo_url):
# convert the image to qcow2 format
if "-O" not in qcow2_args:
qcow2_args.extend(["-O", "qcow2"])
qcow2_img = tempfile.mktemp(prefix="disk", suffix=".img", dir=opts.tmp)
qcow2_img = tempfile.mktemp(prefix="disk", suffix=".img")
execWithRedirect("qemu-img", ["convert"] + qcow2_args + [disk_img, qcow2_img], raise_err=True)
execWithRedirect("mv", ["-f", qcow2_img, disk_img], raise_err=True)
elif opts.make_tar:
@ -928,7 +948,7 @@ def virt_install(opts, install_log, disk_img, disk_size):
mkqcow2(disk_img, disk_size*1024**2, qcow2_args)
if opts.make_fsimage or opts.make_tar:
diskimg_path = tempfile.mktemp(prefix="disk", suffix=".img", dir=opts.tmp)
diskimg_path = tempfile.mktemp(prefix="disk", suffix=".img")
else:
diskimg_path = disk_img
@ -1013,9 +1033,9 @@ def make_image(opts, ks):
log.info("disk_size = %sMiB", disk_size)
if opts.image_name:
disk_img = joinpaths(opts.tmp, opts.image_name)
disk_img = joinpaths(opts.result_dir, opts.image_name)
else:
disk_img = tempfile.mktemp(prefix="disk", suffix=".img", dir=opts.tmp)
disk_img = tempfile.mktemp(prefix="disk", suffix=".img", dir=opts.result_dir)
log.info("disk_img = %s", disk_img)
try:
@ -1290,6 +1310,12 @@ def main():
errors.append("The results_dir (%s) should not exist, please delete or "
"move its contents" % opts.result_dir)
# Default to putting results into tmp
if not opts.result_dir:
opts.result_dir = opts.tmp
else:
os.makedirs(opts.result_dir)
if opts.iso and not os.path.exists(opts.iso):
errors.append("The iso %s is missing." % opts.iso)
@ -1325,7 +1351,7 @@ def main():
errors.append("The appliance template (%s) doesn't "
"exist" % opts.app_template)
if opts.image_name and os.path.exists(joinpaths(opts.tmp, opts.image_name)):
if opts.image_name and os.path.exists(joinpaths(opts.result_dir, opts.image_name)):
errors.append("The disk image to be created should not exist.")
if opts.qcow2 and not os.path.exists("/usr/bin/qemu-img"):
@ -1361,7 +1387,7 @@ def main():
opts.compress_args = ["-9"]
if opts.app_file:
opts.app_file = joinpaths(opts.tmp, opts.app_file)
opts.app_file = joinpaths(opts.result_dir, opts.app_file)
if opts.make_ostree_live:
opts.make_pxe_live = True
@ -1378,6 +1404,12 @@ def main():
ks = KickstartParser(ks_version, errorsAreFatal=False, missingIncludeIsFatal=False)
ks.readKickstart(opts.ks[0])
# live iso usually needs dracut-live so warn the user if it is missing
if opts.ks and opts.make_iso:
if "dracut-live" not in ks.handler.packages.packageList:
log.error("dracut-live package is missing from the kickstart.")
sys.exit(1)
# Make the disk or filesystem image
if not opts.disk_image and not opts.fs_image:
errors = []
@ -1473,8 +1505,8 @@ def main():
if mounted_sysroot_boot_dir:
umount(mounted_sysroot_boot_dir)
if opts.result_dir and result_dir:
shutil.copytree(result_dir, opts.result_dir)
if opts.result_dir != opts.tmp and result_dir:
copytree(result_dir, opts.result_dir)
shutil.rmtree(result_dir)
log.info("SUMMARY")
@ -1484,8 +1516,7 @@ def main():
log.info("Disk image is at {0}".format(disk_img))
if opts.make_appliance:
log.info("Appliance description is in {0}".format(opts.app_file))
if result_dir:
log.info("Results are in {0}".format(opts.result_dir or result_dir))
log.info("Results are in {0}".format(opts.result_dir))
sys.exit( 0 )

View File

@ -137,11 +137,17 @@ def main(args):
optional.add_option("--tmp", default="/var/tmp",
help="Top level temporary directory" )
optional.add_option("--add-template", dest="add_templates",
action="append", help="Additional template to execute",
default=[])
action="append", help="Additional template for runtime image",
default=[])
optional.add_option("--add-template-var", dest="add_template_vars",
action="append", help="Set variable for additional templates",
default=[])
action="append", help="Set variable for runtime image template",
default=[])
optional.add_option("--add-arch-template", dest="add_arch_templates",
action="append", help="Additional template for architecture-specific image",
default=[])
optional.add_option("--add-arch-template-var", dest="add_arch_template_vars",
action="append", help="Set variable for architecture-specific image",
default=[])
# add the option groups to the parser
parser.add_option_group(required)
@ -201,6 +207,13 @@ def main(args):
raise ValueError("Missing '=' for key=value in " % kv)
parsed_add_template_vars[k] = v
parsed_add_arch_template_vars = {}
for kv in opts.add_arch_template_vars:
k, t, v = kv.partition('=')
if t == '':
raise ValueError("Missing '=' for key=value in " % kv)
parsed_add_arch_template_vars[k] = v
# run lorax
lorax = pylorax.Lorax()
lorax.configure(conf_file=opts.config)
@ -211,6 +224,8 @@ def main(args):
installpkgs=opts.installpkgs,
add_templates=opts.add_templates,
add_template_vars=parsed_add_template_vars,
add_arch_templates=opts.add_arch_templates,
add_arch_template_vars=parsed_add_arch_template_vars,
remove_temp=True)