Commit graph

81 commits

Author SHA1 Message Date
jlam
1ec8131688 Set PKG_REFCOUNT_DBDIR in the environment for the +INSTALL script, just
like pkg_add(1) does in pkg_install-20050204.
2005-02-05 01:17:59 +00:00
jlam
9896c47ccf Create a new INSTALL script action "UNPACK" that unpacks all of the
sub-scripts.
2005-02-03 23:29:08 +00:00
jlam
a6f8c45bfc Next round of install script cleanup -- we now create +FILES,
+RCD_SCRIPTS, and +PERMS subscripts to handle copying config files
and rc.d scripts, and setting special permissions on files.  The +FILES
and +RCD_SCRIPTS are basically identical except for different embedded
packets of data, and they feature reference-counting for the files in
case multiple packages share the same config file.

Garbage-collect unused functions and definitions in the install scripts
now that the subscripts are self-contained.
2005-02-02 10:33:01 +00:00
jlam
0a8bdc04af Avoid hardcoding the refcount database into the INSTALL scripts. We
now simply make ${PKG_REFCOUNT_DBDIR} always be ${PKG_DBDIR}.refcount
so that it always follows the location of ${PKG_DBDIR}.  This preserves
the ability for PKG_DBDIR (and PKG_REFCOUNT_DBDIR) to be different on
different machines despite using the same binary packages.
2005-01-28 19:06:07 +00:00
jlam
8f3180c914 Move the default directory for the reference counts database outside
of ${PKG_DBDIR} to avoid problems with the package tools thinking that
it is a bad package.  The default directory is ${PKG_DBDIR} with
".refcount" appended to the name.  This may be set explicitly through
PKG_REFCOUNT_DBDIR in /etc/mk.conf (bootstrap users may want to do
this, although the default value should do the right thing).
2005-01-28 18:32:40 +00:00
jlam
b474d00694 If PKG_SYSCONFSUBDIR is non-empty, then add ${PKG_SYSCONFDIR} to the
list of +DIRS-maintained directories.  This allows for a package to
specify where its config files should go and creates the directory
automatically, even if it doesn't have any example config files to
put in place.
2005-01-28 08:17:53 +00:00
jlam
0d547bd690 Note the end of the install-dirs unpack template within the INSTALL
script.
2005-01-28 07:39:13 +00:00
jlam
f9d620373a Continue with install script cleanup -- we now create a +USERGROUP
script that is unpacked by the +INSTALL script at PRE-INSTALL time
before any other actions take place, and invoke +USERGROUP to create
any necessary users and groups.  Remove the now-unused code for
PKG_USERS and PKG_GROUPS from the install and deinstall templates.

We also reference count the users and groups and store the reference
counts in ${PKG_DBDIR}/.refcount/{users,groups}.  This allows multiple
packages to register that they use same users and groups, and allows
+USERGROUP to be invoked at any time to repair an installed package.

Also fix the install and deinstall templates to invoke the CHECK-*
actions with ${PKG_METADATA_DIR} so that the correct PKGNAME can be
derived.  This fixes the weird messages asking the user to create
directories for ".pkgdb" during a "make install".
2005-01-28 07:37:55 +00:00
jlam
5aa13ad4ee Use reference counts to properly account for the creation and removal
of directories needed for the proper functioning of each package.

The +INSTALL script unpacks a +DIRS script that adds and removes
directories.  The +DIRS script entirely encapsulates the directory
creation and removal, and completely replaces the code in the
mk/install/install and mk/install/deinstall templates that handled
{MAKE,OWN}_DIRS and {MAKE,OWN}_DIRS_PERMS.

The +DIRS script is meant to be executed from within the package
meta-data directory, e.g.  /var/db/pkg/<pkgname>.  It's usage is:

	./+DIRS ADD|REMOVE|CHECK-ADD|CHECK-REMOVE

The ADD and REMOVE actions cause the necessary directories to be added
or removed from the system.  The CHECK-ADD and CHECK-REMOVE actions
print out informative messages prompting the user to either create or
remove some necessary directories.

The behaviour of "ADD" is such that if the directory already exists
on the system and is not already ref-counted, then that directory is
marked as "pre-existing".  On "REMOVE", pre-existing directories are
left untouched on the filesystem.

At any time, the root user can sanity-check the directories needed by
packages by invoking all of the +DIRS scripts with the "CHECK-ADD"
action.  If there are missing directories, then invoking all of the
+DIRS scripts with the "ADD" action will ensure that any missing
directories are created.

The reference counts database is stored in ${PKG_DBDIR}/.refcount.
The reference counts related to directories managed by the +DIRS script
are stored in ${PKG_DBDIR}/.refcount/dirs.  If the directory reference
counts database is removed, then invoking all of the +DIRS scripts
with the "ADD" action will reconstruct the database; however, directories
may be marked as being pre-existing, so they won't be removed at
package de-installation (although a message will be displayed informing
the user that those directories can be removed).
2005-01-28 06:30:58 +00:00
jlam
c858a36842 Also substitute for PWD_CMD so we can use it in the INSTALL scripts. 2005-01-26 23:15:03 +00:00
jlam
b09a6d5308 Create a new variable "INSTALL_UNPACK_TMPL" that points to a list of
shell script fragments that unpack sub-scripts before the any of the
other PRE-INSTALL stages are run.
2005-01-26 23:14:12 +00:00
jlam
daf62c2000 Rework the way that packages are registered during a "make install". We
split the fake-pkg target into three smaller pieces:

pre-install-fake-pkg - Create files in ${WRKSRC}/.pkgdb meant to be
	installed into ${PKG_DBDIR}/${PKGNAME} that don't depend on
	the installed files.

post-install-fake-pkg - Create files in ${WRKSRC}/.pkgdb meant to be
	installed into ${PKG_DBDIR}/${PKGNAME} that may depend on the
	installed files.

register-pkg - Copy the files in ${WRKSRC}/.pkgdb and create a few
	additional meta-files in ${PKG_DBDIR}/${PKGNAME}.

The idea is that ${WRKSRC}/.pkgdb contains as much of the state as
possible that will be copied into ${PKG_DBDIR}/${PKGNAME}.

The INSTALL and DEINSTALL scripts generated by bsd.pkg.install.mk are
now invoked with ${WRKSRC}/.pkgdb as the working directory, so the
scripts may use the working directory to store temporary files,
regardless of whether they're invoked from bsd.pkg.mk or by pkg_add.
2005-01-23 20:45:22 +00:00
jmmv
af92a2b644 - Move all CHECK_FILES_SKIP definitions to a central place in bsd.pkg.mk.
- Move the previous block of code down in the file so that all used variables
  are defined (specially PKG_SYSCONFDIR).  Fixes a problem noticed by
  kristerw@'s bulk build in comms/minicom.
- Ignore diff's return code, which aborts make in NetBSD 1.6.2.  Also noticed
  by kristerw@'s bulk build.
- Use full paths to do the checks, instead of relative to ${PREFIX}.  Less
  ambiguity.  Matches should be turned into regular expressions that anchor
  to a whole line (tried that, but found some problems).
- Turn CHECK_FILES to NO by default.  As said in the previous point, there
  are still some problems that have to be fixed and minor improvements to
  be done.  And I have no time to fix this ATM.  Yes, this definitely needs
  more testing.  I'm sorry for all the noise.  (But hey!  you should set and
  try this feature locally! ;-)
2005-01-15 10:50:17 +00:00
jmmv
99909219cc Automatically add any of the {CONF,SUPPORT}_FILES and {MAKE,OWN}_DIRS stuff
to CHECK_FILES_SKIP to avoid some false positives.  These directories are
created in the pre-install stage so are included in the generated file list.
The files are also added to silence some problems that may arise during
"make replace".  Found by wiz@ in the gtk2 package.
2005-01-14 18:02:38 +00:00
reed
32d8f290c2 The default location of the pkgsrc-installed rc.d scripts is now
under share/examples/rc.d. The variable name already was named
RCD_SCRIPTS_EXAMPLEDIR.

This is from ideas from Greg Woods and others.

Also bumped PKGREVISION for all packages using RCD_SCRIPTS mechanism
(as requested by wiz).
2004-12-28 02:47:40 +00:00
jlam
25b81680be Remove USERADD and GROUPADD definitions from OSes where the useradd
and groupadd commands won't follow the calling conventions of the
NetBSD useradd/groupadd.  Modify the INSTALL scripts to *never* create
users or groups if there is no available ${USERADD} or ${GROUPADD}
command, but will warn the user of users and groups that need to be
created before the package can be installed.
2004-12-27 06:41:50 +00:00
reed
15fee44a6c Make it so RCD_SCRIPTS_EXAMPLEDIR is a directory relative to
${PREFIX}. It is not an absolute path because with the automatic
addition of the entry to the PLIST would be bogus if someone
defined it to some RCD_SCRIPTS_EXAMPLEDIR outside of PREFIX.
(This may cause multiple rc.d directories if there are multiple
PREFIXes, but I think that is fine.)

Note that at this time, this doesn't change the RCD_SCRIPTS_EXAMPLEDIR
default directory. This will change soon.

Most of this has been in use for over a year.

Also some of this is from Greg Woods. Thank you Greg.

I will next update a few other references to RCD_SCRIPTS_EXAMPLEDIR.
2004-10-11 22:04:19 +00:00
reed
1f144be250 Add RCD_SCRIPTS_EXAMPLEDIR to the MESSAGE_SUBST. www/tinyproxy's MESSAGE
used it but it was not defined. Other MESSAGE files use it too.
2004-10-11 21:49:00 +00:00
jlam
dffc19378a Reorganize some of the files under pkgsrc/mk:
(1) defs.${OPSYS}.mk --> platform/${OPSYS}.mk.

The "platform" subdirectory is where all of the ${OPSYS}-specific
infrastructure logic should reside.

    (2) bsd.pkg.defaults.mk --> defaults/mk.conf
        bsd.pkg.obsolete.mk --> defaults/obsolete.mk

Renaming bsd.pkg.defaults.mk to defaults/mk.conf is to mimic the way
that NetBSD has /etc/rc.conf as well as /etc/defaults/rc.conf, where
the latter is a full list of user-settable variables, and the two
files share the same name to reinforce the fact /etc/defaults/rc.conf
can be directly copied in place as /etc/rc.conf.  This is the same
relationship shared by defaults/mk.conf and /etc/mk.conf.
2004-10-06 20:51:47 +00:00
wiz
a4eac7e63f Be explicit about the fact that USE_PKGINSTALL has to be set to YES
for this Makefile fragment to get included.

XXX: This should be documented in Packages.txt, not here.
2004-07-10 20:54:44 +00:00
reed
74492f1522 Replace VARBASE in INSTALL/DEINSTALL scripts and in rc.d scripts. 2004-07-08 14:58:30 +00:00
tv
0830f78ac1 Add ECHO_N to the list of substituted variables in [DE]INSTALL. 2004-04-27 18:31:08 +00:00
agc
d56f4d205d Indent properly. 2004-04-27 14:00:16 +00:00
tv
3d5851ce2f Add Interix hack: if user and group are the same name, trip up with a
BROKEN message telling the user that they must be different.
2004-04-27 12:06:11 +00:00
tv
66e99a7868 It's USE_GROUPADD, not USE_USERGROUP. 2004-04-27 03:30:04 +00:00
reed
9c790735db mk/bsd.pkg.install.mk now automatically registers
the RCD_SCRIPTS rc.d script(s) to the PLIST.

This GENERATE_PLIST idea is part of Greg A. Woods'
PR #22954.

This helps when the RC_SCRIPTS are installed to
a different ${RCD_SCRIPTS_EXAMPLEDIR}. (Later,
the default RCD_SCRIPTS_EXAMPLEDIR will be changed
to be more clear that they are the examples.)

These patches also remove the etc/rc.d/ scripts from PLISTs
(of packages that use RCD_SCRIPTS). (This also removes
now unused references from openssh* makefiles. Note that
qmail package has not been changed yet.)

I have been doing automatic PLIST registration for RC_SCRIPTS
for over a year. Not all of these packages have been tested,
but many have been tested and used.

Somethings maybe to do:
- a few packages still manually install the rc.d scripts to
  hard-coded etc/rc.d. These need to be fixed.
- maybe  remove from mk/${OPSYS}.pkg.dist mtree specifications too.
2004-04-23 22:07:52 +00:00
salo
6b65040cd4 Sync comment with reality: tell about USE_PKGINSTALL and discourage direct
inclusion of this file.
Suggested bu cjep.
2004-01-12 12:58:23 +00:00
jmmv
a58b3e0738 Define LS in install scripts (needed by install/fonts). 2003-12-20 09:45:55 +00:00
jlam
62fd86d085 In the overwrite package case:
* Ensure that VIEW-INSTALL is called after _all_ POST-INSTALL actions
     (including any in the INSTALL_EXTRA_TMPL file) by moving the call to
     a file that is included after all other INSTALL templates.

   * Ensure that VIEW-DEINSTALL is called before _all_ DEINSTALL actions
     (including any in the DEINSTALL_EXTRA_TMPL file) by moving the call to
     a file that is included before all other DEINSTALL templates.
2003-11-23 07:14:43 +00:00
jlam
399f83c526 Introduce a new variable "CONF_DEPENDS" for pkgviews: a package's
config directory matches the config directory for the dependency
listed in CONF_DEPENDS.  Use symlinks to physically point the
package's config directory to the dependency's config directory, and
handle all of this in the INSTALL/DEINSTALL scripts.

Also make the INSTALL/DEINSTALL scripts a bit smarter about not
copying files and not removing files if the source and destination
file locations point to the same thing.
2003-09-17 02:38:22 +00:00
jlam
08c49aada0 Make adding config files to views other than the default view work if
PKG_SYSCONFBASE points outside of ${PREFIX}.
2003-09-12 05:15:03 +00:00
jlam
ed5b560723 Move RCD_SCRIPTS_DIR definition to bsd.pkg.defaults.mk. This implies that
RCD_SCRIPTS_DIR is user-settable in /etc/mk.conf.
2003-09-06 11:51:16 +00:00
jlam
831a403f7f Install the rcd scripts at post-install time, not at post-install-script
time.  The rc.d script needs to be recorded in the PLIST, and
post-install-script time is too late if we use dynamic PLISTs.
2003-09-06 11:43:55 +00:00
jlam
27e999941f Add .PHONY targets for Makefile correctness. 2003-09-06 11:41:31 +00:00
jlam
19fd2859c5 Package Makefiles should refer to PKG_SYSCONFBASEDIR instead of
PKG_SYSCONFBASE when they want PKG_SYSCONFDIR stripped of
PKG_SYSCONFSUBDIR.  This makes PKG_SYSCONFBASE=/etc work with pkgviews by
installing all config files into /etc/packages/<pkg> instead of
occasionally putting some directly into /etc.

Also only create PKG_SYSCONFDIR if we're actually going to copy config
files.
2003-09-05 11:34:25 +00:00
jlam
841b57441b Merge pkgviews-mk branch into the HEAD by running:
cd pkgsrc/mk
	cvs update -Pd -A
	cvs update -Pd -j pkgviews-mk-base -j pkgviews-mk
2003-09-02 06:59:37 +00:00
jlam
d505acc9c8 No longer assume that a DEINSTALL/INSTALL script in the package directory
is meant for {,DE}INSTALL_EXTRA_TMPL.  Package makefiles should explicitly
set those variables if they want to use them in conjunction with
USE_PKGINSTALL.
2003-08-30 22:53:39 +00:00
jlam
8eeebf165b Add for use by the INSTALL/DEINSTALL scripts. 2003-08-30 18:42:36 +00:00
jmmv
38dd4422e2 Let a package override the name of the automatically generated rc.d script
files inside the WRKDIR.  This is done by setting RCD_SCRIPT_WRK.<name> to
the requested filename, like:

	RCD_SCRIPT_WRK.foobar=	${WRKDIR}/foobar.sh

This fixes a problem (rc.d script not beeing generated) when there is a name
conflict in the WRKDIR (i.e., the file already exists or WRKSRC has the same
basename).
2003-07-31 10:36:03 +00:00
jlam
ca8050d834 If a HEADER file exists in the package directory, then assume it's meant
for the HEADER_EXTRA_TMPL variable.
2003-07-30 10:31:20 +00:00
jlam
6a9e4d3fe5 Allow package Makefiles to insert a supplementary header to the
INSTALL/DEINSTALL scripts via HEADER_EXTRA_TMPL, that is meant to contain
variable definitions to be used by the various actions.
2003-07-30 10:27:05 +00:00
jschauma
6695c7df6a Add initial support for IRIX.
Again, anybody's feedback (success or failure) will be appreciated.
2002-12-02 17:07:27 +00:00
salo
1fde293f32 Introduce new framework which unifies registering packages providing login
shells to /etc/shells.

This feature can be disabled by setting PKG_REGISTER_SHELLS to NO in
/etc/mk.conf.

An excerpt from Packages.txt, section 10.28:

 10.28 Packages providing login shells
 =====================================

If the purpose of the package is to provide a login shell, the variable
PKG_SHELL should contain the full pathname of the shell executable installed
by this package. The package Makefile also must include
"../../mk/bsd.pkg.install.mk" prior to the inclusion of bsd.pkg.mk to use the
automatically generated INSTALL/DEINSTALL scripts.

An example taken from shells/zsh:

        PKG_SHELL=      ${PREFIX}/bin/zsh
        .include "../../mk/bsd.pkg.install.mk"

The shell is registered into /etc/shells file automatically in the
post-install target by the INSTALL script generated by bsd.pkg.install.mk and
removed in the deinstall target by the DEINSTALL script.
2002-11-17 08:58:49 +00:00
jlam
416feb0be7 Unless PKG_RCD_SCRIPTS=YES and RCD_SCRIPTS is non-empty, don't create
${RCD_SCRIPTS_DIR} as it's not used at all.
2002-10-23 17:43:16 +00:00
jlam
eb37e4bb5f Only create RCD_SCRIPTS_DIR if RCD_SCRIPTS is defined and non-empty in
the package Makefile.
2002-10-23 01:16:41 +00:00
jlam
980f9a3271 SETUID_ROOT_PERMS is a convenience definition to note an executable is
meant to be setuid-root, and should be used as follows:

	SPECIAL_PERMS+= /path/to/suidroot ${SETUID_ROOT_PERMS}
2002-10-20 18:01:47 +00:00
jlam
8f33914f7c Generate the INSTALL/DEINSTALL scripts at post-build time, and use proper
make dependencies to ensure that the actual scripts are up-to-date if the
sources are changed.
2002-10-20 09:10:42 +00:00
jlam
9ee42664eb Generate the rc.d scripts at post-build time and use proper make
dependencies to deal with changes in the source rc.d script file (this is
possible now that some variables have moved to bsd.prefs.mk from
bsd.pkg.mk).
2002-10-20 04:11:39 +00:00
jlam
ad8e5c1fab Substitute for ${RCD_SCRIPTS_DIR} in MESSAGE files. 2002-10-19 01:33:51 +00:00
jlam
e098523a14 Substitute for ${FIND} and ${XARGS}. 2002-10-08 11:31:24 +00:00