From patchwork Fri Feb 12 17:21:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Radetsky X-Patchwork-Id: 1872 Return-Path: Delivered-To: patchwork@archlinux.org Received: from mail.archlinux.org [95.216.189.61] by patchwork.archlinux.org with IMAP (fetchmail-6.4.15) for (single-drop); Fri, 12 Feb 2021 17:21:32 +0000 (UTC) Received: from mail.archlinux.org by mail.archlinux.org with LMTP id 0p8HARy5JmCAdAgAK+/4rw (envelope-from ) for ; Fri, 12 Feb 2021 17:21:32 +0000 Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.archlinux.org (Postfix) with ESMTPS id 2630F3E83C8; Fri, 12 Feb 2021 17:21:31 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id C17D02C578; Fri, 12 Feb 2021 17:21:30 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id E0B052C559 for ; Fri, 12 Feb 2021 17:21:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on luna.archlinux.org X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=DKIM_SIGNED=0.1, DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,FREEMAIL_FROM=0.5, HTML_MESSAGE=0.001,RCVD_IN_DNSWL_NONE=-0.0001,SPF_HELO_NONE=0.001, T_DMARC_POLICY_NONE=0.01,T_DMARC_SIMPLE_DKIM=0.01 autolearn=no autolearn_force=no version=3.4.4 X-Spam-BL-Results: [127.0.5.0] Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) by luna.archlinux.org (Postfix) with ESMTPS for ; Fri, 12 Feb 2021 17:21:27 +0000 (UTC) Received: by mail-qv1-xf2e.google.com with SMTP id p12so107455qvv.5 for ; Fri, 12 Feb 2021 09:21:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=PdJrqERbHIoVeYoKJvCQahhv+QIZ/9IQDjFz13pVBVI=; b=uquWqlyclM42HaTEdz6EU1nHh02Bun2uLUi26WrE1blpM1PRD3UgLfNkzxYp0G5msF 8Kr+QAUa4QCGKJlMd51gyKXnJUKB/0HTuYJU2VRqVWkzj/dhUSQsKhvojzi5uu9YVD2m i5rLHJSd0zcr/37OzR8DmP4oW9ZE06cm+ltA1tl+e+J8zwzaS7sy3+8p11nMuVSEx0p/ Kp5gfGW75F/611a03moi0qcDAyfjkk4Y4cMeBbbRlIL31uQpdsywVWS7qjrnmvqwN94x L5vVHsd5Waro75oD2IV+yyy1//Wg6PvdNc9LmJ42ijlHFMPW6E/2RbBVEDzCTd5mdrGN xk4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=PdJrqERbHIoVeYoKJvCQahhv+QIZ/9IQDjFz13pVBVI=; b=oK4qa0axvpXTvyau3crFHCIlloiT47QtY5ltiJaCl74pVcfI86oGSJLGfAHMn35N8s MzAxn9b2J6HDqIh/lHrPr9+kTOmU4Na3uWWrmZ8uwc7pn5aiICa69uusdFgxrsWzLBOw wzQY4H0g8i15LTgUPQrRLGhxorkE4Z4rgCk6tsNr/X6lwpul7hW79klkrqrsE1FyeJIX T9SmdZ0C6V4hyHM5fD8la+kEwWqhCUCDGPoNA0tTiZM9QQ1PEm4V/3RtchhWbWwbnANZ mNYhrXFPaw6PVKOIXb6prvBW2NYai2oPpx5L0Y4HRL5muIUSOrmcosQTMsP7q21FIpXd HMZQ== X-Gm-Message-State: AOAM530wsFlnHdHZ7pxxD3m1p8d4w6J1hGRWD/POCinQsG163Qo4pykC gTMfBiOt4n16pDx1nKkquZxGki1Ymi12SsWK9PUSzSjx1DIavw== X-Google-Smtp-Source: ABdhPJzTt748OgqDA7R4L+MHqItTA6X6qWtM6m/laYjxjWBzk26fIfS3l6hdDx878lNVNJARBJLzUd8K5Ew3nBs7Fek= X-Received: by 2002:a0c:e414:: with SMTP id o20mr3362055qvl.24.1613150485501; Fri, 12 Feb 2021 09:21:25 -0800 (PST) MIME-Version: 1.0 From: Daniel Radetsky Date: Fri, 12 Feb 2021 09:21:14 -0800 Message-ID: To: pacman-dev@lists.archlinux.org X-Content-Filtered-By: Mailman/MimeDel 2.1.34 Subject: [pacman-dev] [PATCH] Adds a --nowait option X-BeenThere: pacman-dev@lists.archlinux.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussion list for pacman development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Discussion list for pacman development Errors-To: pacman-dev-bounces@lists.archlinux.org Sender: "pacman-dev" Authentication-Results: mail.archlinux.org; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=uquWqlyc; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (mail.archlinux.org: domain of pacman-dev-bounces@lists.archlinux.org designates 2a01:4f8:160:3033::2 as permitted sender) smtp.mailfrom=pacman-dev-bounces@lists.archlinux.org X-Rspamd-Queue-Id: 2630F3E83C8 X-Spamd-Result: default: False [0.59 / 15.00]; HAS_REPLYTO(0.00)[pacman-dev@lists.archlinux.org]; ARC_NA(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; FROM_HAS_DN(0.00)[]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : SPF not aligned (relaxed),none]; FREEMAIL_FROM(0.00)[gmail.com]; R_DKIM_REJECT(1.00)[gmail.com:s=20161025]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[pacman-dev@lists.archlinux.org]; TO_DN_NONE(0.00)[]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; MID_RHS_MATCH_FROMTLD(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2a01:4f8:160:3033::2]; DKIM_TRACE(0.00)[gmail.com:-]; NEURAL_HAM(-0.00)[-1.000]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:24940, ipnet:2a01:4f8::/29, country:DE]; FROM_NEQ_ENVFROM(0.00)[dradetsky@gmail.com,pacman-dev-bounces@lists.archlinux.org]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Server: mail.archlinux.org Apologies if gmail ruins this. I'm used to github prs & don't have time to setup mutt at the moment. If pacman is in use, makepkg -si will wait until it is available. This can be undesirable if you aren't running makepkg -si in the normal interactive way. For example, if you're running it from ansible (so shell output is supressed), and you also have a pacman -Syuw running in another terminal which you forgot to confirm, it will hang forever and you won't know why. More generally, if you're running it in any kind of non-interactive environment, you may want it to fail fast instead of waiting for some other condition to resolve. This is kind of a work-in-progress. I'm not totally sure what to do with the .po files (do I manually fix all the line number comments? God, I hope not). And maybe --nowait is a bad name; I'd have gone with a longer name normally like --no-wait-for-pacman, since I don't expect this to be something a user is typing a lot in a terminal, but writing and copypasta-ing in a script. But I also didn't want to buck the conventions. Whatever, I can change it. Signed-off-by: Daniel Radetsky --- scripts/makepkg.sh.in | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) use")\n" printf -- "$(gettext " --packagelist Only list package filepaths that would be produced")\n" printf -- "$(gettext " --printsrcinfo Print the generated SRCINFO and exit")\n" printf -- "$(gettext " --sign Sign the resulting package with %s")\n" "gpg" @@ -1030,10 +1036,11 @@ ARGLIST=("$@") # Parse Command Line Options. OPT_SHORT="AcCdefFghiLmop:rRsSV" OPT_LONG=('allsource' 'check' 'clean' 'cleanbuild' 'config:' 'force' 'geninteg' - 'help' 'holdver' 'ignorearch' 'install' 'key:' 'log' 'noarchive' 'nobuild' - 'nocolor' 'nocheck' 'nodeps' 'noextract' 'noprepare' 'nosign' 'packagelist' - 'printsrcinfo' 'repackage' 'rmdeps' 'sign' 'skipchecksums' 'skipinteg' - 'skippgpcheck' 'source' 'syncdeps' 'verifysource' 'version') + 'help' 'holdver' 'ignorearch' 'install' 'key:' 'log' 'noarchive' + 'nobuild' 'nocolor' 'nocheck' 'nodeps' 'noextract' 'noprepare' + 'nosign' 'nowait' 'packagelist' 'printsrcinfo' 'repackage' 'rmdeps' + 'sign' 'skipchecksums' 'skipinteg' 'skippgpcheck' 'source' 'syncdeps' + 'verifysource' 'version') # Pacman Options OPT_LONG+=('asdeps' 'noconfirm' 'needed' 'noprogressbar') @@ -1074,6 +1081,7 @@ while true; do --nocheck) RUN_CHECK='n' ;; --noprepare) RUN_PREPARE='n' ;; --nosign) SIGNPKG='n' ;; + --nowait) NOWAIT=1 ;; -o|--nobuild) BUILDPKG=0 NOBUILD=1 ;; -p) shift; BUILDFILE=$1 ;; --packagelist) BUILDPKG=0 PACKAGELIST=1 IGNOREARCH=1;; diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index b39433f3..a1a450dd 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -67,6 +67,7 @@ NOARCHIVE=0 NOBUILD=0 NODEPS=0 NOEXTRACT=0 +NOWAIT=0 PKGFUNC=0 PKGVERFUNC=0 PREPAREFUNC=0 @@ -236,6 +237,10 @@ run_pacman() { cmd=(su root -c "$(printf '%q ' "${cmd[@]}")") fi local lockfile="$(pacman-conf DBPath)/db.lck" + if (( NOWAIT )) && [[ -f $lockfile ]]; then + msg "$(gettext "Pacman is currently in use, exiting")" + exit $E_FAIL + fi while [[ -f $lockfile ]]; do local timer=0 msg "$(gettext "Pacman is currently in use, please wait...")" @@ -984,6 +989,7 @@ usage() { printf -- "$(gettext " --nocheck Do not run the %s function in the %s")\n" "check()" "$BUILDSCRIPT" printf -- "$(gettext " --noprepare Do not run the %s function in the %s")\n" "prepare()" "$BUILDSCRIPT" printf -- "$(gettext " --nosign Do not create a signature for the package")\n" + printf -- "$(gettext " --nowait Exit immediately if pacman is in