From patchwork Sun Mar 4 17:06:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 881195 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=free.fr Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EfLzzjdb"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zvTw90F0lz9sXL for ; Mon, 5 Mar 2018 04:06:32 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id DBBB3887E2; Sun, 4 Mar 2018 17:06:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZcVGq9XTCepS; Sun, 4 Mar 2018 17:06:26 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id B044688894; Sun, 4 Mar 2018 17:06:25 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id DC79A1C2797 for ; Sun, 4 Mar 2018 17:06:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id D946C87F0D for ; Sun, 4 Mar 2018 17:06:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rUx2ACRga5bW for ; Sun, 4 Mar 2018 17:06:23 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by hemlock.osuosl.org (Postfix) with ESMTPS id E7FCC87DFE for ; Sun, 4 Mar 2018 17:06:22 +0000 (UTC) Received: by mail-wr0-f195.google.com with SMTP id f14so14864508wre.8 for ; Sun, 04 Mar 2018 09:06:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q34VfcH0d7azjZOhkjWB/Da5pgMttdc8ev8W8YdnmE8=; b=EfLzzjdbbHK0zMFWhVuLEYB6vaTAJmKSPKlEfuRQ+ygQ84YIFnkpr3Ua1bx1cRym+n Ab8cPx7kpT8nsZaDRKy/8K7aitqBOwv9Dmwj8j1TnF/XZ38nSqdwBkK1njcPB4yDJVk3 qaV8Awi171btboM54LEEpQodUNPWJaRnyuD0VVJmvNThfvkfP4pWfrL21YM1BmQqpBrW QM2+B6wxcth7tuEq54va3+vdGwPmK1dlE+dWLu3KjIlvKRradXKDVdQ7P2f5jYlFerLO CZJQfSfJGdtFZcVzEs+0MKewY9vm57ypCE6WJpFri4oGBnrsWezfnqoMoyGK5srLR9n7 623g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Q34VfcH0d7azjZOhkjWB/Da5pgMttdc8ev8W8YdnmE8=; b=pk7ze873prhjgrZtPM2WXg+crKV/zH5wPjX9thE4NRq3HCr/PQJ2FBLkfSbKKQEZV+ EGo2SQVCqWuBvTv8vm1w9oAuoMgpEmuVu9kAj7ExkuzPKqfz4higxVDB2OuMLWa5cww5 V2H17NiHNVIi8mWZ7QBPeADcHFuiJpdnVkCI1GOfm/jBaFC23xLk4ro8RK00VJ6Lnr1P ShN99MIeWdA0vRofgjaAEB7x9HL8yRRN/i2LLujL4tNBnC7xRCmoHyVElSSvX7eYkerZ VTM7IU4d45cI43OsgeGWfjJnNfY4rkZ5I1ieA+EC9sHVeUyiL53P9rXppjGltS+D2dgl 4nGA== X-Gm-Message-State: APf1xPAsUnp7L0ZjWNs+qlFAjlvmkmALoX773csDCw3vuG2U75Zo0wgn ig7VYVk2o72HBo7qezYcf9tl1g== X-Google-Smtp-Source: AG47ELvEwiRwQ2E9/qWPjKoliBigUOG6geGBmZaNrS2+uuTTEaW+LGID08DxZsDQIajGs0NOsgKwUg== X-Received: by 10.223.163.136 with SMTP id l8mr11082919wrb.270.1520183181263; Sun, 04 Mar 2018 09:06:21 -0800 (PST) Received: from scaer.bzh.lan (2a01cb088610730051248d9ab6022d60.ipv6.abo.wanadoo.fr. [2a01:cb08:8610:7300:5124:8d9a:b602:2d60]) by smtp.gmail.com with ESMTPSA id 41sm9390071wrc.33.2018.03.04.09.06.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Mar 2018 09:06:20 -0800 (PST) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Sun, 4 Mar 2018 18:06:16 +0100 Message-Id: X-Mailer: git-send-email 2.14.1 In-Reply-To: References: Subject: [Buildroot] [PATCH 2/3] package/skeleton-systemd: invert factory logic X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni , Romain Naour , Maxime Hadjinlian , "Yann E. MORIN" , Adam Duskett , Trent Piepho MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Currently, we handle the factory by redirectoring /var with a symlink at build time, and with some trickery during the filesystem generation, depending on whether we need to remount the filesystem read-write or not. However, this is causing wquite some pain with latest systemd, now that they have moved their dbus socket to /run instead of /var/run. As such, trying to play tricks with /var/run as a symlink is difficult, because at times it is in .usr/share/factory/var/run (during build) and then it is in /var/run (at runtime). So a relative symlink is not possible. But an absolute symlink is not possible either, because we are installing out-pf-tree. Oh the joys of cross-compilation... :-) We fix all this mess by making /var a real directory from the onset, so that we can use the runtime-expected layout even during the build. Then, during filesystem generation, we move /var away to the factory, and populate it as we used to do. This still requires a post-fs hook to restore /var after the filesystem generation. This leaves a situation that, should the filesystem generation fails, /var will be left in an inconsistent state. But that is not worse than what we already had anyway. Signed-off-by: "Yann E. MORIN" Cc: Maxime Hadjinlian Cc: Trent Piepho Cc: Adam Duskett Cc: Romain Naour Cc: Thomas Petazzoni Cc: Peter Korsgaard --- Note: even with this, we can't move the /var directory back to the common skeleton, becasue the sysv skeleton has a slew of symlinks back to /tmp anyway. So /var has to stay a per-skeleton directory. Pfeew... --- package/skeleton-init-systemd/skeleton-init-systemd.mk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package/skeleton-init-systemd/skeleton-init-systemd.mk b/package/skeleton-init-systemd/skeleton-init-systemd.mk index 6a0527fde2..ff64205cbe 100644 --- a/package/skeleton-init-systemd/skeleton-init-systemd.mk +++ b/package/skeleton-init-systemd/skeleton-init-systemd.mk @@ -19,7 +19,6 @@ ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y) define SKELETON_INIT_SYSTEMD_ROOT_RO_OR_RW echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab - mkdir -p $(TARGET_DIR)/var endef else @@ -31,15 +30,14 @@ else # back there by the tmpfiles.d mechanism. define SKELETON_INIT_SYSTEMD_ROOT_RO_OR_RW mkdir -p $(TARGET_DIR)/etc/systemd/tmpfiles.d - mkdir -p $(TARGET_DIR)/usr/share/factory/var - ln -s usr/share/factory/var $(TARGET_DIR)/var echo "/dev/root / auto ro 0 1" >$(TARGET_DIR)/etc/fstab echo "tmpfs /var tmpfs mode=1777 0 0" >>$(TARGET_DIR)/etc/fstab endef define SKELETON_INIT_SYSTEMD_PRE_ROOTFS_VAR - rm -f $(TARGET_DIR)/var - mkdir $(TARGET_DIR)/var + rm -rf $(TARGET_DIR)/usr/share/factory/var + mv $(TARGET_DIR)/var $(TARGET_DIR)/usr/share/factory/var + mkdir -p $(TARGET_DIR)/var for i in $(TARGET_DIR)/usr/share/factory/var/* \ $(TARGET_DIR)/usr/share/factory/var/lib/* \ $(TARGET_DIR)/usr/share/factory/var/lib/systemd/*; do \ @@ -59,7 +57,7 @@ SKELETON_INIT_SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SKELETON_INIT_SYSTEMD_PRE_ROOTFS_V define SKELETON_INIT_SYSTEMD_POST_ROOTFS_VAR rm -rf $(TARGET_DIR)/var - ln -s usr/share/factory/var $(TARGET_DIR)/var + mv $(TARGET_DIR)/usr/share/factory/var $(TARGET_DIR)/var endef SKELETON_INIT_SYSTEMD_ROOTFS_POST_CMD_HOOKS += SKELETON_INIT_SYSTEMD_POST_ROOTFS_VAR @@ -68,6 +66,8 @@ endif define SKELETON_INIT_SYSTEMD_INSTALL_TARGET_CMDS mkdir -p $(TARGET_DIR)/home mkdir -p $(TARGET_DIR)/srv + mkdir -p $(TARGET_DIR)/var + ln -s ../run $(TARGET_DIR)/var/run $(SKELETON_INIT_SYSTEMD_ROOT_RO_OR_RW) endef