continue
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
<PISI>
|
||||
<Name>kernel.tools</Name>
|
||||
</PISI>
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Licensed under the GNU General Public License, version 3.
|
||||
# See the file http://www.gnu.org/licenses/gpl.txt
|
||||
|
||||
from pisi.actionsapi import pisitools
|
||||
from pisi.actionsapi import shelltools
|
||||
|
||||
|
||||
WorkDir = "./"
|
||||
|
||||
def setup():
|
||||
shelltools.move("README.mkinitramfs", "README")
|
||||
|
||||
def install():
|
||||
pisitools.dodir("/etc/initramfs.d")
|
||||
pisitools.dodoc("README")
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import piksemel
|
||||
import subprocess
|
||||
|
||||
def generate_initramfs(filepath):
|
||||
patterns = ("lib/initramfs", "boot/kernel", "bin/busybox")
|
||||
doc = piksemel.parse(filepath)
|
||||
for item in doc.tags("File"):
|
||||
path = item.getTagData("Path")
|
||||
if path.startswith(patterns):
|
||||
for kernel in os.listdir("/etc/kernel"):
|
||||
subprocess.call(["/sbin/mkinitramfs", "--type", kernel])
|
||||
return
|
||||
|
||||
def setupPackage(metapath, filepath):
|
||||
generate_initramfs(filepath)
|
||||
|
||||
def cleanupPackage(metapath, filepath):
|
||||
pass
|
||||
|
||||
def postCleanupPackage(metapath, filepath):
|
||||
generate_initramfs(filepath)
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Simple script to handle uevents
|
||||
#
|
||||
|
||||
if [ "$SUBSYSTEM/$ACTION" == "firmware/add" ]; then
|
||||
[ -e "/sys$DEVPATH/loading" ] || exit 1
|
||||
DIR=/lib/firmware
|
||||
[ -e "$DIR/$FIRMWARE" ] || exit 1
|
||||
echo 1 > /sys$DEVPATH/loading
|
||||
cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data
|
||||
echo 0 > /sys$DEVPATH/loading
|
||||
exit 0
|
||||
fi
|
||||
@@ -0,0 +1,593 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Simple init script that should handle both
|
||||
# livecd/livedisk, thinclient and hdd boot
|
||||
#
|
||||
|
||||
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
INITRAMFSCONF="/etc/initramfs.conf"
|
||||
|
||||
ROOT_LINKS="bin sbin lib boot usr opt"
|
||||
ROOT_TREES="etc root home var run"
|
||||
TMPFS_DIRS="dev mnt mnt/cdrom mnt/livecd mnt/thin tmp sys proc media"
|
||||
LOOPBACKFILE="/boot/pisi.sqfs"
|
||||
|
||||
NORESUME=0
|
||||
LIVE=0
|
||||
NFSROOT=0
|
||||
QUIET=0
|
||||
RAID_INCREMENTAL=1
|
||||
RAID=0
|
||||
LVM=0
|
||||
COPYTORAM=0
|
||||
SPLASH=0
|
||||
WIPEMEM=0
|
||||
|
||||
HOTPLUG="/sbin/hotplug"
|
||||
|
||||
MNTDIR=""
|
||||
FS_TYPE=""
|
||||
INITRAMFS=""
|
||||
ROOT_FLAGS=""
|
||||
ROOT_DEVICE=""
|
||||
ROOT_TARGET=""
|
||||
RESUME_DEVICE=""
|
||||
WIPEMEM_OPTS="-llv"
|
||||
|
||||
###########################
|
||||
# Miscellaneous functions #
|
||||
###########################
|
||||
|
||||
info() {
|
||||
echo "<6>initramfs: $1" > /dev/kmsg
|
||||
}
|
||||
|
||||
log_output() {
|
||||
$@ | echo "<6>`sed 's#^\(.*\)$#initramfs:\1#g'`" > /dev/kmsg
|
||||
}
|
||||
|
||||
fall2sh() {
|
||||
# Kill any possible plymouth instances
|
||||
test -x /bin/plymouth && /bin/plymouth quit &> /dev/null
|
||||
kill -9 $(pidof plymouthd) &> /dev/null
|
||||
|
||||
echo "--> $*"
|
||||
echo "Reboot with initramfs=shell(noprobe) to further debug the issue."
|
||||
|
||||
# Use a login shell for sourcing /etc/profile
|
||||
/bin/sh -l
|
||||
}
|
||||
|
||||
run_dhcpc() {
|
||||
udhcpc -C -i eth0 -s /etc/udhcpc.script
|
||||
}
|
||||
|
||||
##################
|
||||
# Device probers #
|
||||
##################
|
||||
|
||||
probe_devices() {
|
||||
# Set hotplug helper for firmware loading
|
||||
echo $HOTPLUG > /proc/sys/kernel/hotplug
|
||||
|
||||
if [ "x$1" = "x--with-kms" ]; then
|
||||
probe_kms
|
||||
test -x /bin/plymouth && /bin/plymouth show-splash
|
||||
fi
|
||||
|
||||
probe_pci_devices
|
||||
probe_virtio_devices
|
||||
probe_usb_devices
|
||||
|
||||
# Unset hotplug helper
|
||||
echo > /proc/sys/kernel/hotplug
|
||||
|
||||
[ "${RAID}" -eq "1" ] && probe_raid
|
||||
[ "${LVM}" -eq "1" ] && probe_lvm
|
||||
}
|
||||
|
||||
probe_kms() {
|
||||
for device in /sys/bus/pci/devices/*/boot_vga; do
|
||||
[ -f $device ] || continue
|
||||
info "Loading KMS driver"
|
||||
grep -q 1 $device && modprobe -bq `cat ${device%boot_vga}modalias`
|
||||
done
|
||||
if [ ! -c /dev/fb0 ]; then
|
||||
echo "options uvesafb scroll=ywrap mtrr=0 nocrtc=1 mode_option=1024x768-32" > /etc/modprobe.d/uvesafb.conf
|
||||
modprobe -bq uvesafb
|
||||
fi
|
||||
}
|
||||
|
||||
probe_pci_devices() {
|
||||
info "Probing PCI devices"
|
||||
local MODULES=""
|
||||
for module in /sys/bus/pci/devices/*/modalias; do
|
||||
[ -f $module ] || continue
|
||||
MODULES="$MODULES $(cat $module)"
|
||||
done
|
||||
modprobe -bqa $MODULES
|
||||
}
|
||||
|
||||
probe_usb_devices() {
|
||||
info "Probing USB devices"
|
||||
local MODULES=""
|
||||
for module in /sys/bus/usb/devices/*/modalias; do
|
||||
[ -f $module ] || continue
|
||||
MODULES="$MODULES $(cat $module)"
|
||||
done
|
||||
modprobe -bqa $MODULES
|
||||
}
|
||||
|
||||
probe_raid() {
|
||||
info "Probing RAID devices"
|
||||
modprobe -bqa dm-mod raid0 raid1 raid10 raid456
|
||||
if [ -x /sbin/mdadm ]
|
||||
then
|
||||
/sbin/mdadm --examine --scan > /etc/mdadm.conf
|
||||
/sbin/mdadm -As
|
||||
fi
|
||||
}
|
||||
|
||||
probe_lvm() {
|
||||
info "Probing LVM devices"
|
||||
modprobe -qa dm-mod
|
||||
if [ -x /sbin/lvm ]
|
||||
then
|
||||
/sbin/lvm vgscan --ignorelockingfailure &> /dev/null
|
||||
/sbin/lvm vgchange -ay --sysinit --ignorelockingfailure &> /dev/null
|
||||
/sbin/lvm vgmknodes --ignorelockingfailure &> /dev/null
|
||||
fi
|
||||
}
|
||||
probe_virtio_devices() {
|
||||
local MODULES=""
|
||||
for module in /sys/bus/virtio/devices/*/modalias; do
|
||||
[ -f $module ] || continue
|
||||
MODULES="$MODULES $(cat $module)"
|
||||
done
|
||||
modprobe -bqa $MODULES
|
||||
}
|
||||
|
||||
#################################
|
||||
# Filesystem specific functions #
|
||||
#################################
|
||||
|
||||
mount_rootfs() {
|
||||
FS_TYPE=`disktype $ROOT_DEVICE | grep KERNELMODULE | awk '{print $2}'`
|
||||
info "Mounting rootfs: $ROOT_DEVICE ($FS_TYPE)"
|
||||
mount -r -t $FS_TYPE -n ${ROOT_FLAGS} ${ROOT_DEVICE} /newroot
|
||||
}
|
||||
|
||||
find_live_mount() {
|
||||
if [ "$#" -gt "0" ]
|
||||
then
|
||||
for x in $*
|
||||
do
|
||||
# this is used for non Linux fs detection
|
||||
FS_TYPE=`disktype $1 | grep KERNELMODULE | awk '{print $2}'`
|
||||
if [ -n "$FS_TYPE" -a -f /lib/modules/*/$FS_TYPE.ko ]
|
||||
then
|
||||
modprobe $FS_TYPE 1> /dev/null 2>&1
|
||||
fi
|
||||
|
||||
mount -r ${x} /newroot/mnt/cdrom > /dev/null 2>&1
|
||||
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
# Check for cdroot image
|
||||
if [ -e /newroot/mnt/cdrom/${LOOPBACKFILE} ]
|
||||
then
|
||||
ROOT_DEVICE="/newroot${x}"
|
||||
if [ "$COPYTORAM" == "1" ]
|
||||
then
|
||||
info "Copying Live Media files to RAM"
|
||||
mkdir /newroot/mnt/cdromtemp
|
||||
cp -af /newroot/mnt/cdrom/* /newroot/mnt/cdromtemp/
|
||||
umount /newroot/mnt/cdrom
|
||||
rmdir /newroot/mnt/cdrom
|
||||
mv /newroot/mnt/cdromtemp /newroot/mnt/cdrom
|
||||
fi
|
||||
break
|
||||
else
|
||||
umount /newroot/mnt/cdrom
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
manage_tmpfs() {
|
||||
mount -t tmpfs tmpfs /newroot
|
||||
|
||||
for d in ${TMPFS_DIRS}; do
|
||||
mkdir -p "/newroot/${d}"
|
||||
done
|
||||
}
|
||||
|
||||
mount_nfs() {
|
||||
FS_LOCATION='mnt/thin'
|
||||
|
||||
# Change directory to /newroot
|
||||
cd /newroot
|
||||
|
||||
# FIXME: busybox mount does not load automatically
|
||||
modprobe -q nfs
|
||||
|
||||
# mount nfs
|
||||
if [ -z "/etc/udhcpc.info" ]
|
||||
then
|
||||
fall2sh "/etc/udhcpc.info not found"
|
||||
fi
|
||||
|
||||
. /etc/udhcpc.info
|
||||
|
||||
if [ -z "${ROOTPATH}" ]
|
||||
then
|
||||
fall2sh "NFS rootpath not found"
|
||||
fi
|
||||
|
||||
echo "Mounting NFS from $ROOTPATH"
|
||||
mount -o tcp,nolock,ro $ROOTPATH /newroot/mnt/thin
|
||||
|
||||
if [ "$?" != '0' ]
|
||||
then
|
||||
fall2sh "Could not nfs root"
|
||||
fi
|
||||
|
||||
# Create necessary links
|
||||
for x in ${ROOT_LINKS}; do
|
||||
ln -s "${FS_LOCATION}/${x}" "${x}"
|
||||
done
|
||||
|
||||
if [ -e "${FS_LOCATION}/lib32" ]
|
||||
then
|
||||
ln -s "${FS_LOCATION}/lib32" "lib32"
|
||||
fi
|
||||
|
||||
# We need this for x86_64
|
||||
ln -s "${FS_LOCATION}/lib" "lib64"
|
||||
|
||||
chmod 1777 tmp
|
||||
(cd /newroot/${FS_LOCATION}; cp -a ${ROOT_TREES} /newroot)
|
||||
|
||||
# Needed for ltspfs mechanism
|
||||
echo "$IP $HOSTNAME" >> /newroot/etc/hosts
|
||||
}
|
||||
|
||||
mount_cdroot() {
|
||||
FS_LOCATION="mnt/livecd"
|
||||
|
||||
# Change directory to /newroot
|
||||
cd /newroot
|
||||
|
||||
# These are not loaded automatically
|
||||
modprobe -q squashfs
|
||||
|
||||
# Loop type squashfs
|
||||
mount -t squashfs -o loop,ro /newroot/mnt/cdrom/${LOOPBACKFILE} /newroot/mnt/livecd
|
||||
|
||||
if [ "$?" != "0" ]
|
||||
then
|
||||
fall2sh "Could not mount root image"
|
||||
fi
|
||||
|
||||
# Create necessary links
|
||||
for x in ${ROOT_LINKS}; do
|
||||
ln -s "${FS_LOCATION}/${x}" "${x}"
|
||||
done
|
||||
|
||||
if [ -e "${FS_LOCATION}/lib32" ]
|
||||
then
|
||||
ln -s "${FS_LOCATION}/lib32" "lib32"
|
||||
fi
|
||||
|
||||
# We need this for x86_64
|
||||
ln -s "${FS_LOCATION}/lib" "lib64"
|
||||
|
||||
chmod 1777 tmp
|
||||
(cd /newroot/${FS_LOCATION}; cp -a ${ROOT_TREES} /newroot)
|
||||
|
||||
# FIXME: the device list is taken from udev, we can't rely on sys entries since pluggable means different
|
||||
# in kernel world. Suggestions that do not include this kind of regexp mania are welcome
|
||||
|
||||
# for userspace applications
|
||||
REAL_ROOT_TYPE=`echo "${ROOT_DEVICE}" | sed -e 's/^\/newroot\/dev\///' | grep -qE '^sr[0-9]*|^hd[a-z]|^pcd[0-9]|^xvd*' && echo "optical" || echo "harddisk"`
|
||||
echo "${REAL_ROOT_TYPE}" > /newroot/run/pisilinux/livemedia
|
||||
|
||||
# this is needed for yali
|
||||
MNTDIR=`grep \/mnt\/cdrom\ /proc/mounts|sed 's/\/newroot//g'`
|
||||
echo "$MNTDIR" >> /newroot/etc/fstab
|
||||
}
|
||||
|
||||
##############################
|
||||
# Config and cmdline parsers #
|
||||
##############################
|
||||
|
||||
# FIXME: maybe we should just source the file instead of parsing
|
||||
# also consider merging conf parser and cmdline parser
|
||||
parse_config() {
|
||||
while read inputline;
|
||||
do
|
||||
case "${inputline}" in
|
||||
raid=*)
|
||||
RAID=$(echo $inputline|cut -f2- -d=)
|
||||
;;
|
||||
lvm=*)
|
||||
LVM=$(echo $inputline|cut -f2- -d=)
|
||||
;;
|
||||
thin=*)
|
||||
NFSROOT=$(echo $inputline|cut -f2- -d=)
|
||||
;;
|
||||
root=*)
|
||||
ROOT_TARGET=$(echo $inputline|cut -f2- -d=)
|
||||
;;
|
||||
rootflags=*)
|
||||
ROOT_FLAGS=$(echo $inputline|cut -f2- -d=)
|
||||
;;
|
||||
liveroot=*)
|
||||
# Installation or livecd, enable RAID by default
|
||||
# to be able to read existing RAID installations
|
||||
LIVE=1
|
||||
RAID_INCREMENTAL=0
|
||||
LIVEROOT=$(echo $inputline|cut -f2- -d=)
|
||||
;;
|
||||
resume=*)
|
||||
RESUME_DEVICE="${inputline#resume=}"
|
||||
;;
|
||||
noresume)
|
||||
NORESUME=1
|
||||
;;
|
||||
copytoram)
|
||||
COPYTORAM=1
|
||||
;;
|
||||
wipemem)
|
||||
WIPEMEM=1
|
||||
;;
|
||||
wipememopts=*)
|
||||
WIPEMEM=1
|
||||
WIPEMEM_OPTS=$(echo $inputline|cut -f2- -d=)
|
||||
;;
|
||||
splash)
|
||||
SPLASH=1
|
||||
;;
|
||||
init=*)
|
||||
INIT="${inputline#INIT=}"
|
||||
;;
|
||||
esac
|
||||
done < $INITRAMFSCONF
|
||||
}
|
||||
|
||||
parse_cmdline() {
|
||||
for x in `cat /proc/cmdline`; do
|
||||
case "${x}" in
|
||||
[0123456Ss])
|
||||
# Normalize 'S' to 's'
|
||||
LEVEL=`echo ${x}|tr A-Z a-z`
|
||||
;;
|
||||
mudur=*)
|
||||
for m in `echo ${x}|cut -f2 -d=|sed 's/,/ /g'`; do
|
||||
case "${m}" in
|
||||
livecd)
|
||||
LIVE=1
|
||||
;;
|
||||
livedisk)
|
||||
LIVE=1
|
||||
;;
|
||||
raid)
|
||||
RAID=1
|
||||
;;
|
||||
lvm)
|
||||
LVM=1
|
||||
;;
|
||||
thin)
|
||||
NFSROOT=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
initramfs=*)
|
||||
INITRAMFS=`echo ${x}|cut -f2- -d=`
|
||||
;;
|
||||
root=*)
|
||||
ROOT_TARGET=`echo ${x}|cut -f2- -d=`
|
||||
;;
|
||||
rootflags=*)
|
||||
ROOT_FLAGS="-o ${x#rootflags=}"
|
||||
;;
|
||||
liveroot=*)
|
||||
LIVE=1
|
||||
LIVEROOT=$(echo ${x}|cut -f2- -d=)
|
||||
;;
|
||||
resume=*)
|
||||
RESUME_DEVICE="${x#resume=}"
|
||||
;;
|
||||
noresume)
|
||||
NORESUME=1
|
||||
;;
|
||||
init=*)
|
||||
INIT="${x#init=}"
|
||||
;;
|
||||
copytoram)
|
||||
COPYTORAM=1
|
||||
;;
|
||||
wipemem)
|
||||
WIPEMEM=1
|
||||
;;
|
||||
wipememopts=*)
|
||||
WIPEMEM=1
|
||||
WIPEMEM_OPTS=$(echo $x|cut -f2- -d=)
|
||||
;;
|
||||
splash)
|
||||
SPLASH=1
|
||||
;;
|
||||
single)
|
||||
LEVEL="s"
|
||||
;;
|
||||
quiet)
|
||||
QUIET=1
|
||||
;;
|
||||
blacklist=*)
|
||||
modules=${x#blacklist=}
|
||||
for module in ${modules//,/ }; do
|
||||
echo "blacklist $module" >> /etc/modprobe.d/cmdline.conf
|
||||
done
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -f /etc/modprobe.d/cmdline.conf ]; then
|
||||
cp /etc/modprobe.d/cmdline.conf /dev/.modprobe.initramfs.conf
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
####################
|
||||
# init starts here #
|
||||
####################
|
||||
|
||||
info "Starting init on initramfs"
|
||||
|
||||
# Mount needed filesystems
|
||||
mount -n -t proc proc /proc
|
||||
mount -n -t sysfs sysfs /sys
|
||||
# Added to start udev properly
|
||||
#mkdir -m 0755 /run
|
||||
#mount -t tmpfs tmpfs /run
|
||||
|
||||
# Prepare /dev (Needs kernel >= 2.6.32)
|
||||
mount -t devtmpfs devtmpfs /dev
|
||||
mkdir -m 0755 /dev/pts
|
||||
mount -t devpts -o gid=5,mode=620 devpts /dev/pts
|
||||
|
||||
# First parse config file, then cmdline to allow overwriting internal config
|
||||
if [ -f "$INITRAMFSCONF" ]
|
||||
then
|
||||
#. $INITRAMFSCONF
|
||||
parse_config
|
||||
fi
|
||||
|
||||
# Parse command line parameters
|
||||
parse_cmdline
|
||||
|
||||
# Minimize printk log
|
||||
test "x$QUIET" = "x1" && echo "1" > /proc/sys/kernel/printk
|
||||
|
||||
# Initialize plymouth daemon if found and splash is true
|
||||
# Don't even launch plymouthd if we're in single-user mode
|
||||
if [ "$LEVEL" != "s" -a "$SPLASH" = "1" -a -x /sbin/plymouthd ]; then
|
||||
/sbin/plymouthd --attach-to-session
|
||||
fi
|
||||
|
||||
# Handle initramfs= parameter
|
||||
if [ "${INITRAMFS}" == "shellnoprobe" ]
|
||||
then
|
||||
fall2sh "Starting up a shell without probing"
|
||||
elif [ "${INITRAMFS}" == "shell" ]
|
||||
then
|
||||
probe_devices --with-kms
|
||||
fall2sh "Starting up a shell"
|
||||
fi
|
||||
|
||||
if [ "${WIPEMEM}" = "1" ]
|
||||
then
|
||||
info "Wiping out memory, system will be shutdown after completion"
|
||||
sdmem ${WIPEMEM_OPTS}
|
||||
poweroff -f
|
||||
fi
|
||||
|
||||
# Probe devices
|
||||
probe_devices --with-kms
|
||||
|
||||
if [ -x /usr/sbin/resume -a -b "$RESUME_DEVICE" -a "x$NORESUME" != "x1" ]
|
||||
then
|
||||
if [ "x$SPLASH" == "x1" ]
|
||||
then
|
||||
SPLASHPARAM="-P splash=y"
|
||||
else
|
||||
SPLASHPARAM="-P splash=n"
|
||||
fi
|
||||
# FIXME: This will fail if resume= contains LABEL/UUID
|
||||
info "Attempting to resume from hibernation"
|
||||
/usr/sbin/resume $SPLASHPARAM $RESUME_DEVICE
|
||||
fi
|
||||
|
||||
echo 0x0100 > /proc/sys/kernel/real-root-dev
|
||||
|
||||
if [ "${LIVE}" -eq "1" ]
|
||||
then
|
||||
ROOT_DEVICE=""
|
||||
manage_tmpfs
|
||||
|
||||
# modprobe filesystems that are not in kernel, for live disks
|
||||
modprobe -qa nls_cp857 nls_utf8 vfat
|
||||
|
||||
for i in `seq 50`
|
||||
do
|
||||
t=`findfs ${LIVEROOT} 2>/dev/null`
|
||||
find_live_mount "$t"
|
||||
|
||||
if [ "${ROOT_DEVICE}" != "" ]
|
||||
then
|
||||
break
|
||||
else
|
||||
probe_devices
|
||||
usleep 200000
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${ROOT_DEVICE}" == "" ]
|
||||
then
|
||||
fall2sh "Could not find mount media"
|
||||
fi
|
||||
|
||||
mount_cdroot
|
||||
|
||||
elif [ "${NFSROOT}" -eq "1" ]
|
||||
then
|
||||
run_dhcpc
|
||||
manage_tmpfs
|
||||
mount_nfs
|
||||
|
||||
# set hostname for mudur
|
||||
hostname $HOSTNAME
|
||||
|
||||
else
|
||||
# Wait until ROOT_DEVICE appears
|
||||
for i in `seq 50`
|
||||
do
|
||||
# let findfs handle all conversion
|
||||
ROOT_DEVICE=`findfs ${ROOT_TARGET} 2>/dev/null`
|
||||
|
||||
if [ ! -b "${ROOT_DEVICE}" ]
|
||||
then
|
||||
probe_devices
|
||||
usleep 200000
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ ! -b "${ROOT_DEVICE}" ]
|
||||
then
|
||||
fall2sh "Could not find boot device"
|
||||
else
|
||||
mount_rootfs
|
||||
fi
|
||||
fi
|
||||
|
||||
[ "${INIT}" == "" ] && INIT="/sbin/init";
|
||||
|
||||
# This stops /lib/udev/rules.d/65-md-incremental.rules from medling with mdraid sets.
|
||||
[ "${RAID_INCREMENTAL}" -eq "0" ] && touch /dev/.in_sysinit
|
||||
|
||||
# Move mounts instead of umount/mount
|
||||
mount --move /dev /newroot/dev
|
||||
mount --move /proc /newroot/proc
|
||||
mount --move /sys /newroot/sys
|
||||
# Added to start udev properly
|
||||
#mount --move /run /newroot/run
|
||||
|
||||
|
||||
# And we start
|
||||
info "Switching to the real root"
|
||||
test -x /bin/plymouth && /bin/plymouth update-root-fs --new-root-dir=/newroot
|
||||
exec /bin/switch_root -c /dev/console /newroot ${INIT} ${LEVEL}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# this file is used to configure initramfs, lowercase is preferred
|
||||
#
|
||||
|
||||
# Set to 1 to enable probing raid modules and
|
||||
# calling /sbin/mdadm if it exists
|
||||
# raid=1
|
||||
|
||||
# Set to 1 to enable probing lvm modules and
|
||||
# calling /sbin/lvm if it exists
|
||||
# lvm=1
|
||||
|
||||
# Set to 1 to mount rootfs over NFS
|
||||
# thin=0
|
||||
|
||||
# Set root device
|
||||
# root=LABEL=MyPisiLinuxSystem
|
||||
|
||||
# Set rootfs's mount flags
|
||||
# rootflags=acl,xattr
|
||||
|
||||
# Set resume partition
|
||||
# resume=/dev/sdb5
|
||||
|
||||
# Set to 1 to disable resuming
|
||||
# noresume=0
|
||||
|
||||
# Set Live media label
|
||||
# liveroot=LABEL=PisiLiveImage
|
||||
@@ -0,0 +1,586 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# PisiLinux initramfs creator
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
import stat
|
||||
import shutil
|
||||
import tempfile
|
||||
import subprocess
|
||||
|
||||
from optparse import OptionParser
|
||||
|
||||
config = {"rootDir" : "/",
|
||||
"tmpDir" : "",
|
||||
"debug" : False,
|
||||
"dryrun" : False,
|
||||
"destDir" : "/boot",
|
||||
"blackList" : ["pktcdvd", "floppy"],
|
||||
"kernelType" : "kernel",
|
||||
"initramfsConf" : "/etc/initramfs.conf",
|
||||
"kernelVersion" : "",
|
||||
}
|
||||
|
||||
def loadFile(_file):
|
||||
try:
|
||||
f = file(_file)
|
||||
d = [a.lstrip().rstrip("\n") for a in f]
|
||||
d = filter(lambda x: not (x.startswith("#") or x == ""), d)
|
||||
f.close()
|
||||
return d
|
||||
except:
|
||||
return []
|
||||
|
||||
def writeFile(_file, data):
|
||||
f = open(_file, "w")
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
||||
def mkdir(_dir):
|
||||
os.makedirs(_dir)
|
||||
|
||||
def dohardlink(destination, source):
|
||||
os.link(destination, source)
|
||||
|
||||
def dosymlink(destination, source):
|
||||
os.symlink(destination, source)
|
||||
|
||||
def mknod(nodfile, nodtype, major, minor, perms=0666):
|
||||
# c for character b for block devices, mknod style
|
||||
if nodtype == "c":
|
||||
devtype = stat.S_IFCHR
|
||||
else:
|
||||
devtype = stat.S_IFBLK
|
||||
|
||||
os.mknod(nodfile, perms | devtype, os.makedev(major, minor))
|
||||
|
||||
def copy(source, destination):
|
||||
# First let's check for the target directory and create if
|
||||
# it doesn't exist
|
||||
destdir = os.path.dirname(destination)
|
||||
if not os.path.isdir(destdir):
|
||||
mkdir(destdir)
|
||||
|
||||
try:
|
||||
shutil.copy2(source, destination)
|
||||
except IOError:
|
||||
printWarn("Could not find %s" % source)
|
||||
|
||||
def touch(_file):
|
||||
if os.path.exists(_file):
|
||||
os.utime(_file, None)
|
||||
else:
|
||||
f = open(_file, 'w')
|
||||
f.close()
|
||||
|
||||
def capture(*cmd):
|
||||
a = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
return a.communicate()
|
||||
|
||||
def run(*cmd):
|
||||
f = file("/dev/null", "w")
|
||||
return subprocess.call(cmd, shell=True, stdout=f, stderr=f)
|
||||
|
||||
def printFail(msg):
|
||||
print "ERROR: %s" % msg
|
||||
|
||||
tempdir.cleanup()
|
||||
sys.exit(1)
|
||||
|
||||
def printWarn(msg):
|
||||
print "WARNING: %s" % msg
|
||||
|
||||
def setKernelVersion(Version=""):
|
||||
if Version == "":
|
||||
kver = "".join(loadFile("/etc/kernel/%s" % config["kernelType"]))
|
||||
else:
|
||||
kver = Version
|
||||
|
||||
# FIXME: we should do this an option and in a try/except
|
||||
if kver == "":
|
||||
print "could not find version of %s, autodetecting" % config["kernelType"]
|
||||
kver = os.uname()[2]
|
||||
|
||||
config["kernelVersion"] = kver
|
||||
|
||||
class BaseSystem:
|
||||
def __init__(self):
|
||||
self.kver = config["kernelVersion"]
|
||||
self.tmpDir = config["tmpDir"]
|
||||
self.baseDirs = ["bin", "sbin", "etc/initramfs.d", "dev", "dev/loop", "lib", "newroot", "proc", "sys"]
|
||||
|
||||
self.deviceNodes = {"null" : ["c", 1, 3],
|
||||
"console" : ["c", 5, 1],
|
||||
"tty" : ["c", 5, 0],
|
||||
"tty0" : ["c", 4, 0],
|
||||
"tty1" : ["c", 4, 1],
|
||||
"ram0" : ["b", 1, 0],
|
||||
"fb0" : ["c", 29, 0],
|
||||
"urandom" : ["c", 1, 9],
|
||||
"kmsg" : ["c", 1, 11],
|
||||
}
|
||||
|
||||
self.baseFileList = {
|
||||
"/bin/busybox" : "/bin/",
|
||||
"/bin/busybox.links" : "/bin/",
|
||||
"/usr/bin/disktype" : "/bin/",
|
||||
"/usr/bin/sdmem" : "/bin/",
|
||||
"/lib/initramfs/init" : "/",
|
||||
"/lib/initramfs/hotplug" : "/sbin/",
|
||||
"/lib/initramfs/udhcpc.script" : "/etc/",
|
||||
"/lib/initramfs/profile.rc" : "/etc/profile",
|
||||
}
|
||||
|
||||
self.modprobeBlacklistFileList = dict([(k,"/etc/modprobe.d") for k in glob.glob("/etc/modprobe.d/blacklist*conf")])
|
||||
|
||||
self.suspendFileList = {
|
||||
"/etc/suspend.conf" : "/etc/",
|
||||
"/usr/sbin/resume" : "/bin/",
|
||||
}
|
||||
|
||||
|
||||
def getNewRoot(self, dir):
|
||||
cleandir = dir.lstrip("/")
|
||||
return os.path.join(self.tmpDir, cleandir)
|
||||
|
||||
def createBaseDirectories(self):
|
||||
for i in self.baseDirs:
|
||||
mkdir(self.getNewRoot(i))
|
||||
|
||||
mkdir(self.getNewRoot("/lib/modules/%s" % self.kver))
|
||||
mkdir(self.getNewRoot("/lib/firmware"))
|
||||
mkdir(self.getNewRoot("/etc/modprobe.d"))
|
||||
|
||||
def copyBasefiles(self):
|
||||
for i in self.baseFileList:
|
||||
copy(i, self.getNewRoot(self.baseFileList[i]))
|
||||
|
||||
for i in ["/init", "/etc/udhcpc.script"]:
|
||||
os.chmod(self.getNewRoot(i), 0755)
|
||||
|
||||
for i in ["ext2", "ext3", "ext4", "reiserfs", "xfs"]:
|
||||
touch(self.getNewRoot("/bin/fsck.%s" % i))
|
||||
|
||||
writeFile(self.getNewRoot("/etc/fstab"), "none none none defaults 0 0")
|
||||
|
||||
def createConfig(self):
|
||||
# FIXME: Parse config files and create a proper one by hand
|
||||
configFileSource = config["initramfsConf"]
|
||||
if os.path.exists(configFileSource):
|
||||
copy(configFileSource, self.getNewRoot(configFileSource))
|
||||
|
||||
def createNodes(self):
|
||||
for i in self.deviceNodes:
|
||||
k = self.deviceNodes[i]
|
||||
mknod(self.getNewRoot("dev/%s" % i), k[0], k[1], k[2])
|
||||
|
||||
for i in range(8):
|
||||
mknod(self.getNewRoot("dev/loop/%i" % i), "b", 7, i)
|
||||
dosymlink("loop/%i" % i, self.getNewRoot("dev/loop%i" % i))
|
||||
|
||||
def createBaseSymlinks(self):
|
||||
for i in loadFile(self.getNewRoot("/bin/busybox.links")):
|
||||
# FIXME: python dosym does not play nice with cpio, it creates 120MB initramfs
|
||||
# dosymlink("busybox", self.getNewRoot("/bin/%s" % i.split("/")[-1]))
|
||||
dohardlink(self.getNewRoot("/bin/busybox"), self.getNewRoot("/bin/%s" % i.split("/")[-1]))
|
||||
|
||||
# FIXME: maybe we should symlink sbin to bin
|
||||
dohardlink(self.getNewRoot("/bin/busybox"), self.getNewRoot("/sbin/modprobe"))
|
||||
|
||||
def addRaid(self):
|
||||
mdadmFile = "/sbin/mdadm.static"
|
||||
if os.path.exists(mdadmFile):
|
||||
copy(mdadmFile, self.getNewRoot(mdadmFile.replace(".static", "")))
|
||||
|
||||
def addLvm(self):
|
||||
lvmFile = "/sbin/lvm.static"
|
||||
if os.path.exists(lvmFile):
|
||||
copy(lvmFile, self.getNewRoot(lvmFile.replace(".static", "")))
|
||||
|
||||
def addSuspend(self):
|
||||
for i in self.suspendFileList:
|
||||
copy(i, self.getNewRoot(self.suspendFileList[i]))
|
||||
|
||||
def addModprobeBlacklists(self):
|
||||
for i in self.modprobeBlacklistFileList:
|
||||
copy(i, self.getNewRoot(self.modprobeBlacklistFileList[i]))
|
||||
|
||||
def create(self):
|
||||
self.createBaseDirectories()
|
||||
self.copyBasefiles()
|
||||
self.createNodes()
|
||||
self.createBaseSymlinks()
|
||||
self.createConfig()
|
||||
self.addRaid()
|
||||
self.addLvm()
|
||||
self.addSuspend()
|
||||
self.addModprobeBlacklists()
|
||||
|
||||
class KernelModule:
|
||||
def __init__(self):
|
||||
self.modulesList = []
|
||||
self.allModules = []
|
||||
self.blackList = config["blackList"]
|
||||
self.kernelVersion = config["kernelVersion"]
|
||||
|
||||
self.targetDir = config["tmpDir"]
|
||||
self.rootDir = config["rootDir"]
|
||||
self.modulesDir = os.path.join(self.rootDir, "lib/modules/%s" % self.kernelVersion)
|
||||
self.firmwareDir = os.path.join(self.rootDir, "lib/firmware")
|
||||
|
||||
self.addNetworkModule = config["networkModule"]
|
||||
self.addNetworkModuleBasic = config["networkModuleBasic"]
|
||||
|
||||
self.addDRMModules = not config["excludeDRM"]
|
||||
self.findAllModules()
|
||||
|
||||
self.scsiDirs = ["kernel/drivers/scsi"]
|
||||
self.scsiModules = ["mptfc", "mptsas", "mptscsih", "mptspi", "zfcp"]
|
||||
|
||||
self.mdDirs = ["kernel/drivers/md"]
|
||||
self.ataDirs = ["kernel/drivers/ata"]
|
||||
self.mmcDirs = ["kernel/drivers/mmc"]
|
||||
self.ideDirs = ["kernel/drivers/ide"]
|
||||
self.blockDirs = ["kernel/drivers/block"]
|
||||
|
||||
self.firewireModules = ["firewire-ohci", "firewire-sbp2", "firewire-net", "firewire-core"]
|
||||
self.i2oModules = ["i2o_block"]
|
||||
self.usbModules = ["usb-storage", "sd_mod", "usbcore", "ehci-hcd", "ohci-hcd", "uhci-hcd"]
|
||||
|
||||
self.filesystemModules = ["ext2", "ext3", "ext4", "reiser4", "jfs", "reiserfs", "xfs", "vfat", "fat", "ntfs", "unionfs", "cramfs", "nfs", "nls_utf8", "nls_iso8859_9", "nls_cp857", "nls_iso8859-1", "nls_ascii", "nls_cp850", "squashfs"]
|
||||
|
||||
self.networkBaseModules = ["af_packet", "mii", "8390", "via-rhine", "8139too", "ne2k-pci", "e100", "sky2", "tg3", "skge"]
|
||||
self.networkDirs = ["kernel/drivers/net"]
|
||||
|
||||
self.drmDir = "kernel/drivers/gpu/drm"
|
||||
|
||||
self.virtioModules = ["virtio", "virtio_balloon", "virtio_blk", "virtio_net", "virtio_pci"]
|
||||
self.xenModules = ["xenblk", "xenfb", "gntdev", "xennet", "xenkbd"]
|
||||
|
||||
|
||||
def tidyModuleList(self):
|
||||
ml = list(set(self.modulesList))
|
||||
ml.sort()
|
||||
self.modulesList = ml
|
||||
|
||||
def depmod(self, targetdir):
|
||||
cmd = "/sbin/depmod -a -b %s -F %s/System.map %s"
|
||||
capture(cmd % (targetdir, self.modulesDir, self.kernelVersion))
|
||||
|
||||
def installModules(self):
|
||||
for i in self.modulesList:
|
||||
if os.path.basename(i).replace(".ko", "") not in self.blackList:
|
||||
copy(i, os.path.join(self.targetDir, self.modulesDir.replace(self.rootDir, "/").lstrip("/")))
|
||||
|
||||
def findAllModules(self):
|
||||
foundModules = []
|
||||
|
||||
if not os.path.exists(self.modulesDir):
|
||||
printFail("There is no %s, please check your kernel version" % self.modulesDir)
|
||||
|
||||
for root, directory, files in os.walk(self.modulesDir):
|
||||
for name in files:
|
||||
if name.endswith(".ko"):
|
||||
foundModules.append(os.path.join(root, name))
|
||||
|
||||
self.allModules = foundModules
|
||||
|
||||
def findModuleDeps(self):
|
||||
deps = []
|
||||
depdata = loadFile(os.path.join(self.modulesDir, "modules.dep"))
|
||||
|
||||
for line in depdata:
|
||||
for i in self.modulesList:
|
||||
if "%s:" % i.replace("%s/" % self.modulesDir, "") in line:
|
||||
deps.extend(line.split(":")[1].strip().split(" "))
|
||||
|
||||
# return [os.path.join(self.modulesDir, x) for x in deps if not x == ""]
|
||||
self.modulesList.extend([os.path.join(self.modulesDir, x) for x in deps if not x == ""])
|
||||
|
||||
def appendFirmwares(self):
|
||||
ret = capture("/sbin/modinfo -F firmware %s/*.ko" % os.path.join(self.targetDir, self.modulesDir.replace(self.rootDir, "/").lstrip("/")))[0]
|
||||
fwlist = ret.strip("\n").split("\n")
|
||||
|
||||
targetbase = os.path.join(self.targetDir, "lib/firmware")
|
||||
|
||||
for i in fwlist:
|
||||
src = os.path.join(self.firmwareDir, i)
|
||||
target = os.path.join(targetbase, os.path.dirname(i))
|
||||
|
||||
if os.path.exists(src):
|
||||
if not os.path.exists(target):
|
||||
mkdir(target)
|
||||
|
||||
copy(src, target)
|
||||
|
||||
else:
|
||||
printWarn("Could not find firmware %s" % src)
|
||||
pass
|
||||
|
||||
def updateModuleDependencies(self, force=False):
|
||||
# this is here to prevent a race condition with pakhandler, when installing a system from scratch
|
||||
if force or not os.path.exists("%s/modules.dep" % self.modulesDir):
|
||||
printWarn("Could not find module dependencies in %s, running depmod for system" % self.modulesDir)
|
||||
self.depmod(self.rootDir)
|
||||
|
||||
def addDir(self, mdir):
|
||||
newModules = []
|
||||
dirtoadd = os.path.join(self.modulesDir, mdir)
|
||||
|
||||
for line in self.allModules:
|
||||
if line.startswith(dirtoadd):
|
||||
newModules.append(line)
|
||||
|
||||
self.modulesList.extend(newModules)
|
||||
|
||||
def addModule(self, module):
|
||||
if module.endswith(".ko"):
|
||||
module = module[:-3]
|
||||
|
||||
for line in self.allModules:
|
||||
# FIXME: I still don't trust the _ versus - case, try to be sure of it in kernel
|
||||
if line.replace("-", "_").endswith("/%s.ko" % module.replace("-", "_")):
|
||||
self.modulesList.append(line)
|
||||
return
|
||||
|
||||
def addScsi(self):
|
||||
for i in self.scsiDirs:
|
||||
self.addDir(i)
|
||||
|
||||
for i in self.scsiModules:
|
||||
self.addModule(i)
|
||||
|
||||
def addAta(self):
|
||||
for i in self.ataDirs:
|
||||
self.addDir(i)
|
||||
|
||||
def addMmc(self):
|
||||
for i in self.mmcDirs:
|
||||
self.addDir(i)
|
||||
|
||||
def addBlock(self):
|
||||
for i in self.blockDirs:
|
||||
self.addDir(i)
|
||||
|
||||
def addIde(self):
|
||||
for i in self.ideDirs:
|
||||
self.addDir(i)
|
||||
|
||||
def addNetwork(self):
|
||||
if self.addNetworkModule:
|
||||
for i in self.networkDirs:
|
||||
self.addDir(i)
|
||||
|
||||
if self.addNetworkModuleBasic:
|
||||
for i in self.networkBaseModules:
|
||||
self.addModule(i)
|
||||
|
||||
def addDRM(self):
|
||||
if self.addDRMModules:
|
||||
for i in glob.glob("%s/*/*.ko" % os.path.join(self.modulesDir, self.drmDir)):
|
||||
# Check for drm_crtc_init symbol
|
||||
if not os.system("grep -qw drm_crtc_init %s" % i):
|
||||
self.addModule(i.partition(self.modulesDir+'/')[-1])
|
||||
|
||||
# Add uvesafb as a fallback
|
||||
if os.path.exists("/sbin/v86d"):
|
||||
copy("/sbin/v86d", os.path.join(self.targetDir, "sbin/"))
|
||||
self.addModule("kernel/drivers/video/uvesafb.ko")
|
||||
|
||||
def addMd(self):
|
||||
for i in self.mdDirs:
|
||||
self.addDir(i)
|
||||
|
||||
def addFirewire(self):
|
||||
for i in self.firewireModules:
|
||||
self.addModule(i)
|
||||
|
||||
def addI2o(self):
|
||||
for i in self.i2oModules:
|
||||
self.addModule(i)
|
||||
|
||||
def addUsb(self):
|
||||
for i in self.usbModules:
|
||||
self.addModule(i)
|
||||
|
||||
def addFilesystem(self):
|
||||
for i in self.filesystemModules:
|
||||
self.addModule(i)
|
||||
|
||||
def addVirtio(self):
|
||||
for i in self.virtioModules:
|
||||
self.addModule(i)
|
||||
|
||||
def addXen(self):
|
||||
for i in self.xenModules:
|
||||
self.addModule(i)
|
||||
|
||||
def addGeneric(self):
|
||||
self.addScsi()
|
||||
self.addAta()
|
||||
self.addMmc()
|
||||
self.addBlock()
|
||||
self.addIde()
|
||||
self.addNetwork()
|
||||
self.addMd()
|
||||
self.addFirewire()
|
||||
self.addI2o()
|
||||
self.addUsb()
|
||||
self.addFilesystem()
|
||||
self.addVirtio()
|
||||
self.addDRM()
|
||||
|
||||
def autoGenerate(self):
|
||||
self.updateModuleDependencies()
|
||||
self.addGeneric()
|
||||
self.findModuleDeps()
|
||||
self.tidyModuleList()
|
||||
self.installModules()
|
||||
self.appendFirmwares()
|
||||
self.depmod(self.targetDir)
|
||||
|
||||
class Plymouth:
|
||||
def __init__(self):
|
||||
self.fileList = "/lib/initramfs/plymouth.list"
|
||||
self.targetDir = config["tmpDir"]
|
||||
self.theme = "pisilinux"
|
||||
self.themeDir = "/usr/share/plymouth/themes"
|
||||
|
||||
def install_current_theme(self):
|
||||
self.theme = os.popen("plymouth-set-default-theme").read().strip()
|
||||
if os.path.exists("%s/%s" % (self.themeDir, self.theme)):
|
||||
for themeFile in glob.glob("%s/%s/*" % (self.themeDir, self.theme)):
|
||||
copy(themeFile, os.path.join(self.targetDir, themeFile[1:]))
|
||||
|
||||
def install(self):
|
||||
"""Will install plymouth related base stuff."""
|
||||
if os.path.exists(self.fileList):
|
||||
with open(self.fileList, "r") as files:
|
||||
for _file in files:
|
||||
filename = _file.strip()
|
||||
copy(filename.strip(), os.path.join(self.targetDir, filename[1:]))
|
||||
|
||||
self.install_current_theme()
|
||||
|
||||
class Initramfs:
|
||||
def __init__(self):
|
||||
self.destDir = config["destDir"]
|
||||
self.sourceDir = config["tmpDir"]
|
||||
self.initramfs = "initramfs-%s" % config["kernelVersion"]
|
||||
|
||||
def create(self):
|
||||
if not os.path.exists(self.destDir):
|
||||
mkdir(self.destDir)
|
||||
|
||||
cmd = "(cd %s && find . | cpio --quiet --dereference -o -H newc | gzip -6 > %s)"
|
||||
capture(cmd % (self.sourceDir, os.path.join(self.destDir, self.initramfs)))
|
||||
|
||||
class Tempdir:
|
||||
def __init__(self):
|
||||
self.tmpDir = ""
|
||||
self.keepTmp = False
|
||||
|
||||
def create(self):
|
||||
self.tmpDir = tempfile.mkdtemp(prefix="mkinitramfs-")
|
||||
|
||||
def cleanup(self):
|
||||
if self.keepTmp:
|
||||
printWarn("Keeping temporary directory %s" % self.tmpDir)
|
||||
else:
|
||||
shutil.rmtree(self.tmpDir)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
tempdir = Tempdir()
|
||||
tempdir.create()
|
||||
config["tmpDir"] = tempdir.tmpDir
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option("-k", "--kernel", dest="kernelVersion", type="string",
|
||||
help="kernel version to create initramfs for")
|
||||
|
||||
parser.add_option("-t", "--type", dest="type", type="string", default="kernel",
|
||||
help="kernel type to create initramfs for")
|
||||
|
||||
parser.add_option("-o", "--output", dest="destDir", type="string", metavar="DIR", default="/boot",
|
||||
help="create initramfs in DIR")
|
||||
|
||||
parser.add_option("-c", "--configfile", dest="configFile", type="string", metavar="FILE", default="/etc/initramfs.conf",
|
||||
help="use FILE for initramfs config file, default is /etc/initramfs.conf")
|
||||
|
||||
parser.add_option("-r", "--rootdir", dest="rootDir", type="string", metavar="DIR", default="/",
|
||||
help="use DIR as basedir for kernel modules")
|
||||
|
||||
parser.add_option("-f", "--filename", dest="filename", type="string", metavar="FILE",
|
||||
help="use FILE for initramfs file name")
|
||||
|
||||
parser.add_option("-d", "--debug", action="store_true", dest="debug", default=False,
|
||||
help="print extra debug info")
|
||||
|
||||
parser.add_option("--blacklist", dest="blackList", type="string", metavar="FILES", default="",
|
||||
help="define modules to be blacklisted, seperated by comma. Example: e100,rtl819,ahci")
|
||||
|
||||
parser.add_option("--network", action="store_true", dest="networkModule", default=False,
|
||||
help="add network modules")
|
||||
|
||||
parser.add_option("--nodrm", action="store_true", dest="excludeDRM", default=False,
|
||||
help="Don't include KMS capable DRM modules")
|
||||
|
||||
parser.add_option("--network-generic", action="store_true", dest="networkModuleBasic", default=False,
|
||||
help="add only generic network modules")
|
||||
|
||||
parser.add_option("--keeptmp", action="store_true", dest="keepTmp", default=False,
|
||||
help="whether to keep temporary dir after operation")
|
||||
|
||||
parser.add_option("-n", "--dry-run", action="store_true", dest="dryrun", default=False,
|
||||
help="do not perform any action, just show what will be done")
|
||||
|
||||
parser.add_option("--list-modules", action="store_true", dest="listModules", default=False,
|
||||
help="do not perform any action, just show what will be done")
|
||||
|
||||
parser.add_option("--list-base", action="store_true", dest="listBase", default=False,
|
||||
help="do not perform any action, just show what will be done")
|
||||
|
||||
(opts, args) = parser.parse_args()
|
||||
|
||||
config["initramfsConf"] = opts.configFile
|
||||
|
||||
config["destDir"] = os.path.abspath(opts.destDir)
|
||||
config["rootDir"] = os.path.abspath(opts.rootDir)
|
||||
|
||||
config["debug"] = opts.debug
|
||||
config["dryrun"] = opts.dryrun
|
||||
tempdir.keepTmp = opts.keepTmp
|
||||
|
||||
config["kernelType"] = opts.type
|
||||
config["networkModule"] = opts.networkModule
|
||||
config["networkModuleBasic"] = opts.networkModuleBasic
|
||||
config["excludeDRM"] = opts.excludeDRM
|
||||
|
||||
if "," in opts.blackList:
|
||||
config["blackList"].extend(opts.blackList.split(","))
|
||||
|
||||
if opts.kernelVersion:
|
||||
config["kernelVersion"] = opts.kernelVersion
|
||||
else:
|
||||
setKernelVersion()
|
||||
|
||||
basesystem = BaseSystem()
|
||||
basesystem.create()
|
||||
|
||||
# Check for plymouth and install if found
|
||||
plymouth = Plymouth()
|
||||
plymouth.install()
|
||||
|
||||
kernelmodule = KernelModule()
|
||||
kernelmodule.autoGenerate()
|
||||
|
||||
initramfs = Initramfs()
|
||||
initramfs.create()
|
||||
|
||||
tempdir.cleanup()
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Simple profile file for sh
|
||||
|
||||
alias ls='ls --color=auto'
|
||||
alias ll='ls --color -l'
|
||||
|
||||
export PS1="\[\033[1;31m\]initramfs \[\033[1;34m\]\W # \[\033[00m\]"
|
||||
@@ -0,0 +1,85 @@
|
||||
#!/bin/sh
|
||||
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
||||
|
||||
RESOLV_CONF="/etc/resolv.conf"
|
||||
|
||||
UDHCPC_INFO="/etc/udhcpc.info"
|
||||
|
||||
update_interface()
|
||||
{
|
||||
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
|
||||
[ -n "$subnet" ] && NETMASK="netmask $subnet"
|
||||
/bin/ifconfig $interface $ip $BROADCAST $NETMASK
|
||||
}
|
||||
|
||||
update_routes()
|
||||
{
|
||||
if [ -n "$router" ]
|
||||
then
|
||||
echo "deleting routes"
|
||||
while /bin/route del default gw 0.0.0.0 dev $interface > /dev/null 2>&1
|
||||
do :
|
||||
done
|
||||
|
||||
for i in $router
|
||||
do
|
||||
/bin/route add default gw $i dev $interface
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
update_dns()
|
||||
{
|
||||
echo -n > $RESOLV_CONF
|
||||
[ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF
|
||||
for i in $dns
|
||||
do
|
||||
echo adding dns $i
|
||||
echo nameserver $i >> $RESOLV_CONF
|
||||
done
|
||||
}
|
||||
|
||||
deconfig()
|
||||
{
|
||||
/bin/ifconfig $interface 0.0.0.0
|
||||
}
|
||||
|
||||
update_udhcpc_info()
|
||||
{
|
||||
cat > $UDHCPC_INFO <<EOF
|
||||
HOSTNAME=$hostname
|
||||
INTERFACE=$interface
|
||||
IP=$ip
|
||||
BROADCAST=$broadcast
|
||||
NETMASK=$netmask
|
||||
ROOTPATH=$rootpath
|
||||
EOF
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
bound)
|
||||
update_interface;
|
||||
update_routes;
|
||||
update_dns;
|
||||
update_udhcpc_info;
|
||||
;;
|
||||
|
||||
renew)
|
||||
update_interface;
|
||||
update_routes;
|
||||
update_dns;
|
||||
update_udhcpc_info;
|
||||
;;
|
||||
|
||||
deconfig)
|
||||
deconfig;
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {bound|renew|deconfig}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE PISI SYSTEM "http://www.pisilinux.org/projeler/pisi/pisi-spec.dtd">
|
||||
<PISI>
|
||||
<Source>
|
||||
<Name>mkinitramfs</Name>
|
||||
<Homepage>http://www.busybox.net</Homepage>
|
||||
<Packager>
|
||||
<Name>PisiLinux Community</Name>
|
||||
<Email>admins@pisilinux.org</Email>
|
||||
</Packager>
|
||||
<License>GPLv2</License>
|
||||
<IsA>app:console</IsA>
|
||||
<Summary>A tool to create the initramfs image</Summary>
|
||||
<Description>mkinitramfs contains a tool to create the initramfs image with busybox.</Description>
|
||||
<Archive sha1sum="c35fcf085f1bb73b851d7525c135a483c903b13d" type="binary">http://source.pisilinux.org/1.0/README.mkinitramfs</Archive>
|
||||
</Source>
|
||||
|
||||
<Package>
|
||||
<Name>mkinitramfs</Name>
|
||||
<RuntimeDependencies>
|
||||
<Dependency>disktype</Dependency>
|
||||
<Dependency>busybox</Dependency>
|
||||
</RuntimeDependencies>
|
||||
<Files>
|
||||
<Path fileType="config">/etc</Path>
|
||||
<Path fileType="executable">/sbin</Path>
|
||||
<Path fileType="executable">/lib/initramfs</Path>
|
||||
<Path fileType="doc">/usr/share/doc/mkinitramfs</Path>
|
||||
</Files>
|
||||
<AdditionalFiles>
|
||||
<AdditionalFile owner="root" permission="0755" target="/sbin/mkinitramfs">mkinitramfs</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0755" target="/lib/initramfs/init">init</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0755" target="/lib/initramfs/udhcpc.script">udhcpc.script</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0755" target="/lib/initramfs/hotplug">hotplug</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/lib/initramfs/profile.rc">profile.rc</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/etc/initramfs.conf.example">initramfs.conf</AdditionalFile>
|
||||
</AdditionalFiles>
|
||||
<Provides>
|
||||
<COMAR script="pakhandler.py">System.PackageHandler</COMAR>
|
||||
</Provides>
|
||||
</Package>
|
||||
|
||||
<History>
|
||||
<Update release="8">
|
||||
<Date>2014-05-11</Date>
|
||||
<Version>1.0.7</Version>
|
||||
<Comment>Release bump.</Comment>
|
||||
<Name>Marcin Bojara</Name>
|
||||
<Email>marcin@pisilinux.org</Email>
|
||||
</Update>
|
||||
<Update release="7">
|
||||
<Date>2014-05-10</Date>
|
||||
<Version>1.0.7</Version>
|
||||
<Comment>Fix probing LVM devices</Comment>
|
||||
<Name>Marcin Bojara</Name>
|
||||
<Email>marcin@pisilinux.org</Email>
|
||||
</Update>
|
||||
<Update release="6">
|
||||
<Date>2013-09-10</Date>
|
||||
<Version>1.0.7</Version>
|
||||
<Comment>Disable mount tmpfs on /run</Comment>
|
||||
<Name>Marcin Bojara</Name>
|
||||
<Email>marcin@pisilinux.org</Email>
|
||||
</Update>
|
||||
<Update release="5">
|
||||
<Date>2013-09-05</Date>
|
||||
<Version>1.0.7</Version>
|
||||
<Comment>Add missing method to pakhandler.py</Comment>
|
||||
<Name>Marcin Bojara</Name>
|
||||
<Email>marcin@pisilinux.org</Email>
|
||||
</Update>
|
||||
<Update release="4">
|
||||
<Date>2013-09-03</Date>
|
||||
<Version>1.0.7</Version>
|
||||
<Comment>Fix default plymouth theme name.</Comment>
|
||||
<Name>Serdar Soytetir</Name>
|
||||
<Email>kaptan@pisilinux.org</Email>
|
||||
</Update>
|
||||
<Update release="3">
|
||||
<Date>2013-06-17</Date>
|
||||
<Version>1.0.7</Version>
|
||||
<Comment>Fix resume path.</Comment>
|
||||
<Name>Marcin Bojara</Name>
|
||||
<Email>marcin@pisilinux.org</Email>
|
||||
</Update>
|
||||
<Update release="2">
|
||||
<Date>2013-02-13</Date>
|
||||
<Version>1.0.7</Version>
|
||||
<Comment>Change loopbackimage address and name.</Comment>
|
||||
<Name>Serdar Soytetir</Name>
|
||||
<Email>kaptan@pisilinux.org</Email>
|
||||
</Update>
|
||||
<Update release="1">
|
||||
<Date>2013-01-13</Date>
|
||||
<Version>1.0.7</Version>
|
||||
<Comment>First release</Comment>
|
||||
<Name>Serdar Soytetir</Name>
|
||||
<Email>kaptan@pisilinux.org</Email>
|
||||
</Update>
|
||||
</History>
|
||||
</PISI>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" ?>
|
||||
<PISI>
|
||||
<Source>
|
||||
<Name>mkinitramfs</Name>
|
||||
<Summary xml:lang="tr">initramfs image dosyası yaratmak için araç</Summary>
|
||||
<Description xml:lang="tr">initramfs image dosyası yaratmak için araç</Description>
|
||||
<Description xml:lang="fr">Un outil pour créer les images initramfs</Description>
|
||||
</Source>
|
||||
</PISI>
|
||||
Reference in New Issue
Block a user