From patchwork Thu Dec 22 06:44:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Zaman X-Patchwork-Id: 13079458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0866C4332F for ; Thu, 22 Dec 2022 06:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235167AbiLVGpC (ORCPT ); Thu, 22 Dec 2022 01:45:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235120AbiLVGpA (ORCPT ); Thu, 22 Dec 2022 01:45:00 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A09B72655C for ; Wed, 21 Dec 2022 22:44:58 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id 82so765456pgc.0 for ; Wed, 21 Dec 2022 22:44:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perfinion-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/qdKW6drgjaAKPQctIZGm42tB4XxXiboA+UGu0Tw1Ck=; b=ofev30Kh6yN9Pogeb6TuMkYRrxQNLmTUMOkx7eoNGX3CwaWhT6fItNGpPsiNcyfbQd YA+WHLqessi5tUofXpp7BBFkCtkqTcYwlGzCV3gRO4brMLmKdNqjRs0lxXMx3Nke6F3t akRyrWN8RN0lTlO1hrRpt7FCV62lGuYXnP0RoFrzNQ8mgj+4ziDlX2j+thu2saLn0OT6 oPhN1Xgf5OoC62z3atVRmX9VGe0+LQu0+DKMCBxmgBhZkLLluG9miH3E2qAg3BWEVtHj kqlBlyLIfRD8VPYGEq3ckljwZByo1E8l+wD51W0EBHjgEuVhZ7T189OCZJ8V84GKzB/h PaOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/qdKW6drgjaAKPQctIZGm42tB4XxXiboA+UGu0Tw1Ck=; b=5cSafjuSDUUzgVvFUyUwtqKsFsS1CpBJmPLxN3SWrp4NqalVmyvFBbfJqLr9/Higq5 ImyHWE7YMkf2fgNulLgk83Tt8FOIv1ACFd0Xyx8t1dRkij7hy+7UO8P+LBK6fwqtX953 4/w6pGiViOZ0QRslKtKxQq7f4RtXQgYdLlV1HwzGU3kEnHy6+mnRZvmEXv5/qS9KrUzB /v75KJrz1NTLiME5sHvl4a43hVSjwy5HxtSspPGjHlx7M4cCFhbDQIiLmFE7k3UDhkaH 52ROYdPSHiq/1CwiOss8XsvOp/EMQs5ZcgG8vMNCA2jXEF0UT13Xi7+m5YdrnH8W7Qcd /SpA== X-Gm-Message-State: AFqh2koF64/1o6V54ZDVCe//jJPzF6LcoDuQqPptQEiXHWXAYVySN6kM kEb49V/3n0+X03K1i/X51VNfqjwyySp6G5naLU0= X-Google-Smtp-Source: AMrXdXuQqw4uNkOBllt6nNxMflOZXMD2BkBekmsxn2hoyEdTNbzOylhR8p/aZ3TgXgErEEDiXJHKQw== X-Received: by 2002:a62:1c8e:0:b0:576:ddd4:6a02 with SMTP id c136-20020a621c8e000000b00576ddd46a02mr5174115pfc.22.1671691497652; Wed, 21 Dec 2022 22:44:57 -0800 (PST) Received: from localhost (99-123-3-233.lightspeed.sntcca.sbcglobal.net. [99.123.3.233]) by smtp.gmail.com with ESMTPSA id z29-20020aa7991d000000b005754f96f89fsm11752653pff.76.2022.12.21.22.44.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 22:44:56 -0800 (PST) From: Jason Zaman To: selinux@vger.kernel.org Cc: Jason Zaman Subject: [PATCH 1/2] libselinux: Ignore installed when installing python bindings to DESTDIR Date: Wed, 21 Dec 2022 22:44:51 -0800 Message-Id: <20221222064452.13722-1-jason@perfinion.com> X-Mailer: git-send-email 2.38.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org When the python bindings are installed to a destdir with pip install --prefix= --root=, pip tries to uninstall the existing root-owned package and fails Fixes: running build_ext python3 -m pip install --prefix=/usr `test -n "/tmp/selinux-release//build-master" && echo --root /tmp/selinux-release//build-master` . Processing /tmp/selinux-release/selinux-master/libselinux/src Preparing metadata (setup.py) ... done Building wheels for collected packages: selinux Building wheel for selinux (setup.py) ... done Created wheel for selinux: filename=selinux-3.4-cp310-cp310-linux_x86_64.whl size=725511 sha256=b35e9cdb2a6efce389eeece45446826b4ac6b41f81fdc128893f947036f27e8e Stored in directory: /tmp/pip-ephem-wheel-cache-kemjh99e/wheels/ca/2d/1e/d1ab52426d9add92931471cfa0d2558bcbeed89084af2388c9 Successfully built selinux Installing collected packages: selinux Attempting uninstall: selinux Found existing installation: selinux 3.4 Uninstalling selinux-3.4: ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '__init__.cpython-310.pyc' Consider using the `--user` option or check the permissions. Acked-by: Petr Lautrbach --- libselinux/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile index 0f6396ab..70ba063a 100644 --- a/libselinux/src/Makefile +++ b/libselinux/src/Makefile @@ -187,7 +187,7 @@ install: all ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET) install-pywrap: pywrap - $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTHON_SETUP_ARGS) . + $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) . install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux$(PYCEXT) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT) From patchwork Thu Dec 22 06:44:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Zaman X-Patchwork-Id: 13079459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47BADC4332F for ; Thu, 22 Dec 2022 06:45:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235082AbiLVGpF (ORCPT ); Thu, 22 Dec 2022 01:45:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235011AbiLVGpC (ORCPT ); Thu, 22 Dec 2022 01:45:02 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0131126139 for ; Wed, 21 Dec 2022 22:45:01 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id 17so1192998pll.0 for ; Wed, 21 Dec 2022 22:45:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perfinion-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nJyOJwM5s/tx+bEgWo/Px0r5bcG0YdsjOJ0qsV76vlI=; b=fdY9s7M4theQ15sqisNEUDJaIZVhqf1JK3/G+sKUvH1axrYGuEKwe6uphwfiGVlBIc epn7tK1ctVsDBM5RaPwMcvreiT48QiLmUNdbJ7St01YpurpdaBuilXR/k61xKmxZsQNq X9Bvmrt9PBltIJ6KfvIBuNFbP3QMRqbTfLTSzsyhm8o6HCNG6R69T+eYHMrFb8m5+xgV uvQ4wG3v7gREQX3BFqReJ8njDftEtIDfiCKd4V9l8uiN/9Gi6pkaBRqX8CRYXTkCI2zd Oava0K2jiqM2O+zDvEv3VRi2oXfJDMUoyFVxeBFQa5PMe2Iip4BQs3vaQgu2mxe9fZ5m wrGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nJyOJwM5s/tx+bEgWo/Px0r5bcG0YdsjOJ0qsV76vlI=; b=Jkqyf8MVyyK2iiAQeLl70KPww9dvJTUb1cDiEpu7tWE/CmhBtEbXjD2lUHyzHgGq3L jKA/KQHGatI8rJx1OVNjCJ31kfst+Zq8fMk+q6PwHyBxT1MkQYMyNrfRmtK9ZXr1qhNi Yb9vUf0mKokltAHiMb/ALLxCckBNfuvDbJV+uoDuD0zt0cYgd02y+1IEJujHgMPoxWNY vzzZuYr+yr3Aw3H2079qn5TqWp2pEGhlSHvNgIRzalIL22+cMvx3ZWGNi5X3h1mDn8w8 tzsxmW/oqZ93GbjRqNcoNHcTRBuXwYkzLXvKxyDDBN1flG3wyEtSEb2HYs5xxoO0tdMk xLeA== X-Gm-Message-State: AFqh2kqeIfbcHFmUw5c/qyEmQpgtMAh+WvrTlyvxr9D3+zyS43vwr7cJ Px+PqfFOx2TxNO1u4lrJY6Zr7sjLGbjfZrOlaYI= X-Google-Smtp-Source: AMrXdXu07c2036dElu+ROjT8e+vz92pAIxbG8ky4kcEFi3UFXzdBbtviGG+hu24U9Fa4V4YpEiwFFg== X-Received: by 2002:a17:902:8d95:b0:189:5265:a647 with SMTP id v21-20020a1709028d9500b001895265a647mr5068922plo.41.1671691500082; Wed, 21 Dec 2022 22:45:00 -0800 (PST) Received: from localhost (99-123-3-233.lightspeed.sntcca.sbcglobal.net. [99.123.3.233]) by smtp.gmail.com with ESMTPSA id m16-20020a170902db1000b0017854cee6ebsm12637632plx.72.2022.12.21.22.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 22:44:59 -0800 (PST) From: Jason Zaman To: selinux@vger.kernel.org Cc: Jason Zaman Subject: [PATCH 2/2] python: Ignore installed when installing to DESTDIR Date: Wed, 21 Dec 2022 22:44:52 -0800 Message-Id: <20221222064452.13722-2-jason@perfinion.com> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20221222064452.13722-1-jason@perfinion.com> References: <20221222064452.13722-1-jason@perfinion.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org When installing to a destdir with pip install --prefix= --root=, pip tries to uninstall the existing root-owned package and fails Fixes: python3 -m pip install --prefix=/usr `test -n "/tmp/selinux-release//build-master" && echo --root /tmp/selinux-release//build-master` . Processing /tmp/selinux-release/selinux-master/python/sepolicy Preparing metadata (setup.py) ... done Building wheels for collected packages: sepolicy Building wheel for sepolicy (setup.py) ... done Created wheel for sepolicy: filename=sepolicy-3.4-py3-none-any.whl size=1663564 sha256=229546db123e7d84613d190d49c192291b1a4f7f2a037657b39283b04ac391a4 Stored in directory: /tmp/pip-ephem-wheel-cache-50r2x4cn/wheels/b2/9e/63/6a6212a84d65a709923228719d065ed34e66a90c7fed01e8cf Successfully built sepolicy Installing collected packages: sepolicy Attempting uninstall: sepolicy Found existing installation: sepolicy 3.4 Uninstalling sepolicy-3.4: ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: 'generate.py' Consider using the `--user` option or check the permissions. Acked-by: Petr Lautrbach --- python/sepolicy/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/sepolicy/Makefile b/python/sepolicy/Makefile index 57a2e55e..4e9e93d0 100644 --- a/python/sepolicy/Makefile +++ b/python/sepolicy/Makefile @@ -27,7 +27,7 @@ test: @$(PYTHON) test_sepolicy.py -v install: - $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTHON_SETUP_ARGS) . + $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) . [ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) install -m 755 sepolicy.py $(DESTDIR)$(BINDIR)/sepolicy (cd $(DESTDIR)$(BINDIR); ln -sf sepolicy sepolgen)