242 desire ability to set content root
3815 depot manpage doesn't explain --mirror option
--- a/src/depot.py Mon Oct 13 20:53:58 2008 +0100
+++ b/src/depot.py Mon Oct 13 15:46:42 2008 -0500
@@ -45,6 +45,8 @@
AUTH_DEFAULT = "opensolaris.org"
# The default repository path.
REPO_PATH_DEFAULT = "/var/pkg/repo"
+# The default path for static and other web content.
+CONTENT_PATH_DEFAULT = "/usr/share/lib/pkg"
# The default port to serve data from.
PORT_DEFAULT = 80
# The minimum number of threads allowed.
@@ -109,17 +111,15 @@
emsg(text)
print """\
-Usage: /usr/lib/pkg.depotd [--readonly] [--rebuild] [--mirror] [--proxy-base url]
- [--log-access dest] [--log-errors dest] [-d repo_dir] [-p port]
- [-s threads] [-t socket_timeout]
+Usage: /usr/lib/pkg.depotd [-d repo_dir] [-p port] [-s threads]
+ [-t socket_timeout] [--content-root] [--log-access dest]
+ [--log-errors dest] [--mirror] [--proxy-base url] [--readonly]
+ [--rebuild]
- --readonly Read-only operation; modifying operations disallowed
- --rebuild Re-build the catalog from pkgs in depot
- Cannot be used with --readonly or --mirror
- --mirror Content mirror mode. Publishing and metadata operations
- disabled
- --proxy-base The url to use as the base for generating internal
- redirects and content.
+ --content-root The file system path to the directory containing the
+ the static and other web content used by the depot's
+ browser user interface. The default value is
+ '/usr/share/lib/pkg'.
--log-access The destination for any access related information
logged by the depot process. Possible values are:
stderr, stdout, none, or an absolute pathname. The
@@ -129,6 +129,15 @@
logged by the depot process. Possible values are:
stderr, stdout, none, or an absolute pathname. The
default value is stderr.
+ --mirror Package mirror mode; publishing and metadata operations
+ disallowed. Cannot be used with --readonly or
+ --rebuild.
+ --proxy-base The url to use as the base for generating internal
+ redirects and content.
+ --readonly Read-only operation; modifying operations disallowed.
+ Cannot be used with --mirror or --rebuild.
+ --rebuild Re-build the catalog from pkgs in depot. Cannot be
+ used with --mirror or --readonly.
"""
sys.exit(2)
@@ -154,6 +163,15 @@
else:
repo_path = REPO_PATH_DEFAULT
+ try:
+ content_root = os.environ["PKG_DEPOT_CONTENT"]
+ except KeyError:
+ try:
+ content_root = os.path.join(os.environ['PKG_HOME'],
+ 'share/lib/pkg')
+ except KeyError:
+ content_root = CONTENT_PATH_DEFAULT
+
# By default, if the destination for a particular log type is not
# specified, this is where we will send the output.
log_routes = {
@@ -169,8 +187,8 @@
opt = None
try:
- long_opts = ["readonly", "rebuild", "mirror", "refresh-index",
- "proxy-base="]
+ long_opts = ["content-root=", "mirror", "proxy-base=",
+ "readonly", "rebuild", "refresh-index"]
for opt in log_opts:
long_opts.append("%s=" % opt.lstrip('--'))
opts, pargs = getopt.getopt(sys.argv[1:], "d:np:s:t:",
@@ -192,12 +210,33 @@
"maximum value is %d" % THREADS_MAX
elif opt == "-t":
socket_timeout = int(arg)
+ elif opt == "--content-root":
+ if arg == "":
+ raise OptionError, "You must specify " \
+ "a directory path."
+ content_root = arg
elif opt in log_opts:
if arg is None or arg == "":
raise OptionError, \
"You must specify a log " \
"destination."
log_routes[opt.lstrip("--log-")] = arg
+ elif opt == "--mirror":
+ mirror = True
+ elif opt == "--proxy-base":
+ # Attempt to decompose the url provided into
+ # its base parts. This is done so we can
+ # remove any scheme information since we
+ # don't need it.
+ scheme, netloc, path, params, query, \
+ fragment = urlparse.urlparse(arg,
+ allow_fragments=0)
+
+ # Rebuild the url without the scheme and
+ # remove the leading // urlunparse adds.
+ proxy_base = urlparse.urlunparse(("", netloc,
+ path, params, query, fragment)
+ ).lstrip("//")
elif opt == "--readonly":
readonly = True
elif opt == "--rebuild":
@@ -213,23 +252,6 @@
# pkg.depot process. The index will be rebuilt
# automatically on startup.
reindex = True
- elif opt == "--proxy-base":
- # Attempt to decompose the url provided into
- # its base parts. This is done so we can
- # remove any scheme information since we
- # don't need it.
- scheme, netloc, path, params, query, \
- fragment = urlparse.urlparse(arg,
- allow_fragments=0)
-
- # Rebuild the url without the scheme and
- # remove the leading // urlunparse adds.
- proxy_base = urlparse.urlunparse(("", netloc,
- path, params, query, fragment)
- ).lstrip("//")
-
- elif opt == "--mirror":
- mirror = True
except getopt.GetoptError, e:
usage("pkg.depotd: %s" % e.msg)
except OptionError, e:
@@ -255,12 +277,7 @@
"port: %d. Reason: %s" % (port, msg)
sys.exit(1)
- try:
- face.set_content_root(os.environ["PKG_DEPOT_CONTENT"])
- except KeyError:
- pass
-
- scfg = config.SvrConfig(os.path.abspath(repo_path), AUTH_DEFAULT)
+ scfg = config.SvrConfig(repo_path, content_root, AUTH_DEFAULT)
if rebuild:
scfg.destroy_catalog()
@@ -273,7 +290,7 @@
try:
scfg.init_dirs()
- except EnvironmentError, e:
+ except (RuntimeError, EnvironmentError), e:
print "pkg.depotd: an error occurred while trying to " \
"initialize the depot repository directory " \
"structures:\n%s" % e
@@ -333,12 +350,12 @@
},
"/robots.txt": {
"tools.staticfile.on": True,
- "tools.staticfile.filename": os.path.join(face.content_root,
+ "tools.staticfile.filename": os.path.join(scfg.web_static_root,
"robots.txt")
},
"/static": {
"tools.staticdir.on": True,
- "tools.staticdir.root": face.content_root,
+ "tools.staticdir.root": scfg.web_static_root,
"tools.staticdir.dir": ""
}
}
--- a/src/man/pkg.depotd.1m.txt Mon Oct 13 20:53:58 2008 +0100
+++ b/src/man/pkg.depotd.1m.txt Mon Oct 13 15:46:42 2008 -0500
@@ -5,9 +5,9 @@
pkg.depotd - image packaging system depot server
SYNOPSIS
- /usr/lib/pkg.depotd [--readonly] [--rebuild] [--proxy-base url]
- [--log-access dest] [--log-errors dest] [-d repo_dir] [-p port]
- [-s threads] [-t socket_timeout]
+ /usr/lib/pkg.depotd [-d repo_dir] [-p port] [-s threads]
+ [-t socket_timeout] [--content-root] [--log-access] [--log-errors]
+ [--mirror] [--proxy-base url] [--readonly] [--rebuild]
DESCRIPTION
pkg.depotd is the depot server for the image packaging system.
@@ -19,19 +19,38 @@
purposes.
The pkg.depot server is generally configured via the smf(5)
- properties associated with its service. Four properties
+ properties associated with its service. Eight properties
are currently recognized:
+ pkg/content_root (astring) The file system path at which
+ the instance should find its static
+ and other web content. The default
+ value is /usr/share/lib/pkg.
+
+ pkg/inst_root (astring) The file system path at which
+ the instance should find its repository
+ data. The default value is
+ /var/pkg/repo.
+
+ pkg/log_access (astring) The destination for any access
+ related information logged by the depot
+ process. Possible values are: stderr,
+ stdout, none, or an absolute pathname.
+ The default value is stdout if stdout is
+ a tty; otherwise the default value is
+ none.
+
+ pkg/log_errors (astring) The destination for any errors
+ or other information logged by the depot
+ process. Possible values are: stderr,
+ stdout, none, or an absolute pathname.
+ The default value is stderr.
+
pkg/port (count) The port number on which the
instance should listen for incoming
package requests. The default value is
80.
- pkg/inst_root (astring) The file system path at which
- the instance should find its repository
- data. The default value is
- /var/pkg/repo.
-
pkg/proxy_base (uri) This changes the base URL for the
depot server and is most useful when
running behind Apache or some other
@@ -47,20 +66,6 @@
be started to serve requests. The default
value is 10.
- pkg/log_access (astring) The destination for any access
- related information logged by the depot
- process. Possible values are: stderr,
- stdout, none, or an absolute pathname.
- The default value is stdout if stdout is
- a tty; otherwise the default value is
- none.
-
- pkg/log_errors (astring) The destination for any errors
- or other information logged by the depot
- process. Possible values are: stderr,
- stdout, none, or an absolute pathname.
- The default value is stderr.
-
OPTIONS
The following options alter the default behavior, if present, and
will override the settings from the service instance when managed
@@ -84,16 +89,30 @@
--log-errors dest Overrides pkg/log_errors with the value
given by dest.
+ --content-root root_dir Overrides pkg/content_root with the value
+ given by root_dir.
+
+ --mirror Package mirror mode; publishing and
+ metadata operations are disabled and
+ only a limited browser user interface is
+ provided. This option may not be
+ combined with the --readonly or
+ --rebuild options.
+
+ --proxy-base url Overrides pkg/proxy_base with the value
+ given by url. Ignored if empty value is
+ provided.
+
--readonly Modifying operations, such as those
initiated by pkgsend(1M) are disabled.
- Retrieval operations are still
- available.
+ Retrieval operations are still available.
+ This option may not be combined with the
+ --mirror or --rebuild options.
--rebuild Any existing repository catalog will be
destroyed and then recreated on startup.
-
- --proxy-base url Overrides pkg/proxy_base with the value
- given by url.
+ This option may not be combined with the
+ --mirror or --readonly options.
EXAMPLES
Example 1: Enabling the depot server.
--- a/src/modules/server/config.py Mon Oct 13 20:53:58 2008 +0100
+++ b/src/modules/server/config.py Mon Oct 13 15:46:42 2008 -0500
@@ -44,11 +44,11 @@
the primary derived configuration. State is the current set of
transactions and packages stored by the repository."""
- def __init__(self, repo_root, authority):
+ def __init__(self, repo_root, content_root, authority):
self.set_repo_root(repo_root)
+ self.set_content_root(content_root)
self.authority = authority
-
self.read_only = False
self.mirror = False
@@ -66,7 +66,6 @@
self.pkgs_renamed = 0
def init_dirs(self):
-
if not os.path.exists(self.repo_root):
try:
os.makedirs(self.repo_root)
@@ -86,11 +85,15 @@
for d in self.required_dirs:
if not os.path.exists(d):
raise RuntimeError, emsg
+
+ if not os.path.exists(self.content_root):
+ raise RuntimeError("The specified content root (%s) "
+ "does not exist." % self.content_root)
+
return
def set_repo_root(self, root):
- assert(os.path.isabs(root))
- self.repo_root = root
+ self.repo_root = os.path.abspath(root)
self.trans_root = os.path.join(self.repo_root, "trans")
self.file_root = os.path.join(self.repo_root, "file")
self.pkg_root = os.path.join(self.repo_root, "pkg")
@@ -102,7 +105,11 @@
self.cat_root, self.update_root]
self.optional_dirs = [self.index_root]
-
+
+ def set_content_root(self, root):
+ self.content_root = os.path.abspath(root)
+ # XXX Same as content_root for now, but won't be soon...
+ self.web_static_root = self.content_root
def set_read_only(self):
self.read_only = True
--- a/src/modules/server/face.py Mon Oct 13 20:53:58 2008 +0100
+++ b/src/modules/server/face.py Mon Oct 13 15:46:42 2008 -0500
@@ -34,11 +34,6 @@
# XXX Use small templating module?
-try:
- content_root = os.path.join(os.environ['PKG_HOME'], 'share/lib/pkg')
-except KeyError:
- content_root = '/usr/share/lib/pkg'
-
def init(scfg, rcfg):
"""Ensure that the BUI is properly initialized.
"""
@@ -260,10 +255,6 @@
"/index.html" : index
}
-def set_content_root(path):
- global content_root
- content_root = path
-
def match(scfg, rcfg, request, response):
path = request.path_info.rstrip("/")
if path in pages:
--- a/src/modules/server/repository.py Mon Oct 13 20:53:58 2008 +0100
+++ b/src/modules/server/repository.py Mon Oct 13 15:46:42 2008 -0500
@@ -114,9 +114,9 @@
self.rcfg = rc.RepositoryConfig()
# Allow our interface module to do any startup work.
- face.init(self.scfg, self.rcfg)
+ face.init(scfg, self.rcfg)
- if not self.scfg.is_read_only():
+ if not scfg.is_read_only():
# While our configuration can be parsed during
# initialization, no changes can be written to disk in
# readonly mode.
@@ -137,7 +137,7 @@
# setup an instance-level handler instead of just updating
# its configuration information.
self.favicon_ico = cherrypy.tools.staticfile.handler(
- os.path.join(face.content_root,
+ os.path.join(scfg.web_static_root,
self.rcfg.get_attribute("repository", "icon")))
for name, func in inspect.getmembers(self, inspect.ismethod):
--- a/src/pkg-server.xml Mon Oct 13 20:53:58 2008 +0100
+++ b/src/pkg-server.xml Mon Oct 13 15:46:42 2008 -0500
@@ -85,7 +85,7 @@
<exec_method
type='method'
name='start'
- exec='/usr/lib/pkg.depotd -p %{pkg/port} -d %{pkg/inst_root} -t %{pkg/socket_timeout} -s %{pkg/threads} --proxy-base=%{pkg/proxy_base} --log-access=%{pkg/log_access} --log-errors=%{pkg/log_errors}'
+ exec='/usr/lib/pkg.depotd -d %{pkg/inst_root} -p %{pkg/port} -s %{pkg/threads} -t %{pkg/socket_timeout} --content-root=%{pkg/content_root} --log-access=%{pkg/log_access} --log-errors=%{pkg/log_errors} --proxy-base=%{pkg/proxy_base}'
timeout_seconds='0' />
<exec_method
@@ -99,12 +99,14 @@
</property_group>
<property_group name='pkg' type='application'>
+ <propval name='inst_root' type='astring'
+ value='/var/pkg/repo' />
<propval name='port' type='count' value='80' />
<propval name='proxy_base' type='astring' value='' />
- <propval name='inst_root' type='astring'
- value='/var/pkg/repo' />
<propval name='socket_timeout' type='count' value='60' />
<propval name='threads' type='count' value='10' />
+ <propval name='content_root' type='astring'
+ value='/usr/share/lib/pkg' />
<propval name='log_access' type='astring'
value='none' />
<propval name='log_errors' type='astring'