From nobody Sun Nov 13 21:54:00 2022 X-Original-To: dev-commits-doc-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4N9R6J4pLLz4hF8q for ; Sun, 13 Nov 2022 21:54:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N9R6J44yJz3JP9; Sun, 13 Nov 2022 21:54:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668376440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4stR7SrSBJBCb1TOekXMthh6jXkrOAaxmfZnSti35Fo=; b=mZU6j7lxjLdUQpIUxJmcmZ2VymJHVTOlLow0yg/Bt/KLG6vRlEYk6XxQbnEPohI6hC4Zgl ZHR/Z0BUrKH97kKFRhrveWaJWgrKS1sfO0jmn/hbDqm3yx2ICUn0m2Frpwrgmw/mZeklG/ jIiOGkw7PPLfydwzHwt0AqVip1yk55ZPXz1ZmuitZwHM0xWkahkZEbIwgSQW+exj/RvcjV 3gqW7hriHT5HO3bKXBWIFDi5GmWvfDwD2ZPFAetkbYbOgaL+Y3I0WQqvtYPRid165IKmAp SwQ9PHeHlrB3cWtGDf8ab1oyWRYpiLDyCli17XgQrd7LUFQK5GVTNr0rk9HZBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668376440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4stR7SrSBJBCb1TOekXMthh6jXkrOAaxmfZnSti35Fo=; b=uzIN05rgO0ZW5sq5EfRljBbL2VjqnPYz20uJ01C9xDX92P62EMwIAqaWDiqzsC3c8wCLM+ swxDMS9CridZ+DNjYSlLPQ5TtbpJfH7EakTNd4LgG/t73spApzCwQOhZF2dGnq2pCglXYy YywZzJ3W1VFWiE3RqXW4HMX7uaiooJaQ3LD0v3elTO/zEzGcXnsd3FBmedPVRpiYQAj6AK xsk0O6BZDsnu/J4KxbbKHfIOPwTNjATnZOzGvGF9ZgyTI/5SMtw6iqlb1Y+6/yWgtoV2vq pXWTIemTjif4ygvakQH/EjRXVgPTc7MCFUkIWWTLR422ezLeBzRkMdKWTwnEag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668376440; a=rsa-sha256; cv=none; b=iJT8y/OM/efAuY2BY1kHhRuj2TcUXfcAcDZ4xVEUFdVorIN33zpdfrXukz3vc3Z+QKPkKA 7HNkby+zXUyuBwnoHQYlVlJkNQWPfYBKFle9l1KgXBQP4Lx4WLILuzhWp/eEZNk9GWDsek P1dPSqlhIVzkK60xwY6p9PvuTYkTLLs2amcxbcMQQAqDXD+OvH2WmpBbrq4lzeAffuXVTr J8dFY5P3QnYO9hO9CGlc2SfDlLLEIu3bsWjVBAXQLwGq4PARCTuDVVJ2+WPlQ9ZXtpSUDM YGA+AEfmzCkfCbc18/9ct17yDIyCGSbCbXXZEVv0bZ3gUXldrC3vVD6X6RwXHQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N9R6J37d7zJDq; Sun, 13 Nov 2022 21:54:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2ADLs0OK088207; Sun, 13 Nov 2022 21:54:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2ADLs05U088206; Sun, 13 Nov 2022 21:54:00 GMT (envelope-from git) Date: Sun, 13 Nov 2022 21:54:00 GMT Message-Id: <202211132154.2ADLs05U088206@gitrepo.freebsd.org> To: doc-committers@FreeBSD.org, dev-commits-doc-all@FreeBSD.org From: Pau Amma Subject: git: 0265532b9d - main - Add documentation of pkg-{pre,post}-[de]install[.lua] List-Id: Commit messages for all branches of the doc repository List-Archive: https://lists.freebsd.org/archives/dev-commits-doc-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-doc-all@freebsd.org X-BeenThere: dev-commits-doc-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pauamma X-Git-Repository: doc X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0265532b9d1257477d98b832937ac5d0c774a27b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by pauamma: URL: https://cgit.FreeBSD.org/doc/commit/?id=0265532b9d1257477d98b832937ac5d0c774a27b commit 0265532b9d1257477d98b832937ac5d0c774a27b Author: Felix Palmen AuthorDate: 2022-08-04 10:56:04 +0000 Commit: Pau Amma CommitDate: 2022-11-13 21:35:51 +0000 Add documentation of pkg-{pre,post}-[de]install[.lua] PR: 265476 Reported by: Felix Palmen Differential Revision: https://reviews.freebsd.org/D36769 Reviewed by: bcr, carlavilla Approved by: carlavilla (mentor) --- .../books/porters-handbook/pkg-files/_index.adoc | 43 +++++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/documentation/content/en/books/porters-handbook/pkg-files/_index.adoc b/documentation/content/en/books/porters-handbook/pkg-files/_index.adoc index 9de27bfe7d..d56bc79d9c 100644 --- a/documentation/content/en/books/porters-handbook/pkg-files/_index.adoc +++ b/documentation/content/en/books/porters-handbook/pkg-files/_index.adoc @@ -223,34 +223,45 @@ Most of the time it is by using `maximum_version` to limit its usage to upgrades ==== [[pkg-install]] -== pkg-install +== pkg-install, pkg-pre-install and pkg-post-install If the port needs to execute commands when the binary package is installed with `pkg add` or `pkg install`, use [.filename]#pkg-install#. -This script will automatically be added to the package. It will be run twice by `pkg`, the first time as `${SH} pkg-install ${PKGNAME} PRE-INSTALL` before the package is installed, and the second time as `${SH} pkg-install ${PKGNAME} POST-INSTALL` after it has been installed. `$2` can be tested to determine which mode the script is being run in. The `PKG_PREFIX` environmental variable will be set to the package installation directory. +If you use [.filename]#pkg-pre-install# or [.filename]#pkg-post-install# instead, the script is only run once, before or after installation of the package. +You can also use [.filename]#pkg-pre-install.lua# or [.filename]#pkg-post-install.lua# to run a lua script instead of a shell script. +Lua scripts run by `pkg` provide some extensions and a few restrictions, for these see man:pkg-lua-script[5]. + +These scripts will automatically be added to the package. + [IMPORTANT] ==== -This script is here to help you set up the package so that it is as ready to use as possible. -It _must not_ be abused to start services, stop services, or run any other commands that will modify the currently running system. +These scripts are here to help you set up the package so that it is as ready to use as possible. +They _must not_ be abused to start services, stop services, or run any other commands that will modify the currently running system. ==== [[pkg-deinstall]] -== pkg-deinstall +== pkg-deinstall, pkg-pre-deinstall and pkg-post-deinstall -This script executes when a package is removed. +These scripts execute when a package is removed. -This script will be run twice by `pkg delete`. +The [.filename]#pkg-deinstall# script will be run twice by `pkg delete`. The first time as `${SH} pkg-deinstall ${PKGNAME} DEINSTALL` before the port is de-installed and the second time as `${SH} pkg-deinstall ${PKGNAME} POST-DEINSTALL` after the port has been de-installed. `$2` can be tested to determine which mode the script is being run in. -The `PKG_PREFIX` environmental variable will be set to the package installation directory +The `PKG_PREFIX` environmental variable will be set to the package installation directory. + +If you use [.filename]#pkg-pre-deinstall# or [.filename]#pkg-post-deinstall# instead, the script is only run once, before or after removal of the package. +You can also use [.filename]#pkg-pre-deinstall.lua# or [.filename]#pkg-post-deinstall.lua# to run a lua script instead of a shell script. +Lua scripts run by `pkg` provide some extensions and a few restrictions, for these see man:pkg-lua-script[5]. + +These scripts will automatically be added to the package. [IMPORTANT] ==== -This script is here to help you set up the package so that it is as ready to use as possible. -It _must not_ be abused to start services, stop services, or run any other commands that will modify the currently running system. +These scripts are here to help you set up the package so that it is as ready to use as possible. +They _must not_ be abused to start services, stop services, or run any other commands that will modify the currently running system. ==== [[pkg-names]] @@ -278,9 +289,21 @@ Here is a list of variable names and their default values. |`PKGINSTALL` |`${PKGDIR}/pkg-install` +|`PKGPREINSTALL` +|`${PKGDIR}/pkg-pre-install` + +|`PKGPOSTINSTALL` +|`${PKGDIR}/pkg-post-install` + |`PKGDEINSTALL` |`${PKGDIR}/pkg-deinstall` +|`PKGPREDEINSTALL` +|`${PKGDIR}/pkg-pre-deinstall` + +|`PKGPOSTDEINSTALL` +|`${PKGDIR}/pkg-post-deinstall` + |`PKGMESSAGE` |`${PKGDIR}/pkg-message` |===