Experimental single initrd image
This commit is contained in:
parent
8034dd06bb
commit
45c5ef566c
3
Makefile
3
Makefile
@ -9,3 +9,6 @@ install:
|
||||
|
||||
clean:
|
||||
-rm -rf build
|
||||
|
||||
test:
|
||||
/usr/bin/lorax -p FEDORA -v RAWHIDE -r 2010 -s /rawrepo /root/rawhide
|
||||
|
@ -1,4 +0,0 @@
|
||||
[lorax]
|
||||
|
||||
packages:
|
||||
kernel-PAE grub memtest86+
|
@ -1,51 +0,0 @@
|
||||
[lorax]
|
||||
|
||||
packages:
|
||||
anaconda anaconda-yum-plugins yum yum-metadata-parser
|
||||
kernel *firmware* man-db
|
||||
rsyslog ethtool openssh openssh-server strace
|
||||
udev hal dbus dbus-python dbus-x11
|
||||
xorg-x11-server-Xorg xorg-x11-server-utils xorg-x11-drivers
|
||||
xorg-x11-xauth xorg-x11-font-utils xorg-x11-fonts-misc
|
||||
dejavu-sans-fonts dejavu-sans-mono-fonts fontconfig freetype
|
||||
fonts-ISO8859-2
|
||||
gtk2 gtk2-engines gnome-themes metacity pango cairo echo-icon-theme
|
||||
device-mapper device-mapper-libs
|
||||
device-mapper-multipath device-mapper-multipath-libs
|
||||
mdadm lvm2 dmraid dmraid-libs
|
||||
selinux-policy-targeted fcoe-utils
|
||||
libselinux libselinux-python libsemanage libsemanage-python
|
||||
lohit-assamese-fonts lohit-bengali-fonts lohit-gujarati-fonts
|
||||
lohit-hindi-fonts lohit-kashmiri-fonts lohit-kannada-fonts
|
||||
lohit-maithili-fonts lohit-marathi-fonts lohit-oriya-fonts
|
||||
lohit-punjabi-fonts lohit-sindhi-fonts lohit-tamil-fonts lohit-telugu-fonts
|
||||
bitmap-fonts-cjk cjkuni-uming-fonts smc-meera-fonts taipeifonts
|
||||
un-core-dotum-fonts urw-fonts vlgothic-fonts lklug-fonts
|
||||
coreutils bzip2 bzip2-libs cpio
|
||||
cracklib cracklib-dicts cracklib-python cryptsetup-luks
|
||||
GConf2 gnome-python2-gconf gnome-python2-canvas
|
||||
/etc/gtk-2.0/gtkrc ORBit2
|
||||
comps-extras
|
||||
NetworkManager NetworkManager-gnome
|
||||
firstboot setup newt newt-python report-gtk report-newt
|
||||
parted pyparted dosfstools e2fsprogs e2fsprogs-libs gfs2-utils jfsutils
|
||||
nfs-utils ntfs-3g reiserfs-utils xfsprogs samba-client
|
||||
tigervnc-server tigervnc-server-module vim-minimal wget
|
||||
kbd ncurses
|
||||
notification-daemon
|
||||
gobject-introspection
|
||||
syslinux
|
||||
|
||||
modules:
|
||||
sunrpc lockd floppy cramfs loop edd pcspkr squashfs
|
||||
ipv6 virtio_pci ohci-hcd uhci-hcd ehci-hcd usbhid mousedev usb-storage
|
||||
sd_mod sr_mod ub appletouch ohci1394 sbp2 fw-ohci fw-sbp2 firewire-sbp2
|
||||
firewire-ohci mmc-block sdhci sdhci-pci ide-cd ide-cd_mod sr_mod sg st
|
||||
sd_mod scsi_mod iscsi_tcp iscsi_ibft fat msdos vfat ext2 ext3 ext4 reiserfs
|
||||
jfs xfs gfs2 cifs nfs fuse btrfs dm-mod dm-zero dm-snapshot dm-mirror
|
||||
dm-multipath dm-round-robin dm-crypt raid0 raid1 raid5 raid6 raid456 raid10
|
||||
linear sha256_generic cbc xts lrw aes_generic crypto_blkcipher crc32c ecb
|
||||
arc4 yenta_socket i82365 tcic pcmcia =scsi =net =drm
|
||||
|
||||
initrd_template = templates/initrd.ltmpl
|
||||
install_template = templates/install.ltmpl
|
@ -1,243 +0,0 @@
|
||||
## create required directories
|
||||
makedirs "sbin"
|
||||
symlink "sbin" "bin"
|
||||
makedirs "dev"
|
||||
makedirs "etc"
|
||||
makedirs "proc"
|
||||
makedirs "selinux"
|
||||
makedirs "sys"
|
||||
makedirs "tmp"
|
||||
makedirs "var"
|
||||
|
||||
## copy etc stuff
|
||||
copy "etc/passwd"
|
||||
copy "etc/group"
|
||||
copy "etc/hosts"
|
||||
copy "etc/nsswitch.conf"
|
||||
|
||||
## copy mount/umount files
|
||||
copy "bin/mount"
|
||||
copy "bin/umount"
|
||||
copy "sbin/mount.*"
|
||||
copy "sbin/umount.*"
|
||||
|
||||
## copy udev stuff
|
||||
copy "sbin/udevd"
|
||||
copy "sbin/udevadm"
|
||||
symlink "udevadm" "sbin/udevinfo"
|
||||
|
||||
## copy udev conf and rules
|
||||
copy "etc/udev/udev.conf"
|
||||
copy "etc/udev/rules.d/*.rules"
|
||||
copy "lib/udev/*"
|
||||
remove "lib/udev/rules.d/*generator*"
|
||||
|
||||
## copy bash
|
||||
copy "bin/bash"
|
||||
symlink "bash" "bin/sh"
|
||||
|
||||
## other
|
||||
copy "sbin/consoletype"
|
||||
copy "usr/bin/logger" "bin"
|
||||
|
||||
## copy init functions
|
||||
copy "etc/rc.d/init.d/functions"
|
||||
copy "etc/sysconfig/network-scripts/network-functions*"
|
||||
|
||||
## create init.d symlink
|
||||
symlink "/etc/rc.d/init.d" "etc/init.d"
|
||||
|
||||
## dhcp client daemons and support programs
|
||||
copy "sbin/dhclient"
|
||||
copy "sbin/dhclient-script"
|
||||
copy "sbin/arping"
|
||||
copy "sbin/ifconfig"
|
||||
copy "sbin/ip"
|
||||
copy "bin/ipcalc"
|
||||
copy "bin/hostname"
|
||||
copy "sbin/ethtool"
|
||||
copy "sbin/route"
|
||||
touch "etc/resolv.conf"
|
||||
makedirs "etc/dhcp"
|
||||
|
||||
## hwdata
|
||||
copy "usr/share/hwdata/pci.ids"
|
||||
copy "usr/share/hwdata/usb.ids"
|
||||
|
||||
## hal
|
||||
copy "usr/sbin/hald" "sbin"
|
||||
copy "usr/libexec/hald-runner"
|
||||
copy "usr/libexec/hald-generate-fdi-cache"
|
||||
copy "usr/libexec/hal*storage*"
|
||||
copy "usr/share/hal/fdi/*"
|
||||
copy "etc/hal/fdi/*"
|
||||
copy "etc/dbus-1/system.d/hal.conf"
|
||||
makedirs "var/run"
|
||||
touch "var/run/hald.acl-list"
|
||||
|
||||
## policykit
|
||||
copy "etc/polkit-1"
|
||||
copy "usr/share/dbus-1/system-services/org.freedesktop.PolicyKit1.service"
|
||||
copy "usr/share/polkit-1/actions/org.freedesktop.policykit.policy"
|
||||
|
||||
## dbus
|
||||
copy "bin/dbus-uuidgen"
|
||||
copy "bin/dbus-daemon"
|
||||
copy "etc/dbus-1/system.conf"
|
||||
copy "${libdir}/dbus-1/dbus-daemon-launch-helper"
|
||||
makedirs "var/lib/dbus"
|
||||
makedirs "var/run/dbus"
|
||||
|
||||
## wpa_supplicant
|
||||
copy "usr/sbin/wpa_passphrase"
|
||||
copy "usr/sbin/wpa_supplicant"
|
||||
copy "etc/dbus-1/system.d/wpa_supplicant.conf"
|
||||
copy "etc/wpa_supplicant/wpa_supplicant.conf"
|
||||
copy "usr/share/dbus-1/system-services/fi.epitest.hostap.WPASupplicant.service"
|
||||
|
||||
## networkmanager
|
||||
copy "usr/sbin/NetworkManager"
|
||||
makedirs "etc/NetworkManager/dispatcher.d"
|
||||
copy "etc/NetworkManager/nm-system-settings.conf"
|
||||
copy "etc/dbus-1/system.d/NetworkManager.conf"
|
||||
copy "etc/dbus-1/system.d/nm-*.conf"
|
||||
copy "usr/${libdir}/NetworkManager/libnm-*"
|
||||
copy "usr/libexec/nm-*"
|
||||
copy "usr/share/dbus-1/system-services/org.freedesktop.nm_dispatcher.service"
|
||||
|
||||
## modprobe
|
||||
makedirs "etc/modprobe.d"
|
||||
copy "sbin/modprobe"
|
||||
copy "sbin/insmod"
|
||||
copy "sbin/rmmod"
|
||||
copy "sbin/depmod"
|
||||
|
||||
## terminfos
|
||||
copy "usr/share/terminfo/a/ansi"
|
||||
copy "usr/share/terminfo/d/dumb"
|
||||
copy "usr/share/terminfo/l/linux"
|
||||
copy "usr/share/terminfo/s/screen"
|
||||
copy "usr/share/terminfo/v/vt100"
|
||||
copy "usr/share/terminfo/v/vt100-nav"
|
||||
copy "usr/share/terminfo/v/vt102"
|
||||
copy "usr/share/terminfo/x/xterm"
|
||||
copy "usr/share/terminfo/x/xterm-color"
|
||||
copy "usr/share/terminfo/g/gnome"
|
||||
|
||||
## misc
|
||||
copy "bin/awk"
|
||||
copy "bin/grep"
|
||||
copy "bin/egrep"
|
||||
copy "bin/fgrep"
|
||||
copy "bin/kill"
|
||||
copy "bin/ln"
|
||||
copy "usr/bin/readlink" "bin"
|
||||
copy "bin/rm"
|
||||
copy "bin/rmdir"
|
||||
copy "bin/sed"
|
||||
copy "bin/sleep"
|
||||
copy "bin/touch"
|
||||
copy "usr/sbin/dmidecode" "sbin"
|
||||
copy "sbin/load_policy"
|
||||
copy "sbin/mdadm"
|
||||
copy "sbin/mdmon"
|
||||
copy "bin/mkdir"
|
||||
copy "usr/bin/wget" "bin"
|
||||
|
||||
## misc symlinks
|
||||
symlink "/sbin/init" "init"
|
||||
symlink "/proc/mounts" "etc/mtab"
|
||||
makedirs "var/lib"
|
||||
symlink "../../tmp" "var/lib/xkb"
|
||||
|
||||
## loader
|
||||
copy "usr/${libdir}/anaconda/loader" "sbin"
|
||||
copy "usr/share/anaconda/loader.tr" "etc"
|
||||
|
||||
## ld-linux
|
||||
% if basearch in ("i386",):
|
||||
copy "${libdir}/ld-linux.so.2"
|
||||
% elif basearch in ("x86_64",):
|
||||
copy "${libdir}/ld-linux-x86-64.so.2"
|
||||
% endif
|
||||
|
||||
## indirect dependencies
|
||||
copy "${libdir}/libcom_err.so.2"
|
||||
copy "${libdir}/libgcc_s.so.1"
|
||||
copy "${libdir}/libnss_dns.so.2"
|
||||
copy "${libdir}/libnss_files.so.2"
|
||||
copy "usr/${libdir}/libsqlite3.so.0"
|
||||
|
||||
## langtable
|
||||
copy "usr/share/anaconda/lang-table" "etc"
|
||||
|
||||
## arch bits
|
||||
edit "etc/arch" "${buildarch}"
|
||||
|
||||
## rsyslogd
|
||||
copy "sbin/rsyslogd"
|
||||
copy "${libdir}/rsyslog/*"
|
||||
copy "etc/rsyslog.conf"
|
||||
|
||||
|
||||
## missing files
|
||||
copy "usr/sbin/sshd"
|
||||
copy "usr/bin/ssh-keygen"
|
||||
copy "usr/bin/strace"
|
||||
|
||||
makedirs "var/empty"
|
||||
makedirs "var/empty/sshd"
|
||||
makedirs "var/lock"
|
||||
makedirs "var/lock/rpm"
|
||||
makedirs "var/run/NetworkManager"
|
||||
makedirs "var/run/wpa_supplicant"
|
||||
makedirs "var/run/hald"
|
||||
makedirs "var/lib/dhclient"
|
||||
|
||||
|
||||
## security libraries
|
||||
makedirs "${libdir}/security"
|
||||
copy "${libdir}/security/*"
|
||||
|
||||
|
||||
## architecture specific code
|
||||
% if basearch in ("i386", "x86_64"):
|
||||
copy "usr/${libdir}/anaconda/init" "sbin"
|
||||
symlink "init" "sbin/reboot"
|
||||
symlink "init" "sbin/halt"
|
||||
symlink "init" "sbin/poweroff"
|
||||
|
||||
## screenfont
|
||||
copy "usr/share/anaconda/screenfont-${basearch}.gz" "etc"
|
||||
rename "etc/screenfont-${basearch}.gz" "etc/screenfont.gz"
|
||||
% endif
|
||||
|
||||
% if basearch in ("s390", "s390x"):
|
||||
makedirs "etc/ssh"
|
||||
makedirs "etc/security"
|
||||
makedirs "${libdir}/security"
|
||||
makedirs "var/empty/sshd"
|
||||
symlink "../../tmp" "var/state/xkb"
|
||||
|
||||
copy "${libdir}/libpam_misc.so*"
|
||||
copy "${libdir}/libwrap*.so*"
|
||||
|
||||
copy "usr/${libdir}/anaconda/shutdown" "sbin"
|
||||
copy "usr/${libdir}/anaconda/linuxrc.s390" "sbin"
|
||||
rename "sbin/linuxrc.s390" "sbin/init"
|
||||
copy "usr/${libdir}/anaconda/lsznet.raw" "sbin"
|
||||
rename "sbin/lsznet.raw" "sbin/lsznet"
|
||||
copy "usr/${libdir}/anaconda/controlunits.sh" "sbin"
|
||||
rename "sbin/controlunits.sh" "sbin/controlunits"
|
||||
|
||||
copy "${libdir}/security/pam*.so"
|
||||
copy "etc/pam.d/other"
|
||||
copy "etc/security/limits.conf"
|
||||
copy "etc/security/pam_env.conf"
|
||||
|
||||
copy "bin/login"
|
||||
copy "usr/sbin/dasdfmt"
|
||||
copy "usr/sbin/sshd"
|
||||
copy "usr/bin/xauth"
|
||||
copy "usr/sbin/cmsfs*"
|
||||
% endif
|
@ -1,259 +0,0 @@
|
||||
## packages to remove
|
||||
removepkg "acl"
|
||||
removepkg "aic94xx-firmware"
|
||||
removepkg "alsa-firmware"
|
||||
removepkg "alsa-lib"
|
||||
removepkg "alsa-tools-firmware"
|
||||
removepkg "ar9170-firmware"
|
||||
removepkg "atmel-firmware"
|
||||
removepkg "authconfig-gtk"
|
||||
removepkg "avahi-autoipd"
|
||||
removepkg "avahi-libs"
|
||||
removepkg "basesystem"
|
||||
removepkg "bfa-firmware"
|
||||
removepkg "checkpolicy"
|
||||
removepkg "chkconfig"
|
||||
removepkg "control-center-filesystem"
|
||||
removepkg "coreutils-libs"
|
||||
removepkg "cracklib-dicts" "/usr/lib/*"
|
||||
removepkg "cracklib-dicts" "/usr/sbin/*"
|
||||
removepkg "cronie"
|
||||
removepkg "cronie-anacron"
|
||||
removepkg "crontabs"
|
||||
removepkg "crystalhd-firmware"
|
||||
removepkg "cups-libs"
|
||||
removepkg "curl"
|
||||
removepkg "cx18-firmware"
|
||||
removepkg "dash"
|
||||
removepkg "db4-utils"
|
||||
removepkg "dejavu-fonts-common"
|
||||
removepkg "deltarpm"
|
||||
removepkg "desktop-file-utils"
|
||||
removepkg "device-mapper-event"
|
||||
removepkg "diffutils"
|
||||
removepkg "dmraid-events"
|
||||
removepkg "dracut"
|
||||
removepkg "echo-icon-theme"
|
||||
removepkg "exim"
|
||||
removepkg "fedora-release"
|
||||
removepkg "fedora-release-rawhide"
|
||||
removepkg "file"
|
||||
removepkg "filesystem"
|
||||
removepkg "fipscheck"
|
||||
removepkg "firmware-addon-dell"
|
||||
removepkg "firmware-tools"
|
||||
removepkg "firstboot"
|
||||
removepkg "flac"
|
||||
removepkg "fontpackages-filesystem"
|
||||
removepkg "fxload"
|
||||
removepkg "gamin"
|
||||
removepkg "genisoimage"
|
||||
removepkg "gnome-python2"
|
||||
removepkg "gnupg2"
|
||||
removepkg "grubby"
|
||||
removepkg "gstreamer"
|
||||
removepkg "gstreamer-tools"
|
||||
removepkg "hal"
|
||||
removepkg "hal-filesystem"
|
||||
removepkg "hal-info"
|
||||
removepkg "hal-libs"
|
||||
removepkg "info"
|
||||
removepkg "iptables"
|
||||
removepkg "iptables-ipv6"
|
||||
removepkg "ipw2100-firmware"
|
||||
removepkg "ipw2200-firmware"
|
||||
removepkg "iscan-firmware"
|
||||
removepkg "isight-firmware-tools"
|
||||
removepkg "iso8859-2-fonts-common"
|
||||
removepkg "iso8859-2-misc-fonts"
|
||||
removepkg "isomd5sum"
|
||||
removepkg "ivtv-firmware"
|
||||
removepkg "iwl1000-firmware"
|
||||
removepkg "iwl3945-firmware"
|
||||
removepkg "iwl4965-firmware"
|
||||
removepkg "iwl5000-firmware"
|
||||
removepkg "iwl5150-firmware"
|
||||
removepkg "iwl6000-firmware"
|
||||
removepkg "iwl6050-firmware"
|
||||
removepkg "jasper-libs"
|
||||
removepkg "kbd-misc"
|
||||
removepkg "kernel"
|
||||
removepkg "kernel-PAE"
|
||||
removepkg "libasyncns"
|
||||
removepkg "libcgroup"
|
||||
removepkg "libcrystalhd"
|
||||
removepkg "libdaemon"
|
||||
removepkg "libertas-sd8686-firmware"
|
||||
removepkg "libertas-usb8388-firmware"
|
||||
removepkg "libevent"
|
||||
removepkg "libhbaapi"
|
||||
removepkg "libhbalinux"
|
||||
removepkg "libIDL"
|
||||
removepkg "libmcpp"
|
||||
removepkg "libmount"
|
||||
removepkg "libnih"
|
||||
removepkg "libpcap"
|
||||
removepkg "libselinux-utils"
|
||||
removepkg "libsmbios"
|
||||
removepkg "libsndfile"
|
||||
removepkg "libtiff"
|
||||
removepkg "libutempter"
|
||||
removepkg "libwnck"
|
||||
removepkg "libx86"
|
||||
removepkg "libXmu"
|
||||
removepkg "libXres"
|
||||
removepkg "libXt"
|
||||
removepkg "libXv"
|
||||
removepkg "libXvMC"
|
||||
removepkg "libXxf86misc"
|
||||
removepkg "libXxf86vm"
|
||||
removepkg "linux-atm-libs"
|
||||
removepkg "linux-firmware"
|
||||
removepkg "logrotate"
|
||||
removepkg "lvm2-libs"
|
||||
removepkg "m4"
|
||||
removepkg "makebootfat"
|
||||
##removepkg "man-db"
|
||||
removepkg "mcpp"
|
||||
removepkg "memtest86+"
|
||||
removepkg "midisport-firmware"
|
||||
removepkg "mingetty"
|
||||
removepkg "mobile-broadband-provider-info"
|
||||
removepkg "nfs-utils-lib"
|
||||
removepkg "notification-daemon"
|
||||
removepkg "nss-sysinit"
|
||||
removepkg "ntp"
|
||||
removepkg "ntpdate"
|
||||
removepkg "passwd"
|
||||
removepkg "perl"
|
||||
removepkg "perl-Crypt-PasswdMD5"
|
||||
removepkg "perl-Digest-SHA1"
|
||||
removepkg "perl-libs"
|
||||
removepkg "perl-Module-Pluggable"
|
||||
removepkg "perl-Pod-Escapes"
|
||||
removepkg "perl-Pod-Simple"
|
||||
removepkg "pinentry"
|
||||
removepkg "pkgconfig"
|
||||
removepkg "plymouth"
|
||||
removepkg "plymouth-core-libs"
|
||||
removepkg "plymouth-scripts"
|
||||
removepkg "pm-utils"
|
||||
removepkg "ppp"
|
||||
removepkg "pth"
|
||||
removepkg "pulseaudio-libs"
|
||||
removepkg "python-smbios"
|
||||
removepkg "ql2100-firmware"
|
||||
removepkg "ql2200-firmware"
|
||||
removepkg "ql23xx-firmware"
|
||||
removepkg "ql2400-firmware"
|
||||
removepkg "ql2500-firmware"
|
||||
removepkg "radeontool"
|
||||
removepkg "rpcbind"
|
||||
removepkg "rt61pci-firmware"
|
||||
removepkg "rt73usb-firmware"
|
||||
removepkg "samba-client"
|
||||
removepkg "samba-common"
|
||||
removepkg "samba-winbind-clients"
|
||||
removepkg "selinux-policy"
|
||||
removepkg "setuptool"
|
||||
removepkg "sgml-common"
|
||||
removepkg "sgpio"
|
||||
removepkg "shadow-utils"
|
||||
removepkg "shared-mime-info"
|
||||
removepkg "smbios-utils"
|
||||
removepkg "smbios-utils-bin"
|
||||
removepkg "smbios-utils-python"
|
||||
removepkg "smc-fonts-common"
|
||||
removepkg "sound-theme-freedesktop"
|
||||
removepkg "squashfs-tools"
|
||||
removepkg "system-config-firewall-base"
|
||||
removepkg "system-config-users"
|
||||
removepkg "systemd-units"
|
||||
removepkg "system-setup-keyboard"
|
||||
removepkg "taipeifonts"
|
||||
removepkg "ueagle-atm4-firmware"
|
||||
removepkg "un-core-fonts-common"
|
||||
removepkg "upstart"
|
||||
removepkg "upstart-sysvinit"
|
||||
removepkg "urw-fonts"
|
||||
removepkg "usermode"
|
||||
removepkg "usermode-gtk"
|
||||
removepkg "vbetool"
|
||||
removepkg "vlgothic-fonts-common"
|
||||
removepkg "which"
|
||||
removepkg "xdg-utils"
|
||||
removepkg "xml-common"
|
||||
removepkg "xorg-x11-drivers"
|
||||
removepkg "xorg-x11-font-utils"
|
||||
removepkg "xorg-x11-server-common"
|
||||
removepkg "xorg-x11-xauth"
|
||||
removepkg "yum-utils"
|
||||
removepkg "zd1211-firmware"
|
||||
|
||||
## files to remove
|
||||
remove "boot"
|
||||
remove "cgroup"
|
||||
remove "dev"
|
||||
remove "home"
|
||||
remove "media"
|
||||
remove "mnt"
|
||||
remove "opt"
|
||||
remove "pungi"
|
||||
remove "root"
|
||||
remove "selinux"
|
||||
remove "srv"
|
||||
remove "sys"
|
||||
remove "tmp"
|
||||
|
||||
remove "var/cache"
|
||||
remove "var/db"
|
||||
remove "var/empty"
|
||||
remove "var/games"
|
||||
remove "var/lib/NetworkManager"
|
||||
remove "var/lib/alternatives"
|
||||
remove "var/lib/authconfig"
|
||||
remove "var/lib/dhclient"
|
||||
remove "var/lib/dnsmasq"
|
||||
remove "var/lib/games"
|
||||
remove "var/lib/iscsi"
|
||||
remove "var/lib/misc"
|
||||
remove "var/lib/nfs"
|
||||
remove "var/lib/ntp"
|
||||
remove "var/lib/plymouth"
|
||||
remove "var/lib/rpcbind"
|
||||
remove "var/lib/rpm"
|
||||
remove "var/lib/rpm-state"
|
||||
remove "var/lib/samba"
|
||||
remove "var/lib/statless"
|
||||
remove "var/lib/yum"
|
||||
remove "var/local"
|
||||
remove "var/lock"
|
||||
remove "var/log"
|
||||
remove "var/nis"
|
||||
remove "var/opt"
|
||||
remove "var/preserve"
|
||||
remove "var/report"
|
||||
remove "var/run/ConsoleKit"
|
||||
remove "var/run/NetworkManager"
|
||||
remove "var/run/console"
|
||||
remove "var/run/hald"
|
||||
remove "var/run/mdadm"
|
||||
remove "var/run/netreport"
|
||||
remove "var/run/plymouth"
|
||||
remove "var/run/pm-utils"
|
||||
remove "var/run/ppp"
|
||||
remove "var/run/sepermit"
|
||||
remove "var/run/setrans"
|
||||
remove "var/run/wpa_supplicant"
|
||||
remove "var/run/utmp"
|
||||
remove "var/spool"
|
||||
remove "var/tmp"
|
||||
remove "var/yp"
|
||||
|
||||
remove "usr/share/alsa"
|
||||
remove "usr/share/doc"
|
||||
remove "usr/share/gnome/help"
|
||||
remove "usr/share/man"
|
||||
remove "usr/share/mime"
|
||||
remove "usr/share/selinux"
|
||||
remove "usr/share/sgml"
|
@ -1,69 +0,0 @@
|
||||
--- __init__.py.orig 2010-04-15 01:23:43.000000000 +0200
|
||||
+++ __init__.py 2010-08-13 15:17:39.011410249 +0200
|
||||
@@ -754,44 +754,30 @@
|
||||
def doBuildinstall(self):
|
||||
"""Run anaconda-runtime's buildinstall on the tree."""
|
||||
|
||||
+ # initialize yum object
|
||||
+ self._inityum()
|
||||
|
||||
- # setup the buildinstall call
|
||||
- buildinstall = ['/usr/lib/anaconda-runtime/buildinstall']
|
||||
- #buildinstall.append('TMPDIR=%s' % self.workdir) # TMPDIR broken in buildinstall
|
||||
+ # get the required stuff for lorax
|
||||
+ yb = self.ayum
|
||||
+ installtree = self.ayum._conf.installroot
|
||||
+ outputdir = self.topdir
|
||||
+
|
||||
+ product = self.config.get('pungi', 'name')
|
||||
+ version = self.config.get('pungi', 'version')
|
||||
+ release = "%s %s" % (product, version)
|
||||
+
|
||||
+ workdir = self.workdir
|
||||
+
|
||||
+ variant = self.config.get('pungi', 'flavor')
|
||||
+ bugurl = self.config.get('pungi', 'bugurl')
|
||||
+
|
||||
+ # run lorax
|
||||
+ import pylorax
|
||||
+ lorax = pylorax.Lorax(yb, installtree, outputdir,
|
||||
+ product, version, release,
|
||||
+ workdir, variant, bugurl)
|
||||
|
||||
- buildinstall.append('--product')
|
||||
- buildinstall.append(self.config.get('pungi', 'name'))
|
||||
-
|
||||
- if not self.config.get('pungi', 'flavor') == "":
|
||||
- buildinstall.append('--variant')
|
||||
- buildinstall.append(self.config.get('pungi', 'flavor'))
|
||||
-
|
||||
- buildinstall.append('--version')
|
||||
- buildinstall.append(self.config.get('pungi', 'version'))
|
||||
-
|
||||
- buildinstall.append('--release')
|
||||
- buildinstall.append('%s %s' % (self.config.get('pungi', 'name'), self.config.get('pungi', 'version')))
|
||||
-
|
||||
- if self.config.has_option('pungi', 'bugurl'):
|
||||
- buildinstall.append('--bugurl')
|
||||
- buildinstall.append(self.config.get('pungi', 'bugurl'))
|
||||
-
|
||||
- buildinstall.append('--output')
|
||||
- buildinstall.append(self.topdir)
|
||||
-
|
||||
- for mirrorlist in self.mirrorlists:
|
||||
- buildinstall.append('--mirrorlist')
|
||||
- buildinstall.append(mirrorlist)
|
||||
-
|
||||
- buildinstall.append(self.topdir)
|
||||
-
|
||||
- # Add any extra repos of baseurl type
|
||||
- for repo in self.repos:
|
||||
- buildinstall.append(repo)
|
||||
-
|
||||
- # run the command
|
||||
- # TMPDIR is still broken with buildinstall.
|
||||
- pypungi.util._doRunCommand(buildinstall, self.logger) #, env={"TMPDIR": self.workdir})
|
||||
+ lorax.run()
|
||||
|
||||
# write out the tree data for snake
|
||||
self.writeinfo('tree: %s' % self.mkrelative(self.topdir))
|
7
setup.py
7
setup.py
@ -5,11 +5,10 @@ from glob import glob
|
||||
import os
|
||||
|
||||
|
||||
data_files = [("/etc/lorax", glob("etc/config.*")),
|
||||
("/etc/lorax", ["etc/ignore_errors"]),
|
||||
("/etc/lorax/templates", glob("etc/templates/*"))
|
||||
]
|
||||
# config file
|
||||
data_files = [("/etc/lorax", ["etc/lorax.conf"])]
|
||||
|
||||
# shared files
|
||||
for root, dnames, fnames in os.walk("share"):
|
||||
for fname in fnames:
|
||||
data_files.append((root.replace("share", "/usr/share/lorax", 1),
|
||||
|
@ -1,10 +0,0 @@
|
||||
[defaults]
|
||||
skeleton = /mnt/sysimage/etc/skel
|
||||
mailspooldir = /mnt/sysimage/var/mail
|
||||
crypt_style = md5
|
||||
modules = files shadow
|
||||
create_modules = files shadow
|
||||
[files]
|
||||
directory = /mnt/sysimage/etc
|
||||
[shadow]
|
||||
directory = /mnt/sysimage/etc
|
@ -1,2 +0,0 @@
|
||||
SELINUX=permissive
|
||||
SELINUXTYPE=targeted
|
0
share/ignorelist
Normal file
0
share/ignorelist
Normal file
795
share/lorax-s1.ltmpl
Normal file
795
share/lorax-s1.ltmpl
Normal file
@ -0,0 +1,795 @@
|
||||
## lorax template file
|
||||
|
||||
## anaconda package
|
||||
install "anaconda"
|
||||
|
||||
## other required packages
|
||||
install "NetworkManager-gnome"
|
||||
install "at-spi"
|
||||
install "at-spi-python"
|
||||
install "audit"
|
||||
install "bind-libs-lite"
|
||||
install "bind-utils"
|
||||
install "bitmap-fangsongti-fonts"
|
||||
install "btrfs-progs"
|
||||
install "cjkuni-uming-fonts"
|
||||
install "dcbd"
|
||||
install "dejavu-sans-fonts"
|
||||
install "dejavu-sans-mono-fonts"
|
||||
install "dogtail"
|
||||
install "dump"
|
||||
install "efibootmgr"
|
||||
install "ethtool"
|
||||
install "fedora-gnome-theme"
|
||||
install "fedora-icon-theme"
|
||||
install "firstaidkit-engine"
|
||||
install "ftp"
|
||||
install "gdk-pixbuf"
|
||||
install "generic-logos"
|
||||
install "gfs2-utils"
|
||||
install "gir-repository"
|
||||
install "glib"
|
||||
install "gnome-bluetooth-libs"
|
||||
install "gnome-keyring"
|
||||
install "gnome-python2-gconf"
|
||||
install "gnome-themes-legacy"
|
||||
install "groff"
|
||||
install "grub"
|
||||
install "gtk+"
|
||||
install "hdparm"
|
||||
install "jfsutils"
|
||||
install "lcms-libs"
|
||||
install "libbonobo"
|
||||
install "libgnome-keyring"
|
||||
install "libgssglue"
|
||||
install "libjpeg"
|
||||
install "libmlx4"
|
||||
install "libsemanage-python"
|
||||
install "libsysfs"
|
||||
install "libtirpc"
|
||||
install "lklug-fonts"
|
||||
install "lohit-assamese-fonts"
|
||||
install "lohit-bengali-fonts"
|
||||
install "lohit-devanagari-fonts"
|
||||
install "lohit-gujarati-fonts"
|
||||
install "lohit-kannada-fonts"
|
||||
install "lohit-oriya-fonts"
|
||||
install "lohit-punjabi-fonts"
|
||||
install "lohit-tamil-fonts"
|
||||
install "lohit-telugu-fonts"
|
||||
install "lsof"
|
||||
install "lvm2-cluster"
|
||||
install "madan-fonts"
|
||||
install "man-db"
|
||||
install "mt-st"
|
||||
install "mtr"
|
||||
install "network-manager-netbook"
|
||||
install "nfs-utils"
|
||||
install "notification-daemon"
|
||||
install "ntfs-3g"
|
||||
install "ntfsprogs"
|
||||
install "openssh-server"
|
||||
install "pciutils"
|
||||
install "pciutils-libs"
|
||||
install "pcmciautils"
|
||||
install "polkit-desktop-policy"
|
||||
install "python-epdb"
|
||||
install "python-imaging"
|
||||
install "python-volume_key"
|
||||
install "reiserfs-utils"
|
||||
install "rsh"
|
||||
install "rsync"
|
||||
install "rsyslog"
|
||||
install "samba-common"
|
||||
install "samba-winbind-clients"
|
||||
install "selinux-policy-targeted"
|
||||
install "smartmontools"
|
||||
install "smc-meera-fonts"
|
||||
install "strace"
|
||||
install "systemd-sysvinit"
|
||||
install "tigervnc-server-minimal"
|
||||
install "tigervnc-server-module"
|
||||
install "un-core-dotum-fonts"
|
||||
install "usbutils"
|
||||
install "vim-minimal"
|
||||
install "vlgothic-fonts"
|
||||
install "volume_key"
|
||||
install "volume_key-libs"
|
||||
install "wget"
|
||||
install "xfsprogs"
|
||||
install "xorg-x11-drv-acecad"
|
||||
install "xorg-x11-drv-aiptek"
|
||||
install "xorg-x11-drv-apm"
|
||||
install "xorg-x11-drv-ast"
|
||||
install "xorg-x11-drv-ati"
|
||||
install "xorg-x11-drv-cirrus"
|
||||
install "xorg-x11-drv-dummy"
|
||||
install "xorg-x11-drv-elographics"
|
||||
install "xorg-x11-drv-evdev"
|
||||
install "xorg-x11-drv-fbdev"
|
||||
install "xorg-x11-drv-fpit"
|
||||
install "xorg-x11-drv-glint"
|
||||
install "xorg-x11-drv-hyperpen"
|
||||
install "xorg-x11-drv-i128"
|
||||
install "xorg-x11-drv-i740"
|
||||
install "xorg-x11-drv-intel"
|
||||
install "xorg-x11-drv-keyboard"
|
||||
install "xorg-x11-drv-mach64"
|
||||
install "xorg-x11-drv-mga"
|
||||
install "xorg-x11-drv-mouse"
|
||||
install "xorg-x11-drv-mutouch"
|
||||
install "xorg-x11-drv-nouveau"
|
||||
install "xorg-x11-drv-nv"
|
||||
install "xorg-x11-drv-openchrome"
|
||||
install "xorg-x11-drv-penmount"
|
||||
install "xorg-x11-drv-qxl"
|
||||
install "xorg-x11-drv-r128"
|
||||
install "xorg-x11-drv-rendition"
|
||||
install "xorg-x11-drv-s3virge"
|
||||
install "xorg-x11-drv-savage"
|
||||
install "xorg-x11-drv-siliconmotion"
|
||||
install "xorg-x11-drv-sis"
|
||||
install "xorg-x11-drv-sisusb"
|
||||
install "xorg-x11-drv-synaptics"
|
||||
install "xorg-x11-drv-tdfx"
|
||||
install "xorg-x11-drv-trident"
|
||||
install "xorg-x11-drv-v4l"
|
||||
install "xorg-x11-drv-vesa"
|
||||
install "xorg-x11-drv-vmmouse"
|
||||
install "xorg-x11-drv-vmware"
|
||||
install "xorg-x11-drv-void"
|
||||
install "xorg-x11-drv-voodoo"
|
||||
install "xorg-x11-drv-wacom"
|
||||
install "xorg-x11-fonts-ethiopic"
|
||||
install "xorg-x11-server-Xorg"
|
||||
install "xorg-x11-server-utils"
|
||||
##install "${product}-logos"
|
||||
##install "${product}-release"
|
||||
|
||||
## required firmware
|
||||
install "aic94xx-firmware"
|
||||
install "ar9170-firmware"
|
||||
install "atmel-firmware"
|
||||
install "ipw2100-firmware"
|
||||
install "ipw2200-firmware"
|
||||
install "iwl1000-firmware"
|
||||
install "iwl3945-firmware"
|
||||
install "iwl4965-firmware"
|
||||
install "iwl5000-firmware"
|
||||
install "iwl5150-firmware"
|
||||
install "iwl6000-firmware"
|
||||
install "iwl6050-firmware"
|
||||
install "ql2100-firmware"
|
||||
install "ql2200-firmware"
|
||||
install "ql23xx-firmware"
|
||||
install "ql2400-firmware"
|
||||
install "ql2500-firmware"
|
||||
install "zd1211-firmware"
|
||||
|
||||
## not required packages installed as dependencies
|
||||
remove "ConsoleKit-x11"
|
||||
remove "alsa-lib"
|
||||
remove "augeas-libs"
|
||||
remove "authconfig-gtk"
|
||||
remove "avahi-autoipd"
|
||||
remove "avahi-libs"
|
||||
remove "basesystem"
|
||||
remove "checkpolicy"
|
||||
remove "chkconfig"
|
||||
remove "clusterlib"
|
||||
remove "clutter"
|
||||
remove "clutter-gesture"
|
||||
remove "clutter-imcontext"
|
||||
remove "cman"
|
||||
remove "control-center-filesystem"
|
||||
remove "coreutils-libs"
|
||||
remove "corosync"
|
||||
remove "corosynclib"
|
||||
remove "cronie"
|
||||
remove "cronie-anacron"
|
||||
remove "crontabs"
|
||||
remove "cups-libs"
|
||||
remove "curl"
|
||||
remove "cyrus-sasl"
|
||||
remove "cyrus-sasl-md5"
|
||||
remove "dash"
|
||||
remove "db4-utils"
|
||||
remove "dejavu-fonts-common"
|
||||
remove "deltarpm"
|
||||
remove "desktop-file-utils"
|
||||
remove "device-mapper-event"
|
||||
remove "diffutils"
|
||||
remove "dmraid-events"
|
||||
remove "dracut"
|
||||
remove "fedora-release"
|
||||
remove "fedora-release-rawhide"
|
||||
remove "fence-agents"
|
||||
remove "fence-virt"
|
||||
remove "file"
|
||||
remove "filesystem"
|
||||
remove "fipscheck"
|
||||
remove "firstaidkit"
|
||||
remove "firstboot"
|
||||
remove "flac"
|
||||
remove "fontpackages-filesystem"
|
||||
remove "gamin"
|
||||
remove "genisoimage"
|
||||
remove "gnome-python2"
|
||||
remove "gnupg2"
|
||||
remove "grubby"
|
||||
remove "gstreamer-tools"
|
||||
remove "info"
|
||||
remove "ipmitool"
|
||||
remove "iptables"
|
||||
remove "iptables-ipv6"
|
||||
remove "isomd5sum"
|
||||
remove "jasper-libs"
|
||||
remove "json-glib"
|
||||
remove "kbd-misc"
|
||||
remove "libIDL"
|
||||
remove "libXScrnSaver"
|
||||
remove "libXmu"
|
||||
remove "libXres"
|
||||
remove "libXt"
|
||||
remove "libXv"
|
||||
remove "libXvMC"
|
||||
remove "libXxf86misc"
|
||||
remove "libXxf86vm"
|
||||
remove "libassuan"
|
||||
remove "libasyncns"
|
||||
remove "libccss"
|
||||
remove "libcgroup"
|
||||
remove "libcroco"
|
||||
remove "libdaemon"
|
||||
remove "libevent"
|
||||
remove "libhbaapi"
|
||||
remove "libhbalinux"
|
||||
remove "libibverbs"
|
||||
remove "libmcpp"
|
||||
remove "libmodman"
|
||||
remove "libmount"
|
||||
remove "libmx"
|
||||
remove "libnih"
|
||||
remove "libpcap"
|
||||
remove "libproxy"
|
||||
remove "librdmacm"
|
||||
remove "librsvg2"
|
||||
remove "libselinux-utils"
|
||||
remove "libsndfile"
|
||||
remove "libsoup"
|
||||
remove "libtiff"
|
||||
remove "libusb1"
|
||||
remove "libutempter"
|
||||
remove "libvirt-client"
|
||||
remove "libwnck"
|
||||
remove "libxslt"
|
||||
remove "linux-atm-libs"
|
||||
remove "llvm"
|
||||
remove "lm_sensors-libs"
|
||||
remove "logrotate"
|
||||
remove "lvm2-libs"
|
||||
remove "m4"
|
||||
remove "mailx"
|
||||
remove "makebootfat"
|
||||
remove "mcpp"
|
||||
remove "mesa-dri-drivers"
|
||||
remove "mesa-libGL"
|
||||
remove "mingetty"
|
||||
remove "mobile-broadband-provider-info"
|
||||
remove "modcluster"
|
||||
remove "mutter-mbl"
|
||||
remove "mutter-moblin"
|
||||
remove "nbtk"
|
||||
remove "nc"
|
||||
remove "net-snmp-libs"
|
||||
remove "net-snmp-utils"
|
||||
remove "netcf-libs"
|
||||
remove "nfs-utils-lib"
|
||||
remove "nss-sysinit"
|
||||
remove "nss-tools"
|
||||
remove "ntp"
|
||||
remove "ntpdate"
|
||||
remove "numactl"
|
||||
remove "oddjob"
|
||||
remove "openais"
|
||||
remove "openaislib"
|
||||
remove "passwd"
|
||||
remove "perl"
|
||||
remove "perl-Module-Pluggable"
|
||||
remove "perl-Net-Telnet"
|
||||
remove "perl-Pod-Escapes"
|
||||
remove "perl-Pod-Simple"
|
||||
remove "perl-libs"
|
||||
remove "pexpect"
|
||||
remove "pinentry"
|
||||
remove "pkgconfig"
|
||||
remove "plymouth"
|
||||
remove "plymouth-core-libs"
|
||||
remove "plymouth-scripts"
|
||||
remove "ppp"
|
||||
remove "pth"
|
||||
remove "pulseaudio-libs"
|
||||
remove "redhat-menus"
|
||||
remove "ricci"
|
||||
remove "rmt"
|
||||
remove "rpcbind"
|
||||
remove "setuptool"
|
||||
remove "sg3_utils"
|
||||
remove "sg3_utils-libs"
|
||||
remove "sgml-common"
|
||||
remove "sgpio"
|
||||
remove "shadow-utils"
|
||||
remove "shared-mime-info"
|
||||
remove "smc-fonts-common"
|
||||
remove "sound-theme-freedesktop"
|
||||
remove "squashfs-tools"
|
||||
remove "system-config-firewall-base"
|
||||
remove "system-config-users"
|
||||
remove "systemd-units"
|
||||
remove "telnet"
|
||||
remove "tigervnc-license"
|
||||
remove "ttmkfdir"
|
||||
remove "un-core-fonts-common"
|
||||
remove "usermode"
|
||||
remove "usermode-gtk"
|
||||
remove "vlgothic-fonts-common"
|
||||
remove "which"
|
||||
remove "xdg-utils"
|
||||
remove "xen-libs"
|
||||
remove "xen-licenses"
|
||||
remove "xml-common"
|
||||
remove "xorg-x11-font-utils"
|
||||
remove "xorg-x11-server-common"
|
||||
remove "xorg-x11-xauth"
|
||||
remove "xorg-x11-xinit"
|
||||
remove "yajl"
|
||||
remove "yum-utils"
|
||||
|
||||
## required modules
|
||||
module "8021q"
|
||||
module "=drm"
|
||||
module "=net"
|
||||
module "=scsi"
|
||||
module "aes_generic"
|
||||
module "appletouch"
|
||||
module "arc4"
|
||||
module "bcm5974"
|
||||
module "btrfs"
|
||||
module "cbc"
|
||||
module "cifs"
|
||||
module "cramfs"
|
||||
module "crc32c"
|
||||
module "crypto_blkcipher"
|
||||
module "dm-crypt"
|
||||
module "dm-mirror"
|
||||
module "dm-mod"
|
||||
module "dm-multipath"
|
||||
module "dm-round-robin"
|
||||
module "dm-snapshot"
|
||||
module "dm-zero"
|
||||
module "ecb"
|
||||
module "edd"
|
||||
module "ehci-hcd"
|
||||
module "ext2"
|
||||
module "ext3"
|
||||
module "ext4"
|
||||
module "fat"
|
||||
module "firewire-ohci"
|
||||
module "firewire-sbp2"
|
||||
module "floppy"
|
||||
module "fuse"
|
||||
module "fw-ohci"
|
||||
module "fw-sbp2"
|
||||
module "gfs2"
|
||||
module "hfsplus"
|
||||
module "i82365"
|
||||
module "ide-cd"
|
||||
module "ide-cd_mod"
|
||||
module "ipv6"
|
||||
module "iscsi_ibft"
|
||||
module "iscsi_tcp"
|
||||
module "jfs"
|
||||
module "linear"
|
||||
module "lockd"
|
||||
module "loop"
|
||||
module "lrw"
|
||||
module "mmc-block"
|
||||
module "mousedev"
|
||||
module "msdos"
|
||||
module "netconsole"
|
||||
module "nfs"
|
||||
module "ohci-hcd"
|
||||
module "ohci1394"
|
||||
module "pcmcia"
|
||||
module "pcspkr"
|
||||
module "raid0"
|
||||
module "raid1"
|
||||
module "raid10"
|
||||
module "raid456"
|
||||
module "raid5"
|
||||
module "raid6"
|
||||
module "reiserfs"
|
||||
module "sbp2"
|
||||
module "scsi_mod"
|
||||
module "scsi_wait_scan"
|
||||
module "sd_mod"
|
||||
module "sdhci"
|
||||
module "sdhci-pci"
|
||||
module "sg"
|
||||
module "sha256_generic"
|
||||
module "squashfs"
|
||||
module "sr_mod"
|
||||
module "st"
|
||||
module "sunrpc"
|
||||
module "tcic"
|
||||
module "ub"
|
||||
module "uhci-hcd"
|
||||
module "ums-alauda"
|
||||
module "ums-cypress"
|
||||
module "ums-datafab"
|
||||
module "ums-freecom"
|
||||
module "ums-jumpshot"
|
||||
module "ums-karma"
|
||||
module "ums-onetouch"
|
||||
module "ums-sddr09"
|
||||
module "ums-sddr55"
|
||||
module "ums-usbat"
|
||||
module "usb-storage"
|
||||
module "usbhid"
|
||||
module "vfat"
|
||||
module "virtio_pci"
|
||||
module "xfs"
|
||||
module "xts"
|
||||
module "yenta_socket"
|
||||
|
||||
## other removals
|
||||
remove --path "/usr/share/doc"
|
||||
remove --path "/usr/share/info"
|
||||
remove --path "/usr/share/man"
|
||||
|
||||
remove --path "/boot"
|
||||
remove --path "/cgroup"
|
||||
remove --path "/home"
|
||||
remove --path "/media"
|
||||
remove --path "/mnt"
|
||||
remove --path "/opt"
|
||||
remove --path "/srv"
|
||||
|
||||
remove --path "/var/cache"
|
||||
remove --path "/var/db"
|
||||
remove --path "/var/games"
|
||||
remove --path "/var/local"
|
||||
remove --path "/var/log"
|
||||
remove --path "/var/mail"
|
||||
remove --path "/var/nis"
|
||||
remove --path "/var/opt"
|
||||
remove --path "/var/preserve"
|
||||
remove --path "/var/report"
|
||||
remove --path "/var/spool"
|
||||
remove --path "/var/tmp"
|
||||
remove --path "/var/yp"
|
||||
|
||||
## other package specific removals
|
||||
remove "ConsoleKit" "/etc/ConsoleKit*"
|
||||
remove "ConsoleKit" "/etc/init/*"
|
||||
remove "ConsoleKit" "/lib/systemd/*"
|
||||
remove "ConsoleKit" "/usr/bin/*"
|
||||
remove "ConsoleKit" "/usr/lib/*"
|
||||
remove "ConsoleKit" "/usr/sbin/*"
|
||||
remove "GConf2" "/etc/rpm/*"
|
||||
remove "GConf2" "/etc/xdg/*"
|
||||
remove "GConf2" "/usr/bin/*"
|
||||
remove "GConf2" "/usr/share/GConf/*"
|
||||
remove "GConf2" "/usr/share/locale/*"
|
||||
remove "GConf2" "/usr/share/sgml/*"
|
||||
remove "ModemManager" "/usr/${libdir}/*"
|
||||
remove "ModemManager" "/usr/sbin/*"
|
||||
remove "ModemManager" "/usr/share/icons/*"
|
||||
remove "NetworkManager" "/etc/rc.d/*"
|
||||
remove "NetworkManager" "/lib/systemd/*"
|
||||
remove "NetworkManager" "/usr/bin/*"
|
||||
remove "NetworkManager" "/usr/share/NetworkManager/*"
|
||||
remove "NetworkManager-gnome" "/etc/xdg/*"
|
||||
remove "NetworkManager-gnome" "/usr/${libdir}/*"
|
||||
remove "NetworkManager-gnome" "/usr/share/applications/*"
|
||||
remove "anaconda" "/etc/*"
|
||||
remove "anaconda" "/usr/bin/*"
|
||||
remove "anaconda" "/usr/share/applications/*"
|
||||
remove "anaconda" "/usr/share/icons/*"
|
||||
remove "at-spi" "/etc/xdg/*"
|
||||
remove "at-spi" "/usr/share/locale/*"
|
||||
remove "atk" "/usr/share/locale/*"
|
||||
remove "audit" "/etc/*"
|
||||
remove "audit" "/usr/bin/*"
|
||||
remove "audit-libs" "/etc/*"
|
||||
remove "authconfig" "/usr/sbin/*"
|
||||
remove "authconfig" "/usr/share/*"
|
||||
remove "bash" "/etc/*"
|
||||
remove "bash" "/usr/bin/*"
|
||||
remove "bash" "/usr/share/*"
|
||||
remove "bitmap-fangsongti-fonts" "/usr/share/fonts/*"
|
||||
remove "ca-certificates" "/etc/ssl/*"
|
||||
remove "cjkuni-uming-fonts" "/etc/X11/*"
|
||||
remove "coreutils" "/etc/*"
|
||||
remove "coreutils" "/sbin/*"
|
||||
remove "coreutils" "/usr/share/*"
|
||||
remove "cpio" "/usr/share/*"
|
||||
remove "cracklib" "/usr/sbin/*"
|
||||
remove "cracklib-dicts" "/usr/${libdir}/*"
|
||||
remove "cracklib-dicts" "/usr/sbin/*"
|
||||
remove "createrepo" "/usr/bin/*"
|
||||
remove "createrepo" "/usr/share/*"
|
||||
remove "cryptsetup-luks" "/usr/share/*"
|
||||
remove "cyrus-sasl-lib" "/usr/sbin/*"
|
||||
remove "db4" "/usr/*"
|
||||
remove "dbus" "/lib/systemd/*"
|
||||
remove "dbus-glib" "/usr/bin/*"
|
||||
remove "dbus-x11" "/etc/X11/*"
|
||||
remove "dcbd" "/etc/*"
|
||||
remove "device-mapper-multipath" "/etc/*"
|
||||
remove "dhclient" "/usr/*"
|
||||
remove "dmz-cursor-themes" "/usr/share/icons/dmz/*"
|
||||
remove "dnsmasq" "/etc/rc.d/*"
|
||||
remove "dnsmasq" "/usr/sbin/*"
|
||||
remove "dogtail" "/usr/bin/*"
|
||||
remove "dogtail" "/usr/share/applications/*"
|
||||
remove "dogtail" "/usr/share/dogtail/*"
|
||||
remove "dogtail" "/usr/share/icons/*"
|
||||
remove "dump" "/etc/*"
|
||||
remove "e2fsprogs" "/usr/sbin/*"
|
||||
remove "e2fsprogs" "/usr/share/locale/*"
|
||||
remove "elfutils-libelf" "/usr/share/locale/*"
|
||||
remove "ethtool" "/usr/sbin/*"
|
||||
remove "expat" "/usr/bin/*"
|
||||
remove "fcoe-utils" "/etc/rc.d/*"
|
||||
remove "fedora-gnome-theme" "/etc/gtk-3.0/*"
|
||||
remove "fedora-gnome-theme" "/usr/share/themes/*"
|
||||
remove "fedora-logos" "/etc/*"
|
||||
remove "fedora-logos" "/usr/share/firstboot/*"
|
||||
remove "fedora-logos" "/usr/share/gnome-screensaver/*"
|
||||
remove "fedora-logos" "/usr/share/icons/Bluecurve/*"
|
||||
remove "fedora-logos" "/usr/share/icons/hicolor/*"
|
||||
remove "fedora-logos" "/usr/share/icons/oxygen/*"
|
||||
remove "fedora-logos" "/usr/share/pixmaps/*"
|
||||
remove "fedora-logos" "/usr/share/plymouth/*"
|
||||
remove "file-libs" "/usr/share/*"
|
||||
remove "findutils" "/usr/share/*"
|
||||
remove "fontconfig" "/usr/bin/*"
|
||||
remove "gawk" "/usr/bin/*"
|
||||
remove "gawk" "/usr/libexec/*"
|
||||
remove "gawk" "/usr/share/*"
|
||||
remove "gdk-pixbuf2" "/usr/share/locale/*"
|
||||
remove "generic-logos" "/usr/share/pixmaps/*"
|
||||
remove "generic-logos" "/usr/share/plymouth/*"
|
||||
remove "gfs2-utils" "/usr/sbin/*"
|
||||
remove "glib2" "/etc/*"
|
||||
remove "glib2" "/usr/bin/*"
|
||||
remove "glib2" "/usr/share/locale/*"
|
||||
remove "glibc" "/sbin/*"
|
||||
remove "glibc" "/usr/libexec/*"
|
||||
remove "glibc" "/usr/sbin/*"
|
||||
remove "glibc-common" "/etc/*"
|
||||
remove "glibc-common" "/usr/libexec/*"
|
||||
remove "glibc-common" "/usr/share/i18n/*"
|
||||
remove "gnome-bluetooth-libs" "/usr/share/*"
|
||||
remove "gnome-keyring" "/etc/xdg/*"
|
||||
remove "gnome-keyring" "/usr/bin/*"
|
||||
remove "gnome-keyring" "/usr/${libdir}/*"
|
||||
remove "gnome-keyring" "/usr/libexec/*"
|
||||
remove "gnome-keyring" "/usr/share/GConf/*"
|
||||
remove "gnome-keyring" "/usr/share/gcr-3/*"
|
||||
remove "gnome-keyring" "/usr/share/glib-2.0/*"
|
||||
remove "gnome-keyring" "/usr/share/gnome-keyring*"
|
||||
remove "gnome-keyring" "/usr/share/locale/*"
|
||||
remove "gnome-python2-gconf" "/usr/share/pygtk/*"
|
||||
remove "gnome-themes" "/usr/share/icons/Crux/*"
|
||||
remove "gnome-themes" "/usr/share/icons/HighContrast*"
|
||||
remove "gnome-themes" "/usr/share/icons/LargePrint/*"
|
||||
remove "gnome-themes" "/usr/share/locale/*"
|
||||
remove "gnome-themes" "/usr/share/themes/Crux/*"
|
||||
remove "gnome-themes" "/usr/share/themes/Glider/*"
|
||||
remove "gnome-themes" "/usr/share/themes/Glossy/*"
|
||||
remove "gnome-themes" "/usr/share/themes/HighContrast*"
|
||||
remove "gnome-themes" "/usr/share/themes/Inverted/*"
|
||||
remove "gnome-themes" "/usr/share/themes/LargePrint/*"
|
||||
remove "gnome-themes" "/usr/share/themes/LowContrast*"
|
||||
remove "gnome-themes" "/usr/share/themes/Mist/*"
|
||||
remove "gnome-themes" "/usr/share/themes/Simple/*"
|
||||
remove "gnutls" "/usr/share/locale/*"
|
||||
remove "grep" "/etc/*"
|
||||
remove "grep" "/usr/share/locale/*"
|
||||
remove "groff" "/usr/share/*"
|
||||
remove "gstreamer" "/usr/bin/*"
|
||||
remove "gstreamer" "/usr/libexec/*"
|
||||
remove "gstreamer" "/usr/share/locale/*"
|
||||
remove "gtk+" "/etc/*"
|
||||
remove "gtk+" "/usr/share/locale/*"
|
||||
remove "gtk2" "/usr/share/themes/*"
|
||||
remove "gtk2-engines" "/usr/share/gtk-engines/*"
|
||||
remove "gtk2-engines" "/usr/share/locale/*"
|
||||
remove "gtk2-engines" "/usr/share/themes/Crux/*"
|
||||
remove "gtk2-engines" "/usr/share/themes/Industrial/*"
|
||||
remove "gtk2-engines" "/usr/share/themes/Mist/*"
|
||||
remove "gtk2-engines" "/usr/share/themes/ThinIce/*"
|
||||
remove "gtk3" "/usr/share/*"
|
||||
remove "gtk3-engines" "/usr/${libdir}/*"
|
||||
remove "gtk3-engines" "/usr/share/gtk-engines/*"
|
||||
remove "gtk3-engines" "/usr/share/locale/*"
|
||||
remove "gtk3-engines" "/usr/share/themes/Crux/*"
|
||||
remove "gtk3-engines" "/usr/share/themes/GNOME3/*"
|
||||
remove "gtk3-engines" "/usr/share/themes/Industrial/*"
|
||||
remove "gtk3-engines" "/usr/share/themes/Mist/*"
|
||||
remove "gtk3-engines" "/usr/share/themes/Redmond/*"
|
||||
remove "gtk3-engines" "/usr/share/themes/ThinIce/*"
|
||||
remove "gzip" "/usr/bin/*"
|
||||
remove "initscripts" "/etc/ppp/*"
|
||||
remove "initscripts" "/lib/systemd/*"
|
||||
remove "initscripts" "/usr/sbin/*"
|
||||
remove "initscripts" "/usr/share/locale/*"
|
||||
remove "iproute" "/etc/*"
|
||||
remove "iproute" "/usr/*"
|
||||
remove "iputils" "/etc/*"
|
||||
remove "iputils" "/usr/sbin/*"
|
||||
remove "iscsi-initiator-utils" "/etc/rc.d/*"
|
||||
remove "kbd" "/usr/bin/*"
|
||||
remove "kbd" "/usr/share/locale/*"
|
||||
remove "krb5-libs" "/usr/${libdir}/*"
|
||||
remove "less" "/etc/*"
|
||||
remove "libbonobo" "/etc/*"
|
||||
remove "libbonobo" "/usr/bin/*"
|
||||
remove "libbonobo" "/usr/sbin/*"
|
||||
remove "libbonobo" "/usr/share/locale/*"
|
||||
remove "libcanberra" "/usr/${libdir}/libcanberra-*"
|
||||
remove "libcanberra-gtk2" "/usr/${libdir}/gtk-2.0/*"
|
||||
remove "libcanberra-gtk3" "/usr/bin/*"
|
||||
remove "libcanberra-gtk3" "/usr/${libdir}/*"
|
||||
remove "libcap" "/usr/sbin/*"
|
||||
remove "libgnome-keyring" "/usr/share/locale/*"
|
||||
remove "libgnomecanvas" "/usr/share/locale/*"
|
||||
remove "libgpg-error" "/usr/bin/*"
|
||||
remove "libgpg-error" "/usr/share/locale/*"
|
||||
remove "libgssglue" "/etc/*"
|
||||
remove "libidn" "/usr/bin/*"
|
||||
remove "libidn" "/usr/share/locale/*"
|
||||
remove "libjpeg" "/usr/bin/*"
|
||||
remove "libmlx4" "/etc/rdma/*"
|
||||
remove "libmlx4" "/usr/${libdir}/*"
|
||||
remove "libnotify" "/usr/bin/*"
|
||||
remove "libselinux" "/sbin/*"
|
||||
remove "libsemanage" "/etc/selinux/*"
|
||||
remove "libstdc++" "/usr/share/*"
|
||||
remove "libthai" "/usr/share/libthai/*"
|
||||
remove "libuser" "/usr/bin/*"
|
||||
remove "libuser" "/usr/sbin/*"
|
||||
remove "libuser" "/usr/share/locale/*"
|
||||
remove "libxcb" "/usr/${libdir}/libxcb-*"
|
||||
remove "libxml2" "/usr/bin/*"
|
||||
remove "lldpad" "/etc/*"
|
||||
remove "lua" "/usr/bin/*"
|
||||
remove "lvm2" "/etc/*"
|
||||
remove "man-db" "/etc/sysconfig/*"
|
||||
remove "man-db" "/usr/bin/*"
|
||||
remove "man-db" "/usr/libexec/*"
|
||||
remove "man-db" "/usr/sbin/*"
|
||||
remove "man-db" "/usr/share/locale/*"
|
||||
remove "mdadm" "/etc/*"
|
||||
remove "metacity" "/usr/share/applications/*"
|
||||
remove "metacity" "/usr/share/gnome-control-center/*"
|
||||
remove "metacity" "/usr/share/gnome/*"
|
||||
remove "metacity" "/usr/share/locale/*"
|
||||
remove "metacity" "/usr/share/metacity/*"
|
||||
remove "metacity" "/usr/share/themes/AgingGorilla/*"
|
||||
remove "metacity" "/usr/share/themes/Bright/*"
|
||||
remove "metacity" "/usr/share/themes/Crux/*"
|
||||
remove "metacity" "/usr/share/themes/Esco/*"
|
||||
remove "metacity" "/usr/share/themes/Metabox/*"
|
||||
remove "metacity" "/usr/share/themes/Simple/*"
|
||||
remove "module-init-tools" "/etc/*"
|
||||
remove "mt-st" "/etc/*"
|
||||
remove "mt-st" "/sbin/*"
|
||||
remove "mtools" "/etc/*"
|
||||
remove "nettools" "/bin/*"
|
||||
remove "nettools" "/etc/*"
|
||||
remove "nettools" "/usr/share/locale/*"
|
||||
remove "network-manager-netbook" "/etc/*"
|
||||
remove "network-manager-netbook" "/usr/libexec/*"
|
||||
remove "network-manager-netbook" "/usr/share/dbus-1/*"
|
||||
remove "network-manager-netbook" "/usr/share/locale/*"
|
||||
remove "network-manager-netbook" "/usr/share/network-manager-netbook/*"
|
||||
remove "newt" "/usr/share/locale/*"
|
||||
remove "nfsutils" "/etc/*"
|
||||
remove "nfsutils" "/usr/sbin/*"
|
||||
remove "nfsutils" "/var/lib/*"
|
||||
remove "notification-daemon" "/usr/${libdir}/*"
|
||||
remove "notification-daemon" "/usr/libexec/*"
|
||||
remove "notification-daemon" "/usr/share/locale/*"
|
||||
remove "nss" "/etc/pki/*"
|
||||
remove "nss-softokn" "/usr/${libdir}/nss/*"
|
||||
remove "ntfs-3g" "/usr/bin/*"
|
||||
remove "ntfs-progs" "/sbin/*"
|
||||
remove "openldap" "/etc/openldap/*"
|
||||
remove "openssh" "/etc/ssh/*"
|
||||
remove "openssh" "/usr/libexec/*"
|
||||
remove "openssh-clients" "/etc/ssh/*"
|
||||
remove "openssh-clients" "/usr/${libdir}/*"
|
||||
remove "openssh-clients" "/usr/libexec/*"
|
||||
remove "openssh-server" "/etc/ssh/*"
|
||||
remove "openssh-server" "/usr/${libdir}/*"
|
||||
remove "openssh-server" "/usr/libexec/*"
|
||||
remove "openssl" "/etc/pki/*"
|
||||
remove "openssl" "/usr/bin/*"
|
||||
remove "openssl" "/usr/${libdir}/openssl/*"
|
||||
remove "pam" "/sbin/*"
|
||||
remove "pam" "/usr/share/locale/*"
|
||||
remove "pciutils" "/usr/sbin/*"
|
||||
remove "pcmciautils" "/sbin/*"
|
||||
remove "pcre" "/usr/bin/*"
|
||||
remove "pcre" "/usr/${libdir}/*"
|
||||
remove "policycoreutils" "/etc/*"
|
||||
remove "policycoreutils" "/usr/bin/*"
|
||||
remove "policycoreutils" "/usr/share/locale/*"
|
||||
remove "polkit" "/usr/bin/*"
|
||||
remove "polkit-desktop-policy" "/var/lib/*"
|
||||
remove "popt" "/usr/share/locale/*"
|
||||
remove "procps" "/sbin/*"
|
||||
remove "psmisc" "/sbin/*"
|
||||
remove "psmisc" "/usr/share/locale/*"
|
||||
remove "pygtk2" "/usr/bin/*"
|
||||
remove "pygtk2" "/usr/${libdir}/pygtk/*"
|
||||
remove "pykickstart" "/usr/bin/*"
|
||||
remove "pykickstart" "/usr/share/locale/*"
|
||||
remove "python-bugzilla" "/usr/bin/*"
|
||||
remove "python-ethtool" "/usr/sbin/*"
|
||||
remove "python-meh" "/usr/share/locale/*"
|
||||
remove "readline" "/usr/${libdir}/*"
|
||||
remove "report" "/usr/bin/*"
|
||||
remove "report" "/usr/include/*"
|
||||
remove "report" "/usr/${libdir}/libstrata_*"
|
||||
remove "report" "/usr/share/locale/*"
|
||||
remove "rpm" "/usr/bin/*"
|
||||
remove "rpm" "/usr/lib/rpm/platform/*"
|
||||
remove "rpm" "/usr/share/locale/*"
|
||||
remove "rsync" "/etc/*"
|
||||
remove "samba-common" "/etc/*"
|
||||
remove "samba-common" "/usr/bin/*"
|
||||
remove "samba-common" "/usr/include/*"
|
||||
remove "samba-common" "/usr/${libdir}/*"
|
||||
remove "samba-common" "/usr/share/locale/*"
|
||||
remove "sed" "/usr/share/locale/*"
|
||||
remove "selinux-policy-targeted" "/usr/share/selinux/*"
|
||||
remove "smartmontools" "/etc/*"
|
||||
remove "smartmontools" "/usr/share/smartmontools/*"
|
||||
remove "sqlite" "/usr/bin/*"
|
||||
remove "system-config-date" "/etc/*"
|
||||
remove "system-config-date" "/usr/bin/*"
|
||||
remove "system-config-date" "/usr/share/icons/*"
|
||||
remove "system-config-keyboard" "/etc/*"
|
||||
remove "system-config-keyboard" "/usr/bin/*"
|
||||
remove "system-config-keyboard" "/usr/share/icons/*"
|
||||
remove "systemd" "/bin/*"
|
||||
remove "systemd" "/lib/systemd/*"
|
||||
remove "systemd" "/usr/share/systemd/*"
|
||||
remove "sysvinit-tools" "/bin/*"
|
||||
remove "sysvinit-tools" "/usr/bin/*"
|
||||
remove "tar" "/usr/share/locale/*"
|
||||
remove "usbutils" "/usr/bin/*"
|
||||
remove "util-linux-ng" "/usr/share/locale/*"
|
||||
remove "volume_key-libs" "/usr/share/locale/*"
|
||||
remove "wget" "/etc/*"
|
||||
remove "wget" "/usr/share/locale/*"
|
||||
remove "xfsprogs" "/${libdir}/*"
|
||||
remove "xfsprogs" "/usr/share/locale/*"
|
||||
remove "xkeyboard-config" "/usr/share/locale/*"
|
||||
remove "xorg-x11-drv-intel" "/usr/${libdir}/libI*"
|
||||
remove "xorg-x11-drv-openchrome" "/usr/${libdir}/libchrome*"
|
||||
remove "xorg-x11-drv-synaptics" "/usr/bin/*"
|
||||
remove "xorg-x11-drv-vmmouse" "/usr/bin/*"
|
||||
remove "xorg-x11-drv-wacom" "/usr/bin/*"
|
||||
remove "xorg-x11-fonts-ethiopic" "/etc/X11/*"
|
||||
remove "xorg-x11-fonts-misc" "/etc/X11/*"
|
||||
remove "xorg-x11-fonts-misc" "/usr/share/X11/fonts/encodings/*"
|
||||
remove "yum" "etc/*"
|
||||
remove "yum" "/usr/share/locale/*"
|
||||
remove "yum" "/usr/share/yum-cli/*"
|
||||
remove "zenity" "/usr/share/gnome/help/*"
|
||||
remove "zenity" "/usr/share/omf/*"
|
3
share/lorax-s2.ltmpl
Normal file
3
share/lorax-s2.ltmpl
Normal file
@ -0,0 +1,3 @@
|
||||
## locales.img template file
|
||||
|
||||
move "/usr/share/locale"
|
142
src/bin/lorax
Normal file → Executable file
142
src/bin/lorax
Normal file → Executable file
@ -27,15 +27,15 @@ import sys
|
||||
import os
|
||||
import tempfile
|
||||
from optparse import OptionParser, OptionGroup
|
||||
import ConfigParser
|
||||
|
||||
import yum
|
||||
import pylorax
|
||||
import pylorax.config
|
||||
from pylorax.yumbase import get_yum_base_object
|
||||
|
||||
|
||||
def main(args):
|
||||
version = "{0} 0.1".format(os.path.basename(args[0]))
|
||||
usage = "%prog -p PRODUCT -v VERSION -r RELEASE -o OUTPUTDIR REPOSITORY"
|
||||
usage = "%prog -p PRODUCT -v VERSION -r RELEASE -s REPOSITORY OUTPUTDIR"
|
||||
|
||||
parser = OptionParser(usage=usage)
|
||||
|
||||
@ -47,8 +47,9 @@ def main(args):
|
||||
metavar="STRING")
|
||||
required.add_option("-r", "--release", help="release information",
|
||||
metavar="STRING")
|
||||
required.add_option("-o", "--outputdir", help="output directory",
|
||||
metavar="PATHSPEC")
|
||||
required.add_option("-s", "--source",
|
||||
help="source repository (may be listed multibple times)",
|
||||
metavar="REPOSITORY", action="append", default=[])
|
||||
|
||||
# optional arguments
|
||||
optional = OptionGroup(parser, "optional arguments")
|
||||
@ -60,30 +61,10 @@ def main(args):
|
||||
optional.add_option("-b", "--bugurl",
|
||||
help="bug reporting URL for the product", metavar="URL",
|
||||
default="your distribution provided bug reporting tool")
|
||||
optional.add_option("-u", "--updates",
|
||||
help="directory containing updates", metavar="PATHSPEC")
|
||||
|
||||
# output settings
|
||||
output = OptionGroup(parser, "output settings")
|
||||
output.add_option("--no-colors", help="disable color output",
|
||||
action="store_false", default=True, dest="colors")
|
||||
output.add_option("--encoding", help="set encoding",
|
||||
metavar="STRING", default="utf-8")
|
||||
output.add_option("-d", "--debug", help="enable debugging messages",
|
||||
action="store_true", default=False)
|
||||
|
||||
# lorax settings
|
||||
settings = OptionGroup(parser, "lorax settings")
|
||||
settings.add_option("--pedantic", help="don't ignore copy errors",
|
||||
action="store_true", default=False)
|
||||
settings.add_option("-c", "--cleanup", help="clean up on exit",
|
||||
action="store_true", default=False)
|
||||
|
||||
# add the option groups to the parser
|
||||
parser.add_option_group(required)
|
||||
parser.add_option_group(optional)
|
||||
parser.add_option_group(output)
|
||||
parser.add_option_group(settings)
|
||||
|
||||
# add the show version option
|
||||
parser.add_option("-V", help="show program's version number and exit",
|
||||
@ -91,7 +72,7 @@ def main(args):
|
||||
|
||||
# parse the arguments
|
||||
opts, args = parser.parse_args()
|
||||
repositories = args
|
||||
outputdir = args[0]
|
||||
|
||||
if opts.showver:
|
||||
print(version)
|
||||
@ -99,7 +80,7 @@ def main(args):
|
||||
|
||||
# check for the required arguments
|
||||
if not opts.product or not opts.version or not opts.release \
|
||||
or not opts.outputdir or not repositories:
|
||||
or not opts.source or not outputdir:
|
||||
parser.error("missing one or more required arguments")
|
||||
|
||||
# create the temporary directory for lorax
|
||||
@ -111,7 +92,7 @@ def main(args):
|
||||
yumtempdir = os.path.join(tempdir, "yum")
|
||||
os.mkdir(yumtempdir)
|
||||
|
||||
yb = get_yum_base_object(installtree, repositories, opts.mirrorlist,
|
||||
yb = get_yum_base_object(installtree, opts.source, opts.mirrorlist,
|
||||
yumtempdir)
|
||||
|
||||
if yb is None:
|
||||
@ -119,27 +100,94 @@ def main(args):
|
||||
shutil.rmtree(tempdir)
|
||||
sys.exit(1)
|
||||
|
||||
# configure lorax
|
||||
config = pylorax.config.LoraxConfig()
|
||||
config.colors = opts.colors
|
||||
config.encoding = opts.encoding
|
||||
config.debug = opts.debug
|
||||
|
||||
config.pedantic = opts.pedantic
|
||||
|
||||
# run lorax
|
||||
params = {"installtree": installtree,
|
||||
"outputdir": opts.outputdir,
|
||||
"product": opts.product,
|
||||
"version": opts.version,
|
||||
"release": opts.release,
|
||||
"workdir": tempdir,
|
||||
"variant": opts.variant,
|
||||
"bugurl": opts.bugurl,
|
||||
"updatesdir": opts.updates}
|
||||
lorax = pylorax.Lorax()
|
||||
lorax.configure()
|
||||
lorax.run(yb, opts.product, opts.version, opts.release,
|
||||
opts.variant, opts.bugurl,
|
||||
workdir=tempdir, outputdir=outputdir)
|
||||
|
||||
lorax = pylorax.Lorax(yb, **params)
|
||||
lorax.run()
|
||||
|
||||
def get_yum_base_object(installroot, repositories, mirrorlists=[],
|
||||
tempdir="/tmp"):
|
||||
|
||||
def sanitize_repo(repo):
|
||||
if repo.startswith("/"):
|
||||
return "file://{0}".format(repo)
|
||||
elif (repo.startswith("http://") or repo.startswith("ftp://")
|
||||
or repo.startswith("file://")):
|
||||
return repo
|
||||
else:
|
||||
return None
|
||||
|
||||
# sanitize the repositories
|
||||
repositories = map(sanitize_repo, repositories)
|
||||
mirrorlists = map(sanitize_repo, mirrorlists)
|
||||
|
||||
# remove invalid repositories
|
||||
repositories = filter(bool, repositories)
|
||||
mirrorlists = filter(bool, mirrorlists)
|
||||
|
||||
#cachedir = os.path.join(tempdir, "yum.cache")
|
||||
#if not os.path.isdir(cachedir):
|
||||
# os.mkdir(cachedir)
|
||||
|
||||
yumconf = os.path.join(tempdir, "yum.conf")
|
||||
c = ConfigParser.ConfigParser()
|
||||
|
||||
# add the main section
|
||||
section = "main"
|
||||
data = {#"cachedir": cachedir,
|
||||
#"keepcache": 0,
|
||||
"gpgcheck": 0,
|
||||
"plugins": 0,
|
||||
"reposdir": "",
|
||||
"tsflags": "nodocs"}
|
||||
|
||||
c.add_section(section)
|
||||
map(lambda (key, value): c.set(section, key, value), data.items())
|
||||
|
||||
# add the main repository - the first repository from list
|
||||
section = "lorax-repo"
|
||||
data = {"name": "lorax repo",
|
||||
"baseurl": repositories[0],
|
||||
"enabled": 1}
|
||||
|
||||
c.add_section(section)
|
||||
map(lambda (key, value): c.set(section, key, value), data.items())
|
||||
|
||||
# add the extra repositories
|
||||
for n, extra in enumerate(repositories[1:], start=1):
|
||||
section = "lorax-extra-repo-{0:d}".format(n)
|
||||
data = {"name": "lorax extra repo {0:d}".format(n),
|
||||
"baseurl": extra,
|
||||
"enabled": 1}
|
||||
|
||||
c.add_section(section)
|
||||
map(lambda (key, value): c.set(section, key, value), data.items())
|
||||
|
||||
# add the mirrorlists
|
||||
for n, mirror in enumerate(mirrorlists, start=1):
|
||||
section = "lorax-mirrorlist-{0:d}".format(n)
|
||||
data = {"name": "lorax mirrorlist {0:d}".format(n),
|
||||
"mirrorlist": mirror,
|
||||
"enabled": 1 }
|
||||
|
||||
c.add_section(section)
|
||||
map(lambda (key, value): c.set(section, key, value), data.items())
|
||||
|
||||
# write the yum configuration file
|
||||
with open(yumconf, "w") as f:
|
||||
c.write(f)
|
||||
|
||||
# create the yum base object
|
||||
yb = yum.YumBase()
|
||||
|
||||
yb.preconf.fn = yumconf
|
||||
yb.preconf.root = installroot
|
||||
#yb.repos.setCacheDir(cachedir)
|
||||
|
||||
return yb
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -20,17 +20,9 @@
|
||||
#
|
||||
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
import sys
|
||||
import os
|
||||
import shlex
|
||||
import shutil
|
||||
|
||||
import config
|
||||
import constants
|
||||
import output
|
||||
import ltmpl
|
||||
from sysutils import *
|
||||
|
||||
|
||||
class BaseLoraxClass(object):
|
||||
@ -39,9 +31,6 @@ class BaseLoraxClass(object):
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
self.conf = config.LoraxConfig()
|
||||
self.const = constants.LoraxConstants()
|
||||
self.cmd = constants.LoraxCommands()
|
||||
self.output = output.LoraxOutput()
|
||||
|
||||
def pcritical(self, msg, file=sys.stdout):
|
||||
@ -58,97 +47,3 @@ class BaseLoraxClass(object):
|
||||
|
||||
def pdebug(self, msg, file=sys.stdout):
|
||||
self.output.debug(msg, file)
|
||||
|
||||
|
||||
class BaseImageClass(BaseLoraxClass):
|
||||
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
BaseLoraxClass.__init__(self)
|
||||
self.srctree, self.dsttree = None, None
|
||||
self.pkgs_to_remove = set()
|
||||
|
||||
def parse_template(self, template_file, variables={}):
|
||||
template = ltmpl.Template()
|
||||
|
||||
for lineno, line in template.parse(template_file, variables):
|
||||
fields = shlex.split(line)
|
||||
func, args = fields[0], fields[1:]
|
||||
|
||||
func = getattr(self, func, None)
|
||||
|
||||
if not func:
|
||||
err = "invalid command: {0}"
|
||||
err = err.format(line)
|
||||
self.perror(err)
|
||||
else:
|
||||
try:
|
||||
msg = "{0}({1})".format(func.__name__, ", ".join(args))
|
||||
self.pdebug(msg)
|
||||
func(*args)
|
||||
except TypeError:
|
||||
err = "invalid command syntax: {0}"
|
||||
err = err.format(line)
|
||||
self.perror(err)
|
||||
|
||||
def makedirs(self, *dirs):
|
||||
for dir in dirs:
|
||||
dir = os.path.join(self.dsttree, dir)
|
||||
makedirs_(dir)
|
||||
|
||||
def remove(self, *fnames):
|
||||
for fname in fnames:
|
||||
fname = os.path.join(self.dsttree, fname)
|
||||
remove_(fname)
|
||||
|
||||
def removepkg(self, *args):
|
||||
pkgname = args[0]
|
||||
try:
|
||||
mask = args[1]
|
||||
except IndexError:
|
||||
mask = "*"
|
||||
|
||||
self.pkgs_to_remove.add((pkgname, mask))
|
||||
|
||||
def symlink(self, link_target, link_name):
|
||||
link_name = os.path.join(self.dsttree, link_name)
|
||||
symlink_(link_target, link_name)
|
||||
|
||||
def touch(self, fname):
|
||||
fname = os.path.join(self.dsttree, fname)
|
||||
touch_(fname)
|
||||
|
||||
def chown(self):
|
||||
# TODO
|
||||
raise NotImplementedError
|
||||
|
||||
def chmod(self):
|
||||
# TODO
|
||||
raise NotImplementedError
|
||||
|
||||
def replace(self):
|
||||
# TODO
|
||||
raise NotImplementedError
|
||||
|
||||
def copy(self, fname, target=None):
|
||||
dstdir = os.path.dirname(fname)
|
||||
if target:
|
||||
dstdir = target
|
||||
|
||||
if dstdir:
|
||||
makedirs_(os.path.join(self.dsttree, dstdir))
|
||||
|
||||
dcopy_(fname, dstdir, self.srctree, self.dsttree,
|
||||
ignore_errors=not self.conf.pedantic)
|
||||
|
||||
def rename(self, fname, target):
|
||||
fname = os.path.join(self.dsttree, fname)
|
||||
target = os.path.join(self.dsttree, target)
|
||||
shutil.move(fname, target)
|
||||
|
||||
def edit(self, fname, text):
|
||||
fname = os.path.join(self.dsttree, fname)
|
||||
with open(fname, "w") as f:
|
||||
f.write(text)
|
||||
|
@ -1,44 +0,0 @@
|
||||
#
|
||||
# config.py
|
||||
#
|
||||
# Copyright (C) 2009 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
||||
#
|
||||
|
||||
from decorators import singleton
|
||||
import output
|
||||
|
||||
|
||||
@singleton
|
||||
class LoraxConfig(object):
|
||||
|
||||
def __init__(self):
|
||||
# output settings
|
||||
self.colors = True
|
||||
self.encoding = "utf-8"
|
||||
self.debug = True
|
||||
|
||||
self.pedantic = False
|
||||
|
||||
self.confdir = "/etc/lorax"
|
||||
self.datadir = "/usr/share/lorax"
|
||||
|
||||
self.ignore_errors = "/etc/lorax/ignore_errors"
|
||||
|
||||
def __setattr__(self, attr, value):
|
||||
output.LoraxOutput().debug("[set {0}={1}]".format(attr, value))
|
||||
object.__setattr__(self, attr, value)
|
@ -19,63 +19,44 @@
|
||||
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
||||
#
|
||||
|
||||
from os.path import join as pjoin
|
||||
import os
|
||||
|
||||
from sysutils import joinpaths
|
||||
|
||||
|
||||
class LoraxConstants(object):
|
||||
|
||||
ROOT_UID = 0
|
||||
|
||||
ANACONDA_PACKAGE = "anaconda"
|
||||
ANACONDA_RUNTIME = "usr/share/anaconda"
|
||||
ANACONDA_BOOTDIR = "usr/share/anaconda/boot"
|
||||
|
||||
BOOTDIR = "boot"
|
||||
BOOTDIR_IA64 = "boot/efi/EFI/redhat"
|
||||
|
||||
EFIDIR = "boot/efi/EFI/redhat"
|
||||
SPLASH = "boot/grub/splash.xpm.gz"
|
||||
|
||||
VESASPLASH = "usr/lib/anaconda-runtime/syslinux-vesa-splash.jpg"
|
||||
SYSLINUXSPLASH = pjoin(ANACONDA_BOOTDIR, "syslinux-splash.jpg")
|
||||
SPLASHTOOLS = pjoin(ANACONDA_RUNTIME, "splashtools.sh")
|
||||
SPLASHLSS = pjoin(ANACONDA_BOOTDIR, "splash.lss")
|
||||
VESAMENU = "usr/share/syslinux/vesamenu.c32"
|
||||
|
||||
MODDIR = "lib/modules"
|
||||
FWDIR = "lib/firmware"
|
||||
|
||||
MODDEPFILE = "modules.dep"
|
||||
MODULEINFO = "module-info"
|
||||
|
||||
LOCALEDIR = "usr/lib/locale"
|
||||
LOCALES = "usr/share/locale"
|
||||
LANGTABLE = "usr/share/anaconda/lang-table"
|
||||
|
||||
ISOLINUXBIN = "usr/share/syslinux/isolinux.bin"
|
||||
SYSLINUXCFG = "usr/share/anaconda/boot/syslinux.cfg"
|
||||
|
||||
LDSOCONF = "etc/ld.so.conf"
|
||||
MANCONF = "etc/man_db.conf"
|
||||
|
||||
|
||||
class LoraxCommands(dict):
|
||||
class LoraxRequiredCommands(dict):
|
||||
|
||||
def __init__(self):
|
||||
self["MODINFO"] = "/sbin/modinfo"
|
||||
self["DEPMOD"] = "/sbin/depmod"
|
||||
self["LOCALEDEF"] = "/usr/bin/localedef"
|
||||
self["MKDOSFS"] = "/sbin/mkdosfs"
|
||||
self["MKSQUASHFS"] = "/sbin/mksquashfs"
|
||||
self["MKISOFS"] = "/usr/bin/mkisofs"
|
||||
self["ISOHYBRID"] = "/usr/bin/isohybrid"
|
||||
self["LOSETUP"] = "/sbin/losetup"
|
||||
self["DMSETUP"] = "/sbin/dmsetup"
|
||||
self["AWK"] = "/usr/bin/awk"
|
||||
self["MOUNT"] = "/bin/mount"
|
||||
self["UMOUNT"] = "/bin/umount"
|
||||
self["LDCONFIG"] = "/sbin/ldconfig"
|
||||
self["PARTED"] = "/sbin/parted"
|
||||
self.__path = os.environ["PATH"].split(":")
|
||||
|
||||
self["AWK"] = "awk"
|
||||
self["BUILD_LOCALE_ARCHIVE"] = "build-locale-archive"
|
||||
self["CPIO"] = "cpio"
|
||||
self["DEPMOD"] = "depmod"
|
||||
self["DMSETUP"] = "dmsetup"
|
||||
self["FIND"] = "find"
|
||||
self["ISOHYBRID"] = "isohybrid"
|
||||
self["LDCONFIG"] = "ldconfig"
|
||||
self["LOCALEDEF"] = "localedef"
|
||||
self["LOSETUP"] = "losetup"
|
||||
self["MKDOSFS"] = "mkdosfs"
|
||||
self["MKISOFS"] = "mkisofs"
|
||||
self["MKSQUASHFS"] = "mksquashfs"
|
||||
self["MODINFO"] = "modinfo"
|
||||
self["MOUNT"] = "mount"
|
||||
self["PARTED"] = "parted"
|
||||
self["UMOUNT"] = "umount"
|
||||
|
||||
def __getattr__(self, attr):
|
||||
return self[attr]
|
||||
|
||||
def get_missing(self):
|
||||
missing = []
|
||||
for cmd in self.values():
|
||||
found = [joinpaths(path, cmd) for path in self.__path
|
||||
if os.path.exists(joinpaths(path, cmd))]
|
||||
|
||||
if not found:
|
||||
missing.append(cmd)
|
||||
|
||||
return missing
|
||||
|
@ -1,915 +0,0 @@
|
||||
#
|
||||
# images.py
|
||||
#
|
||||
# Copyright (C) 2009 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
||||
#
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import gzip
|
||||
import commands
|
||||
import tempfile
|
||||
import math
|
||||
import glob
|
||||
import fnmatch
|
||||
|
||||
from base import BaseImageClass
|
||||
from sysutils import *
|
||||
|
||||
|
||||
class InitRD(BaseImageClass):
|
||||
|
||||
def __init__(self, installtree, modules, template_file, workdir="/tmp"):
|
||||
BaseImageClass.__init__(self)
|
||||
|
||||
self.installtree = installtree
|
||||
self.modules = modules
|
||||
self.template_file = template_file
|
||||
self.workdir = workdir
|
||||
|
||||
self.srctree = self.installtree.rootdir
|
||||
self.dsttree = None
|
||||
|
||||
def create(self):
|
||||
for kernel in self.installtree.kernels:
|
||||
msg = ":: creating the initrd image for <b>{0}</b>"
|
||||
msg = msg.format(kernel.filename)
|
||||
self.pinfo(msg)
|
||||
|
||||
# prepare the working environment
|
||||
self.pinfo("preparing the work environment")
|
||||
self.prepare(kernel)
|
||||
|
||||
# get the kernel modules
|
||||
self.pinfo("getting the kernel modules")
|
||||
self.get_kernel_modules(kernel, self.modules)
|
||||
|
||||
# get keymaps
|
||||
self.pinfo("creating keymaps")
|
||||
ok = self.get_keymaps()
|
||||
if not ok:
|
||||
self.perror("could not create keymaps")
|
||||
continue
|
||||
|
||||
# create locales
|
||||
self.pinfo("creating locales")
|
||||
ok = self.create_locales()
|
||||
if not ok:
|
||||
self.perror("could not create locales")
|
||||
continue
|
||||
|
||||
# parse the template file
|
||||
self.pinfo("parsing the template")
|
||||
variables = {"buildarch": self.conf.buildarch,
|
||||
"basearch": self.conf.basearch,
|
||||
"libdir": self.conf.libdir}
|
||||
self.parse_template(self.template_file, variables)
|
||||
|
||||
# create the initrd file
|
||||
self.pinfo("compressing the initrd image file")
|
||||
initrdfile = self.compress(kernel)
|
||||
if not initrdfile:
|
||||
self.perror("could not create the initrd image file")
|
||||
continue
|
||||
|
||||
yield (kernel, initrdfile)
|
||||
|
||||
def prepare(self, kernel):
|
||||
# create the initrd working directory
|
||||
dir = os.path.join(self.workdir, "initrd-{0}".format(kernel.version))
|
||||
if os.path.isdir(dir):
|
||||
shutil.rmtree(dir)
|
||||
os.mkdir(dir)
|
||||
|
||||
# set the destination tree
|
||||
self.dsttree = dir
|
||||
|
||||
# copy the buildstamp
|
||||
shutil.copy2(self.conf.buildstamp, self.dsttree)
|
||||
|
||||
# create the .profile
|
||||
profile = os.path.join(self.dsttree, ".profile")
|
||||
text = """PS1="[anaconda \u@\h \W]\\$ "
|
||||
PATH=/bin:/usr/bin:/usr/sbin:/mnt/sysimage/sbin:/mnt/sysimage/usr/sbin:/mnt/sysimage/bin:/mnt/sysimage/usr/bin
|
||||
export PS1 PATH
|
||||
|
||||
"""
|
||||
|
||||
with open(profile, "w") as f:
|
||||
f.write(text)
|
||||
|
||||
# create the lib directories
|
||||
os.mkdir(os.path.join(self.dsttree, self.conf.libdir))
|
||||
os.makedirs(os.path.join(self.dsttree, "usr", self.conf.libdir))
|
||||
|
||||
# XXX
|
||||
def get_kernel_modules(self, kernel, modset):
|
||||
moddir = os.path.join(self.const.MODDIR, kernel.version)
|
||||
src_moddir = os.path.join(self.srctree, moddir)
|
||||
dst_moddir = os.path.join(self.dsttree, "modules", kernel.version)
|
||||
|
||||
# create the lib/modules symlink
|
||||
libmod = os.path.join(self.dsttree, self.const.MODDIR)
|
||||
libmoddir = os.path.dirname(libmod)
|
||||
if not os.path.isdir(libmoddir):
|
||||
os.makedirs(libmoddir)
|
||||
os.symlink("../modules", libmod)
|
||||
|
||||
# copy all modules to the initrd tree
|
||||
os.makedirs(os.path.dirname(dst_moddir))
|
||||
shutil.copytree(src_moddir, dst_moddir)
|
||||
|
||||
# expand modules
|
||||
modules = set()
|
||||
pattern = re.compile(r"\.ko$")
|
||||
for name in modset:
|
||||
if name.startswith("="):
|
||||
group = name[1:]
|
||||
if group in ("scsi", "ata"):
|
||||
p = os.path.join(src_moddir, "modules.block")
|
||||
elif group == "net":
|
||||
p = os.path.join(src_moddir, "modules.networking")
|
||||
else:
|
||||
p = os.path.join(src_moddir, "modules.{0}".format(group))
|
||||
|
||||
if os.path.isfile(p):
|
||||
with open(p, "r") as f:
|
||||
for line in f:
|
||||
module = pattern.sub("", line.strip())
|
||||
modules.add(module)
|
||||
else:
|
||||
modules.add(name)
|
||||
|
||||
# resolve modules dependencies
|
||||
moddep = os.path.join(src_moddir, self.const.MODDEPFILE)
|
||||
with open(moddep, "r") as f:
|
||||
lines = map(lambda line: line.strip(), f.readlines())
|
||||
|
||||
modpattern = re.compile(r"^.*/(?P<name>.*)\.ko:(?P<deps>.*)$")
|
||||
deppattern = re.compile(r"^.*/(?P<name>.*)\.ko$")
|
||||
unresolved = True
|
||||
|
||||
while unresolved:
|
||||
unresolved = False
|
||||
for line in lines:
|
||||
m = modpattern.match(line)
|
||||
modname = m.group("name")
|
||||
if modname in modules:
|
||||
# add the dependencies
|
||||
for dep in m.group("deps").split():
|
||||
m = deppattern.match(dep)
|
||||
depname = m.group("name")
|
||||
if depname not in modules:
|
||||
unresolved = True
|
||||
modules.add(depname)
|
||||
|
||||
# remove not needed modules
|
||||
for root, dirs, files in os.walk(dst_moddir):
|
||||
for file in files:
|
||||
path = os.path.join(root, file)
|
||||
name, ext = os.path.splitext(file)
|
||||
|
||||
if ext == ".ko":
|
||||
if name not in modules:
|
||||
os.unlink(path)
|
||||
else:
|
||||
# get the required firmware
|
||||
cmd = "{0.MODINFO} -F firmware {1}"
|
||||
cmd = cmd.format(self.cmd, path)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.perror(stdout)
|
||||
continue
|
||||
|
||||
for fw in stdout.split():
|
||||
src = os.path.join(self.srctree,
|
||||
self.const.FWDIR, fw)
|
||||
if not os.path.exists(src):
|
||||
msg = "missing firmware {0}".format(fw)
|
||||
self.pwarning(msg)
|
||||
continue
|
||||
|
||||
# copy the firmware
|
||||
dst = os.path.join(self.dsttree, "firmware", fw)
|
||||
dir = os.path.dirname(dst)
|
||||
makedirs_(dir)
|
||||
shutil.copy2(src, dst)
|
||||
|
||||
# create the lib/firmware symlink
|
||||
libfw = os.path.join(self.dsttree, self.const.FWDIR)
|
||||
libfwdir = os.path.dirname(libfw)
|
||||
if not os.path.isdir(libfwdir):
|
||||
os.makedirs(libfwdir)
|
||||
os.symlink("../firmware", libfw)
|
||||
|
||||
# copy additional firmware
|
||||
fw = [("ipw2100", "ipw2100*"),
|
||||
("ipw2200", "ipw2200*"),
|
||||
("iwl3945", "iwlwifi-3945*"),
|
||||
("iwl4965", "iwlwifi-4965*"),
|
||||
("atmel", "atmel_*.bin"),
|
||||
("zd1211rw", "zd1211"),
|
||||
("qla2xxx", "ql*")]
|
||||
|
||||
for module, fname in fw:
|
||||
if module in modules:
|
||||
scopy_(src_root=self.srctree,
|
||||
src_path=os.path.join(self.const.FWDIR, fname),
|
||||
dst_root=self.dsttree,
|
||||
dst_path="firmware")
|
||||
|
||||
# XXX
|
||||
# remove empty directories
|
||||
#empty_dirs = set()
|
||||
#for root, dirs, files in os.walk(dst_moddir, topdown=False):
|
||||
# if not dirs and not files:
|
||||
# shutil.rmtree(root)
|
||||
|
||||
# get the modules paths
|
||||
modpaths = {}
|
||||
for root, dirs, files in os.walk(dst_moddir):
|
||||
for file in files:
|
||||
modpaths[file] = os.path.join(root, file)
|
||||
|
||||
# create the modules list
|
||||
modlist = {}
|
||||
for modtype, fname in {"scsi": "modules.block",
|
||||
"eth": "modules.networking"}.items():
|
||||
|
||||
fname = os.path.join(dst_moddir, fname)
|
||||
with open(fname, "r") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
|
||||
modname, ext = os.path.splitext(line)
|
||||
if (line not in modpaths or
|
||||
modname in ("floppy", "libiscsi", "scsi_mod")):
|
||||
continue
|
||||
|
||||
cmd = "{0.MODINFO} -F description {1}"
|
||||
cmd = cmd.format(self.cmd, modpaths[line])
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.pwarning(stdout)
|
||||
desc = ""
|
||||
else:
|
||||
desc = stdout.split("\n")[0]
|
||||
desc = desc.strip()[:65]
|
||||
|
||||
if not desc:
|
||||
desc = "{0} driver".format(modname)
|
||||
|
||||
info = '{0}\n\t{1}\n\t"{2}"\n'
|
||||
info = info.format(modname, modtype, desc)
|
||||
modlist[modname] = info
|
||||
|
||||
# write the module-info
|
||||
moduleinfo = os.path.join(os.path.dirname(dst_moddir),
|
||||
self.const.MODULEINFO)
|
||||
|
||||
with open(moduleinfo, "w") as f:
|
||||
f.write("Version 0\n")
|
||||
for modname in sorted(modlist.keys()):
|
||||
f.write(modlist[modname])
|
||||
|
||||
# compress modules
|
||||
for root, dirs, files in os.walk(dst_moddir):
|
||||
for file in filter(lambda f: f.endswith(".ko"), files):
|
||||
path = os.path.join(root, file)
|
||||
with open(path, "rb") as f:
|
||||
data = f.read()
|
||||
|
||||
gzipped = gzip.open("{0}.gz".format(path), "wb")
|
||||
gzipped.write(data)
|
||||
gzipped.close()
|
||||
os.unlink(path)
|
||||
|
||||
# run depmod
|
||||
systemmap = os.path.join(self.srctree, self.const.BOOTDIR,
|
||||
"System.map-{0}".format(kernel.version))
|
||||
|
||||
cmd = "{0.DEPMOD} -a -F {1} -b {2} {3}"
|
||||
cmd = cmd.format(self.cmd, systemmap,
|
||||
self.dsttree, kernel.version)
|
||||
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.perror(stdout)
|
||||
|
||||
# remove *map files
|
||||
remove_(os.path.join(dst_moddir, "*map"))
|
||||
|
||||
def get_keymaps(self):
|
||||
override = "keymaps-override-{0}".format(self.conf.basearch)
|
||||
override = os.path.join(self.srctree, self.const.ANACONDA_RUNTIME,
|
||||
override)
|
||||
|
||||
getkeymaps = os.path.join(self.srctree, self.const.ANACONDA_RUNTIME,
|
||||
"getkeymaps")
|
||||
|
||||
dst = os.path.join(self.dsttree, "etc/keymaps.gz")
|
||||
dir = os.path.dirname(dst)
|
||||
if not os.path.isdir(dir):
|
||||
os.makedirs(dir)
|
||||
|
||||
if os.path.isfile(override):
|
||||
self.pinfo("using keymaps override")
|
||||
shutil.copy2(override, dst)
|
||||
else:
|
||||
cmd = "{0} {1} {2} {3}"
|
||||
cmd = cmd.format(getkeymaps, self.conf.basearch, dst, self.srctree)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.perror(stdout)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def create_locales(self):
|
||||
localedir = os.path.join(self.dsttree, self.const.LOCALEDIR)
|
||||
os.makedirs(localedir)
|
||||
|
||||
cmd = "{0.LOCALEDEF} -c -i en_US -f UTF-8 --prefix {1} en_US"
|
||||
cmd = cmd.format(self.cmd, self.dsttree)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.perror(stdout)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def compress(self, kernel):
|
||||
filename = "initrd-{0}.img".format(kernel.version)
|
||||
filepath = os.path.join(self.workdir, filename)
|
||||
|
||||
# create the cpio archive
|
||||
cpioarchive = "{0}.cpio".format(filepath)
|
||||
|
||||
cwd = os.getcwd()
|
||||
os.chdir(self.dsttree)
|
||||
|
||||
cmd = "find . | cpio --quiet -c -o > {0}".format(cpioarchive)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
|
||||
os.chdir(cwd)
|
||||
|
||||
if err:
|
||||
self.perror(stdout)
|
||||
return None
|
||||
|
||||
# create the gzip archive
|
||||
with open(cpioarchive, "rb") as f:
|
||||
cpiodata = f.read()
|
||||
|
||||
gzipped = gzip.open(filepath, "wb")
|
||||
gzipped.write(cpiodata)
|
||||
gzipped.close()
|
||||
|
||||
# remove the cpio archive
|
||||
os.unlink(cpioarchive)
|
||||
|
||||
# remove the initrd tree
|
||||
#shutil.rmtree(self.dsttree)
|
||||
|
||||
return filepath
|
||||
|
||||
|
||||
class EFI(BaseImageClass):
|
||||
|
||||
def __init__(self, installtree, kernel, initrd, product, version,
|
||||
workdir="/tmp"):
|
||||
|
||||
BaseImageClass.__init__(self)
|
||||
|
||||
self.srctree = installtree.rootdir
|
||||
self.dsttree = None
|
||||
|
||||
self.kernel = kernel
|
||||
self.initrd = initrd
|
||||
self.product = product
|
||||
self.version = version
|
||||
|
||||
self.workdir = workdir
|
||||
|
||||
def create(self):
|
||||
msg = ":: creating the efi images for <b>{0}</b>"
|
||||
self.pinfo(msg.format(self.kernel.filename))
|
||||
|
||||
# create efiboot image with kernel
|
||||
self.pinfo("creating efiboot image with kernel")
|
||||
efiboot_kernel = self.create_efiboot(with_kernel=True)
|
||||
if efiboot_kernel is None:
|
||||
self.perror("unable to create the efiboot image")
|
||||
return None, None
|
||||
|
||||
# create the efidisk image
|
||||
self.pinfo("creating efidisk image")
|
||||
efidisk = self.create_efidisk(efiboot_kernel)
|
||||
if efidisk is None:
|
||||
self.perror("unable to create the efidisk image")
|
||||
return None, None
|
||||
|
||||
# remove the efiboot image with kernel
|
||||
os.unlink(efiboot_kernel)
|
||||
|
||||
# create efiboot image without kernel
|
||||
self.pinfo("creating efiboot image without kernel")
|
||||
efiboot_nokernel = self.create_efiboot(with_kernel=False)
|
||||
if efiboot_nokernel is None:
|
||||
self.perror("unable to create the efiboot image")
|
||||
return None, None
|
||||
|
||||
return efiboot_nokernel, efidisk
|
||||
|
||||
def create_efiboot(self, with_kernel=True):
|
||||
# create the efi tree directory
|
||||
efitree = tempfile.mkdtemp(prefix="efitree.", dir=self.workdir)
|
||||
|
||||
efikernelpath = "/images/pxeboot/vmlinuz"
|
||||
efiinitrdpath = "/images/pxeboot/initrd.img"
|
||||
efisplashpath = "/EFI/BOOT/splash.xpm.gz"
|
||||
|
||||
# copy kernel and initrd files to efi tree directory
|
||||
if with_kernel:
|
||||
kpath = self.kernel.path
|
||||
shutil.copy2(kpath, os.path.join(efitree, "vmlinuz"))
|
||||
shutil.copy2(self.initrd, os.path.join(efitree, "initrd.img"))
|
||||
efikernelpath = "/EFI/BOOT/vmlinuz"
|
||||
efiinitrdpath = "/EFI/BOOT/initrd.img"
|
||||
|
||||
# copy conf files to efi tree directory
|
||||
srcdir = os.path.join(self.srctree, self.const.ANACONDA_BOOTDIR)
|
||||
scopy_(src_root=srcdir, src_path="*.conf",
|
||||
dst_root=efitree, dst_path="")
|
||||
|
||||
# edit the grub.conf file
|
||||
grubconf = os.path.join(efitree, "grub.conf")
|
||||
replace_(grubconf, "@PRODUCT@", self.product)
|
||||
replace_(grubconf, "@VERSION@", self.version)
|
||||
replace_(grubconf, "@KERNELPATH@", efikernelpath)
|
||||
replace_(grubconf, "@INITRDPATH@", efiinitrdpath)
|
||||
replace_(grubconf, "@SPLASHPATH@", efisplashpath)
|
||||
|
||||
if self.conf.efiarch == "IA32":
|
||||
shutil.copy2(grubconf, os.path.join(efitree, "BOOT.conf"))
|
||||
|
||||
dst = os.path.join(efitree, "BOOT{0}.conf".format(self.conf.efiarch))
|
||||
shutil.move(grubconf, dst)
|
||||
|
||||
# copy grub.efi
|
||||
grubefi = os.path.join(self.srctree, self.const.EFIDIR, "grub.efi")
|
||||
|
||||
if self.conf.efiarch == "IA32":
|
||||
shutil.copy2(grubefi, os.path.join(efitree, "BOOT.efi"))
|
||||
|
||||
dst = os.path.join(efitree, "BOOT{0}.efi".format(self.conf.efiarch))
|
||||
shutil.copy2(grubefi, dst)
|
||||
|
||||
# copy splash.xpm.gz
|
||||
splash = os.path.join(self.srctree, self.const.SPLASH)
|
||||
shutil.copy2(splash, efitree)
|
||||
|
||||
efiboot = os.path.join(self.workdir, "efiboot.img")
|
||||
if os.path.isfile(efiboot):
|
||||
os.unlink(efiboot)
|
||||
|
||||
# calculate the size of the efi tree directory
|
||||
self.pdebug("calculating the efiboot image size")
|
||||
fsoverhead = 100 * 1024
|
||||
self.pdebug("using {0} bytes for fs overhead".format(fsoverhead))
|
||||
|
||||
sizeinbytes = fsoverhead
|
||||
for root, dirs, files in os.walk(efitree):
|
||||
for file in files:
|
||||
filepath = os.path.join(root, file)
|
||||
filesize = os.path.getsize(filepath)
|
||||
|
||||
# round to multiplications of 1024
|
||||
filesize = math.ceil(filesize / 1024.0) * 1024
|
||||
|
||||
self.pdebug("adding {0} bytes for file {1}".format(filesize,
|
||||
filepath))
|
||||
|
||||
sizeinbytes += filesize
|
||||
|
||||
self.pdebug("required size in bytes: {0}".format(sizeinbytes))
|
||||
|
||||
# mkdosfs needs the size in blocks of 1024 bytes
|
||||
size = int(math.ceil(sizeinbytes / 1024.0))
|
||||
self.pdebug("required size in 1024 byte blocks: {0}".format(size))
|
||||
|
||||
cmd = "{0.MKDOSFS} -n ANACONDA -C {1} {2} > /dev/null"
|
||||
cmd = cmd.format(self.cmd, efiboot, size)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.perror(stdout)
|
||||
return None
|
||||
|
||||
# mount the efiboot image
|
||||
efibootdir = tempfile.mkdtemp(prefix="efiboot.", dir=self.workdir)
|
||||
|
||||
cmd = "mount -o loop,shortname=winnt,umask=0777 -t vfat {0} {1}"
|
||||
cmd = cmd.format(efiboot, efibootdir)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.perror(stdout)
|
||||
return None
|
||||
|
||||
# copy the files to the efiboot image
|
||||
dstdir = os.path.join(efibootdir, "EFI/BOOT")
|
||||
os.makedirs(dstdir)
|
||||
|
||||
scopy_(src_root=efitree, src_path="*",
|
||||
dst_root=dstdir, dst_path="")
|
||||
|
||||
# unmount the efiboot image
|
||||
cmd = "umount {0}".format(efibootdir)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.pwarning(stdout)
|
||||
|
||||
# remove the working directories
|
||||
shutil.rmtree(efibootdir)
|
||||
#shutil.rmtree(efitree)
|
||||
|
||||
# XXX copy the conf files and splash.xpm.gz to the output directory
|
||||
if not with_kernel:
|
||||
scopy_(src_root=efitree, src_path="*.conf",
|
||||
dst_root=self.conf.efidir, dst_path="")
|
||||
shutil.copy2(splash, self.conf.efidir)
|
||||
|
||||
return efiboot
|
||||
|
||||
def create_efidisk(self, efiboot):
|
||||
efidisk = os.path.join(self.workdir, "efidisk.img")
|
||||
if os.path.isfile(efidisk):
|
||||
os.unlink(efidisk)
|
||||
|
||||
partsize = os.path.getsize(efiboot)
|
||||
disksize = 17408 + partsize + 17408
|
||||
disksize = disksize + (disksize % 512)
|
||||
|
||||
# create the efidisk file
|
||||
with open(efidisk, "wb") as f:
|
||||
f.truncate(disksize)
|
||||
|
||||
# create the loop device
|
||||
cmd = "{0.LOSETUP} -v -f {1} | {0.AWK} '{{print $4}}'"
|
||||
cmd = cmd.format(self.cmd, efidisk)
|
||||
err, loop = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.perror(loop)
|
||||
os.unlink(efidisk)
|
||||
return None
|
||||
|
||||
# create the dm device
|
||||
dmdev = "efiboot"
|
||||
cmd = '{0.DMSETUP} create {1} --table "0 {2} linear {3} 0"'
|
||||
cmd = cmd.format(self.cmd, dmdev, disksize / 512, loop)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.perror(stdout)
|
||||
self.remove_loop_dev(loop)
|
||||
os.unlink(efidisk)
|
||||
return None
|
||||
|
||||
cmd = ("{0.PARTED} --script /dev/mapper/{1} "
|
||||
"mklabel gpt unit b mkpart '\"EFI System Partition\"' "
|
||||
"fat32 17408 {2} set 1 boot on")
|
||||
cmd = cmd.format(self.cmd, dmdev, partsize + 17408)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.perror(stdout)
|
||||
self.remove_dm_dev(dmdev)
|
||||
self.remove_loop_dev(loop)
|
||||
os.unlink(efidisk)
|
||||
return None
|
||||
|
||||
with open(efiboot, "rb") as f_from:
|
||||
with open("/dev/mapper/{0}p1".format(dmdev), "wb") as f_to:
|
||||
efidata = f_from.read(1024)
|
||||
while efidata:
|
||||
f_to.write(efidata)
|
||||
efidata = f_from.read(1024)
|
||||
|
||||
self.remove_dm_dev("{0}p1".format(dmdev))
|
||||
self.remove_dm_dev(dmdev)
|
||||
self.remove_loop_dev(loop)
|
||||
|
||||
return efidisk
|
||||
|
||||
def remove_loop_dev(self, dev):
|
||||
cmd = "{0.LOSETUP} -d {1}".format(self.cmd, dev)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.pwarning(stdout)
|
||||
|
||||
def remove_dm_dev(self, dev):
|
||||
cmd = "{0.DMSETUP} remove /dev/mapper/{1}".format(self.cmd, dev)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.pwarning(stdout)
|
||||
|
||||
|
||||
class Install(BaseImageClass):
|
||||
|
||||
def __init__(self, installtree, template_file, workdir="/tmp"):
|
||||
BaseImageClass.__init__(self)
|
||||
|
||||
self.installtree = installtree
|
||||
self.srctree = installtree.rootdir
|
||||
self.dsttree = installtree.rootdir
|
||||
self.template_file = template_file
|
||||
self.workdir = workdir
|
||||
|
||||
def create(self, type="squashfs"):
|
||||
self.pinfo(":: creating the install image")
|
||||
|
||||
# copy the .buildstamp
|
||||
shutil.copy2(self.conf.buildstamp, self.srctree)
|
||||
|
||||
# parse the template file
|
||||
self.pinfo("parsing the template")
|
||||
variables = {"buildarch": self.conf.buildarch,
|
||||
"basearch": self.conf.basearch,
|
||||
"libdir": self.conf.libdir}
|
||||
self.parse_template(self.template_file, variables)
|
||||
|
||||
# XXX remove packages
|
||||
installed_packages = self.installtree.yum.installed_packages
|
||||
for pkgname, mask in self.pkgs_to_remove:
|
||||
if pkgname not in installed_packages:
|
||||
continue
|
||||
|
||||
self.pinfo("removing files from package %s matching mask %s" \
|
||||
% (pkgname, mask))
|
||||
|
||||
pkgobj = installed_packages.get(pkgname)
|
||||
for fname in pkgobj.filelist:
|
||||
if fnmatch.fnmatch(fname, mask):
|
||||
self.pdebug("removing file %s%s" \
|
||||
% (self.srctree, fname))
|
||||
remove_("%s%s" % (self.srctree, fname))
|
||||
|
||||
self.copy_stubs()
|
||||
self.copy_bootloaders()
|
||||
self.rename_repos()
|
||||
self.move_anaconda_files()
|
||||
self.create_modules_symlinks()
|
||||
self.fix_man_pages()
|
||||
self.remove_locales()
|
||||
self.remove_unnecessary_files()
|
||||
self.move_bins()
|
||||
|
||||
# copy custom files
|
||||
self.pinfo("copying custom files")
|
||||
self.copy_custom_files()
|
||||
|
||||
installimg = os.path.join(self.workdir, "install.img")
|
||||
if os.path.isfile(installimg):
|
||||
os.unlink(installimg)
|
||||
|
||||
if type == "squashfs":
|
||||
self.pinfo("using squash filesystem")
|
||||
cmd = "{0.MKSQUASHFS} {1} {2} -all-root -no-fragments -no-progress"
|
||||
cmd = cmd.format(self.cmd, self.srctree, installimg)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.perror(stdout)
|
||||
return None
|
||||
elif type == "cramfs":
|
||||
# TODO
|
||||
raise NotImplementedError
|
||||
elif type == "ext2":
|
||||
# TODO
|
||||
raise NotImplementedError
|
||||
|
||||
return installimg
|
||||
|
||||
def copy_stubs(self):
|
||||
stubs = ("raidstart", "raidstop", "losetup", "list-harddrives",
|
||||
"loadkeys", "mknod", "syslogd")
|
||||
|
||||
for stub in map(lambda s: "{0}-stub".format(s), stubs):
|
||||
src = os.path.join(self.srctree, "usr/lib/anaconda", stub)
|
||||
dst = os.path.join(self.srctree, "usr/bin", stub)
|
||||
if os.path.isfile(src):
|
||||
shutil.copy2(src, dst)
|
||||
|
||||
def copy_bootloaders(self):
|
||||
srcdir = os.path.join(self.srctree, self.const.BOOTDIR)
|
||||
dstdir = os.path.join(self.srctree, self.const.ANACONDA_BOOTDIR)
|
||||
|
||||
if self.conf.buildarch in ("i386", "i586", "i686", "x86_64"):
|
||||
for f in glob.iglob(os.path.join(srcdir, "memtest*")):
|
||||
shutil.copy2(f, dstdir)
|
||||
|
||||
elif self.conf.buildarch in ("ppc", "ppc64"):
|
||||
f = os.path.join(srcdir, "efika.forth")
|
||||
shutil.copy2(f, dstdir)
|
||||
|
||||
elif self.conf.buildarch in ("sparc", "sparc64"):
|
||||
for f in glob.iglob(os.path.join(srcdir, "*.b")):
|
||||
shutil.copy2(f, dstdir)
|
||||
|
||||
elif self.conf.buildarch == "ia64":
|
||||
srcdir = os.path.join(self.srctree, self.const.BOOTDIR_IA64)
|
||||
for f in glob.iglob(os.path.join(srcdir, "*")):
|
||||
shutil.copy2(dstdir)
|
||||
|
||||
def rename_repos(self):
|
||||
src = os.path.join(self.srctree, "etc/yum.repos.d")
|
||||
dst = os.path.join(self.srctree, "etc/anaconda.repos.d")
|
||||
shutil.move(src, dst)
|
||||
|
||||
def move_anaconda_files(self):
|
||||
# move anaconda executable
|
||||
src = os.path.join(self.srctree, "usr/sbin/anaconda")
|
||||
dst = os.path.join(self.srctree, "usr/bin/anaconda")
|
||||
shutil.move(src, dst)
|
||||
|
||||
# move anaconda libraries
|
||||
srcdir = os.path.join(self.srctree, self.const.ANACONDA_RUNTIME)
|
||||
dstdir = os.path.join(self.srctree, "usr", self.conf.libdir)
|
||||
for f in glob.iglob(os.path.join(srcdir, "lib*")):
|
||||
shutil.move(f, dstdir)
|
||||
|
||||
def create_modules_symlinks(self):
|
||||
mkdir_(os.path.join(self.srctree, "modules"))
|
||||
mkdir_(os.path.join(self.srctree, "firmware"))
|
||||
remove_(os.path.join(self.srctree, self.const.MODDIR))
|
||||
remove_(os.path.join(self.srctree, self.const.FWDIR))
|
||||
os.symlink("/modules", os.path.join(self.srctree, self.const.MODDIR))
|
||||
os.symlink("/firmware", os.path.join(self.srctree, self.const.FWDIR))
|
||||
|
||||
def fix_man_pages(self):
|
||||
# fix up some links for man page related stuff
|
||||
for file in ("nroff", "groff", "iconv", "geqn", "gtbl", "gpic",
|
||||
"grefer"):
|
||||
|
||||
target = os.path.join("/mnt/sysimage/usr/bin", file)
|
||||
name = os.path.join(self.srctree, "usr/bin", file)
|
||||
if not os.path.isfile(name):
|
||||
os.symlink(target, name)
|
||||
|
||||
# fix /etc/man.config to point into /mnt/sysimage
|
||||
manconf = os.path.join(self.srctree, self.const.MANCONF)
|
||||
replace_(manconf, r"^MANPATH\s+(\S+)", "MANPATH\t/mnt/sysimage\g<1>")
|
||||
replace_(manconf, r"^MANPATH_MAP\s+(\S+)\s+(\S+)",
|
||||
"MANPATH_MAP\t\g<1>\t/mnt/sysimage\g<2>")
|
||||
|
||||
def remove_locales(self):
|
||||
langtable = os.path.join(self.srctree, self.const.LANGTABLE)
|
||||
localepath = os.path.join(self.srctree, self.const.LOCALES)
|
||||
|
||||
if os.path.isfile(langtable):
|
||||
keep = set()
|
||||
|
||||
with open(langtable, "r") as f:
|
||||
lines = f.readlines()
|
||||
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#"):
|
||||
continue
|
||||
|
||||
fields = line.split("\t")
|
||||
|
||||
dir = os.path.join(localepath, fields[1])
|
||||
if os.path.isdir(dir):
|
||||
keep.add(fields[1])
|
||||
|
||||
locale = fields[3].split(".")[0]
|
||||
dir = os.path.join(localepath, locale)
|
||||
if os.path.isdir(dir):
|
||||
keep.add(locale)
|
||||
|
||||
for locale in os.listdir(localepath):
|
||||
if locale not in keep:
|
||||
path = os.path.join(localepath, locale)
|
||||
remove_(path)
|
||||
|
||||
def remove_unnecessary_files(self):
|
||||
for root, dirs, files in os.walk(self.srctree):
|
||||
for file in files:
|
||||
path = os.path.join(root, file)
|
||||
|
||||
if (fnmatch.fnmatch(path, "*.a") and
|
||||
not path.count("kernel-wrapper/wrapper.a")):
|
||||
os.unlink(path)
|
||||
|
||||
if (fnmatch.fnmatch(path, "lib*.la") and
|
||||
not path.count("gtk-2.0")):
|
||||
os.unlink(path)
|
||||
|
||||
if fnmatch.fnmatch(path, "*.py"):
|
||||
pyo, pyc = path + "o", path + "c"
|
||||
if os.path.isfile(pyo):
|
||||
os.unlink(pyo)
|
||||
if os.path.isfile(pyc):
|
||||
os.unlink(pyc)
|
||||
|
||||
os.symlink("/dev/null", pyc)
|
||||
|
||||
# remove libunicode-lite
|
||||
remove_(os.path.join(self.srctree, "usr", self.conf.libdir,
|
||||
"libunicode-lite*"))
|
||||
|
||||
def move_bins(self):
|
||||
# move bin to usr/bin
|
||||
scopy_(src_root=self.srctree, src_path="bin/*",
|
||||
dst_root=self.srctree, dst_path="usr/bin",
|
||||
ignore_errors=not self.conf.pedantic)
|
||||
remove_(os.path.join(self.srctree, "bin"))
|
||||
|
||||
# move sbin to /usr/sbin
|
||||
scopy_(src_root=self.srctree, src_path="sbin/*",
|
||||
dst_root=self.srctree, dst_path="usr/sbin",
|
||||
ignore_errors=not self.conf.pedantic)
|
||||
remove_(os.path.join(self.srctree, "sbin"))
|
||||
|
||||
# fix broken links
|
||||
brokenlinks = []
|
||||
for dir in ("bin", "sbin"):
|
||||
dir = os.path.join(self.srctree, "usr", dir)
|
||||
for root, dnames, fnames in os.walk(dir):
|
||||
for fname in fnames:
|
||||
fname = os.path.join(root, fname)
|
||||
if os.path.islink(fname) and not os.path.exists(fname):
|
||||
brokenlinks.append(fname)
|
||||
|
||||
pattern = re.compile(r"^\.\./\.\./(bin|sbin)/(.*)$")
|
||||
for link in brokenlinks:
|
||||
target = os.readlink(link)
|
||||
newtarget = pattern.sub(r"../\g<1>/\g<2>", target)
|
||||
if newtarget != target:
|
||||
os.unlink(link)
|
||||
os.symlink(newtarget, link)
|
||||
|
||||
def copy_custom_files(self):
|
||||
scopy_(src_root=self.conf.datadir, src_path="*",
|
||||
dst_root=self.dsttree, dst_path="")
|
||||
|
||||
|
||||
class Boot(BaseImageClass):
|
||||
|
||||
def __init__(self, product, workdir="/tmp"):
|
||||
BaseImageClass.__init__(self)
|
||||
self.product = product
|
||||
self.workdir = workdir
|
||||
|
||||
self.efiboot = os.path.join(self.conf.imgdir, "efiboot.img")
|
||||
|
||||
def create(self):
|
||||
self.pinfo(":: creating the boot iso image")
|
||||
bootiso = os.path.join(self.workdir, "boot.iso")
|
||||
if os.path.isfile(bootiso):
|
||||
os.unlink(bootiso)
|
||||
|
||||
if os.path.isfile(self.efiboot):
|
||||
self.pinfo("creating efi capable boot iso")
|
||||
efiargs = "-eltorito-alt-boot -e images/efiboot.img -no-emul-boot"
|
||||
efigraft = "EFI/BOOT={0}".format(self.conf.efidir)
|
||||
else:
|
||||
efiargs = ""
|
||||
efigraft = ""
|
||||
|
||||
cmd = ("{0.MKISOFS} -U -A {1} -V {1} -volset {1} -J -joliet-long"
|
||||
" -r -v -T -o {2} -b isolinux/isolinux.bin -c isolinux/boot.cat"
|
||||
" -no-emul-boot -boot-load-size 4 -boot-info-table"
|
||||
" {3} -graft-points isolinux={4} images={5} {6}")
|
||||
cmd = cmd.format(self.cmd, self.product, bootiso, efiargs,
|
||||
self.conf.isodir, self.conf.imgdir, efigraft)
|
||||
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.perror(stdout)
|
||||
return None
|
||||
|
||||
if os.path.isfile(self.cmd.ISOHYBRID):
|
||||
self.pinfo("creating hybrid boot iso")
|
||||
cmd = "{0.ISOHYBRID} {1}".format(self.cmd, bootiso)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.pwarning(stdout)
|
||||
|
||||
return bootiso
|
@ -1,148 +0,0 @@
|
||||
#
|
||||
# insttree.py
|
||||
#
|
||||
# Copyright (C) 2009 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
||||
#
|
||||
|
||||
import os
|
||||
import re
|
||||
import commands
|
||||
|
||||
from base import BaseLoraxClass
|
||||
from sysutils import *
|
||||
|
||||
|
||||
class Kernel(object):
|
||||
pass
|
||||
|
||||
|
||||
class InstallTree(BaseLoraxClass):
|
||||
|
||||
def __init__(self, yum, rootdir, updatesdir=None):
|
||||
BaseLoraxClass.__init__(self)
|
||||
self.yum = yum
|
||||
self.rootdir = rootdir
|
||||
self.updatesdir = updatesdir
|
||||
|
||||
self.kpattern = re.compile(r"vmlinuz-(?P<ver>[-._0-9a-z]+?"
|
||||
r"(?P<pae>(PAE)?)(?P<xen>(xen)?))$")
|
||||
|
||||
def install_packages(self, packages):
|
||||
for name in packages:
|
||||
if not self.yum.install(name):
|
||||
self.pwarning("no package <b>{0}</b> found".format(name))
|
||||
|
||||
self.yum.process_transaction()
|
||||
|
||||
def run_ldconfig(self):
|
||||
ldsoconf = os.path.join(self.rootdir, self.const.LDSOCONF)
|
||||
|
||||
# XXX
|
||||
with open(ldsoconf, "w") as f:
|
||||
f.write("/usr/kerberos/{0}\n".format(self.conf.libdir))
|
||||
|
||||
procdir = os.path.join(self.rootdir, "proc")
|
||||
mkdir_(procdir)
|
||||
|
||||
# mount proc
|
||||
cmd = "{0.MOUNT} -t proc proc {1}".format(self.cmd, procdir)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.perror(stdout)
|
||||
return
|
||||
|
||||
cwd = os.getcwd()
|
||||
|
||||
# chroot to the install tree directory, and run ldconfig
|
||||
pid = os.fork()
|
||||
if pid:
|
||||
# parent
|
||||
os.waitpid(pid, 0)
|
||||
else:
|
||||
# child
|
||||
os.chroot(self.rootdir)
|
||||
os.chdir("/")
|
||||
|
||||
err, stdout = commands.getstatusoutput(self.cmd.LDCONFIG)
|
||||
if err:
|
||||
self.perror(stdout)
|
||||
|
||||
os._exit(0)
|
||||
|
||||
os.chdir(cwd)
|
||||
|
||||
# umount proc
|
||||
cmd = "{0.UMOUNT} {1}".format(self.cmd, procdir)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
self.pwarning(stdout)
|
||||
|
||||
# XXX
|
||||
os.unlink(ldsoconf)
|
||||
|
||||
def copy_updates(self):
|
||||
if self.updatesdir and os.path.isdir(self.updatesdir):
|
||||
scopy_(src_root=self.updatesdir, src_path="*",
|
||||
dst_root=self.rootdir, dst_path="")
|
||||
|
||||
@property
|
||||
def kernels(self):
|
||||
if self.conf.buildarch == "ia64":
|
||||
kerneldir = self.const.BOOTDIR_IA64
|
||||
else:
|
||||
kerneldir = self.const.BOOTDIR
|
||||
|
||||
self.kerneldir = os.path.join(self.rootdir, kerneldir)
|
||||
for filename in os.listdir(self.kerneldir):
|
||||
m = self.kpattern.match(filename)
|
||||
if m:
|
||||
kernel = Kernel()
|
||||
kernel.filename = filename
|
||||
kernel.path = os.path.join(self.kerneldir, filename)
|
||||
kernel.version = m.group("ver")
|
||||
kernel.is_pae = bool(m.group("pae"))
|
||||
kernel.is_xen = bool(m.group("xen"))
|
||||
|
||||
yield kernel
|
||||
|
||||
@property
|
||||
def do_efi(self):
|
||||
return os.path.isdir(os.path.join(self.rootdir, self.const.EFIDIR))
|
||||
|
||||
# XXX this should be just a temporary fix,
|
||||
# should get fixed in the respective packages
|
||||
def fix_problems(self):
|
||||
# remove broken build and source links from the modules directory
|
||||
for kernel in self.kernels:
|
||||
moddir = os.path.join(self.rootdir, self.const.MODDIR,
|
||||
kernel.version)
|
||||
|
||||
build = os.path.join(moddir, "build")
|
||||
if os.path.islink(build) and not os.path.exists(build):
|
||||
os.unlink(build)
|
||||
|
||||
source = os.path.join(moddir, "source")
|
||||
if os.path.islink(source) and not os.path.exists(source):
|
||||
os.unlink(source)
|
||||
|
||||
# fix udev broken links
|
||||
for fname in ("udevcontrol", "udevsettle", "udevtrigger"):
|
||||
fname = os.path.join(self.rootdir, "sbin", fname)
|
||||
if os.path.islink(fname):
|
||||
os.unlink(fname)
|
||||
os.symlink("udevadm", fname)
|
@ -19,21 +19,27 @@
|
||||
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
||||
#
|
||||
|
||||
from mako.template import Template as MakoTemplate
|
||||
from mako.lookup import TemplateLookup as MakoTemplateLookup
|
||||
import shlex
|
||||
|
||||
from mako.template import Template
|
||||
from mako.lookup import TemplateLookup
|
||||
|
||||
|
||||
class Template(object):
|
||||
class LoraxTemplate(object):
|
||||
|
||||
def parse(self, template_file, variables):
|
||||
# we have to set the template lookup directories to ["/"],
|
||||
# otherwise the file includes will not work properly
|
||||
lookup = MakoTemplateLookup(directories=["/"])
|
||||
template = MakoTemplate(filename=template_file, lookup=lookup)
|
||||
lookup = TemplateLookup(directories=["/"])
|
||||
template = Template(filename=template_file, lookup=lookup)
|
||||
s = template.render(**variables)
|
||||
|
||||
# enumerate, strip and remove empty lines
|
||||
lines = enumerate(s.splitlines(), start=1)
|
||||
lines = map(lambda (n, line): (n, line.strip()), lines)
|
||||
lines = filter(lambda (n, line): line, lines)
|
||||
# split, strip and remove empty lines
|
||||
lines = s.splitlines()
|
||||
lines = map(lambda line: line.strip(), lines)
|
||||
lines = filter(lambda line: line, lines)
|
||||
|
||||
# split with shlex
|
||||
lines = map(lambda line: shlex.split(line), lines)
|
||||
|
||||
return lines
|
||||
|
@ -22,7 +22,16 @@
|
||||
import sys
|
||||
import re
|
||||
|
||||
from decorators import singleton
|
||||
import decorators
|
||||
|
||||
|
||||
# output levels
|
||||
CRITICAL = 50
|
||||
ERROR = 40
|
||||
WARNING = 30
|
||||
INFO = 20
|
||||
DEBUG = 10
|
||||
NOTSET = 0
|
||||
|
||||
|
||||
# color codes
|
||||
@ -48,48 +57,28 @@ TAGS = [(re.compile(r"<b>"), C_BOLD),
|
||||
(re.compile(r"<red>"), C_RED),
|
||||
(re.compile(r"<green>"), C_GREEN),
|
||||
(re.compile(r"<blue>"), C_BLUE),
|
||||
(re.compile(r"</(b|u|red|green|blue/)>"), C_RESET)]
|
||||
(re.compile(r"</(b|u|red|green|blue)>"), C_RESET)]
|
||||
|
||||
|
||||
# output levels
|
||||
CRITICAL = 50
|
||||
ERROR = 40
|
||||
WARNING = 30
|
||||
INFO = 20
|
||||
DEBUG = 10
|
||||
NOTSET = 0
|
||||
|
||||
|
||||
@singleton
|
||||
class LoraxOutput(object):
|
||||
@decorators.singleton
|
||||
class LinuxTerminalOutput(object):
|
||||
|
||||
def __init__(self):
|
||||
self._output_level = INFO
|
||||
self._colors = True
|
||||
self._encoding = "utf-8"
|
||||
self._output_level = INFO
|
||||
self._ignore_msgs = set()
|
||||
self._ignored_messages = set()
|
||||
self._indent_level = 0
|
||||
|
||||
def basic_config(self, colors=None, encoding=None, output_level=None):
|
||||
if colors is not None:
|
||||
self._colors = colors
|
||||
self.width = 79
|
||||
|
||||
if encoding is not None:
|
||||
self._encoding = encoding
|
||||
def basic_config(self, output_level=None, colors=None, encoding=None):
|
||||
self._output_level = output_level or self._output_level
|
||||
self._colors = colors or self._colors
|
||||
self._encoding = encoding or self._encoding
|
||||
|
||||
if output_level is not None:
|
||||
self._output_level = output_level
|
||||
|
||||
def ignore_message(self, messages):
|
||||
if type(messages) is str:
|
||||
self._ignore_msgs.add(messages)
|
||||
else:
|
||||
for msg in messages:
|
||||
self.ignore_message(msg)
|
||||
|
||||
@property
|
||||
def ignore(self):
|
||||
return self._ignore_msgs
|
||||
def ignore(self, message):
|
||||
self._ignored_messages.add(message)
|
||||
|
||||
def indent(self):
|
||||
self._indent_level += 1
|
||||
@ -114,19 +103,19 @@ class LoraxOutput(object):
|
||||
def critical(self, s, file=sys.stdout):
|
||||
s = "** critical: {0}".format(s)
|
||||
if (self._output_level <= CRITICAL and
|
||||
self.__raw(s) not in self.ignore):
|
||||
self.__raw(s) not in self._ignored_messages):
|
||||
self.writeline(s, file=file)
|
||||
|
||||
def error(self, s, file=sys.stdout):
|
||||
s = "** error: {0}".format(s)
|
||||
if (self._output_level <= ERROR and
|
||||
self.__raw(s) not in self.ignore):
|
||||
self.__raw(s) not in self._ignored_messages):
|
||||
self.writeline(s, file=file)
|
||||
|
||||
def warning(self, s, file=sys.stdout):
|
||||
s = "** warning: {0}".format(s)
|
||||
if (self._output_level <= WARNING and
|
||||
self.__raw(s) not in self.ignore):
|
||||
self.__raw(s) not in self._ignored_messages):
|
||||
self.writeline(s, file=file)
|
||||
|
||||
def info(self, s, file=sys.stdout):
|
||||
@ -146,3 +135,7 @@ class LoraxOutput(object):
|
||||
for tag, ccode in TAGS:
|
||||
s = tag.sub("", s)
|
||||
return s
|
||||
|
||||
|
||||
# set up the output type to be used by lorax
|
||||
LoraxOutput = LinuxTerminalOutput
|
||||
|
@ -19,97 +19,27 @@
|
||||
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
||||
#
|
||||
|
||||
__all__ = ["mkdir_", "makedirs_", "remove_", "symlink_", "touch_",
|
||||
"chown_", "chmod_", "replace_", "scopy_", "dcopy_"]
|
||||
__all__ = ["joinpaths", "replace", "create_loop_dev", "remove_loop_dev",
|
||||
"create_dm_dev", "remove_dm_dev"]
|
||||
|
||||
|
||||
import sys
|
||||
import os
|
||||
import shutil
|
||||
import glob
|
||||
import fileinput
|
||||
import re
|
||||
import pwd
|
||||
import grp
|
||||
import commands
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger("sysutils")
|
||||
import fileinput
|
||||
import subprocess
|
||||
|
||||
|
||||
class SysUtilsError(Exception):
|
||||
pass
|
||||
def joinpaths(*args, **kwargs):
|
||||
path = os.path.sep.join(args)
|
||||
|
||||
|
||||
class SmartCopyError(SysUtilsError):
|
||||
pass
|
||||
|
||||
|
||||
class LinkerError(SysUtilsError):
|
||||
pass
|
||||
|
||||
|
||||
def mkdir_(dir):
|
||||
if not os.path.isdir(dir):
|
||||
os.mkdir(dir)
|
||||
|
||||
|
||||
def makedirs_(dir):
|
||||
if not os.path.isdir(dir):
|
||||
os.makedirs(dir)
|
||||
|
||||
|
||||
def remove_(path):
|
||||
for fname in glob.iglob(path):
|
||||
if os.path.islink(fname) or os.path.isfile(fname):
|
||||
os.unlink(fname)
|
||||
else:
|
||||
shutil.rmtree(fname)
|
||||
|
||||
|
||||
def symlink_(link_target, link_name, force=True):
|
||||
if force and (os.path.islink(link_name) or os.path.isfile(link_name)):
|
||||
os.unlink(link_name)
|
||||
|
||||
os.symlink(link_target, link_name)
|
||||
|
||||
|
||||
def touch_(fname):
|
||||
if os.path.exists(fname):
|
||||
os.utime(fname, None)
|
||||
if kwargs.get("follow_symlinks"):
|
||||
return os.path.realpath(path)
|
||||
else:
|
||||
with open(fname, "w") as f:
|
||||
pass
|
||||
return path
|
||||
|
||||
|
||||
def chown_(path, user=None, group=None, recursive=False):
|
||||
uid = gid = -1
|
||||
|
||||
if user is not None:
|
||||
uid = pwd.getpwnam(user)[2]
|
||||
if group is not None:
|
||||
gid = grp.getgrnam(group)[2]
|
||||
|
||||
for fname in glob.iglob(path):
|
||||
os.chown(fname, uid, gid)
|
||||
|
||||
if recursive and os.path.isdir(fname):
|
||||
for nested in os.listdir(fname):
|
||||
nested = os.path.join(fname, nested)
|
||||
chown_(nested, user, group, recursive)
|
||||
|
||||
|
||||
def chmod_(path, mode, recursive=False):
|
||||
for fname in glob.iglob(path):
|
||||
os.chmod(fname, mode)
|
||||
|
||||
if recursive and os.path.isdir(fname):
|
||||
for nested in os.listdir(fname):
|
||||
nested = os.path.join(fname, nested)
|
||||
chmod_(nested, mode, recursive)
|
||||
|
||||
|
||||
def replace_(fname, find, replace):
|
||||
def replace(fname, find, replace):
|
||||
fin = fileinput.input(fname, inplace=1)
|
||||
pattern = re.compile(find)
|
||||
|
||||
@ -120,292 +50,43 @@ def replace_(fname, find, replace):
|
||||
fin.close()
|
||||
|
||||
|
||||
def scopy_(src_path, dst_path, src_root="/", dst_root="/", symlinks=True,
|
||||
ignore_errors=False):
|
||||
def create_loop_dev(fname):
|
||||
cmd = ["losetup", "-f"]
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
rc = p.wait()
|
||||
if not rc == 0:
|
||||
return None
|
||||
|
||||
__copy(src_path, dst_path, src_root, dst_root,
|
||||
symlinks, deps=False, ignore_errors=ignore_errors)
|
||||
loopdev = p.stdout.read().strip()
|
||||
|
||||
cmd = ["losetup", loopdev, fname]
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
rc = p.wait()
|
||||
if not rc == 0:
|
||||
return None
|
||||
|
||||
def dcopy_(src_path, dst_path, src_root="/", dst_root="/", symlinks=True,
|
||||
ignore_errors=False):
|
||||
return loopdev
|
||||
|
||||
__copy(src_path, dst_path, src_root, dst_root,
|
||||
symlinks, deps=True, ignore_errors=ignore_errors)
|
||||
|
||||
def remove_loop_dev(dev):
|
||||
cmd = ["losetup", "-d", dev]
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
rc = p.wait()
|
||||
|
||||
def __copy(src_path, dst_path, src_root="/", dst_root="/",
|
||||
symlinks=True, deps=False, ignore_errors=False):
|
||||
|
||||
if not src_root.endswith("/"):
|
||||
src_root += "/"
|
||||
if not dst_root.endswith("/"):
|
||||
dst_root += "/"
|
||||
def create_dm_dev(name, size, loopdev):
|
||||
table = '0 {0} linear {1} 0'.format(size, loopdev)
|
||||
|
||||
smartcopy = SmartCopy(src_root, dst_root, symlinks, deps, ignore_errors)
|
||||
cmd = ["dmsetup", "create", name, "--table", table]
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
rc = p.wait()
|
||||
if not rc == 0:
|
||||
return None
|
||||
|
||||
src = os.path.join(src_root, src_path)
|
||||
pattern = re.compile(r"(\*|\?|\[.*?\])")
|
||||
if pattern.search(src):
|
||||
fnames = glob.glob(src)
|
||||
else:
|
||||
fnames = [src]
|
||||
return joinpaths("/dev/mapper", name)
|
||||
|
||||
if not fnames and not ignore_errors:
|
||||
err_msg = "cannot stat '{0}': No such file or directory"
|
||||
raise SysUtilsError(err_msg.format(src))
|
||||
|
||||
for fname in fnames:
|
||||
fname = fname.replace(src_root, "", 1)
|
||||
smartcopy.copy(fname, dst_path)
|
||||
|
||||
smartcopy.process()
|
||||
|
||||
|
||||
# XXX
|
||||
class SmartCopy(object):
|
||||
|
||||
def __init__(self, src_root="/", dst_root="/", symlinks=True, deps=False,
|
||||
ignore_errors=False):
|
||||
|
||||
self.src_root = src_root
|
||||
self.dst_root = dst_root
|
||||
self.symlinks = symlinks
|
||||
self.deps = deps
|
||||
self.ignore_errors = ignore_errors
|
||||
|
||||
self.linker = Linker(src_root)
|
||||
|
||||
self.clear()
|
||||
|
||||
def clear(self):
|
||||
self.makedirs = []
|
||||
self.copyfiles = set()
|
||||
self.links = set()
|
||||
self.errors = []
|
||||
|
||||
def copy(self, src_path, dst_path):
|
||||
src = os.path.normpath(os.path.join(self.src_root, src_path))
|
||||
dst = os.path.normpath(os.path.join(self.dst_root, dst_path))
|
||||
|
||||
# check if the source path exists
|
||||
if not os.path.exists(src):
|
||||
err_msg = "cannot stat '{0}': No such file or directory"
|
||||
err_msg = err_msg.format(src)
|
||||
if not self.ignore_errors:
|
||||
raise SmartCopyError(err_msg)
|
||||
else:
|
||||
self.errors.append(err_msg)
|
||||
return
|
||||
|
||||
if os.path.isfile(src):
|
||||
self.__copy_file(src_path, dst_path, src, dst)
|
||||
elif os.path.isdir(src):
|
||||
self.__copy_dir(src_path, dst_path, src, dst)
|
||||
|
||||
def __copy_file(self, src_path, dst_path, src, dst):
|
||||
# if destination is an existing directory,
|
||||
# append the source filename to the destination
|
||||
if os.path.isdir(dst):
|
||||
dst = os.path.join(dst, os.path.basename(src))
|
||||
|
||||
# check if the new destination is still an existing directory
|
||||
if os.path.isdir(dst):
|
||||
err_msg = "cannot overwrite directory '{0}' with non-directory"
|
||||
err_msg = err_msg.format(dst)
|
||||
if not self.ignore_errors:
|
||||
raise SmartCopyError(err_msg)
|
||||
else:
|
||||
self.errors.append(err_msg)
|
||||
return
|
||||
|
||||
if os.path.islink(src):
|
||||
self.__copy_link(src_path, dst_path, src, dst)
|
||||
else:
|
||||
self.copyfiles.add((src, dst))
|
||||
|
||||
def __copy_dir(self, src_path, dst_path, src, dst):
|
||||
# append the source directory name to the destination path
|
||||
dirname = os.path.basename(src)
|
||||
new_dst = os.path.join(dst, dirname)
|
||||
|
||||
# remove the trailing "/"
|
||||
if new_dst.endswith("/"):
|
||||
new_dst = new_dst[:-1]
|
||||
|
||||
if os.path.islink(src):
|
||||
self.__copy_link(src_path, dst_path, src, new_dst, dir=True)
|
||||
else:
|
||||
# create the destination directory
|
||||
if not os.path.isdir(new_dst):
|
||||
makedirs_(new_dst)
|
||||
elif os.path.isfile(new_dst):
|
||||
err_msg = "cannot overwrite file '{0}' with directory"
|
||||
err_msg = err_msg.format(new_dst)
|
||||
if not self.ignore_errors:
|
||||
raise SmartCopyError(err_msg)
|
||||
else:
|
||||
self.errors.append(err_msg)
|
||||
return
|
||||
|
||||
new_dst_path = os.path.join(dst_path, dirname)
|
||||
|
||||
try:
|
||||
fnames = os.listdir(src)
|
||||
except OSError as why:
|
||||
err_msg = "cannot list directory '{0}': {1}'"
|
||||
err_msg = err_msg.format(src, why)
|
||||
if not self.ignore_errors:
|
||||
raise SmartCopyError(err_msg)
|
||||
else:
|
||||
self.errors.append(err_msg)
|
||||
return
|
||||
|
||||
for fname in fnames:
|
||||
fname = os.path.join(src_path, fname)
|
||||
self.copy(fname, new_dst_path)
|
||||
|
||||
def __copy_link(self, src_path, dst_path, src, dst, dir=False):
|
||||
if not self.symlinks:
|
||||
# TODO
|
||||
raise NotImplementedError
|
||||
|
||||
# read the link target
|
||||
link_target = os.readlink(src)
|
||||
|
||||
# get the target source and destination paths
|
||||
target_src_path = os.path.join(os.path.dirname(src_path), link_target)
|
||||
target_dst_dir = os.path.join(dst_path, os.path.dirname(link_target))
|
||||
|
||||
# if the link target is an absolute path,
|
||||
# make sure we copy it relative to the dst_root
|
||||
if target_dst_dir.startswith("/"):
|
||||
target_dst_dir = target_dst_dir[1:]
|
||||
|
||||
# remove the trailing "/"
|
||||
if target_dst_dir.endswith("/"):
|
||||
target_dst_dir = target_dst_dir[:-1]
|
||||
|
||||
# create the destination directory
|
||||
target_dst = os.path.join(self.dst_root, target_dst_dir)
|
||||
if not os.path.isdir(target_dst) and target_dst not in self.makedirs:
|
||||
self.makedirs.append(target_dst)
|
||||
|
||||
# copy the target along with the link
|
||||
self.copy(target_src_path, target_dst_dir)
|
||||
|
||||
# create the symlink named dst, pointing to link_target
|
||||
self.links.add((link_target, dst))
|
||||
|
||||
def __get_deps(self):
|
||||
deps = set()
|
||||
|
||||
for src, dst in self.copyfiles:
|
||||
if self.linker.is_elf(src):
|
||||
deps = deps.union(self.linker.get_deps(src))
|
||||
|
||||
for src in deps:
|
||||
src_path = src.replace(self.src_root, "", 1)
|
||||
dst_path = os.path.dirname(src_path)
|
||||
|
||||
# create the destination directory
|
||||
dst_dir = os.path.join(self.dst_root, dst_path)
|
||||
if not os.path.isdir(dst_dir) and dst_dir not in self.makedirs:
|
||||
self.makedirs.append(dst_dir)
|
||||
|
||||
self.copy(src_path, dst_path)
|
||||
|
||||
def process(self):
|
||||
if self.deps:
|
||||
self.__get_deps()
|
||||
|
||||
# create required directories
|
||||
map(makedirs_, self.makedirs)
|
||||
|
||||
# remove the dst, if it is a link to src
|
||||
for src, dst in self.copyfiles:
|
||||
if os.path.realpath(dst) == src:
|
||||
os.unlink(dst)
|
||||
|
||||
# copy all the files
|
||||
for src, dst in self.copyfiles:
|
||||
logger.debug("copying {0}".format(src))
|
||||
try:
|
||||
shutil.copy2(src, dst)
|
||||
except shutil.Error as why:
|
||||
err_msg = "error copying file {0} -> {1}: {2}"
|
||||
err_msg = err_msg.format(src, dst, why)
|
||||
raise SmartCopyError(err_msg)
|
||||
|
||||
# create symlinks
|
||||
for target, name in self.links:
|
||||
try:
|
||||
symlink_(target, name)
|
||||
except OSError as why:
|
||||
err_msg = "error creating symlink {0} -> {1}: {2}"
|
||||
err_msg = err_msg.format(name, target, why)
|
||||
raise SmartCopyError(err_msg)
|
||||
|
||||
|
||||
# XXX
|
||||
class Linker(object):
|
||||
|
||||
LIBDIRS = ("lib64",
|
||||
"usr/lib64",
|
||||
"lib",
|
||||
"usr/lib")
|
||||
|
||||
LDDBIN = "/usr/bin/ldd"
|
||||
FILEBIN = "/usr/bin/file"
|
||||
|
||||
def __init__(self, root="/"):
|
||||
libdirs = map(lambda path: os.path.join(root, path), self.LIBDIRS)
|
||||
libdirs = ":".join(libdirs)
|
||||
|
||||
ld_linux = None
|
||||
pattern = re.compile(r'^RTLDLIST="?(?P<ld_linux>.*?)"?$')
|
||||
|
||||
with open(self.LDDBIN, "r") as f:
|
||||
for line in f:
|
||||
m = pattern.match(line.strip())
|
||||
if m:
|
||||
ld_linux = m.group("ld_linux")
|
||||
break
|
||||
|
||||
if ld_linux:
|
||||
ld_linux = filter(os.path.isfile, ld_linux.split())
|
||||
|
||||
if not ld_linux:
|
||||
raise LinkerError("cannot find the ld_linux executable")
|
||||
|
||||
self.lddcmd = "LD_LIBRARY_PATH={0} {1} --list"
|
||||
self.lddcmd = self.lddcmd.format(libdirs, ld_linux[0])
|
||||
|
||||
self.pattern = re.compile(r"^[-._/a-zA-Z0-9]+\s=>\s"
|
||||
r"(?P<lib>[-._/a-zA-Z0-9]+)"
|
||||
r"\s\(0x[0-9a-f]+\)$")
|
||||
|
||||
def is_elf(self, fname):
|
||||
cmd = "{0} --brief {1}".format(self.FILEBIN, fname)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
raise LinkerError(stdout)
|
||||
|
||||
if not stdout.count("ELF"):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def get_deps(self, fname):
|
||||
cmd = "{0} {1}".format(self.lddcmd, fname)
|
||||
err, stdout = commands.getstatusoutput(cmd)
|
||||
if err:
|
||||
raise LinkerError(stdout)
|
||||
|
||||
deps = set()
|
||||
for line in stdout.splitlines():
|
||||
m = self.pattern.match(line.strip())
|
||||
if m:
|
||||
deps.add(m.group("lib"))
|
||||
|
||||
return deps
|
||||
def remove_dm_dev(dev):
|
||||
cmd = ["dmsetup", "remove", dev]
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
rc = p.wait()
|
||||
|
@ -1,107 +0,0 @@
|
||||
#
|
||||
# yumbase.py
|
||||
#
|
||||
# Copyright (C) 2009 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
||||
#
|
||||
|
||||
import os
|
||||
import ConfigParser
|
||||
|
||||
import yum
|
||||
|
||||
|
||||
def get_yum_base_object(installroot, repositories, mirrorlists=[],
|
||||
tempdir="/tmp"):
|
||||
|
||||
def sanitize_repo(repo):
|
||||
if repo.startswith("/"):
|
||||
return "file://{0}".format(repo)
|
||||
elif (repo.startswith("http://") or repo.startswith("ftp://")
|
||||
or repo.startswith("file://")):
|
||||
return repo
|
||||
else:
|
||||
return None
|
||||
|
||||
# sanitize the repositories
|
||||
repositories = map(sanitize_repo, repositories)
|
||||
mirrorlists = map(sanitize_repo, mirrorlists)
|
||||
|
||||
# remove invalid repositories
|
||||
repositories = filter(bool, repositories)
|
||||
mirrorlists = filter(bool, mirrorlists)
|
||||
|
||||
#cachedir = os.path.join(tempdir, "yum.cache")
|
||||
#if not os.path.isdir(cachedir):
|
||||
# os.mkdir(cachedir)
|
||||
|
||||
yumconf = os.path.join(tempdir, "yum.conf")
|
||||
c = ConfigParser.ConfigParser()
|
||||
|
||||
# add the main section
|
||||
section = "main"
|
||||
data = {#"cachedir": cachedir,
|
||||
#"keepcache": 0,
|
||||
"gpgcheck": 0,
|
||||
"plugins": 0,
|
||||
"reposdir": "",
|
||||
"tsflags": "nodocs"}
|
||||
|
||||
c.add_section(section)
|
||||
map(lambda (key, value): c.set(section, key, value), data.items())
|
||||
|
||||
# add the main repository - the first repository from list
|
||||
section = "lorax-repo"
|
||||
data = {"name": "lorax repo",
|
||||
"baseurl": repositories[0],
|
||||
"enabled": 1}
|
||||
|
||||
c.add_section(section)
|
||||
map(lambda (key, value): c.set(section, key, value), data.items())
|
||||
|
||||
# add the extra repositories
|
||||
for n, extra in enumerate(repositories[1:], start=1):
|
||||
section = "lorax-extra-repo-{0:d}".format(n)
|
||||
data = {"name": "lorax extra repo {0:d}".format(n),
|
||||
"baseurl": extra,
|
||||
"enabled": 1}
|
||||
|
||||
c.add_section(section)
|
||||
map(lambda (key, value): c.set(section, key, value), data.items())
|
||||
|
||||
# add the mirrorlists
|
||||
for n, mirror in enumerate(mirrorlists, start=1):
|
||||
section = "lorax-mirrorlist-{0:d}".format(n)
|
||||
data = {"name": "lorax mirrorlist {0:d}".format(n),
|
||||
"mirrorlist": mirror,
|
||||
"enabled": 1 }
|
||||
|
||||
c.add_section(section)
|
||||
map(lambda (key, value): c.set(section, key, value), data.items())
|
||||
|
||||
# write the yum configuration file
|
||||
with open(yumconf, "w") as f:
|
||||
c.write(f)
|
||||
|
||||
# create the yum base object
|
||||
yb = yum.YumBase()
|
||||
|
||||
yb.preconf.fn = yumconf
|
||||
yb.preconf.root = installroot
|
||||
#yb.repos.setCacheDir(cachedir)
|
||||
|
||||
return yb
|
226
src/pylorax/yumhelper.py
Normal file
226
src/pylorax/yumhelper.py
Normal file
@ -0,0 +1,226 @@
|
||||
#
|
||||
# yumhelper.py
|
||||
#
|
||||
# Copyright (C) 2010 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
||||
#
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger("pylorax.yumhelper")
|
||||
|
||||
import sys
|
||||
import os
|
||||
import fnmatch
|
||||
import glob
|
||||
import shutil
|
||||
|
||||
import yum
|
||||
import yum.callbacks
|
||||
import yum.rpmtrans
|
||||
|
||||
import output
|
||||
from sysutils import joinpaths
|
||||
|
||||
|
||||
class LoraxYumHelper(object):
|
||||
|
||||
def __init__(self, yb):
|
||||
self.yb = yb
|
||||
self.installroot = self.yb.conf.installroot
|
||||
self.installed_packages = self.get_packages("installed")
|
||||
|
||||
def install(self, pattern):
|
||||
try:
|
||||
self.yb.install(name=pattern)
|
||||
except yum.Errors.InstallError:
|
||||
try:
|
||||
self.yb.install(pattern=pattern)
|
||||
except yum.Errors.InstallError as e:
|
||||
msg = "cannot install {0}: {1}"
|
||||
logger.error(msg.format(pattern, e))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def remove(self, package, pattern_list):
|
||||
if package:
|
||||
pkgobj = self.installed_packages.get(package)
|
||||
if not pkgobj:
|
||||
msg = "cannot erase {0}: Package not installed"
|
||||
logger.error(msg.format(package))
|
||||
return False
|
||||
|
||||
# XXX match every file if no pattern specified
|
||||
if None in pattern_list:
|
||||
if len(pattern_list) > 1:
|
||||
msg = "redundant patterns specified, " \
|
||||
"removing whole package {0}"
|
||||
logger.warning(msg.format(pkgobj.name))
|
||||
|
||||
pattern_list = ["*"]
|
||||
|
||||
logger.debug("erasing package {0}".format(pkgobj.name))
|
||||
|
||||
total = len(pkgobj.filelist)
|
||||
newline = False
|
||||
count = 0
|
||||
for n, fname in enumerate(pkgobj.filelist, start=1):
|
||||
msg = "[{0:3.0f}%] erasing <b>{1.ui_envra}</b>\r"
|
||||
msg = msg.format(float(n) / float(total) * 100, pkgobj)
|
||||
output.LoraxOutput().write(msg)
|
||||
newline = True
|
||||
|
||||
for pattern in pattern_list:
|
||||
if fnmatch.fnmatch(fname, pattern):
|
||||
fullpath = joinpaths(self.installroot, fname)
|
||||
if os.path.isfile(fullpath):
|
||||
os.unlink(fullpath)
|
||||
logger.debug("removed {0}".format(fullpath))
|
||||
count += 1
|
||||
|
||||
if newline:
|
||||
output.LoraxOutput().write("\n")
|
||||
|
||||
if not count:
|
||||
msg = "no files matched patterns {0}"
|
||||
logger.warning(msg.format(pattern_list))
|
||||
|
||||
else:
|
||||
for pattern in pattern_list:
|
||||
msg = "erasing files matching pattern {0}"
|
||||
logger.info(msg.format(pattern))
|
||||
|
||||
fullpattern = joinpaths(self.installroot, pattern)
|
||||
count = 0
|
||||
for fname in glob.glob(fullpattern):
|
||||
if os.path.isdir(fname):
|
||||
shutil.rmtree(fname)
|
||||
else:
|
||||
os.unlink(fname)
|
||||
|
||||
logger.debug("removed {0}".format(fname))
|
||||
count += 1
|
||||
|
||||
if not count:
|
||||
msg = "no files matched pattern {0}"
|
||||
logger.error(msg.format(pattern))
|
||||
|
||||
return True
|
||||
|
||||
def process_transaction(self):
|
||||
self.yb.buildTransaction()
|
||||
|
||||
self.yb.repos.setProgressBar(LoraxDownloadCallback())
|
||||
|
||||
try:
|
||||
self.yb.processTransaction(callback=LoraxTransactionCallback(),
|
||||
rpmDisplay=LoraxRpmCallback())
|
||||
except yum.Errors.YumRPMCheckError as e:
|
||||
logger.error("yum transaction error: {0}".format(e))
|
||||
sys.exit(1)
|
||||
|
||||
self.yb.closeRpmDB()
|
||||
|
||||
self.installed_packages = self.get_packages("installed")
|
||||
|
||||
def search(self, pattern):
|
||||
pl = self.yb.doPackageLists(patterns=[pattern])
|
||||
return pl.installed, pl.available
|
||||
|
||||
def get_packages(self, type="available"):
|
||||
if type not in ("available", "installed"):
|
||||
raise TypeError
|
||||
|
||||
pl = self.yb.doPackageLists(pkgnarrow=type)
|
||||
|
||||
d = {}
|
||||
for pkgobj in getattr(pl, type):
|
||||
d[pkgobj.name] = pkgobj
|
||||
|
||||
return d
|
||||
|
||||
|
||||
class LoraxDownloadCallback(yum.callbacks.DownloadBaseCallback):
|
||||
|
||||
def __init__(self):
|
||||
yum.callbacks.DownloadBaseCallback.__init__(self)
|
||||
self.output = output.LoraxOutput()
|
||||
|
||||
def updateProgress(self, name, frac, fread, ftime):
|
||||
"""
|
||||
Update the progress bar
|
||||
@param name: filename
|
||||
@param frac: progress fraction (0 -> 1)
|
||||
@param fread: formated string containing BytesRead
|
||||
@param ftime: formated string containing remaining or elapsed time
|
||||
"""
|
||||
|
||||
# XXX
|
||||
msg = "{0}; {1}; {2}; {3}\r".format(name, frac, fread, ftime)
|
||||
|
||||
self.output.write(msg)
|
||||
if frac == 1:
|
||||
self.output.write("\n")
|
||||
|
||||
|
||||
class LoraxTransactionCallback(object):
|
||||
|
||||
def __init__(self):
|
||||
self.output = output.LoraxOutput()
|
||||
|
||||
def event(self, state, data=None):
|
||||
# XXX
|
||||
if state == yum.callbacks.PT_DOWNLOAD:
|
||||
self.output.write("downloading packages\n")
|
||||
elif state == yum.callbacks.PT_DOWNLOAD_PKGS:
|
||||
pass
|
||||
elif state == yum.callbacks.PT_GPGCHECK:
|
||||
self.output.write("checking package signatures\n")
|
||||
elif state == yum.callbacks.PT_TEST_TRANS:
|
||||
self.output.write("running test transaction\n")
|
||||
elif state == yum.callbacks.PT_TRANSACTION:
|
||||
self.output.write("running transaction\n")
|
||||
|
||||
|
||||
class LoraxRpmCallback(yum.rpmtrans.RPMBaseCallback):
|
||||
|
||||
def __init__(self):
|
||||
yum.rpmtrans.RPMBaseCallback.__init__(self)
|
||||
self.output = output.LoraxOutput()
|
||||
|
||||
def event(self, package, action, te_current, te_total,
|
||||
ts_current, ts_total):
|
||||
|
||||
info = "({0:3d}/{1:3d}) [{2:3.0f}%] {3} "
|
||||
info = info.format(ts_current, ts_total,
|
||||
float(te_current) / float(te_total) * 100,
|
||||
self.action[action].lower())
|
||||
|
||||
pkg = "{0}".format(package)
|
||||
|
||||
infolen, pkglen = len(info), len(pkg)
|
||||
if (infolen + pkglen) > self.output.width:
|
||||
pkg = "{0}...".format(pkg[:self.output.width-infolen-3])
|
||||
|
||||
msg = "{0}<b>{1}</b>\r".format(info, pkg)
|
||||
self.output.write(msg)
|
||||
if te_current == te_total:
|
||||
self.output.write("\n")
|
||||
|
||||
def filelog(self, package, action):
|
||||
if self.fileaction.get(action) == "Installed":
|
||||
logger.debug("{0} installed successfully".format(package))
|
Loading…
Reference in New Issue
Block a user