diff --git a/srcpkgs/busybox-ntpd b/srcpkgs/busybox-ntpd deleted file mode 120000 index c3fa810285..0000000000 --- a/srcpkgs/busybox-ntpd +++ /dev/null @@ -1 +0,0 @@ -busybox \ No newline at end of file diff --git a/srcpkgs/busybox-ntpd/files b/srcpkgs/busybox-ntpd/files new file mode 120000 index 0000000000..bd963d91c4 --- /dev/null +++ b/srcpkgs/busybox-ntpd/files @@ -0,0 +1 @@ +../busybox/files/ \ No newline at end of file diff --git a/srcpkgs/busybox-ntpd/patches b/srcpkgs/busybox-ntpd/patches new file mode 120000 index 0000000000..02b71e5738 --- /dev/null +++ b/srcpkgs/busybox-ntpd/patches @@ -0,0 +1 @@ +../busybox/patches/ \ No newline at end of file diff --git a/srcpkgs/busybox-ntpd/template b/srcpkgs/busybox-ntpd/template new file mode 100644 index 0000000000..b9179677de --- /dev/null +++ b/srcpkgs/busybox-ntpd/template @@ -0,0 +1,43 @@ +# Build template for 'busybox-ntpd'. +pkgname=busybox-ntpd +version=1.23.2 +revision=1 +wrksrc="busybox-$version" +hostmakedepends="perl" +short_desc="The Swiss Army Knife of Embedded Linux (ntpd)" +maintainer="Juan RP " +license="GPL-2" +homepage="http://www.busybox.net" +distfiles="${homepage}/downloads/busybox-$version.tar.bz2" +checksum=05a6f9e21aad8c098e388ae77de7b2361941afa7157ef74216703395b14e319a + +pre_build() { + mkdir -p src + mv * src || true + + local t="busybox-ntpd" + mkdir -p $t + make -C $t CFLAGS="$CFLAGS" KBUILD_SRC=${wrksrc}/src \ + -f ${wrksrc}/src/Makefile defconfig + cp -f ${FILESDIR}/${t}.dotconfig ${t}/.config + + case "$XBPS_TARGET_MACHINE" in + *-musl) sed -i -e /CONFIG_FEATURE_VI_REGEX_SEARCH/s/y/n/ \ + -e /CONFIG_FEATURE_MOUNT_NFS/s/y/n/ \ + ${t}/.config;; + esac + + if [ "$CROSS_BUILD" ]; then + sed -e \ + "s,\(CONFIG_CROSS_COMPILER_PREFIX\).*,\1=\"${XBPS_CROSS_TRIPLET}-\",g" \ + -i ${t}/.config + fi +} +do_build() { + local t="busybox-ntpd" + make -C $t SKIP_STRIP=y CFLAGS="$CFLAGS" ${makejobs} +} +do_install() { + vbin busybox-ntpd/busybox_unstripped busybox-ntpd + vsv busybox-ntpd +} diff --git a/srcpkgs/busybox-ntpd/update b/srcpkgs/busybox-ntpd/update new file mode 100644 index 0000000000..791aa2a97d --- /dev/null +++ b/srcpkgs/busybox-ntpd/update @@ -0,0 +1 @@ +ignore="*.0" diff --git a/srcpkgs/busybox/template b/srcpkgs/busybox/template index ede6a53309..f639cb3598 100644 --- a/srcpkgs/busybox/template +++ b/srcpkgs/busybox/template @@ -1,7 +1,7 @@ # Build template for 'busybox'. pkgname=busybox version=1.23.2 -revision=1 +revision=2 hostmakedepends="perl" short_desc="The Swiss Army Knife of Embedded Linux" maintainer="Juan RP " @@ -24,12 +24,12 @@ pre_build() { mv * src || true local t - for t in busybox busybox-static busybox-ntpd; do + for t in busybox busybox-static; do mkdir -p $t make -C $t CFLAGS="$(_cflags $t)" KBUILD_SRC=${wrksrc}/src \ -f ${wrksrc}/src/Makefile defconfig cp -f ${FILESDIR}/${t}.dotconfig ${t}/.config - + case "$XBPS_TARGET_MACHINE" in *-musl) sed -i -e /CONFIG_FEATURE_VI_REGEX_SEARCH/s/y/n/ \ -e /CONFIG_FEATURE_MOUNT_NFS/s/y/n/ \ @@ -45,7 +45,7 @@ pre_build() { } do_build() { local t - for t in busybox busybox-static busybox-ntpd; do + for t in busybox busybox-static; do make -C $t SKIP_STRIP=y CFLAGS="$(_cflags $t)" ${makejobs} done } @@ -60,11 +60,3 @@ busybox-static_package() { vbin busybox-static/busybox busybox.static } } - -busybox-ntpd_package() { - short_desc+=" (ntpd)" - pkg_install() { - vbin busybox-ntpd/busybox_unstripped busybox-ntpd - vsv busybox-ntpd - } -} diff --git a/srcpkgs/mkinitcpio-encrypt b/srcpkgs/mkinitcpio-encrypt new file mode 120000 index 0000000000..dd6b17ac57 --- /dev/null +++ b/srcpkgs/mkinitcpio-encrypt @@ -0,0 +1 @@ +mkinitcpio \ No newline at end of file diff --git a/srcpkgs/mkinitcpio-encryptssh/template b/srcpkgs/mkinitcpio-encryptssh/template new file mode 100644 index 0000000000..8ca16fa6e6 --- /dev/null +++ b/srcpkgs/mkinitcpio-encryptssh/template @@ -0,0 +1,21 @@ +# Template file for 'mkinitcpio-encryptssh' +pkgname=mkinitcpio-encryptssh +version=0.16 +revision=1 +_realname=dropbear_initrd_encrypt +wrksrc="$_realname-$version-$revision" +noarch=yes +depends="mkinitcpio cryptsetup dropbear mkinitcpio-nfs-utils psmisc iproute2" +short_desc="Allows for an encrypted root device to be unlocked remotely over SSH" +maintainer="Andrea Brancaleoni " +license="GPL-3" +homepage="https://github.com/grazzolini/dropbear_initrd_encrypt" +distfiles="$homepage/archive/v$version-$revision.tar.gz" +checksum=6b24ea3d6e1ee55d304ca31707fe17c545f7ea843a13b764e22475f838c41eae + +do_install() { + vinstall dropbear_hook 644 usr/lib/initcpio/hooks dropbear + vinstall dropbear_install 644 usr/lib/initcpio/install dropbear + vinstall encryptssh_hook 644 usr/lib/initcpio/hooks encryptssh + vinstall encryptssh_install 644 usr/lib/initcpio/install encryptssh +} diff --git a/srcpkgs/mkinitcpio-lvm2 b/srcpkgs/mkinitcpio-lvm2 new file mode 120000 index 0000000000..dd6b17ac57 --- /dev/null +++ b/srcpkgs/mkinitcpio-lvm2 @@ -0,0 +1 @@ +mkinitcpio \ No newline at end of file diff --git a/srcpkgs/mkinitcpio-mdadm b/srcpkgs/mkinitcpio-mdadm new file mode 120000 index 0000000000..dd6b17ac57 --- /dev/null +++ b/srcpkgs/mkinitcpio-mdadm @@ -0,0 +1 @@ +mkinitcpio \ No newline at end of file diff --git a/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net new file mode 100644 index 0000000000..4d1ebb9560 --- /dev/null +++ b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net @@ -0,0 +1,90 @@ +# vim: set ft=sh: +run_hook() { + local line i net_mac bootif_mac bootif_dev defaultrootpath defaultserver + # These variables will be parsed from /tmp/net-*.conf generated by ipconfig + local DEVICE + local IPV4ADDR IPV4BROADCAST IPV4NETMASK IPV4GATEWAY IPV4DNS0 IPV4DNS1 + local HOSTNAME DNSDOMAIN NISDOMAIN ROOTSERVER ROOTPATH + local filename + # /tmp/net-*.conf + + if [ -z "${ip}" -a -n "${nfsaddrs}" ]; then + ip="${nfsaddrs}" + fi + + if [ -n "${ip}" ]; then + if [ -n "${BOOTIF}" ]; then + bootif_mac=${BOOTIF#01-} + bootif_mac=${bootif_mac//-/:} + for i in /sys/class/net/*/address; do + read net_mac < ${i} + if [ "${bootif_mac}" == "${net_mac}" ]; then + bootif_dev=${i#/sys/class/net/} + bootif_dev=${bootif_dev%/address} + break + fi + done + ip="${ip}::${bootif_dev}" + fi + + # setup network and save some values + ipconfig "ip=${ip}" + + for conf in /tmp/net-*.conf; do + [ -f "$conf" ] && . "$conf" + done + + # calculate nfs_server, nfs_path and nfs_option for later nfs mount + if [ "${root}" = "/dev/nfs" -o "${nfsroot}" != "" ]; then + # parse ROOTPATH if defined by dhcp server + if [ -n "${ROOTPATH}" ]; then + line="${ROOTPATH}" + nfs_server="${line%%:*}" + [ "${nfs_server}" = "${line}" ] && nfs_server="${ROOTSERVER}" + defaultserver="${nfs_server}" + line="${line#*:}" + nfs_path="${line}" + defaultrootpath="${nfs_path}" + else + # define a default ROOTPATH + if [ "${ROOTPATH}" = "" ]; then + defaultrootpath="/tftpboot/${IPV4ADDR}" + fi + fi + + # parse nfsroot if present (overrides ROOTPATH) + if [ -n "${nfsroot}" ]; then + line="${nfsroot}" + nfs_server="${line%%:*}" + [ -z "${nfs_server}" ] && nfs_server="${defaultserver}" + line="${line#*:}" + nfs_path="${line%%,*}" + line="${line#"${nfs_path}"}" + [ -z "${nfs_path}" ] && nfs_path="${defaultrootpath}" + nfs_option="${line#","}" + fi + + # ensure root and filesystem type are set proper for nfs boot + root="/dev/nfs" + rootfstype="nfs" + + echo "NFS-Mount: ${nfs_server}:${nfs_path}" + + # set mount handler for NFS + mount_handler="nfs_mount_handler" + fi + fi +} + +nfs_mount_handler() { + if [ -z "$nfs_server" -o -z "$nfs_path" ]; then + err "Unable to mount root filesystem over NFS: wrong parameters." + echo "You are being dropped to a recovery shell" + echo " Type 'exit' to try and continue booting" + launch_interactive_shell + msg "Trying to continue (this will most likely fail) ..." + fi + nfsmount ${nfs_option:+-o ${nfs_option}} "${nfs_server}:${nfs_path}" "$1" +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net new file mode 100644 index 0000000000..79b678949c --- /dev/null +++ b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net @@ -0,0 +1,108 @@ +#!/bin/bash + +build() { + add_checked_modules '/drivers/net/' + add_module nfsv3? + + add_binary "/usr/lib/initcpio/ipconfig" "/bin/ipconfig" + add_binary "/usr/lib/initcpio/nfsmount" "/bin/nfsmount" + + add_runscript +} + +help() { + cat <:::::: +nfsaddrs= is an alias to ip= and can be used too. + + IP address of the client. If empty, the address will + either be determined by RARP/BOOTP/DHCP. What protocol + is used de- pends on the parameter. If this + parameter is not empty, autoconf will be used. + + IP address of the NFS server. If RARP is used to + determine the client address and this parameter is NOT + empty only replies from the specified server are + accepted. To use different RARP and NFS server, + specify your RARP server here (or leave it blank), and + specify your NFS server in the 'nfsroot' parameter + (see above). If this entry is blank the address of the + server is used which answered the RARP/BOOTP/DHCP + request. + + IP address of a gateway if the server is on a different + subnet. If this entry is empty no gateway is used and the + server is assumed to be on the local network, unless a + value has been received by BOOTP/DHCP. + + Netmask for local network interface. If this is empty, + the netmask is derived from the client IP address assuming + classful addressing, unless overridden in BOOTP/DHCP reply. + + Name of the client. If empty, the client IP address is + used in ASCII notation, or the value received by + BOOTP/DHCP. + + Name of network device to use. If this is empty, all + devices are used for RARP/BOOTP/DHCP requests, and the + first one we receive a reply on is configured. If you + have only one device, you can safely leave this blank. + + Method to use for autoconfiguration. If this is either + 'rarp', 'bootp', or 'dhcp' the specified protocol is + used. If the value is 'both', 'all' or empty, all + protocols are used. 'off', 'static' or 'none' means + no autoconfiguration. +Examples: +ip=127.0.0.1:::::lo:none --> Enable the loopback interface. +ip=192.168.1.1:::::eth2:none --> Enable static eth2 interface. +ip=:::::eth0:dhcp --> Enable dhcp protcol for eth0 configuration. + +nfsroot=[:][,] + +If the 'nfsroot' parameter is NOT given on the command line, the default +"/tftpboot/%s" will be used. + + Specifies the IP address of the NFS server. If this field + is not given, the default address as determined by the + 'ip' variable (see below) is used. One use of this + parameter is for example to allow using different servers + for RARP and NFS. Usually you can leave this blank. + + Name of the directory on the server to mount as root. If + there is a "%s" token in the string, the token will be + replaced by the ASCII-representation of the client's IP + address. + + Standard NFS options. All options are separated by commas. + If the options field is not given, the following defaults + will be used: + port = as given by server portmap daemon + rsize = 1024 + wsize = 1024 + timeo = 7 + retrans = 3 + acregmin = 3 + acregmax = 60 + acdirmin = 30 + acdirmax = 60 + flags = hard, nointr, noposix, cto, ac + +root=/dev/nfs + +If you don't use nfsroot= parameter you need to set root=/dev/nfs +to boot from a nfs root by autoconfiguration. +HELPEOF +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/srcpkgs/mkinitcpio-nfs-utils/patches/musl.patch b/srcpkgs/mkinitcpio-nfs-utils/patches/musl.patch new file mode 100644 index 0000000000..fa822cb052 --- /dev/null +++ b/srcpkgs/mkinitcpio-nfs-utils/patches/musl.patch @@ -0,0 +1,83 @@ +From 9e6dd28c7b2d9649cc3fc3ea9effadcb29d233c5 Mon Sep 17 00:00:00 2001 +From: Andrea Brancaleoni +Date: Thu, 25 Jun 2015 18:01:23 +0200 +Subject: [PATCH] musl + +--- + ipconfig/packet.c | 27 +++++++++++++-------------- + 1 file changed, 13 insertions(+), 14 deletions(-) + +diff --git a/ipconfig/packet.c b/ipconfig/packet.c +index 446073a..afedf9d 100644 +--- a/ipconfig/packet.c ++++ b/ipconfig/packet.c +@@ -7,10 +7,9 @@ + #include + #include + #include +-#include ++#include + #include + #include +-#include + #include + #include + #include +@@ -92,10 +91,10 @@ static struct header ipudp_hdrs = { + .daddr = INADDR_BROADCAST, + }, + .udp = { +- .source = __constant_htons(LOCAL_PORT), +- .dest = __constant_htons(REMOTE_PORT), +- .len = 0, +- .check = 0, ++ .uh_sport = __constant_htons(LOCAL_PORT), ++ .uh_dport = __constant_htons(REMOTE_PORT), ++ .uh_ulen = 0, ++ .uh_sum = 0, + }, + }; + +@@ -127,8 +126,8 @@ int packet_send(struct netdev *dev, struct iovec *iov, int iov_len) + msg.msg_flags = 0; + + if (cfg_local_port != LOCAL_PORT) { +- ipudp_hdrs.udp.source = htons(cfg_local_port); +- ipudp_hdrs.udp.dest = htons(cfg_remote_port); ++ ipudp_hdrs.udp.uh_sport = htons(cfg_local_port); ++ ipudp_hdrs.udp.uh_dport = htons(cfg_remote_port); + } + + dprintf("\n udp src %d dst %d", ntohs(ipudp_hdrs.udp.source), +@@ -159,7 +158,7 @@ int packet_send(struct netdev *dev, struct iovec *iov, int iov_len) + ipudp_hdrs.ip.check = ip_checksum((uint16_t *) &ipudp_hdrs.ip, + ipudp_hdrs.ip.ihl); + +- ipudp_hdrs.udp.len = htons(len - sizeof(struct iphdr)); ++ ipudp_hdrs.udp.uh_ulen = htons(len - sizeof(struct iphdr)); + + dprintf("\n bytes %d\n", len); + +@@ -243,14 +242,14 @@ int packet_recv(struct netdev *dev, struct iovec *iov, int iov_len) + + ret -= 4 * ip->ihl; + +- dprintf("\n udp src %d dst %d ", ntohs(udp->source), +- ntohs(udp->dest)); ++ dprintf("\n udp src %d dst %d ", ntohs(udp->uh_sport), ++ ntohs(udp->uh_dport)); + +- if (udp->source != htons(cfg_remote_port) || +- udp->dest != htons(cfg_local_port)) ++ if (udp->uh_sport != htons(cfg_remote_port) || ++ udp->uh_dport != htons(cfg_local_port)) + goto free_pkt; + +- if (ntohs(udp->len) > ret) ++ if (ntohs(udp->uh_ulen) > ret) + goto free_pkt; + + ret -= sizeof(struct udphdr); +-- +2.4.4 + diff --git a/srcpkgs/mkinitcpio-nfs-utils/patches/nfsmount-fix-wrong-umount-path.patch b/srcpkgs/mkinitcpio-nfs-utils/patches/nfsmount-fix-wrong-umount-path.patch new file mode 100644 index 0000000000..0f62fea823 --- /dev/null +++ b/srcpkgs/mkinitcpio-nfs-utils/patches/nfsmount-fix-wrong-umount-path.patch @@ -0,0 +1,14 @@ +--- a/nfsmount/mount.c 2012-11-10 20:16:31.894540497 -0500 ++++ b/nfsmount/mount.c 2012-11-10 20:16:39.957369011 -0500 +@@ -358,9 +358,9 @@ + bail: + if (mounted) { + if (data->flags & NFS_MOUNT_VER3) { +- umount_v3(path, clnt); ++ umount_v3(rem_path, clnt); + } else { +- umount_v2(path, clnt); ++ umount_v2(rem_path, clnt); + } + } + diff --git a/srcpkgs/mkinitcpio-nfs-utils/template b/srcpkgs/mkinitcpio-nfs-utils/template new file mode 100644 index 0000000000..68c55ff227 --- /dev/null +++ b/srcpkgs/mkinitcpio-nfs-utils/template @@ -0,0 +1,35 @@ +# Template file for 'mkinitcpio-nfs-utils' +pkgname=mkinitcpio-nfs-utils +version=0.3 +revision=1 +build_style=gnu-makefile +short_desc="Ipconfig and nfsmount tools for NFS root support in mkinitcpio" +maintainer="Andrea Brancaleoni " +license="GPL-2" +homepage="http://www.archlinux.org/" +depends="mkinitcpio" +distfiles="https://sources.archlinux.org/other/mkinitcpio/$pkgname-$version.tar.xz" +checksum=d290d489844fae100ca7b848b8eef40078124ff373203086bacc07329d1e8939 + +case "$XBPS_TARGET_MACHINE" in +*-musl) + CFLAGS="-DSYS_NMLN=65" + # http://osxr.org/glibc/source/sysdeps/unix/sysv/linux/bits/utsname.h?v=glibc-2.15; fixes musl not having set this variable + ;; +esac + +patch_args="-Np1" + +pre_configure() { + case "$XBPS_TARGET_MACHINE" in + *-musl) + sed -i 's|PROGRAMS = ipconfig nfsmount|PROGRAMS = ipconfig|g' Makefile + # No RPC in musl for now + ;; + esac +} + +post_install() { + vinstall ${FILESDIR}/initcpio-install-net 644 usr/lib/initcpio/install net + vinstall ${FILESDIR}/initcpio-hook-net 644 usr/lib/initcpio/hooks net +} diff --git a/srcpkgs/mkinitcpio-udev b/srcpkgs/mkinitcpio-udev new file mode 120000 index 0000000000..dd6b17ac57 --- /dev/null +++ b/srcpkgs/mkinitcpio-udev @@ -0,0 +1 @@ +mkinitcpio \ No newline at end of file diff --git a/srcpkgs/mkinitcpio/files/11-dm-initramfs.rules b/srcpkgs/mkinitcpio/files/11-dm-initramfs.rules new file mode 100644 index 0000000000..d2c1673245 --- /dev/null +++ b/srcpkgs/mkinitcpio/files/11-dm-initramfs.rules @@ -0,0 +1,3 @@ +# needed with new udev/mkinitcpio and as implemented in dracut: +# +SUBSYSTEM=="block", KERNEL=="dm-[0-9]*", ACTION=="add|change", OPTIONS="db_persist" diff --git a/srcpkgs/mkinitcpio/files/69-dm-lvm-metad.rules b/srcpkgs/mkinitcpio/files/69-dm-lvm-metad.rules new file mode 100644 index 0000000000..c032108b46 --- /dev/null +++ b/srcpkgs/mkinitcpio/files/69-dm-lvm-metad.rules @@ -0,0 +1,93 @@ +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# This file is part of LVM2. + +# Udev rules for LVM. +# +# Scan all block devices having a PV label for LVM metadata. +# Store this information in LVMetaD (the LVM metadata daemon) and maintain LVM +# metadata state for improved performance by avoiding further scans while +# running subsequent LVM commands or while using lvm2app library. +# Also, notify LVMetaD about any relevant block device removal. +# +# This rule is essential for having the information in LVMetaD up-to-date. +# It also requires blkid to be called on block devices before so only devices +# used as LVM PVs are processed (ID_FS_TYPE="LVM2_member" or "LVM1_member"). + +SUBSYSTEM!="block", GOTO="lvm_end" + + +ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="lvm_end" + +# If the PV label got lost, inform lvmetad immediately. +# Detect the lost PV label by comparing previous ID_FS_TYPE value with current one. +ENV{.ID_FS_TYPE_NEW}="$env{ID_FS_TYPE}" +IMPORT{db}="ID_FS_TYPE" +ENV{ID_FS_TYPE}=="LVM2_member|LVM1_member", ENV{.ID_FS_TYPE_NEW}!="LVM2_member|LVM1_member", ENV{LVM_PV_GONE}="1" +ENV{ID_FS_TYPE}="$env{.ID_FS_TYPE_NEW}" +ENV{LVM_PV_GONE}=="1", GOTO="lvm_scan" + +# Only process devices already marked as a PV - this requires blkid to be called before. +ENV{ID_FS_TYPE}!="LVM2_member|LVM1_member", GOTO="lvm_end" +ENV{DM_MULTIPATH_DEVICE_PATH}=="1", GOTO="lvm_end" + +# Inform lvmetad about any PV that is gone. +ACTION=="remove", GOTO="lvm_scan" + +# Create /dev/disk/by-id/lvm-pv-uuid- symlink for each PV +ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-id/lvm-pv-uuid-$env{ID_FS_UUID_ENC}" + +# If the PV is a special device listed below, scan only if the device is +# properly activated. These devices are not usable after an ADD event, +# but they require an extra setup and they are ready after a CHANGE event. +# Also support coldplugging with ADD event but only if the device is already +# properly activated. +# This logic should be eventually moved to rules where those particular +# devices are processed primarily (MD and loop). + +# DM device: +KERNEL!="dm-[0-9]*", GOTO="next" +ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", ENV{DM_ACTIVATION}=="1", GOTO="lvm_scan" +GOTO="lvm_end" + +# MD device: +LABEL="next" +KERNEL!="md[0-9]*", GOTO="next" +IMPORT{db}="LVM_MD_PV_ACTIVATED" +ACTION=="add", ENV{LVM_MD_PV_ACTIVATED}=="1", GOTO="lvm_scan" +ACTION=="change", ENV{LVM_MD_PV_ACTIVATED}!="1", TEST=="md/array_state", ENV{LVM_MD_PV_ACTIVATED}="1", GOTO="lvm_scan" +ACTION=="add", KERNEL=="md[0-9]*p[0-9]*", GOTO="lvm_scan" +ENV{LVM_MD_PV_ACTIVATED}!="1", ENV{SYSTEMD_READY}="0" +GOTO="lvm_end" + +# Loop device: +LABEL="next" +KERNEL!="loop[0-9]*", GOTO="next" +ACTION=="add", ENV{LVM_LOOP_PV_ACTIVATED}=="1", GOTO="lvm_scan" +ACTION=="change", ENV{LVM_LOOP_PV_ACTIVATED}!="1", TEST=="loop/backing_file", ENV{LVM_LOOP_PV_ACTIVATED}="1", GOTO="lvm_scan" +ENV{LVM_LOOP_PV_ACTIVATED}!="1", ENV{SYSTEMD_READY}="0" +GOTO="lvm_end" + +# If the PV is not a special device listed above, scan only after device addition (ADD event) +LABEL="next" +ACTION!="add", GOTO="lvm_end" + +LABEL="lvm_scan" + +# The table below summarises the situations in which we reach the LABEL="lvm_scan". +# Marked by X, X* means only if the special dev is properly set up. +# The artificial ADD is supported for coldplugging. We avoid running the pvscan +# on artificial CHANGE so there's no unexpected autoactivation when WATCH rule fires. +# N.B. MD and loop never actually reaches lvm_scan on REMOVE as the PV label is gone +# within a CHANGE event (these are caught by the "LVM_PV_GONE" rule at the beginning). +# +# | real ADD | real CHANGE | artificial ADD | artificial CHANGE | REMOVE +# ============================================================================= +# DM | | X | X* | | X +# MD | | X | X* | | +# loop | | X | X* | | +# other | X | | X | | X +ENV{SYSTEMD_READY}="1" +RUN+="/usr/bin/lvm pvscan --background --cache --activate ay --major $major --minor $minor", ENV{LVM_SCANNED}="1" + +LABEL="lvm_end" diff --git a/srcpkgs/mkinitcpio/files/encrypt_hook b/srcpkgs/mkinitcpio/files/encrypt_hook new file mode 100644 index 0000000000..819c4cf60f --- /dev/null +++ b/srcpkgs/mkinitcpio/files/encrypt_hook @@ -0,0 +1,139 @@ +#!/usr/bin/ash + +run_hook() { + modprobe -a -q dm-crypt >/dev/null 2>&1 + [ "${quiet}" = "y" ] && CSQUIET=">/dev/null" + + # Get keyfile if specified + ckeyfile="/crypto_keyfile.bin" + if [ -n "$cryptkey" ]; then + IFS=: read ckdev ckarg1 ckarg2 </dev/null 2>&1 + umount /ckey + ;; + *) + # Read raw data from the block device + # ckarg1 is numeric: ckarg1=offset, ckarg2=length + dd if="$resolved" of="$ckeyfile" bs=1 skip="$ckarg1" count="$ckarg2" >/dev/null 2>&1 + ;; + esac + fi + [ ! -f ${ckeyfile} ] && echo "Keyfile could not be opened. Reverting to passphrase." + fi + + if [ -n "${cryptdevice}" ]; then + DEPRECATED_CRYPT=0 + IFS=: read cryptdev cryptname cryptoptions <&2 + ;; + esac + done + + if resolved=$(resolve_device "${cryptdev}" ${rootdelay}); then + if cryptsetup isLuks ${resolved} >/dev/null 2>&1; then + [ ${DEPRECATED_CRYPT} -eq 1 ] && warn_deprecated + dopassphrase=1 + # If keyfile exists, try to use that + if [ -f ${ckeyfile} ]; then + if eval cryptsetup --key-file ${ckeyfile} open --type luks ${resolved} ${cryptname} ${cryptargs} ${CSQUIET}; then + dopassphrase=0 + else + echo "Invalid keyfile. Reverting to passphrase." + fi + fi + # Ask for a passphrase + if [ ${dopassphrase} -gt 0 ]; then + echo "" + echo "A password is required to access the ${cryptname} volume:" + + #loop until we get a real password + while ! eval cryptsetup open --type luks ${resolved} ${cryptname} ${cryptargs} ${CSQUIET}; do + sleep 2; + done + fi + if [ -e "/dev/mapper/${cryptname}" ]; then + if [ ${DEPRECATED_CRYPT} -eq 1 ]; then + export root="/dev/mapper/root" + fi + else + err "Password succeeded, but ${cryptname} creation failed, aborting..." + exit 1 + fi + elif [ -n "${crypto}" ]; then + [ ${DEPRECATED_CRYPT} -eq 1 ] && warn_deprecated + msg "Non-LUKS encrypted device found..." + if echo "$crypto" | awk -F: '{ exit(NF == 5) }'; then + err "Verify parameter format: crypto=hash:cipher:keysize:offset:skip" + err "Non-LUKS decryption not attempted..." + return 1 + fi + exe="cryptsetup open --type plain $resolved $cryptname $cryptargs" + IFS=: read c_hash c_cipher c_keysize c_offset c_skip <. + # Replace this subsection name with a custom tag name. + # Multiple subsections like this can be created. + # The '@' prefix for tags is optional. + # This subsection can contain host_list, which is a + # list of machine names. If the name of the local + # machine is found in host_list, then the name of + # this subsection is used as a tag and is applied + # to the local machine as a 'host tag'. + # If this subsection is empty (has no host_list), then + # the subsection name is always applied as a 'host tag'. + # Example: + # The host tag foo is given to all hosts, and the host tag + # bar is given to the hosts named machine1 and machine2. + # tags { foo { } bar { host_list = [ "machine1", "machine2" ] } } + # This configuration section has variable name. + # This configuration section does not have a default value defined. + # tag { + + # Configuration option tags//host_list. + # A list of machine names. + # These machine names are compared to the nodename + # returned by uname(2). If the local machine name + # matches an entry in this list, the name of the + # subsection is applied to the machine as a 'host tag'. + # This configuration option does not have a default value defined. + # host_list = "" + # } +# } diff --git a/srcpkgs/mkinitcpio/files/lvm2_hook b/srcpkgs/mkinitcpio/files/lvm2_hook new file mode 100644 index 0000000000..65de7bd2fd --- /dev/null +++ b/srcpkgs/mkinitcpio/files/lvm2_hook @@ -0,0 +1,12 @@ +#!/usr/bin/ash + +run_earlyhook() { + mkdir /run/lvm + lvmetad +} + +run_cleanuphook() { + kill $(cat /run/lvmetad.pid) +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/srcpkgs/mkinitcpio/files/lvm2_install b/srcpkgs/mkinitcpio/files/lvm2_install new file mode 100644 index 0000000000..49430074fb --- /dev/null +++ b/srcpkgs/mkinitcpio/files/lvm2_install @@ -0,0 +1,34 @@ +#!/usr/bin/bash + +build() { + local mod + for mod in dm-mod dm-snapshot dm-mirror dm-cache dm-cache-mq; do + add_module "$mod" + done + + add_binary "/usr/bin/lvm" + add_binary "/usr/bin/lvmetad" + add_binary "/usr/bin/dmsetup" + add_binary "/usr/bin/cache_check" + add_binary "/usr/bin/cache_dump" + add_binary "/usr/bin/cache_metadata_size" + add_binary "/usr/bin/cache_repair" + add_binary "/usr/bin/cache_restore" + add_file "/usr/lib/udev/rules.d/10-dm.rules" + add_file "/usr/lib/udev/rules.d/13-dm-disk.rules" + add_file "/usr/lib/udev/rules.d/95-dm-notify.rules" + add_file "/usr/lib/udev/rules.d/11-dm-lvm.rules" + add_file "/usr/lib/initcpio/udev/69-dm-lvm-metad.rules" "/usr/lib/udev/rules.d/69-dm-lvm-metad.rules" + add_file "/usr/lib/initcpio/udev/11-dm-initramfs.rules" "/usr/lib/udev/rules.d/11-dm-initramfs.rules" + add_file "/usr/lib/initcpio/conf/lvm.conf" "/etc/lvm/lvm.conf" + + add_runscript +} + +help() { + cat </dev/null + + if [ -n "$md" ]; then + echo 'DEVICE partitions' >"$mdconfig" + for i in $(cat /proc/cmdline); do + case $i in + # raid + md=[0-9]*,/*) + device=${i%%,*} + device=${device/=/} + array=${i#*,} + echo "ARRAY /dev/$device devices=$array" + ;; + # partitionable raid + md=d[0-9]*,/*) + device=${i%%,*} + device=${device/=/_} + array=${i#*,} + echo "ARRAY /dev/$device devices=$array" + ;; + # raid UUID + md=[0-9]*,[0-9,a-fA-F]*) + device=${i%%,*} + device=${device/=/} + array=${i#*,} + echo "ARRAY /dev/$device UUID=$array" + ;; + # partitionable raid UUID + md=d[0-9]*,[0-9,a-fA-F]*) + device=${i%%,*} + device=${device/=/_} + array=${i#*,} + echo "ARRAY /dev/$device UUID=$array" + ;; + esac + done >>"$mdconfig" + fi + + # assemble everything + [ -s "$mdconfig" ] && /usr/bin/mdassemble +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/srcpkgs/mkinitcpio/files/mdadm_install b/srcpkgs/mkinitcpio/files/mdadm_install new file mode 100644 index 0000000000..7390509fab --- /dev/null +++ b/srcpkgs/mkinitcpio/files/mdadm_install @@ -0,0 +1,46 @@ +#!/bin/bash + +build() { + add_checked_modules -f 'dm-' 'drivers/md/*' + + # check if a custom mdadm.conf exists + if grep -q ^ARRAY /etc/mdadm.conf; then + echo "Custom /etc/mdadm.conf file will be used in initramfs for assembling arrays." + add_file "/etc/mdadm.conf" + fi + add_binary "/usr/bin/mdassemble" + add_file "/usr/lib/udev/rules.d/63-md-raid-arrays.rules" + + add_runscript +} + +help() { + cat <,dev0,dev1,...,devn + md=,uuid +- for partitionable raid arrays with persistent superblocks: + md=d,dev0,dev1,...,devn + md=d,uuid + +Parameters: +- = the number of the md device: + 0 means md0, 1 means md1, ... +- : e.g. /dev/hda1,/dev/hdc1,/dev/sda1,/dev/sdb1 + or 0900878d:f95f6057:c39a36e9:55efa60a +Examples: +- md=d0,/dev/sda3,/dev/sda4 md=d1,/dev/hda1,/dev/hdb1 + This will setup 2 md partitionable arrays. +- md=0,/dev/sda3,/dev/sda4 md=1,/dev/hda1,/dev/hdb1 + This will setup 2 md arrays with persistent superblocks. +HELPEOF +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/srcpkgs/mkinitcpio/files/mdadm_udev_install b/srcpkgs/mkinitcpio/files/mdadm_udev_install new file mode 100644 index 0000000000..c01cbaf249 --- /dev/null +++ b/srcpkgs/mkinitcpio/files/mdadm_udev_install @@ -0,0 +1,25 @@ +#!/bin/bash + +build() { + add_checked_modules -f 'dm-' 'drivers/md/*' + + # check if a custom mdadm.conf exists + if grep -qw ^ARRAY "$BASEDIR/etc/mdadm.conf"; then + echo "Custom /etc/mdadm.conf file will be used in initramfs for assembling arrays." + add_file "/etc/mdadm.conf" + fi + + add_binary "/usr/bin/mdadm" + add_file "/usr/lib/udev/rules.d/63-md-raid-arrays.rules" + add_file "/usr/lib/udev/rules.d/64-md-raid-assembly.rules" +} + +help() { + cat < +Date: Mon, 4 Aug 2014 08:31:37 -0400 +Subject: [mkinitcpio] [PATCH] avoid compound conditional leading to spurious + "errors" + +As seen: + +https://bbs.archlinux.org/viewtopic.php?id=185204 +https://bbs.archlinux.org/viewtopic.php?id=185265 +--- + functions | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/functions b/functions +index 20bbffe..362d07b 100644 +--- a/functions ++++ b/functions +@@ -423,11 +423,15 @@ add_full_dir() { + + for f in "$1"/*; do + if [[ -L $f ]]; then +- [[ $f = $filter ]] && add_symlink "$f" "$(readlink "$f")" ++ if [[ $f = $filter ]]; then ++ add_symlink "$f" "$(readlink "$f")" ++ fi + elif [[ -d $f ]]; then + add_full_dir "$f" + elif [[ -f $f ]]; then +- [[ $f = $filter ]] && add_file "$f" ++ if [[ $f = $filter ]]; then ++ add_file "$f" ++ fi + fi + done + fi +-- +2.1.0 + diff --git a/srcpkgs/mkinitcpio/patches/default-to-runit-init.patch b/srcpkgs/mkinitcpio/patches/default-to-runit-init.patch new file mode 100644 index 0000000000..a1a89d03a2 --- /dev/null +++ b/srcpkgs/mkinitcpio/patches/default-to-runit-init.patch @@ -0,0 +1,25 @@ +From 6a100b4a4a709f177f383988079a2a3c3ada08b8 Mon Sep 17 00:00:00 2001 +From: Andrea Brancaleoni +Date: Thu, 25 Jun 2015 01:59:58 +0200 +Subject: [PATCH] default to runit-init + +--- + init | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/init b/init +index 4891ed8..7534d23 100644 +--- a/init ++++ b/init +@@ -2,7 +2,7 @@ + + udevd_running=0 + mount_handler=default_mount_handler +-init=/sbin/init ++init=/usr/bin/runit-init + rd_logmask=0 + + . /init_functions +-- +2.4.4 + diff --git a/srcpkgs/mkinitcpio/template b/srcpkgs/mkinitcpio/template new file mode 100644 index 0000000000..f82a6c08aa --- /dev/null +++ b/srcpkgs/mkinitcpio/template @@ -0,0 +1,67 @@ +# Template file for 'mkinitcpio' +pkgname=mkinitcpio +version=18 +revision=1 +noarch=yes +build_style=gnu-makefile +depends="busybox-static bsdcpio" +short_desc="Next generation of initramfs creation" +maintainer="Andrea Brancaleoni " +license="GPL-2" +homepage="https://wiki.archlinux.org/index.php/Mkinitcpio" +distfiles="https://sources.archlinux.org/other/$pkgname/$pkgname-$version.tar.gz" +checksum=187bdeeade08996010fbff480ccc91e47722d275c22fd6feb4a4b63061e9fc22 + +conf_files="/etc/mkinitcpio.conf" + +patch_args="-Np1" + +post_install() { + ln -s /usr/bin/busybox.static $DESTDIR/usr/lib/initcpio/busybox + + vinstall ${FILESDIR}/kernel-hook-postinst 755 etc/kernel.d/post-install 20-mkinitcpio + vinstall ${FILESDIR}/kernel-hook-postrm 755 etc/kernel.d/post-remove 20-mkinitcpio +} + +mkinitcpio-udev_package() { + depends="${sourcepkg}>=${version}_${revision} eudev" + short_desc+=" - udev support" + pkg_install() { + vinstall ${FILESDIR}/udev_hook 644 usr/lib/initcpio/hooks udev + vinstall ${FILESDIR}/udev_install 644 usr/lib/initcpio/install udev + } +} + +mkinitcpio-lvm2_package() { + depends="${sourcepkg}>=${version}_${revision} lvm2 thin-provisioning-tools" + short_desc+=" - lvm2 support" + conf_files="/usr/lib/initcpio/conf/lvm.conf" + pkg_install() { + vinstall ${FILESDIR}/lvm2_hook 644 usr/lib/initcpio/hooks lvm2 + vinstall ${FILESDIR}/lvm2_install 644 usr/lib/initcpio/install lvm2 + for RULES in ${FILESDIR}/*.rules; do + vinstall $RULES 644 usr/lib/initcpio/udev $(basename $RULES) + done + vinstall ${FILESDIR}/lvm.conf 644 usr/lib/initcpio/conf + } +} + +mkinitcpio-encrypt_package() { + depends="${sourcepkg}>=${version}_${revision} + ${sourcepkg}-lvm2>=${version}_${revision} cryptsetup" + short_desc+=" - encrypt support" + pkg_install() { + vinstall ${FILESDIR}/encrypt_hook 644 usr/lib/initcpio/hooks encrypt + vinstall ${FILESDIR}/encrypt_install 644 usr/lib/initcpio/install encrypt + } +} + +mkinitcpio-mdadm_package() { + depends="${sourcepkg}>=${version}_${revision} mdadm" + short_desc+=" - mdadm support" + pkg_install() { + vinstall ${FILESDIR}/mdadm_hook 644 usr/lib/initcpio/hooks mdadm + vinstall ${FILESDIR}/mdadm_install 644 usr/lib/initcpio/install mdadm + vinstall ${FILESDIR}/mdadm_udev_install 644 usr/lib/initcpio/install mdadm_udev + } +}