From patchwork Sat Oct 18 14:47:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Hadjinlian X-Patchwork-Id: 400684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id 40FA9140095 for ; Sun, 19 Oct 2014 01:47:24 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 3EF29A1C49; Sat, 18 Oct 2014 14:47:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yDLzckqlJSLT; Sat, 18 Oct 2014 14:47:19 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 78133A1CFB; Sat, 18 Oct 2014 14:47:17 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 91F191BF9A7 for ; Sat, 18 Oct 2014 14:47:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8F2FAA1BB2 for ; Sat, 18 Oct 2014 14:47:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AydmdD8R27ES for ; Sat, 18 Oct 2014 14:47:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 89640A1B8B for ; Sat, 18 Oct 2014 14:47:12 +0000 (UTC) Received: by mail-wi0-f171.google.com with SMTP id em10so4052370wid.10 for ; Sat, 18 Oct 2014 07:47:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VzJgu1aJVLxOY+N8gPEaJWYlnwBl5EdQ+e7IDy4vP+o=; b=JnylP8exQ6SdR6CcoMIeyyc4YRssEvSnEaPHSfXoE+OWvwBTwoA8RzeSrDtuSRubri 1GTf/1JcJksx/7kcKQBdIqI1AUn6IiKP8ldM2MH2a+2aC5nUsljVopgEXFZTjQGsrONt ZHjOaRa2vbzuhWyecfrxbtrkzfQnI7p/bkzeEhwNr97EWyzjPKPlpg5SyktK6oiADY+l eiIRVJIHzWTWKEOGsoAQAysE98fVie+SkIqsUlYHySdbVGpA7xL9vRasWyJnuv3ebGM5 LbrSvf0xLda1LXC6FvFmotU6WlG/FrP6jGaqkzkjQAhVWcP47cwFa8toxDyZCNHLCY1m AjhA== X-Received: by 10.180.101.200 with SMTP id fi8mr6365160wib.77.1413643631125; Sat, 18 Oct 2014 07:47:11 -0700 (PDT) Received: from localhost.localdomain (13-105-190-109.dsl.ovh.fr. [109.190.105.13]) by mx.google.com with ESMTPSA id cw6sm5427861wjb.18.2014.10.18.07.47.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 18 Oct 2014 07:47:10 -0700 (PDT) From: Maxime Hadjinlian To: buildroot@buildroot.org Date: Sat, 18 Oct 2014 16:47:02 +0200 Message-Id: <1413643624-14757-4-git-send-email-maxime.hadjinlian@gmail.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1413643624-14757-1-git-send-email-maxime.hadjinlian@gmail.com> References: <1413643624-14757-1-git-send-email-maxime.hadjinlian@gmail.com> Subject: [Buildroot] [PATCH 3/5] infra: Add automatic install of init scripts X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Instead of copy pasting the install code over all our packages, you may now define variables to specify where to take the init script files. Each file will be installed in the default folder of the relevant init system. For systemd, instead of installing the files into $(TARGET_DIR)/etc/systemd/system, the file are now installed in $(TARGET_DIR)/lib/systemd/system which appears to be the right things to do. If you have specific operations to perform in order to install your init scripts or any other file relevant to the init system (tmpfiles for systemd), you can still define the usual FOO_INSTALL_INIT_SYSTEMD for your specific actions. Also add the documentation explaining the mechanism. Signed-off-by: Maxime Hadjinlian --- docs/manual/adding-packages-generic.txt | 17 +++++++++++++++++ package/pkg-generic.mk | 26 ++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/docs/manual/adding-packages-generic.txt b/docs/manual/adding-packages-generic.txt index 67a7453..a0e51f2 100644 --- a/docs/manual/adding-packages-generic.txt +++ b/docs/manual/adding-packages-generic.txt @@ -368,6 +368,23 @@ information is (assuming the package name is +libfoo+) : FLAT binary format is only 4k bytes. If the application consumes more stack, append the required number here. +* +LIBFOO_INIT_SYSV_FILES+ and +LIBFOO_INIT_SYSTEMD_FILES+ are + a space-separated list of init scripts path. Respectively, for + the systemV-like init systems (busybox, sysvinit, etc.) and for + systemd. + Theses init scripts files will only be installed when the relevant + init system is installed (i.e. if systemd is selected as the init + system in the configuration, only +LIBFOO_INIT_SYSTEMD_FILES+ will be + installed). + Each scripts will be installed in the default folder of the relevant + init system. + Note: This doesn't forbid you from defining +LIBFOO_INSTALL_INIT_SYSV+ and + +LIBFOO_INSTALL_INIT_SYSTEMD+ if you need to perform specific actions. + Theses variables are optionnal. + Examples: + + +LIBFOO_INSTALL_INIT_SYSV=package/libfoo/S99libfoo + + +LIBFOO_INSTALL_INIT_SYSV=$(@D)/S99libfoo + + The recommended way to define these variables is to use the following syntax: diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk index 259ee02..1d90ae9 100644 --- a/package/pkg-generic.mk +++ b/package/pkg-generic.mk @@ -229,10 +229,27 @@ $(BUILD_DIR)/%/.stamp_target_installed: @$(call MESSAGE,"Installing to target") $(foreach hook,$($(PKG)_PRE_INSTALL_TARGET_HOOKS),$(call $(hook))$(sep)) +$($(PKG)_INSTALL_TARGET_CMDS) - $(if $(BR2_INIT_SYSTEMD),\ - $($(PKG)_INSTALL_INIT_SYSTEMD)) - $(if $(BR2_INIT_SYSV)$(BR2_INIT_BUSYBOX),\ - $($(PKG)_INSTALL_INIT_SYSV)) +ifeq ($(BR2_INIT_SYSTEMD),y) + $(Q)if test -n "$($(PKG)_INIT_SYSTEMD_FILES)" ; then \ + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants ; \ + for s in $($(PKG)_INIT_SYSTEMD_FILES); do \ + f=$$(basename $${s}); \ + $(INSTALL) -D -m 644 $${s} $(TARGET_DIR)/lib/systemd/system/$${f} ; \ + ln -fs /lib/systemd/system/$${f} \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/$${f} ; \ + done ; \ + fi + $($(PKG)_INSTALL_INIT_SYSTEMD) +endif +ifeq ($(BR2_INIT_SYSV)$(BR2_INIT_BUSYBOX),y) + $(Q)if test -n "$($(PKG)_INIT_SYSV_FILES)" ; then \ + for s in $($(PKG)_INIT_SYSV_FILES); do \ + f=$$(basename $${s}) ; \ + $(INSTALL) -D -m 0755 $${s} $(TARGET_DIR)/etc/init.d/$${f} ; \ + done ; \ + fi + $($(PKG)_INSTALL_INIT_SYSV) +endif $(foreach hook,$($(PKG)_POST_INSTALL_TARGET_HOOKS),$(call $(hook))$(sep)) $(Q)if test -n "$($(PKG)_CONFIG_SCRIPTS)" ; then \ $(RM) -f $(addprefix $(TARGET_DIR)/usr/bin/,$($(PKG)_CONFIG_SCRIPTS)) ; \ @@ -592,6 +609,7 @@ $(1)-reconfigure: $(1)-clean-for-reconfigure $(1) # define the PKG variable for all targets, containing the # uppercase package variable prefix $$($(2)_TARGET_INSTALL_TARGET): PKG=$(2) +$$($(2)_TARGET_INSTALL_TARGET): PKGDIR=$(pkgdir) $$($(2)_TARGET_INSTALL_STAGING): PKG=$(2) $$($(2)_TARGET_INSTALL_IMAGES): PKG=$(2) $$($(2)_TARGET_INSTALL_HOST): PKG=$(2)