From patchwork Fri Jun 25 18:09:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 466859 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1723262jao; Fri, 25 Jun 2021 11:10:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWXkpeVaJf45sqUFUAjwY2wMInzIF8lC+9RGIsM420TGPXxZr8NQsyOtoO/JiwY4U5xbzY X-Received: by 2002:a17:906:5ace:: with SMTP id x14mr12175054ejs.507.1624644617811; Fri, 25 Jun 2021 11:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624644617; cv=none; d=google.com; s=arc-20160816; b=awXF0UxJqw+wwU7bMgtsPXxe8fEZPqJdR/+hBgxIVnbzia4Oo8rbUVtaNDzxFUNBDC n5hu4qO+OwJ3Bu7V/vcsgF5a+NwCj1lXWEnxuRAEpkD7qLMwTn9Hu5WyYaIjHf8Ma7fg evhNcvbnCCsJejHyI/OwP+Bdvw73pV74nGa9CEeZQOXHFtq+HXZQwE8GoLK2i4+8k+D+ wOiOsUFt3O2vjIxvIOtxk9K2D7CVbWcwYcvhbrcqAuq/WtamTbp0i32yHBKQVoOUYKN9 +negFOWCk18+YYFZGirh3CadhJy0E8OnNdcW0Qr+PRa4mCOTkZTA8uYPTp5sCWVKuWz9 ea5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:errors-to:sender:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:cc :mime-version:references:in-reply-to:message-id:date:subject:to:from :delivered-to:dkim-signature; bh=JkEmGIy5C3yL1SFPjacT/V3DRvp9FqRdRTntI5kMYww=; b=AgUV+ADjRog1aRrOsqYIDPm1KWwtq2fRFQYvkzI4ogIx1hxkHd3rk/yhVZHQGkDQxZ RkJf+rd5PKocxAusZz6JYN+gy7ENtQBhF4yxtSTs2GUUaZLKp9X0a8pimQheh8W22j9y HQEaRUanWJ5L4l7GLiOeVNRRbXdPz2WxETatdkYNTF8H6mhgZEba/Gs2VLonm61ujX9m YiZKj4ULxe7Tb9AGtWpoghshX2OmrHINdRioS1AS4LGq8+9l7pfhnw/I1JD7gTQd2mJo Qx58fEtVHwdZDDY8TOcFayRSotxw7ZNnSzUegKLkcaSFoXw329YNgCiuQnJqyNJqYMYb 8Szg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iRDCeHLh; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com. [170.10.133.124]) by mx.google.com with ESMTPS id de13si6327362ejc.314.2021.06.25.11.10.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Jun 2021 11:10:17 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iRDCeHLh; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624644616; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JkEmGIy5C3yL1SFPjacT/V3DRvp9FqRdRTntI5kMYww=; b=iRDCeHLhxGRKcwU6zKhX+epYWABSKrGY6t2YiXYspV6QV/6z8cSiOVgHHNEnjIF1sdQk0t 8IlNrqx4i9vxiuNZzk1jJETB//c8KRC35aen+8s9U02g/+B9IlAghjrivVl80MKYvZoPJG SNWkKOcJJsFB0XCiUK0xoJnr2B6NlRs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-132-0Qn1w7rxNkyUfAee3B9Nsg-1; Fri, 25 Jun 2021 14:10:13 -0400 X-MC-Unique: 0Qn1w7rxNkyUfAee3B9Nsg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E8A3F804309; Fri, 25 Jun 2021 18:10:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE7D926FCC; Fri, 25 Jun 2021 18:10:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D6DAE4EA2A; Fri, 25 Jun 2021 18:10:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15PIA2ix004753 for ; Fri, 25 Jun 2021 14:10:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 74DBA26FC5; Fri, 25 Jun 2021 18:10:02 +0000 (UTC) Delivered-To: libvir-list@redhat.com Received: from localhost.localdomain.com (ovpn-114-183.ams2.redhat.com [10.36.114.183]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FE4D391; Fri, 25 Jun 2021 18:10:01 +0000 (UTC) From: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/3] spec: avoid repeated calls to systemd macros and binaries Date: Fri, 25 Jun 2021 19:09:53 +0100 Message-Id: <20210625180954.454141-3-berrange@redhat.com> In-Reply-To: <20210625180954.454141-1-berrange@redhat.com> References: <20210625180954.454141-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Zbigniew Jędrzejewski-Szmek The macro can take multiple arguments, and the calls are more efficient if done in one go. Signed-off-by: Zbigniew Jędrzejewski-Szmek --- libvirt.spec.in | 50 +++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) -- 2.31.1 diff --git a/libvirt.spec.in b/libvirt.spec.in index 7f12a92b7f..39226175ce 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1257,31 +1257,35 @@ getent group libvirt >/dev/null || groupadd -r libvirt exit 0 %post daemon +%global post_units \\\ + virtlockd.socket virtlockd-admin.socket \\\ + virtlogd.socket virtlogd-admin.socket \\\ + libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket \\\ + libvirtd-tcp.socket libvirtd-tls.socket \\\ + libvirtd.service \\\ + libvirt-guests.service -%systemd_post virtlockd.socket virtlockd-admin.socket -%systemd_post virtlogd.socket virtlogd-admin.socket -%systemd_post libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket -%systemd_post libvirtd-tcp.socket libvirtd-tls.socket -%systemd_post libvirtd.service -%systemd_post libvirt-guests.service +%systemd_post %post_units # request daemon restart in posttrans mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || : touch %{_localstatedir}/lib/rpm-state/libvirt/restart || : %preun daemon -%systemd_preun libvirtd.service -%systemd_preun libvirtd-tcp.socket libvirtd-tls.socket -%systemd_preun libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket -%systemd_preun virtlogd.socket virtlogd-admin.socket virtlogd.service -%systemd_preun virtlockd.socket virtlockd-admin.socket virtlockd.service -%systemd_preun libvirt-guests.service +%global preun_units \\\ + libvirtd.service \\\ + libvirtd-tcp.socket libvirtd-tls.socket \\\ + libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket \\\ + virtlogd.socket virtlogd-admin.socket virtlogd.service \\\ + virtlockd.socket virtlockd-admin.socket virtlockd.service \\\ + libvirt-guests.service + +%systemd_preun %preun_units %postun daemon /bin/systemctl daemon-reload >/dev/null 2>&1 || : if [ $1 -ge 1 ] ; then - /bin/systemctl reload-or-try-restart virtlockd.service >/dev/null 2>&1 || : - /bin/systemctl reload-or-try-restart virtlogd.service >/dev/null 2>&1 || : + /bin/systemctl reload-or-try-restart virtlockd.service virtlogd.service >/dev/null 2>&1 || : fi %systemd_postun libvirt-guests.service @@ -1308,11 +1312,12 @@ if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then # systemd socket activation, because switching things # might confuse mgmt tool like puppet/ansible that # expect the old style libvirtd - /bin/systemctl mask libvirtd.socket >/dev/null 2>&1 || : - /bin/systemctl mask libvirtd-ro.socket >/dev/null 2>&1 || : - /bin/systemctl mask libvirtd-admin.socket >/dev/null 2>&1 || : - /bin/systemctl mask libvirtd-tls.socket >/dev/null 2>&1 || : - /bin/systemctl mask libvirtd-tcp.socket >/dev/null 2>&1 || : + /bin/systemctl mask \ + libvirtd.socket \ + libvirtd-ro.socket \ + libvirtd-admin.socket \ + libvirtd-tls.socket \ + libvirtd-tcp.socket >/dev/null 2>&1 || : else # Old libvirtd owns the sockets and will delete them on # shutdown. Can't use a try-restart as libvirtd will simply @@ -1324,9 +1329,10 @@ if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then then /bin/systemctl stop libvirtd.service >/dev/null 2>&1 || : - /bin/systemctl try-restart libvirtd.socket >/dev/null 2>&1 || : - /bin/systemctl try-restart libvirtd-ro.socket >/dev/null 2>&1 || : - /bin/systemctl try-restart libvirtd-admin.socket >/dev/null 2>&1 || : + /bin/systemctl try-restart \ + libvirtd.socket \ + libvirtd-ro.socket \ + libvirtd-admin.socket >/dev/null 2>&1 || : /bin/systemctl start libvirtd.service >/dev/null 2>&1 || : fi