From 4387da41576f6b2ef9aa7e1bf89954d2b9f7b9a0 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 2 May 2013 19:30:43 +0000 Subject: main/mkinitfs: backport initial pxe support --- .../0001-init-fix-cryptdm-regression.patch | 28 -- main/mkinitfs/APKBUILD | 22 +- main/mkinitfs/git.patch | 282 +++++++++++++++++++++ 3 files changed, 294 insertions(+), 38 deletions(-) delete mode 100644 main/mkinitfs/0001-init-fix-cryptdm-regression.patch create mode 100644 main/mkinitfs/git.patch (limited to 'main/mkinitfs') diff --git a/main/mkinitfs/0001-init-fix-cryptdm-regression.patch b/main/mkinitfs/0001-init-fix-cryptdm-regression.patch deleted file mode 100644 index e989f2b7ed..0000000000 --- a/main/mkinitfs/0001-init-fix-cryptdm-regression.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 17c2183fdd3f788fe38a64024d15c895492114b5 Mon Sep 17 00:00:00 2001 -From: Natanael Copa -Date: Thu, 14 Mar 2013 07:09:32 +0000 -Subject: [PATCH] init: fix cryptdm regression - ---- - initramfs-init.in | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/initramfs-init.in b/initramfs-init.in -index 3c05f81..9bce5f8 100755 ---- a/initramfs-init.in -+++ b/initramfs-init.in -@@ -286,8 +286,9 @@ echo "Alpine Init $VERSION" - # acpi_osi="!Windows 2006" - eval set -- `cat /proc/cmdline` - --myopts="alpine_dev autodetect autoraid chart cryptroot debug_init dma init_args -- keep_apk_new modules ovl_dev pkgs quiet root_size root usbdelay" -+myopts="alpine_dev autodetect autoraid chart cryptroot cryptdm debug_init -+ dma init_args keep_apk_new modules ovl_dev pkgs quiet root_size root -+ usbdelay" - - for opt; do - case "$opt" in --- -1.8.1.5 - diff --git a/main/mkinitfs/APKBUILD b/main/mkinitfs/APKBUILD index a34187ce0a..17d1fce9b0 100644 --- a/main/mkinitfs/APKBUILD +++ b/main/mkinitfs/APKBUILD @@ -1,20 +1,22 @@ # Maintainer: Natanael Copa pkgname=mkinitfs -pkgver=2.4.4 -pkgrel=1 +pkgver=2.4.4_git20130502 +_ver=${pkgver%_git*} +pkgrel=0 pkgdesc="Tool to generate initramfs images for Alpine" url=http://git.alpinelinux.org/cgit/mkinitfs depends="busybox apk-tools>=2.0" triggers="$pkgname.trigger=/usr/share/kernel/*" -source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2 - 0001-init-fix-cryptdm-regression.patch +source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$_ver.tar.bz2 + git.patch eglibc.patch " arch="noarch" license="GPL-2" +_builddir="$srcdir"/$pkgname-$_ver prepare() { - cd "$srcdir"/$pkgname-$pkgver + cd "$_builddir" # If we are using eglibc/glibc we need to include eglibc libs # instead of uclibc libs. @@ -35,20 +37,20 @@ prepare() { } build() { - cd "$srcdir"/$pkgname-$pkgver + cd "$_builddir" make VERSION=$pkgver-r$pkgrel || return 1 } package() { - cd "$srcdir"/$pkgname-$pkgver + cd "$_builddir" make install DESTDIR="$pkgdir" || return 1 } md5sums="5b897ab38204bf62ed8abf63d6b7cafd mkinitfs-2.4.4.tar.bz2 -88c6b7928cd7fd3bce1b7297083a3184 0001-init-fix-cryptdm-regression.patch +6727bb8b3a5cc0ac415a8fb7ae871e87 git.patch 067649665a767ff1a08578e1f4e61524 eglibc.patch" sha256sums="454e43149322e9cdfd7ea397480621b42169b5d78dd8eab1be46b96762fc5dc5 mkinitfs-2.4.4.tar.bz2 -aa458c98f5099154bc0011355acb0ba3b718677d8775b7fd2d1dc71a92e3178b 0001-init-fix-cryptdm-regression.patch +d95bc897f7f850ba2057af5ccaf5814f5ff8d42a2932a3943d390fcfe088bd87 git.patch 2db513d1a058be0f5794dc74d00418807253d8ac850c9713ea0eeb0be5f3f65a eglibc.patch" sha512sums="9f0e49b20a592b4315155453e4398abf710c8bae62496d4b8d281e21d13366804084be26f0303d35ef3f0bf295eba76885ca43ff452d4aea1e59f0bdce0de18e mkinitfs-2.4.4.tar.bz2 -fe9122c5e00ba74476ade44f5e4e6b74690c10bd45cc239a5fab88468a3ee689b4880843aabe7a8efa9be2b6f0126dddbc94130d0b53866ee36138f3b3a96070 0001-init-fix-cryptdm-regression.patch +4e07de46376df4e1a82e04e2276a389c8dfdb9ad43c58b6c3daf2b199f549996562d41cb5f39e85c2c974200acb851bfedb405e1911fbf55d89ca3ae556286c7 git.patch 3498d9930889cd776a34863733d467b50b83679ea7f91d79963c81e4f1dc138f887ef1f2a696da6d836d1f6f862dcfd2c2fb9a55b0e3b2926e9f3fc648bc5a15 eglibc.patch" diff --git a/main/mkinitfs/git.patch b/main/mkinitfs/git.patch new file mode 100644 index 0000000000..b82239e419 --- /dev/null +++ b/main/mkinitfs/git.patch @@ -0,0 +1,282 @@ +diff --git a/initramfs-init.in b/initramfs-init.in +index 3c05f81..5d07157 100755 +--- a/initramfs-init.in ++++ b/initramfs-init.in +@@ -191,7 +191,7 @@ setup_inittab_console(){ + esac + shift + +- # skip "current console" from beign added to inittab ++ # skip "current console" from being added to inittab + [ "$tty" = "tty0" ] && continue + + # do nothing if inittab already have the tty set up +@@ -240,6 +240,81 @@ start_lvm() { + lvm vgchange --ignorelockingfailure -a y >/dev/null 2>&1 + } + ++# determine the default interface to use if ip=dhcp is set ++# uses the first "eth" interface. ++ip_choose_if() { ++ for x in /sys/class/net/eth*; do ++ [ -e "$x" ] && echo ${x##*/} && return ++ done ++} ++ ++# ip_set ++ip_set() { ++ ifconfig "$1" "$2" netmask "$3" || return $? ++ if [ -n "$4" ]; then ++ ip route add 0.0.0.0/0 via "$4" dev "$1" || return $? ++ fi ++} ++ ++# if "ip=dhcp" is specified on the command line, we obtain an IP address ++# using udhcpc. we do this now and not by enabling kernel-mode DHCP because ++# kernel-model DHCP appears to require that network drivers be built into ++# the kernel rather than as modules. At this point all applicable modules ++# in the initrd should have been loaded. ++# ++# You need af_packet.ko available as well modules for your Ethernet card. ++# ++# Valid syntaxes: ++# ip=client-ip:server-ip:gw-ip:netmask:hostname:device:autoconf ++# ip=dhcp ++# "server-ip" and "hostname" are not supported here. ++# ++configure_ip() { ++ [ -n "$KOPT_ip" ] || return ++ OIFS=$IFS ++ IFS=':' ++ eval set -- $KOPT_ip ++ IFS=$OIFS ++ ++ local client_ip="$1" ++ local gw_ip="$3" ++ local netmask="$4" ++ local device="$6" ++ local autoconf="$7" ++ case "$client_ip" in ++ off|none|'') return;; ++ dhcp) autoconf="dhcp";; ++ esac ++ ++ [ -n "$device" ] || device=$(ip_choose_if) ++ if [ -z "$device" ]; then ++ echo "ERROR: IP requested but no network device was found" ++ return 1 ++ fi ++ ++ if [ "$autoconf" = "dhcp" ]; then ++ if [ ! -e /usr/share/udhcpc/default.script ]; then ++ echo "ERROR: DHCP requested but not present in initrd" ++ return 1 ++ fi ++ # automatic configuration ++ ebegin "Obtaining IP via DHCP ($device)..." ++ ifconfig $device 0.0.0.0 ++ udhcpc -i $device -f -q ++ eend $? ++ else ++ # manual configuration ++ [ -n "$client_ip" -a -n "$netmask" ] || return ++ ebegin "Setting IP ($device)..." ++ ip_set "$device" "$client_ip" "$netmask" "$gw_ip" ++ eend $? ++ fi ++ MAC_ADDRESS=$(cat /sys/class/net/$device/address) ++ MACHINE_UUID=$(cat /sys/class/dmi/id/product_uuid) ++ OVL_DEV="${OVL_DEV/{MAC\}/$MAC_ADDRESS}" ++ OVL_DEV="${OVL_DEV/{UUID\}/$MACHINE_UUID}" ++} ++ + # resolve an uuid or symlink to the real device + resolve_dev() { + case "$1" in +@@ -275,8 +350,12 @@ find_fs_type() { + + # find the dirs under ALPINE_MNT that are boot repositories + find_boot_repositories() { +- find $ALPINE_MNT -name .boot_repository -type f -maxdepth 3 \ +- | sed 's:/.boot_repository$::' ++ if [ -n "$ALPINE_REPO" ]; then ++ echo "$ALPINE_REPO" ++ else ++ find $ALPINE_MNT -name .boot_repository -type f -maxdepth 3 \ ++ | sed 's:/.boot_repository$::' ++ fi + } + + # gotta start from somewhere :) +@@ -286,8 +365,9 @@ echo "Alpine Init $VERSION" + # acpi_osi="!Windows 2006" + eval set -- `cat /proc/cmdline` + +-myopts="alpine_dev autodetect autoraid chart cryptroot debug_init dma init_args +- keep_apk_new modules ovl_dev pkgs quiet root_size root usbdelay" ++myopts="alpine_dev autodetect autoraid chart cryptroot cryptdm debug_init ++ dma init_args keep_apk_new modules ovl_dev pkgs quiet root_size root ++ usbdelay ip alpine_repo apkovl" + + for opt; do + case "$opt" in +@@ -340,6 +420,8 @@ ALPINE_DEV_FS=${KOPT_alpine_dev##*:} + if [ "$ALPINE_DEV_FS" = "$ALPINE_DEV" ]; then + unset ALPINE_DEV_FS + fi ++ ++# /dev/blah:ext3 + if [ -n "$KOPT_ovl_dev" ] ; then + OVL_DEV=${KOPT_ovl_dev%%:*} + OVL_DEV_FS=${KOPT_ovl_dev##*:} +@@ -348,13 +430,31 @@ if [ -n "$KOPT_ovl_dev" ] ; then + fi + fi + ++# http://.../blah.apkovl.tar.gz ++case "$KOPT_apkovl" in ++ http://*|https://|ftp://*) ++ OVL_DEV="$KOPT_apkovl";; ++esac ++ + case "$ALPINE_DEV" in + UUID=*|LABEL=*) ;; ++ nfs) ++ # nfs:IP:EXPORT ++ ALPINE_DEV_FS="$ALPINE_DEV" ++ ALPINE_DEV="${KOPT_alpine_dev:4}" ++ ;; + *) ALPINE_DEV=/dev/$ALPINE_DEV ;; + esac + ++# The following values are supported: ++# alpine_repo=auto -- default, search for .boot_repository ++# alpine_repo=http://... -- network repository ++ALPINE_REPO=${KOPT_alpine_repo} ++[ "$ALPINE_REPO" = "auto" ] && ALPINE_REPO= ++ + # look for standard mountpoint locations + ALPINE_MNT=$(find_mnt $ALPINE_DEV /etc/fstab) ++[ -z "$ALPINE_MNT" ] && [ "$ALPINE_DEV_FS" = nfs ] && ALPINE_MNT=/media/alpine + [ -z "$ALPINE_MNT" ] && ALPINE_MNT=/media/${ALPINE_DEV##*/} + + # hide kernel messages +@@ -428,6 +528,9 @@ if [ -z "${ALPINE_DEV##*usb*}" ]; then + wait_usb + fi + ++# IP. This shouldn't be needed if root= is set. ++configure_ip ++ + # incase we have alpine_dev on raid device... + start_raid + start_cryptsetup +@@ -444,6 +547,7 @@ fi + + if [ -n "$ALPINE_DEV_FS" ]; then + mount_opts="-t $ALPINE_DEV_FS" ++ [ "$ALPINE_DEV_FS" = "nfs" ] && mount_opts="$mount_opts -o nolock" + fi + + retry_mount -o ro $mount_opts $ALPINE_DEV $ALPINE_MNT >/dev/null 2>&1 +@@ -462,19 +566,27 @@ if [ -n "$KOPT_root_size" ]; then + fi + mount -t tmpfs $root_opts tmpfs $sysroot + +-if [ -n "$OVL_DEV" ]; then +- mkdir -p /media/$OVL_DEV +- unset mount_opts +- if [ -n "$OVL_DEV_FS" ]; then +- mount_opts="-t $OVL_DEV_FS" +- fi +- +- retry_mount -o ro $mount_opts /dev/$OVL_DEV /media/$OVL_DEV \ +- >/dev/null 2>&1 +- ovl=$(find_ovl /media/$OVL_DEV) +-else +- find_ovl_dev +-fi ++case "$OVL_DEV" in ++ '') ++ find_ovl_dev ++ ;; ++ http://*|https://*|ftp://*) ++ ovl=/tmp/boot.apkovl.tar.gz ++ wget -O "$ovl" "$OVL_DEV" || ovl= ++ ;; ++ *) ++ mkdir -p /media/$OVL_DEV ++ unset mount_opts ++ if [ -n "$OVL_DEV_FS" ]; then ++ mount_opts="-t $OVL_DEV_FS" ++ fi ++ ++ retry_mount -o ro $mount_opts /dev/$OVL_DEV /media/$OVL_DEV \ ++ >/dev/null 2>&1 ++ ovl=$(find_ovl /media/$OVL_DEV) ++ ;; ++esac ++ + if ! [ -f "$ovl" ]; then + ovl=$(find_ovl $ALPINE_MNT) + fi +@@ -508,7 +620,8 @@ if [ -f "$ovl" ]; then + -e 's|:/etc/init.d/rcK|:/sbin/rc shutdown|' \ + "$sysroot"/etc/inittab + fi +-else ++fi ++if [ -f "$sysroot/etc/.default_boot_services" -o ! -f "$ovl" ]; then + # add some boot services by default + rc_add devfs sysinit + rc_add dmesg sysinit +@@ -524,6 +637,8 @@ else + rc_add mount-ro shutdown + rc_add killprocs shutdown + rc_add savecache shutdown ++ ++ rm -f "$sysroot/etc/.default_boot_services" + fi + + if [ -f $sysroot/etc/fstab ]; then +@@ -569,7 +684,14 @@ ebegin "Installing packages to root filesystem" + if [ "$KOPT_chart" = yes ]; then + pkgs="$pkgs acct" + fi +-apkflags="--initdb --progress --force --no-network" ++ ++apkflags="--initdb --progress --force" ++if [ -z "$ALPINE_REPO" ]; then ++ apkflags="$apkflags --no-network" ++else ++ apkflags="$apkflags --update-cache" ++fi ++ + if [ -n "$KOPT_quiet" ]; then + apkflags="$apkflags --quiet" + fi +@@ -580,7 +702,7 @@ if [ "$KOPT_keep_apk_new" != yes ]; then + fi + + if [ -n "$ovlfiles" ]; then +- apk add --root $sysroot $repo_opt $apkflags $pkgs <$ovlfiles>/dev/null ++ apk add --root $sysroot $repo_opt $apkflags $pkgs <$ovlfiles>/dev/null + else + apk add --root $sysroot $repo_opt $apkflags $pkgs >/dev/null + fi +@@ -613,11 +735,14 @@ fi + setup_inittab_console $CONSOLE + + # copy alpine release info +-if ! [ -f "$sysroot"/etc/alpine-release ]; then ++if ! [ -f "$sysroot"/etc/alpine-release ] && [ -f $ALPINE_MNT/.alpine-release ]; then + cp $ALPINE_MNT/.alpine-release $sysroot/ + ln -sf /.alpine-release $sysroot/etc/alpine-release + fi + ++! [ -f "$sysroot"/etc/resolv.conf ] && [ -f /etc/resolv.conf ] && \ ++ cp /etc/resolv.conf "$sysroot"/etc ++ + # setup bootchart for switch_root + chart_init="" + if [ "$KOPT_chart" = yes ]; then -- cgit v1.2.3