/ docs / pkg-script.5
pkg-script.5
  1  .\"
  2  .\" FreeBSD pkg - a next generation package for the installation and maintenance
  3  .\" of non-core utilities.
  4  .\"
  5  .\" Redistribution and use in source and binary forms, with or without
  6  .\" modification, are permitted provided that the following conditions
  7  .\" are met:
  8  .\" 1. Redistributions of source code must retain the above copyright
  9  .\"    notice, this list of conditions and the following disclaimer.
 10  .\" 2. Redistributions in binary form must reproduce the above copyright
 11  .\"    notice, this list of conditions and the following disclaimer in the
 12  .\"    documentation and/or other materials provided with the distribution.
 13  .\"
 14  .Dd December 12, 2025
 15  .Dt PKG-SCRIPT 5
 16  .Os
 17  .Sh NAME
 18  .Nm "shell scripts"
 19  .Nd Shell scripts that are run by
 20  .Xr pkg 8
 21  .Sh DESCRIPTION
 22  .Xr pkg 8
 23  may run scripts at given phases of the process it is executing.
 24  .Pp
 25  The phases are the following:
 26  .Bl -tag -width Ds
 27  .It Cm pre-install :
 28  run before installing the files on the system.
 29  .It Cm post-install :
 30  run after installing the files on the system.
 31  .It Cm pre-deinstall :
 32  run before removing the files on the system.
 33  .It Cm post-deinstall :
 34  run after removing the files on the system.
 35  .El
 36  .Pp
 37  In the particular case of an upgrade the scripts are run in the following order:
 38  .Bl -enum -compact
 39  .It
 40  new pre-install
 41  .It
 42  old pre-deinstall
 43  .It
 44  replace binaries
 45  .It
 46  new post-install
 47  .El
 48  .Sh Environment
 49  The following environment variables are exported to be used by the script.
 50  .Bl -tag -width Ds
 51  .It Ev PKG_NAME
 52  Represents the name of the package.
 53  .It Ev PKG_PREFIX
 54  .Va PREFIX
 55  defined within the package at build time.
 56  .It Ev PKG_ROOTDIR
 57  represents the root directory where the package will be installed as specified
 58  by the
 59  .Fl r
 60  arguments passed to
 61  .Xr pkg 8 .
 62  .It Ev PKG_METALOG
 63  When set, provides the path to a
 64  .Xr mtree 5
 65  METALOG file in which package file metadata (e.g., ownership, mode) should be
 66  recorded.
 67  This is typically used when installing packages as a non-root user.
 68  .It Ev PKG_MSGFD
 69  Number of a file descriptor to be used to be able to send messages to the user
 70  that will be shown at the end of the
 71  .Xr pkg 8
 72  process.
 73  .It Ev PKG_CHROOTED
 74  Set to
 75  .Dq true
 76  when
 77  .Xr pkg 8
 78  is operating inside a chroot via
 79  .Ar -c .
 80  .It Ev PKG_UPGRADE
 81  This variable is set when a script is run in the context of an upgrade of a package.
 82  .El
 83  .Sh SEE ALSO
 84  .Xr pkg_create 3 ,
 85  .Xr pkg_printf 3 ,
 86  .Xr pkg_repo_create 3 ,
 87  .Xr pkg_repos 3 ,
 88  .Xr pkg-keywords 5 ,
 89  .Xr pkg-lua-script 5 ,
 90  .Xr pkg-repository 5 ,
 91  .Xr pkg-triggers 5 ,
 92  .Xr pkg.conf 5 ,
 93  .Xr pkg 8 ,
 94  .Xr pkg-add 8 ,
 95  .Xr pkg-alias 8 ,
 96  .Xr pkg-annotate 8 ,
 97  .Xr pkg-audit 8 ,
 98  .Xr pkg-autoremove 8 ,
 99  .Xr pkg-check 8 ,
100  .Xr pkg-clean 8 ,
101  .Xr pkg-config 8 ,
102  .Xr pkg-create 8 ,
103  .Xr pkg-delete 8 ,
104  .Xr pkg-fetch 8 ,
105  .Xr pkg-help 8 ,
106  .Xr pkg-info 8 ,
107  .Xr pkg-install 8 ,
108  .Xr pkg-key 8 ,
109  .Xr pkg-lock 8 ,
110  .Xr pkg-plugins 8 ,
111  .Xr pkg-query 8 ,
112  .Xr pkg-register 8 ,
113  .Xr pkg-repo 8 ,
114  .Xr pkg-repositories 8 ,
115  .Xr pkg-rquery 8 ,
116  .Xr pkg-search 8 ,
117  .Xr pkg-set 8 ,
118  .Xr pkg-shell 8 ,
119  .Xr pkg-shlib 8 ,
120  .Xr pkg-ssh 8 ,
121  .Xr pkg-stats 8 ,
122  .Xr pkg-triggers 8 ,
123  .Xr pkg-unregister 8 ,
124  .Xr pkg-update 8 ,
125  .Xr pkg-updating 8 ,
126  .Xr pkg-upgrade 8 ,
127  .Xr pkg-version 8 ,
128  .Xr pkg-which 8