From patchwork Sat Sep 23 20:33:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayoub Zaki X-Patchwork-Id: 817829 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4010:c07::23e; helo=mail-lf0-x23e.google.com; envelope-from=swupdate+bncbdbktzhrzujrbd4ktphakgqevlwgvca@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="VPX0uHIH"; dkim-atps=neutral Received: from mail-lf0-x23e.google.com (mail-lf0-x23e.google.com [IPv6:2a00:1450:4010:c07::23e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y029b3d5wz9t5C for ; Sun, 24 Sep 2017 06:33:22 +1000 (AEST) Received: by mail-lf0-x23e.google.com with SMTP id x199sf628987lfd.4 for ; Sat, 23 Sep 2017 13:33:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1506198799; cv=pass; d=google.com; s=arc-20160816; b=q/1wmik9b8sy90iCCcQ2wOBqTTqDixBKaQjbTUETTHmmbHhYukCfYz/tUiwizuT9El /Qnnc7wW8QJSZ7KgxgwIs3+YAhr52b18+mN4dEr5dpXvHTAEYUy8ygOLuw77wI87XPj2 DOOdt1arQF8tMBT4+tGQ4+Jy0lHna8JM5hjOE1SQHNZVFCB1xVFoiMWRRc8G2KCLpoeD Zs7QhTZTw1nu1MHU+ObtvSE6B0P3cNO8DJXdg+wB23jgrdFblrRUr52jx9bunkdNyyAF iLTF+qfiaXEr/zSNAVNTrVJAF93elEco0N/Agpz8IbZNUpSP9/2kAsEqk7z7NlFlfuDK 3Eag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:message-id:date:subject:to:from :arc-authentication-results:arc-message-signature:mime-version :sender:dkim-signature:arc-authentication-results; bh=Z2GIdYXIBeEp04a397GYQ858Q8aX+8dB07JcOZG+Z74=; b=iRW4X6FlWXdbpkmQZ6/ja5bTS34hJ0sr6WgFcq7XEQFQ85Rvt32I88rPfRkjVpusDU jr7tWK52ePEoIdqmXiAcLt5nHHOkB3xRTNI80GFeHCdHhT3fj09zJ0kOsuvYyM4ffH69 n3ziL1qVsiZePGjVQgnkFLxBW8Vtd1kNzLg2TWEvHVlIIv4xsLn+u52jpc+uxGItuGi4 4YJFd+4vZWvI9hn8xRSSLikHlekMoJumcA9wduFJz/1KKJNFjcStSIvyOZfiYG1WmPM7 6QfNET5B73Gd/2Wc5pfaB/4KPvcjCaSEMvoGQmsReVPp/P/H8qpKH+pr9VRHIQgCVMAS XVVg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@embexus.com header.s=20140924 header.b=L9p230uJ; spf=neutral (google.com: 46.30.212.10 is neither permitted nor denied by best guess record for domain of ayoub.zaki@embexus.com) smtp.mailfrom=ayoub.zaki@embexus.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Z2GIdYXIBeEp04a397GYQ858Q8aX+8dB07JcOZG+Z74=; b=VPX0uHIHIjBkX9Pmml6QVzvn/nhDWeM4NUSG0JmrIIg2A+jCyf6qIJQFL1r4P2S3MK Ez/1XgJxFihGdD9zBN1NK5HHh+vovH5QSAFqH6FpcHyaXD5q8SX5VOrcsVJxN8yjqiGZ w+DSP1ZGUATXga5mEczFLxFuqTDO94TB2uJ2kWHBPXO2QyioiwcebclvJywkF/YaeD90 u3ICF9KWLAYtKN943TbpwNd6sqMKNLO3xnaJDeDWyCmiRLbremcP11GZqhmSbGFCAVo/ wZWNjRbJadeMBcasYTD5nQfrgXm+pgta09S5AXGL/hB8ZZqfGoJ+Ci0i67O7uuqU82yd kH3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:subject:date :message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=Z2GIdYXIBeEp04a397GYQ858Q8aX+8dB07JcOZG+Z74=; b=PvgQhJbcIabtkPXDJNzq+p50nm3KSdE5OlqguzEdGAj0f/6ZIcwFdHPsG97TYV2Ns5 9LjDIe617doxB94mDEEOX/VJmMvVHsKFv1DCKmg5mLmWhOYQX5R/KyjRqiMPwTrRQcKN ToqxoPnf3PN+JEV2IN4rpOnNNICDUwnvYVNX0pZU1hEmWgV+t0g93rmWL96ybepWTZ12 hNwJjAjGMw3S0LVRVmi+RPPYtwk+wKkWI3g7W9GSmb7/+684XY+2OYG8j/ZnW2S3S9Bg utrLfJbyrFxu9C+ia0+slN8CNC+kRQ5hZsbD/RAxBhvzzZgq9Ohmn/9X+cUikeftAnTa C2OQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AHPjjUjgmWpRTULrTRN4We8oGWv7ic4FT0zjGHEdm0t5Fd+xRiClbQ0V 14OFol7tiUQs2VZlYuTnF3M= X-Google-Smtp-Source: AOwi7QA+fD9Do0lifDAZXJZ5P1zZOEs1uKnsn7wi64P1fGZoqOrGfealmIOc/DoMQ0h/cbSBrZsh1Q== X-Received: by 10.25.198.87 with SMTP id w84mr4550lff.8.1506198799411; Sat, 23 Sep 2017 13:33:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.46.27.27 with SMTP id b27ls1808672ljb.8.gmail; Sat, 23 Sep 2017 13:33:18 -0700 (PDT) X-Received: by 10.46.67.12 with SMTP id q12mr139344lja.35.1506198798907; Sat, 23 Sep 2017 13:33:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506198798; cv=none; d=google.com; s=arc-20160816; b=GTkGQ2VplAz8+iMQ1RCAp/9j2JSuICfC6nK6CbaixLG+ryDvKX0ehevwSNkD2mRy6T 6WsgU/144XTu2Vc6p6R4umCiXXtT/9Olrb87CiOIPGji5aAXV9cjl508oNBaFojHfxAb Z/b8GFsQS5MKTaAMO/9l6s5ixiAkDldE0qTOByBWi1hF2XleLoWoTJ4OwjEEg6Mx07i3 VCwXlPiBFFHO94jJK2aXsDQ+iEhIiVL9LGn93COTGpY2bz0AD+qjo8HTIiRU9KdXqD4T kU8t0mJdhWpz/FyGcoNOU6hRD8wBv2pvjDkrs5SC3Sto6XOs7WvbnMbSn0w7dRWvf0NU BPVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:dkim-signature :arc-authentication-results; bh=ny0R3420Yk0Ey6+hUdxvzMf/nSA/mZ+kbv4TC0LGrzU=; b=xulM4qzmyIrGB/Vwxl3Q1GXJ2hN6EP3A0R5gl1F6jsBiJa49eoFAYPCMxg2+f2tFSO UjvGXMEsais2vSg/1sjIRKA50/S+vB5IN8QvJZC4+cPRpMUEYucDkYGwasgCdwVlXBTP Xbr8oz7ZP6tq7f5qSQfL/XPickZgChU9MURLtJn7U15e4Ezw/zalf6eLWBIXZfYyFKMu R8QyePxf5apGy0RzDAD0H39+uYVXkgo3UrWH8bO5hN9PEp2+nLsW7KFnx+jFAwXlPdjE /Pce1he7nLYdHv5YbJPVpm+NF6JpQi0Py1TZk2gLBHQKHSPd/yyDtRQprJ/7rtzB9iul JHmA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@embexus.com header.s=20140924 header.b=L9p230uJ; spf=neutral (google.com: 46.30.212.10 is neither permitted nor denied by best guess record for domain of ayoub.zaki@embexus.com) smtp.mailfrom=ayoub.zaki@embexus.com Received: from mailrelay1-3.pub.mailoutpod1-cph3.one.com (mailrelay1-3.pub.mailoutpod1-cph3.one.com. [46.30.212.10]) by gmr-mx.google.com with ESMTPS id 42si88839lfw.7.2017.09.23.13.33.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Sep 2017 13:33:18 -0700 (PDT) Received-SPF: neutral (google.com: 46.30.212.10 is neither permitted nor denied by best guess record for domain of ayoub.zaki@embexus.com) client-ip=46.30.212.10; X-HalOne-Cookie: 535e3da6c13693c2c6d1ff4875351d398ce8693a X-HalOne-ID: 6e3e29c8-a09e-11e7-a520-b8ca3afa9d73 Received: from localhost.localdomain (unknown [145.236.74.125]) by smtpfilter1.public.one.com (Halon) with ESMTPA id 6e3e29c8-a09e-11e7-a520-b8ca3afa9d73; Sat, 23 Sep 2017 20:33:17 +0000 (UTC) From: Ayoub Zaki To: swupdate@googlegroups.com Subject: [swupdate] [meta-swupdate][PATCH] Add systemd swupdate mechanism for usb media Date: Sat, 23 Sep 2017 22:33:17 +0200 Message-Id: <1506198797-29935-1-git-send-email-ayoub.zaki@embexus.com> X-Mailer: git-send-email 2.7.4 X-Original-Sender: ayoub.zaki@embexus.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@embexus.com header.s=20140924 header.b=L9p230uJ; spf=neutral (google.com: 46.30.212.10 is neither permitted nor denied by best guess record for domain of ayoub.zaki@embexus.com) smtp.mailfrom=ayoub.zaki@embexus.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , In case of using swupdate with systemd this add the possibility of updating a device automatically upon inserting an usb media containing a valid update artifact: -swupdate-usb.rules: trigger swupdate-usb@ service by passing device name as argument. -swupdate-usb@.service: mount the media device, run swupdate and trigger a reboot after 1 min in case the update is succesful. Note that swupdate-usb@.service unit specify swupdate.service as conflict which stop the latter when the former service is started. Signed-off-by: Ayoub Zaki --- recipes-support/swupdate/swupdate.inc | 10 +++++++++- recipes-support/swupdate/swupdate/swupdate-usb.rules | 2 ++ recipes-support/swupdate/swupdate/swupdate-usb@.service | 12 ++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 recipes-support/swupdate/swupdate/swupdate-usb.rules create mode 100644 recipes-support/swupdate/swupdate/swupdate-usb@.service diff --git a/recipes-support/swupdate/swupdate.inc b/recipes-support/swupdate/swupdate.inc index 123aa9d..22762b5 100644 --- a/recipes-support/swupdate/swupdate.inc +++ b/recipes-support/swupdate/swupdate.inc @@ -11,6 +11,8 @@ SRC_URI = "git://github.com/sbabic/swupdate.git;protocol=git \ file://defconfig \ file://swupdate \ file://swupdate.service \ + file://swupdate-usb.rules \ + file://swupdate-usb@.service \ " SRCREV = "${AUTOREV}" @@ -114,9 +116,15 @@ do_install () { install -d ${D}${systemd_unitdir}/system install -m 644 ${WORKDIR}/swupdate.service ${D}${systemd_unitdir}/system + install -m 644 ${WORKDIR}/swupdate-usb@.service ${D}${systemd_unitdir}/system/ + + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${sysconfdir}/udev/rules.d + install -m 0644 ${WORKDIR}/swupdate-usb.rules ${D}${sysconfdir}/udev/rules.d/ + fi } INITSCRIPT_NAME = "swupdate" INITSCRIPT_PARAMS = "defaults 70" -SYSTEMD_SERVICE_${PN} = "swupdate.service" +SYSTEMD_SERVICE_${PN} = "swupdate.service swupdate-usb@.service" diff --git a/recipes-support/swupdate/swupdate/swupdate-usb.rules b/recipes-support/swupdate/swupdate/swupdate-usb.rules new file mode 100644 index 0000000..7a9aa76 --- /dev/null +++ b/recipes-support/swupdate/swupdate/swupdate-usb.rules @@ -0,0 +1,2 @@ +ACTION=="add", KERNEL=="sd*", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem", TAG+="systemd", ENV{SYSTEMD_WANTS}="swupdate-usb@%k.service" + diff --git a/recipes-support/swupdate/swupdate/swupdate-usb@.service b/recipes-support/swupdate/swupdate/swupdate-usb@.service new file mode 100644 index 0000000..00b851d --- /dev/null +++ b/recipes-support/swupdate/swupdate/swupdate-usb@.service @@ -0,0 +1,12 @@ +[Unit] +Description=usb media swupdate service +Conflicts=swupdate.service + +[Service] +Type=oneshot +ExecStartPre=/bin/mount /dev/%I /mnt +ExecStart=/usr/bin/swupdate -v -i /mnt/*.swu +ExecStop=/sbin/shutdown -r 1 + +[Install] +WantedBy=multi-user.target