cut down on duplicate code; fix FS#1930; expand man-page examples
This commit is contained in:
parent
8ac36484c5
commit
f2c0f370d4
11
ChangeLog
11
ChangeLog
@ -1,5 +1,14 @@
|
|||||||
|
* 19.03.2023 John McQuah
|
||||||
|
- switch between install and update on a port-by-port basis, whichever is needed
|
||||||
|
- allow dependency injection during sysup (controllable via --nodeps)
|
||||||
|
- check whether a built package already exists before calling pkgmk
|
||||||
|
- consolidate printDependent and printDepTree
|
||||||
|
- consolidate sysup, printQuickDiff, and printDiff
|
||||||
|
- let the argParser recognize some synonyms for old commands
|
||||||
|
- assign meanings to --nodeps and --depsort for other subroutines
|
||||||
|
|
||||||
* 10.03.2023 John McQuah
|
* 10.03.2023 John McQuah
|
||||||
- make it possible to consider optional dependencies when updating
|
- make it possible for the dependency resolver to consider optionals
|
||||||
- bump version of the cache file format, to warn users about the
|
- bump version of the cache file format, to warn users about the
|
||||||
'Packager' field being replaced by 'Optional'
|
'Packager' field being replaced by 'Optional'
|
||||||
|
|
||||||
|
170
doc/prt-get.8
170
doc/prt-get.8
@ -75,33 +75,26 @@ non-option argument passed. This is very similar to
|
|||||||
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B install [\-\-margs] [\-\-aargs] [\-\-log] <package1> [<package2> ...]
|
.B install [\-\-margs] [\-\-aargs] [\-\-log] [\-\-nodeps] [\-\-softdeps] <package1> [<package2> ...]
|
||||||
install all packages in the listed order. Note that you can do this
|
install or update the packages given on the command line. Note that you can do
|
||||||
from any directory.
|
this from any directory. Pass the --nodeps flag to prevent \fBprt\-get\fP from
|
||||||
|
resolving dependencies and injecting any needed ports into the list of targets.
|
||||||
|
Pass the --softdeps flag if you want the dependency resolver to also consider
|
||||||
|
the "Optional" relationships among the packages given on the command line.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B depinst [\-\-margs] [\-\-aargs] [\-\-log] [\-\-softdeps] <package1> [<package2> ...]
|
.B depinst [\-\-margs] [\-\-aargs] [\-\-log] [\-\-softdeps] <package1> [<package2> ...]
|
||||||
install all packages given on the command line, including their dependencies.
|
Basically a synonym for install (without the --nodeps flag).
|
||||||
Passing the --softdeps flag tells \fBprt-get\fP to consider also the optional
|
|
||||||
dependencies when sorting. Note that already-installed packages will be left
|
|
||||||
at their current version, even if out of date. prt\-get depinst behaves this
|
|
||||||
way because all of its child pkgadd processes will \fBlack\fP the \-u flag,
|
|
||||||
which is needed when updating an already-installed package.
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B update [\-\-margs] [\-\-aargs] [\-\-log] <package1> [<package2> ...]
|
.B update [\-\-margs] [\-\-aargs] [\-\-log] [\-\-softdeps] <package1> [<package2> ...]
|
||||||
update all packages listed in this order. Note: if the latest version of
|
Basically a synonym for install. Earlier versions of \fBprt\-get\fP did not adjust
|
||||||
a package has acquired dependencies that were not needed by the currently-installed
|
the \fBpkgadd(8)\fP arguments on a package-by-package basis, but applied "install
|
||||||
version and are not present on the system, the update command will not attempt to
|
mode" or "update mode" to the entire transaction. This latest \fBprt\-get\fP
|
||||||
resolve this omission. prt-get update behaves this way because pkgadd invocations
|
interprets the install command less rigidly, and tries to sync your installed
|
||||||
inherit the flag -u for every package in the transaction, causing an error if
|
ports with their repository versions unless instructed otherwise (using
|
||||||
the package is not already installed. You can follow the CRUX mailing list or the
|
\fBprt\-get lock\fP, the --prefer-higher option, or the \fIprt-get.aliases\fP
|
||||||
IRC channels to stay informed of the situations where an update will require manual
|
file).
|
||||||
intervention, or filter the output of
|
|
||||||
.B prt\-get quickdep $(prt\-get quickdiff)
|
|
||||||
through \fBprt\-get isinst\fP to get a list of packages suitable for an
|
|
||||||
\fBinstall\fP or \fBupdate\fP command.
|
|
||||||
See the \fBEXAMPLES\fP section below for details.
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B remove <package1> [<package2> ...]
|
.B remove <package1> [<package2> ...]
|
||||||
@ -112,14 +105,13 @@ remove packages listed in this order
|
|||||||
Update all installed packages which are outdated. Sorts by hard dependencies
|
Update all installed packages which are outdated. Sorts by hard dependencies
|
||||||
by default. Passing the --softdeps switch tells \fBprt\-get\fP to also consider
|
by default. Passing the --softdeps switch tells \fBprt\-get\fP to also consider
|
||||||
optional dependencies when sorting. Passing the --nodeps switch tells prt-get
|
optional dependencies when sorting. Passing the --nodeps switch tells prt-get
|
||||||
not to sort by dependencies at all, for approximately the same effect as
|
not to sort by dependencies at all.
|
||||||
.B prt\-get update $(prt\-get quickdiff).
|
.B Breaking Change:
|
||||||
As with an \fBupdate\fP command, the child \fBpkgadd\fP processes will
|
If a port has acquired new dependencies since its last successful build,
|
||||||
inherit the \-u flag, so if a port has acquired new dependencies since
|
those new dependencies will be injected into the transaction. This feature
|
||||||
its last successful build, those new dependencies will be omitted from
|
lingered many years on the TODO list, and its absence was the motivation for
|
||||||
the transaction (unless they happen to be installed for some other reason and
|
many clever workarounds (documented in the \fBEXAMPLES\fP section below).
|
||||||
are also in need of an update). See the \fBEXAMPLES\fP section for a way to
|
You can use the
|
||||||
automate the resolution of such omissions. Also see the
|
|
||||||
.B lock
|
.B lock
|
||||||
and
|
and
|
||||||
.B unlock
|
.B unlock
|
||||||
@ -166,15 +158,9 @@ prints a simple list of packages which have a different version in the
|
|||||||
ports tree than what is installed. The output is sorted alphabetically,
|
ports tree than what is installed. The output is sorted alphabetically,
|
||||||
but you can generate a (larger) list sorted by dependencies using
|
but you can generate a (larger) list sorted by dependencies using
|
||||||
.B prt\-get quickdep $(prt\-get quickdiff).
|
.B prt\-get quickdep $(prt\-get quickdiff).
|
||||||
Note that the resulting list is usually a mix of installed and
|
|
||||||
not-installed packages, so it must be filtered by
|
|
||||||
.B prt\-get isinst
|
|
||||||
before being passed as argument to prt\-get install or prt\-get update. See the
|
|
||||||
.B EXAMPLES
|
|
||||||
section below.
|
|
||||||
|
|
||||||
If you want to see only diffs which have a lower version installed than the one in
|
If you want to see only diffs which have a lower version installed than
|
||||||
the ports tree, use the --prefer-higher option.
|
the one in the ports tree, use the --prefer-higher option.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B search [\-v|\-vv] [\-\-path] [\-\-regex] <expr>
|
.B search [\-v|\-vv] [\-\-path] [\-\-regex] <expr>
|
||||||
@ -202,7 +188,6 @@ will change in prt-get 0.6, where full path search will be the
|
|||||||
default. Pattern can be a shell-like wildcard pattern (e.g. prt-get
|
default. Pattern can be a shell-like wildcard pattern (e.g. prt-get
|
||||||
fsearch "*.h") or a regular expression (e.g. prt-get fsearch --regex 'liblz(o2|ma).*')
|
fsearch "*.h") or a regular expression (e.g. prt-get fsearch --regex 'liblz(o2|ma).*')
|
||||||
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B info <port>
|
.B info <port>
|
||||||
Print available info for a port
|
Print available info for a port
|
||||||
@ -231,7 +216,7 @@ if you don't want to filter out manually the ports that are invalid targets for
|
|||||||
installation. For example, instead of
|
installation. For example, instead of
|
||||||
.B prt\-get depinst xorg-server
|
.B prt\-get depinst xorg-server
|
||||||
you might micromanage the process as follows:
|
you might micromanage the process as follows:
|
||||||
.B for i in $(prt\-get quickdep xorg-server); do if prt\-get isinst $i 2>/dev/null; then prt\-get update \-fr $i; else prt\-get install $i; fi; done
|
.B for i in $(prt\-get quickdep xorg-server); do prt\-get install \-fr \-\-nodeps $i; done
|
||||||
which ensures that the latest version of each dependency is built.
|
which ensures that the latest version of each dependency is built.
|
||||||
|
|
||||||
Note: It might be useful to run
|
Note: It might be useful to run
|
||||||
@ -409,13 +394,9 @@ but does not print the version information. This command has a return value of
|
|||||||
greater than 0.
|
greater than 0.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B current <package>
|
.B current <package1> [<package2> ...]
|
||||||
Shows the currently-installed version of <package>, or a message
|
Shows the currently-installed version of <package>, or a message
|
||||||
that <package> is not installed. Unlike
|
that <package> is not installed.
|
||||||
.B prt\-get isinst package1 package2,
|
|
||||||
this command does \fBnot\fP accept more than one package as argument. Use
|
|
||||||
.B pkginfo \-i| grep \-E '^(package1|package2|...)'
|
|
||||||
to work around this limitation.
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B ls [\-\-path] <package>
|
.B ls [\-\-path] <package>
|
||||||
@ -423,7 +404,8 @@ Prints out a listing of the port's directory
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B cat <package> [<file>]
|
.B cat <package> [<file>]
|
||||||
Prints out the file to stdout. If <file> is not specified, 'Pkgfile' is used. If set, uses $PAGER.
|
Prints out the file to stdout. If <file> is not specified, 'Pkgfile' is used.
|
||||||
|
If set, uses $PAGER.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B edit <package> [<file>]
|
.B edit <package> [<file>]
|
||||||
@ -465,14 +447,6 @@ Force install; Implies 'pkgadd -f'; same as --aargs=-f
|
|||||||
.B \-fr
|
.B \-fr
|
||||||
Force rebuild, Implies 'pkgmk -f'; same as --margs=-f
|
Force rebuild, Implies 'pkgmk -f'; same as --margs=-f
|
||||||
|
|
||||||
.TP
|
|
||||||
.B \-um
|
|
||||||
Update md5sum, implies 'pkgmk -um'; same as --margs=-um
|
|
||||||
|
|
||||||
.TP
|
|
||||||
.B \-im
|
|
||||||
Ignore md5sum, implies 'pkgmk -im'; same as --margs=-im
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-us
|
.B \-us
|
||||||
Update signature, implies 'pkgmk -us'; same as --margs=-us
|
Update signature, implies 'pkgmk -us'; same as --margs=-us
|
||||||
@ -515,6 +489,11 @@ future uses and consistency reasons
|
|||||||
.B \-\-ignore=<package1,package2,...>
|
.B \-\-ignore=<package1,package2,...>
|
||||||
Don't install these packages, even if they're listed as dependencies
|
Don't install these packages, even if they're listed as dependencies
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B \-\-nodeps
|
||||||
|
Leave the list of requested ports as-is, without sorting by dependencies
|
||||||
|
or injecting missing dependencies.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-\-softdeps
|
.B \-\-softdeps
|
||||||
Consider optional dependencies when determining the order in which to build
|
Consider optional dependencies when determining the order in which to build
|
||||||
@ -623,29 +602,38 @@ See man prt\-get.conf(5)
|
|||||||
.SH "EXAMPLES"
|
.SH "EXAMPLES"
|
||||||
.TP
|
.TP
|
||||||
.B prt\-get install irssi
|
.B prt\-get install irssi
|
||||||
Download, build and install irssi, with one simple command
|
Download, build and install irssi (and any of its missing dependencies), with
|
||||||
|
one simple command
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B prt\-get install paper yasm
|
.B prt\-get install --nodeps jasper
|
||||||
Install paper and yasm. Abort with an informative error message if either package is already
|
Install jasper, without trying to resolve dependencies.
|
||||||
installed, allowing you to issue a revised command.
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B prt\-get update bmake cmake
|
.B prt\-get update --softdeps webkitgtk
|
||||||
Update bmake and cmake. Abort with an informative error message if either package is not yet
|
Get the latest version of webkitgtk, rebuilding any of its outdated dependencies
|
||||||
installed, allowing you to issue a revised command.
|
(hard and soft) in the optimal order.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B prt\-get update -fr openssh
|
.B prt\-get update -fr openssh
|
||||||
Update your current version of openssh, forcing a rebuild even if no version difference is detected.
|
Update your current version of openssh, forcing a rebuild even if no version
|
||||||
Useful if there was a major version change in one of its dependencies, and \fBrevdep openssh\fP
|
difference is detected.
|
||||||
indicates a broken package. :\-)
|
Useful if there was a major soversion change in one of its dependencies,
|
||||||
|
and \fBrevdep openssh\fP indicates a broken package. :\-)
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B MISSLIBS=$(revdep -vvv mpv | awk -v FS=: '/(missing library)/ {print $3}'); [ -n \(dq${MISSLIBS[@]}\(dq ] && for i in ${MISSLIBS[@]}; do prt\-get fsearch $i; done
|
.B MISSLIBS=$(revdep -vvv mpv | awk -v FS=: '/(missing library)/ {print $3}'); [ -n \(dq${MISSLIBS[@]}\(dq ] && for i in ${MISSLIBS[@]}; do prt\-get fsearch $i; done
|
||||||
(adapted from a script by ppetrov^) Check for the presence of the runtime libraries needed by mpv.
|
(adapted from a script by ppetrov^) Check for the presence of the runtime libraries needed by mpv.
|
||||||
If any are absent, search the footprints to determine which ports provide the missing libraries.
|
If any are absent, search the footprints to determine which ports provide the missing libraries.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B prt\-get printf '%i:%p:%n\en' | awk -v FS=: '/^diff:\e/usr\e/ports\e/core/ { print $3 }' | xargs prt\-get update
|
||||||
|
Basically a \fBsysup\fP operation, but restricted to the core collection.
|
||||||
|
Because core ports are often omitted from the dependency line if they aren't
|
||||||
|
dynamically linked in, the \fBsysup\fP sorting algorithm might not put them
|
||||||
|
at the front of the queue. Run this command before a regular \fBsysup\fP in
|
||||||
|
order to ensure that core ports are updated first.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B prt\-get isinst $(prt-get info ffmpeg | awk -v FS=: '/^Optional/ {gsub(/,/,\(dq \(dq,$2); print $2}') | awk -v FS=\(dq \(dq '/not installed/ {print $2}'
|
.B prt\-get isinst $(prt-get info ffmpeg | awk -v FS=: '/^Optional/ {gsub(/,/,\(dq \(dq,$2); print $2}') | awk -v FS=\(dq \(dq '/not installed/ {print $2}'
|
||||||
Show all the optional dependencies of ffmpeg that are not currently installed.
|
Show all the optional dependencies of ffmpeg that are not currently installed.
|
||||||
@ -663,12 +651,13 @@ place.
|
|||||||
Extension of the above (addressing a use case envisioned by ivandi). The
|
Extension of the above (addressing a use case envisioned by ivandi). The
|
||||||
user can create the file /etc/prt-get.softdeps containing a line like
|
user can create the file /etc/prt-get.softdeps containing a line like
|
||||||
.B ffmpeg: x264 x265
|
.B ffmpeg: x264 x265
|
||||||
and then the above command will perform a depinst --group operation to ensure that
|
and then the above command will perform a depinst --group operation to
|
||||||
at least x264 and x265 (but not necessarily any of the other optional
|
ensure that at least x264 and x265 (but not necessarily any of the other
|
||||||
dependencies) are present before trying to build ffmpeg. In the absence of such
|
optional dependencies) are present before trying to build ffmpeg. In the
|
||||||
a .softdeps config, the operation reverts to the behaviour of the preceding
|
absence of such a .softdeps config, the operation reverts to the behaviour
|
||||||
example (maximal feature set). Implementing Gentoo USE flags with such an
|
of the preceding example (maximal feature set). Implementing Gentoo USE
|
||||||
awkward one-liner might draw criticism from advocates of the KISS principle.
|
flags with such an awkward one-liner might draw criticism from advocates of
|
||||||
|
the KISS principle.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B prt\-get search \-\-regex '^(m|n|p)c.*'
|
.B prt\-get search \-\-regex '^(m|n|p)c.*'
|
||||||
@ -686,46 +675,45 @@ shells (like bash) that support process substitution
|
|||||||
.TP
|
.TP
|
||||||
.B comm -13 <(cat ~/.keepers <(ls /usr/ports/core) | sort) <(prt\-get listorphans) | xargs prt\-get remove
|
.B comm -13 <(cat ~/.keepers <(ls /usr/ports/core) | sort) <(prt\-get listorphans) | xargs prt\-get remove
|
||||||
(system-hosing extension of the above) A one-liner inspired by \fBpkg\-clean\fP
|
(system-hosing extension of the above) A one-liner inspired by \fBpkg\-clean\fP
|
||||||
and \fBpkgfoster\fP, but without the safeguard of interactivity. \fBDo not try this on a
|
and \fBpkgfoster\fP, but without the safeguard of interactivity.
|
||||||
mission-critical system.\fP
|
\fBDo not try this on a mission-critical system.\fP
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B prt\-get isinst $(prt\-get quickdep $(prt\-get quickdiff)) | awk '/not installed/ {print $2}'
|
.B prt\-get isinst $(prt\-get quickdep $(prt\-get quickdiff)) | awk '/not installed/ {print $2}'
|
||||||
(adapted from a comment by Fun) After updating your ports tree, print out a list of dependencies
|
(adapted from a comment by Fun) After updating your ports tree, print out a
|
||||||
that were not needed the last time you built your currently-installed ports, but are needed now by
|
list of dependencies that were not needed the last time you built your
|
||||||
the newer versions of these ports. The output of this command is sorted by dependencies, therefore
|
currently-installed ports, but are needed now by the newer versions of
|
||||||
|
these ports. The output of this command is sorted by dependencies, therefore
|
||||||
suitable for piping to \fBxargs prt\-get install\fP.
|
suitable for piping to \fBxargs prt\-get install\fP.
|
||||||
|
|
||||||
.TP
|
|
||||||
.B prt\-get isinst $(prt\-get quickdep $(prt\-get quickdiff)) | awk '/is installed/ {print $2}'
|
|
||||||
Same as above, but only print the dependencies that are already installed. The output of this
|
|
||||||
command is suitable for piping to \fBxargs prt\-get update\fP.
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B prt\-get printf \(dq%p\et%u\en\(dq | grep myrepo | cut -f 2
|
.B prt\-get printf \(dq%p\et%u\en\(dq | grep myrepo | cut -f 2
|
||||||
Print the upstream URL for each port in the collection \(dqmyrepo\(dq, perhaps as the first step in
|
Print the upstream URL for each port in the collection \(dqmyrepo\(dq,
|
||||||
keeping your personal overlay up to date.
|
perhaps as the first step in keeping your personal overlay up to date.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B prt\-get printf \(dq%M\et%n\en\(dq | grep ^Tim | wc -l
|
.B prt\-get printf \(dq%M\et%n\en\(dq | grep ^Tim | wc -l
|
||||||
Count how many ports our most-overworked core team member claims responsibility for.
|
Count how many ports our most-overworked core team member claims
|
||||||
|
responsibility for.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B comm -13 <(prt\-get depends firefox-bin |tail -n +2 |sort) <(prt\-get depends firefox |tail -n +2 |sort)
|
.B comm -13 <(prt\-get depends firefox-bin |tail -n +2 |sort) <(prt\-get depends firefox |tail -n +2 |sort)
|
||||||
Find the build-time dependencies of firefox. Runtime dependencies would also appear in the list generated by
|
Find the build-time dependencies of firefox. Runtime dependencies would
|
||||||
the first process substitution, and \fBcomm -13\fP will suppress what the two lists have in common.
|
also appear in the list generated by the first process substitution, and
|
||||||
|
\fBcomm -13\fP will suppress what the two lists have in common.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B prt-get listinst \-\-depsort | xargs prt-get install \-\-install\-root=/mnt
|
.B prt-get listinst \-\-depsort | xargs prt-get install \-\-install\-root=/mnt
|
||||||
Sort the list of installed packages by dependencies, and then install all
|
Sort the list of installed packages by dependencies, and then install all
|
||||||
those packages onto a backup filesystem (mounted at /mnt). If you have a customized
|
those packages onto a backup filesystem (mounted at /mnt). If you have a
|
||||||
pkgadd.conf that you want applied to this operation, either copy it to
|
customized pkgadd.conf that you want applied to this operation, either copy
|
||||||
/mnt/etc where pkgadd will be looking for it, or pass the additional option \-\-aargs=\(dq\-c
|
it to /mnt/etc where pkgadd will be looking for it, or pass the additional
|
||||||
/etc/pkgadd.conf\(dq to the install command.
|
option \-\-aargs=\(dq\-c /etc/pkgadd.conf\(dq to the install command.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B prt-get list --path --regex '^xorg.*' | grep -v \(dq/usr/ports/xorg\(dq
|
.B prt-get list --path --regex '^xorg.*' | grep -v \(dq/usr/ports/xorg\(dq
|
||||||
Show the ports whose names begin with xorg, but which appear outside the xorg port collection.
|
Show the ports whose names begin with xorg, but which appear outside the
|
||||||
|
xorg port collection.
|
||||||
(At the time of writing, this command returned at least two font ports.)
|
(At the time of writing, this command returned at least two font ports.)
|
||||||
|
|
||||||
.SH "AUTHORS"
|
.SH "AUTHORS"
|
||||||
|
@ -27,26 +27,28 @@ ArgParser::ArgParser( int argc, char** argv )
|
|||||||
m_hasFilter( false ),
|
m_hasFilter( false ),
|
||||||
m_noStdConfig( false ),
|
m_noStdConfig( false ),
|
||||||
m_writeLog( false ),
|
m_writeLog( false ),
|
||||||
m_nodeps( false ),
|
m_depSort( true ),
|
||||||
m_softdeps( false ),
|
m_softdeps( false ),
|
||||||
|
m_revdep(false),
|
||||||
m_all( false ),
|
m_all( false ),
|
||||||
m_printPath( false ),
|
m_printPath( false ),
|
||||||
m_execPreInstall( false ),
|
m_execPreInstall( false ),
|
||||||
m_execPostInstall( false ),
|
m_execPostInstall( false ),
|
||||||
m_preferHigher( false ),
|
m_preferHigher( false ),
|
||||||
m_strictDiff( false ),
|
m_strictDiff( false ),
|
||||||
|
m_sysup( false ),
|
||||||
m_group( false ),
|
m_group( false ),
|
||||||
m_useRegex(false),
|
m_useRegex(false),
|
||||||
m_fullPath(false),
|
m_fullPath(false),
|
||||||
|
m_quick(false),
|
||||||
m_recursive(false),
|
m_recursive(false),
|
||||||
m_printTree(false),
|
m_printTree(false),
|
||||||
m_depSort(false),
|
|
||||||
m_alternateConfigFile( "" ),
|
m_alternateConfigFile( "" ),
|
||||||
m_pkgmkArgs( "" ),
|
m_pkgmkArgs( "" ),
|
||||||
m_pkgaddArgs( "" ),
|
m_pkgaddArgs( "" ),
|
||||||
m_pkgrmArgs( "" ),
|
m_pkgrmArgs( "" ),
|
||||||
m_sortArgs( "" ),
|
|
||||||
m_filter( "" ),
|
m_filter( "" ),
|
||||||
|
m_sortArgs( "" ),
|
||||||
m_commandName( "" ),
|
m_commandName( "" ),
|
||||||
m_unknownOption( "" ),
|
m_unknownOption( "" ),
|
||||||
m_installRoot( "" ),
|
m_installRoot( "" ),
|
||||||
@ -80,7 +82,7 @@ bool ArgParser::isCommandGiven() const
|
|||||||
/*!
|
/*!
|
||||||
\return a list of arguments not processed by ArgParser
|
\return a list of arguments not processed by ArgParser
|
||||||
*/
|
*/
|
||||||
const list<char*>& ArgParser::otherArgs() const
|
const list<string>& ArgParser::otherArgs() const
|
||||||
{
|
{
|
||||||
return m_otherArgs;
|
return m_otherArgs;
|
||||||
}
|
}
|
||||||
@ -103,7 +105,6 @@ const string& ArgParser::pkgmkArgs() const
|
|||||||
return m_pkgmkArgs;
|
return m_pkgmkArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\return addtional arguments to pkgadd
|
\return addtional arguments to pkgadd
|
||||||
*/
|
*/
|
||||||
@ -112,7 +113,6 @@ const string& ArgParser::pkgaddArgs() const
|
|||||||
return m_pkgaddArgs;
|
return m_pkgaddArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\return the name of the alternative configuration file
|
\return the name of the alternative configuration file
|
||||||
*/
|
*/
|
||||||
@ -121,36 +121,34 @@ const string& ArgParser::alternateConfigFile() const
|
|||||||
return m_alternateConfigFile;
|
return m_alternateConfigFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
parse the arguments
|
parse the arguments
|
||||||
\return true on success
|
\return true on success
|
||||||
*/
|
*/
|
||||||
bool ArgParser::parse()
|
bool ArgParser::parse() {
|
||||||
{
|
const int commandCount = 28;
|
||||||
const int commandCount = 34;
|
string commands[commandCount] = { "help", "info", "version",
|
||||||
string commands[commandCount] = { "list", "search", "dsearch",
|
"search", "dsearch", "fsearch",
|
||||||
"info", "version", "cache",
|
"cache", "install", "remove",
|
||||||
"depends", "install", "depinst",
|
"current", "isinst", "diff",
|
||||||
"help", "isinst", "dup", "update",
|
"path", "printf", "readme",
|
||||||
"quickdep", "diff", "quickdiff",
|
"list", "listinst", "listorphans",
|
||||||
"path", "listinst", "printf", "readme",
|
"lock", "unlock", "listlocked",
|
||||||
"dependent", "sysup", "current",
|
"cat", "ls", "edit", "dumpconfig",
|
||||||
"fsearch", "lock", "unlock",
|
"dup", "depends", "deptree"
|
||||||
"listlocked", "cat", "ls", "edit",
|
};
|
||||||
"remove", "deptree", "dumpconfig",
|
|
||||||
"listorphans" };
|
Type commandID[commandCount] = { HELP, INFO, SHOW_VERSION,
|
||||||
|
SEARCH, DSEARCH, FSEARCH,
|
||||||
|
CREATE_CACHE, INSTALL, REMOVE,
|
||||||
|
CURRENT, ISINST, DIFF,
|
||||||
|
PATH, PRINTF, README,
|
||||||
|
LIST, LISTINST, LISTORPHANS,
|
||||||
|
LOCK, UNLOCK, LISTLOCKED,
|
||||||
|
CAT, LS, EDIT, DUMPCONFIG,
|
||||||
|
DUP, DEPENDS, DEPTREE
|
||||||
|
};
|
||||||
|
|
||||||
Type commandID[commandCount] = { LIST, SEARCH, DSEARCH, INFO,
|
|
||||||
SHOW_VERSION, CREATE_CACHE,
|
|
||||||
DEPENDS, INSTALL, DEPINST,
|
|
||||||
HELP, ISINST, DUP, UPDATE,
|
|
||||||
QUICKDEP, DIFF, QUICKDIFF,
|
|
||||||
PATH, LISTINST, PRINTF, README,
|
|
||||||
DEPENDENT, SYSUP, CURRENT,
|
|
||||||
FSEARCH, LOCK, UNLOCK, LISTLOCKED,
|
|
||||||
CAT, LS, EDIT, REMOVE, DEPTREE,
|
|
||||||
DUMPCONFIG, LISTORPHANS };
|
|
||||||
if ( m_argc < 2 ) {
|
if ( m_argc < 2 ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -170,71 +168,42 @@ bool ArgParser::parse()
|
|||||||
for ( int i = 1; i < m_argc; ++i ) {
|
for ( int i = 1; i < m_argc; ++i ) {
|
||||||
if ( m_argv[i][0] == '-' ) {
|
if ( m_argv[i][0] == '-' ) {
|
||||||
string s = m_argv[i];
|
string s = m_argv[i];
|
||||||
if ( s == "-v" ) {
|
if ( s == "-v" ) { m_verbose += 1;
|
||||||
m_verbose += 1;
|
} else if ( s == "-vv" ) { m_verbose += 2;
|
||||||
} else if ( s == "-vv" ) {
|
} else if ( s == "--test" ) { m_isTest = true;
|
||||||
m_verbose += 2;
|
} else if ( s == "--cache" ) { m_useCache = true;
|
||||||
} else if ( s == "--test" ) {
|
} else if ( s == "--depsort" ) { m_depSort = true;
|
||||||
m_isTest = true;
|
} else if ( s == "--nodeps" ) { m_depSort = false;
|
||||||
} else if ( s == "--cache" ) {
|
} else if ( s == "--softdeps" ) { m_softdeps = true;
|
||||||
m_useCache = true;
|
} else if ( s == "--all" ) { m_all = true;
|
||||||
} else if ( s == "--nodeps" ) {
|
} else if ( s == "--path" ) { m_printPath = true;
|
||||||
m_nodeps = true;
|
} else if ( s == "--log" ) { m_writeLog = true;
|
||||||
} else if ( s == "--softdeps" ) {
|
} else if ( s == "--pre-install" ) { m_execPreInstall = true;
|
||||||
m_softdeps = true;
|
} else if ( s == "--post-install" ) { m_execPostInstall = true;
|
||||||
} else if ( s == "--all" ) {
|
} else if ( s == "--install-scripts" ) { m_execPreInstall = true;
|
||||||
m_all = true;
|
|
||||||
} else if ( s == "--path" ) {
|
|
||||||
m_printPath = true;
|
|
||||||
} else if ( s == "--log" ) {
|
|
||||||
m_writeLog = true;
|
|
||||||
} else if ( s == "--pre-install" ) {
|
|
||||||
m_execPreInstall = true;
|
|
||||||
} else if ( s == "--post-install" ) {
|
|
||||||
m_execPostInstall = true;
|
m_execPostInstall = true;
|
||||||
} else if ( s == "--install-scripts" ) {
|
} else if ( s == "--no-std-config" ) { m_noStdConfig = true;
|
||||||
m_execPreInstall = true;
|
|
||||||
m_execPostInstall = true;
|
|
||||||
} else if ( s == "--no-std-config" ) {
|
|
||||||
m_noStdConfig = true;
|
|
||||||
} else if ( s == "--prefer-higher" || s == "-ph" ) {
|
} else if ( s == "--prefer-higher" || s == "-ph" ) {
|
||||||
m_preferHigher = true;
|
m_preferHigher = true;
|
||||||
} else if ( s == "--strict-diff" || s == "-sd" ) {
|
} else if ( s == "--strict-diff" || s == "-sd" ) {
|
||||||
m_strictDiff = true;
|
m_strictDiff = true;
|
||||||
} else if ( s == "--group" || s == "-g" ) {
|
} else if ( s == "--group" || s == "-g" ) { m_group = true;
|
||||||
m_group = true;
|
} else if ( s == "--quick" || s == "-Q" ) { m_quick = true;
|
||||||
} else if ( s == "--regex" ) {
|
} else if ( s == "--regex" ) { m_useRegex = true;
|
||||||
m_useRegex = true;
|
} else if ( s == "--full" ) { m_fullPath = true;
|
||||||
} else if ( s == "--full" ) {
|
} else if ( s == "--recursive" || s == "-R" ) { m_recursive = true;
|
||||||
m_fullPath = true;
|
} else if ( s == "--tree" || s == "-T" ) { m_printTree = true;
|
||||||
} else if ( s == "--recursive" ) {
|
} else if ( s == "-f" ) { m_pkgaddArgs += " " + s;
|
||||||
m_recursive = true;
|
} else if ( s == "-fi" ) { m_pkgaddArgs += " -f";
|
||||||
} else if ( s == "--tree" ) {
|
} else if ( s == "-fr" ) { m_pkgmkArgs += " -f";
|
||||||
m_printTree = true;
|
} else if ( s == "-if" ) { m_pkgmkArgs += " " + s;
|
||||||
} else if ( s == "--depsort" ) {
|
} else if ( s == "-uf" ) { m_pkgmkArgs += " " + s;
|
||||||
m_depSort = true;
|
} else if ( s == "-im" ) { m_pkgmkArgs += " " + s;
|
||||||
} else if ( s == "-f" ) {
|
} else if ( s == "-um" ) { m_pkgmkArgs += " " + s;
|
||||||
m_pkgaddArgs += " " + s;
|
} else if ( s == "-is" ) { m_pkgmkArgs += " " + s;
|
||||||
} else if ( s == "-fr" ) {
|
} else if ( s == "-us" ) { m_pkgmkArgs += " " + s;
|
||||||
m_pkgmkArgs += " -f";
|
} else if ( s == "-kw" ) { m_pkgmkArgs += " " + s;
|
||||||
} else if ( s == "-if" ) {
|
} else if ( s == "-ns" ) { m_pkgmkArgs += " " + s;
|
||||||
m_pkgmkArgs += " " + s;
|
|
||||||
} else if ( s == "-uf" ) {
|
|
||||||
m_pkgmkArgs += " " + s;
|
|
||||||
} else if ( s == "-im" ) {
|
|
||||||
m_pkgmkArgs += " " + s;
|
|
||||||
} else if ( s == "-um" ) {
|
|
||||||
m_pkgmkArgs += " " + s;
|
|
||||||
} else if ( s == "-is" ) {
|
|
||||||
m_pkgmkArgs += " " + s;
|
|
||||||
} else if ( s == "-us" ) {
|
|
||||||
m_pkgmkArgs += " " + s;
|
|
||||||
} else if ( s == "-kw" ) {
|
|
||||||
m_pkgmkArgs += " " + s;
|
|
||||||
} else if ( s == "-ns" ) {
|
|
||||||
m_pkgmkArgs += " " + s;
|
|
||||||
} else if ( s == "-fi" ) {
|
|
||||||
m_pkgaddArgs += " -f";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// substrings
|
// substrings
|
||||||
@ -244,11 +213,11 @@ bool ArgParser::parse()
|
|||||||
m_pkgaddArgs += " " + s.substr( 8 );
|
m_pkgaddArgs += " " + s.substr( 8 );
|
||||||
} else if ( s.substr( 0, 8 ) == "--rargs=" ) {
|
} else if ( s.substr( 0, 8 ) == "--rargs=" ) {
|
||||||
m_pkgrmArgs = s.substr( 8 );
|
m_pkgrmArgs = s.substr( 8 );
|
||||||
} else if ( s.substr( 0, 7 ) == "--sort=" ) {
|
|
||||||
m_sortArgs = s.substr( 7 );
|
|
||||||
} else if ( s.substr( 0, 9 ) == "--filter=" ) {
|
} else if ( s.substr( 0, 9 ) == "--filter=" ) {
|
||||||
m_filter = s.substr( 9 );
|
m_filter = s.substr( 9 );
|
||||||
m_hasFilter = true;
|
m_hasFilter = true;
|
||||||
|
} else if ( s.substr( 0, 7 ) == "--sort=" ) {
|
||||||
|
m_sortArgs = s.substr( 7 );
|
||||||
} else if ( s.substr( 0, 9 ) == "--config=" ) {
|
} else if ( s.substr( 0, 9 ) == "--config=" ) {
|
||||||
m_alternateConfigFile = s.substr( 9 );
|
m_alternateConfigFile = s.substr( 9 );
|
||||||
m_isAlternateConfigGiven = true;
|
m_isAlternateConfigGiven = true;
|
||||||
@ -271,17 +240,40 @@ bool ArgParser::parse()
|
|||||||
} else {
|
} else {
|
||||||
if (!m_isCommandGiven) {
|
if (!m_isCommandGiven) {
|
||||||
string s = m_argv[i];
|
string s = m_argv[i];
|
||||||
m_commandName = s;
|
if ( s == "grpinst") {
|
||||||
if ( s == "grpinst" ) {
|
|
||||||
m_isCommandGiven = true;
|
m_isCommandGiven = true;
|
||||||
m_commandType = commandID[7];
|
m_commandType = INSTALL;
|
||||||
m_group = true;
|
m_group = true;
|
||||||
cout << "Warning: grpinst is obsolescent";
|
cout << "Warning: grpinst is obsolescent";
|
||||||
cout << "; using install --group" << endl;
|
cout << "; using install --group" << endl;
|
||||||
|
} else if (s == "depinst") {
|
||||||
|
m_isCommandGiven = true;
|
||||||
|
m_commandType = INSTALL;
|
||||||
|
m_depSort = true;
|
||||||
|
} else if (s == "update") {
|
||||||
|
m_isCommandGiven = true;
|
||||||
|
m_commandType = INSTALL;
|
||||||
|
} else if (s == "sysup") {
|
||||||
|
m_isCommandGiven = true;
|
||||||
|
m_commandType = DIFF;
|
||||||
|
m_sysup = true;
|
||||||
|
} else if (s == "quickdiff") {
|
||||||
|
m_isCommandGiven = true;
|
||||||
|
m_commandType = DIFF;
|
||||||
|
m_quick = true;
|
||||||
|
} else if (s == "quickdep") {
|
||||||
|
m_isCommandGiven = true;
|
||||||
|
m_commandType = DEPENDS;
|
||||||
|
m_quick = true;
|
||||||
|
} else if (s == "dependent") {
|
||||||
|
m_isCommandGiven = true;
|
||||||
|
m_commandType = DEPTREE;
|
||||||
|
m_revdep = true;
|
||||||
} else {
|
} else {
|
||||||
for ( int i = 0; i < commandCount; ++i ) {
|
for ( int i = 0; i < commandCount; ++i ) {
|
||||||
if ( s == commands[i] ) {
|
if ( s == commands[i] ) {
|
||||||
m_isCommandGiven = true;
|
m_isCommandGiven = true;
|
||||||
|
m_commandName = s;
|
||||||
m_commandType = commandID[i];
|
m_commandType = commandID[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -297,12 +289,9 @@ bool ArgParser::parse()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return m_isCommandGiven;
|
return m_isCommandGiven;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\return true whether --test has been specified
|
\return true whether --test has been specified
|
||||||
*/
|
*/
|
||||||
@ -311,7 +300,6 @@ bool ArgParser::isTest() const
|
|||||||
return m_isTest;
|
return m_isTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\return the level of verbose: -v -> 1, -vv -> 2
|
\return the level of verbose: -v -> 1, -vv -> 2
|
||||||
*/
|
*/
|
||||||
@ -320,7 +308,6 @@ int ArgParser::verbose() const
|
|||||||
return m_verbose;
|
return m_verbose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\return whether --cache has been specified
|
\return whether --cache has been specified
|
||||||
*/
|
*/
|
||||||
@ -329,7 +316,6 @@ bool ArgParser::useCache() const
|
|||||||
return m_useCache;
|
return m_useCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\return whether prt-get was called as 'prt-cache' or not
|
\return whether prt-get was called as 'prt-cache' or not
|
||||||
*/
|
*/
|
||||||
@ -346,14 +332,6 @@ bool ArgParser::writeLog() const
|
|||||||
return m_writeLog;
|
return m_writeLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\return the --sort="..." string
|
|
||||||
*/
|
|
||||||
const string& ArgParser::sortArgs() const
|
|
||||||
{
|
|
||||||
return m_sortArgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\return whether there was a --filter argument
|
\return whether there was a --filter argument
|
||||||
*/
|
*/
|
||||||
@ -362,7 +340,6 @@ bool ArgParser::hasFilter() const
|
|||||||
return m_hasFilter;
|
return m_hasFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\return whether there was a --no-std-config argument
|
\return whether there was a --no-std-config argument
|
||||||
*/
|
*/
|
||||||
@ -371,7 +348,6 @@ bool ArgParser::noStdConfig() const
|
|||||||
return m_noStdConfig;
|
return m_noStdConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\return the --filter="..." string
|
\return the --filter="..." string
|
||||||
*/
|
*/
|
||||||
@ -381,16 +357,18 @@ const string& ArgParser::filter() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\return whether there was a --nodeps argument
|
\return the --sort="..." string
|
||||||
*/
|
*/
|
||||||
bool ArgParser::nodeps() const
|
const string& ArgParser::sortArgs() const
|
||||||
{
|
{
|
||||||
return m_nodeps;
|
return m_sortArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ArgParser::depSort() const
|
||||||
|
{
|
||||||
|
return m_depSort;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\return whether there was a --softdeps argument
|
|
||||||
*/
|
|
||||||
bool ArgParser::followSoftdeps() const
|
bool ArgParser::followSoftdeps() const
|
||||||
{
|
{
|
||||||
return m_softdeps;
|
return m_softdeps;
|
||||||
@ -409,6 +387,16 @@ bool ArgParser::printPath() const
|
|||||||
return m_printPath;
|
return m_printPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ArgParser::revdep() const
|
||||||
|
{
|
||||||
|
return m_revdep;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ArgParser::quick() const
|
||||||
|
{
|
||||||
|
return m_quick;
|
||||||
|
}
|
||||||
|
|
||||||
bool ArgParser::recursive() const
|
bool ArgParser::recursive() const
|
||||||
{
|
{
|
||||||
return m_recursive;
|
return m_recursive;
|
||||||
@ -416,12 +404,7 @@ bool ArgParser::recursive() const
|
|||||||
|
|
||||||
bool ArgParser::printTree() const
|
bool ArgParser::printTree() const
|
||||||
{
|
{
|
||||||
return m_printTree;
|
return (m_printTree || m_commandName == "deptree");
|
||||||
}
|
|
||||||
|
|
||||||
bool ArgParser::depSort() const
|
|
||||||
{
|
|
||||||
return m_depSort;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const string& ArgParser::commandName() const
|
const string& ArgParser::commandName() const
|
||||||
@ -470,6 +453,11 @@ bool ArgParser::strictDiff() const
|
|||||||
return m_strictDiff;
|
return m_strictDiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ArgParser::sysup() const
|
||||||
|
{
|
||||||
|
return m_sysup;
|
||||||
|
}
|
||||||
|
|
||||||
bool ArgParser::group() const
|
bool ArgParser::group() const
|
||||||
{
|
{
|
||||||
return m_group;
|
return m_group;
|
||||||
@ -485,7 +473,6 @@ bool ArgParser::fullPath() const
|
|||||||
return m_fullPath;
|
return m_fullPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const string& ArgParser::ignore() const
|
const string& ArgParser::ignore() const
|
||||||
{
|
{
|
||||||
return m_ignore;
|
return m_ignore;
|
||||||
|
@ -31,14 +31,15 @@ public:
|
|||||||
bool parse();
|
bool parse();
|
||||||
|
|
||||||
/*! Command type */
|
/*! Command type */
|
||||||
enum Type { HELP, LIST, SEARCH, DSEARCH, INSTALL, DEPINST,
|
enum Type { HELP, INFO, SHOW_VERSION,
|
||||||
INFO, DEPENDS, ISINST, DUP, UPDATE,
|
SEARCH, DSEARCH, FSEARCH,
|
||||||
QUICKDEP, DIFF,
|
CREATE_CACHE, INSTALL, REMOVE,
|
||||||
QUICKDIFF, SHOW_VERSION, CREATE_CACHE, PATH,
|
CURRENT, ISINST, DIFF,
|
||||||
LISTINST, PRINTF, README, DEPENDENT, SYSUP,
|
PATH, PRINTF, README,
|
||||||
CURRENT, FSEARCH, LOCK, UNLOCK, LISTLOCKED,
|
LIST, LISTINST, LISTORPHANS,
|
||||||
CAT, LS, EDIT, REMOVE,
|
LOCK, UNLOCK, LISTLOCKED,
|
||||||
DEPTREE, DUMPCONFIG, LISTORPHANS };
|
CAT, LS, EDIT, DUMPCONFIG,
|
||||||
|
DUP, DEPENDS, DEPTREE };
|
||||||
|
|
||||||
bool isCommandGiven() const;
|
bool isCommandGiven() const;
|
||||||
bool isTest() const;
|
bool isTest() const;
|
||||||
@ -48,27 +49,29 @@ public:
|
|||||||
bool writeLog() const;
|
bool writeLog() const;
|
||||||
bool hasFilter() const;
|
bool hasFilter() const;
|
||||||
bool noStdConfig() const;
|
bool noStdConfig() const;
|
||||||
bool nodeps() const;
|
bool depSort() const;
|
||||||
|
bool followSoftdeps() const;
|
||||||
bool all() const;
|
bool all() const;
|
||||||
bool printPath() const;
|
bool printPath() const;
|
||||||
bool execPreInstall() const;
|
bool execPreInstall() const;
|
||||||
bool execPostInstall() const;
|
bool execPostInstall() const;
|
||||||
bool preferHigher() const;
|
bool preferHigher() const;
|
||||||
bool strictDiff() const;
|
bool strictDiff() const;
|
||||||
|
bool sysup() const;
|
||||||
bool group() const;
|
bool group() const;
|
||||||
bool useRegex() const;
|
bool useRegex() const;
|
||||||
bool fullPath() const;
|
bool fullPath() const;
|
||||||
|
bool revdep() const;
|
||||||
|
bool quick() const;
|
||||||
bool recursive() const;
|
bool recursive() const;
|
||||||
bool printTree() const;
|
bool printTree() const;
|
||||||
bool depSort() const;
|
|
||||||
bool followSoftdeps() const;
|
|
||||||
|
|
||||||
const string& alternateConfigFile() const;
|
const string& alternateConfigFile() const;
|
||||||
const string& pkgmkArgs() const;
|
const string& pkgmkArgs() const;
|
||||||
const string& pkgaddArgs() const;
|
const string& pkgaddArgs() const;
|
||||||
const string& pkgrmArgs() const;
|
const string& pkgrmArgs() const;
|
||||||
const string& sortArgs() const;
|
|
||||||
const string& filter() const;
|
const string& filter() const;
|
||||||
|
const string& sortArgs() const;
|
||||||
const string& installRoot() const;
|
const string& installRoot() const;
|
||||||
const string& ignore() const;
|
const string& ignore() const;
|
||||||
|
|
||||||
@ -78,7 +81,7 @@ public:
|
|||||||
const string& commandName() const;
|
const string& commandName() const;
|
||||||
const string& unknownOption() const;
|
const string& unknownOption() const;
|
||||||
|
|
||||||
const list<char*>& otherArgs() const;
|
const list<string>& otherArgs() const;
|
||||||
|
|
||||||
int verbose() const;
|
int verbose() const;
|
||||||
|
|
||||||
@ -99,8 +102,9 @@ private:
|
|||||||
|
|
||||||
bool m_writeLog;
|
bool m_writeLog;
|
||||||
|
|
||||||
bool m_nodeps;
|
bool m_depSort;
|
||||||
bool m_softdeps;
|
bool m_softdeps;
|
||||||
|
bool m_revdep;
|
||||||
|
|
||||||
bool m_all;
|
bool m_all;
|
||||||
bool m_printPath;
|
bool m_printPath;
|
||||||
@ -109,20 +113,19 @@ private:
|
|||||||
bool m_execPostInstall;
|
bool m_execPostInstall;
|
||||||
bool m_preferHigher;
|
bool m_preferHigher;
|
||||||
bool m_strictDiff;
|
bool m_strictDiff;
|
||||||
|
bool m_sysup;
|
||||||
bool m_group;
|
bool m_group;
|
||||||
bool m_useRegex;
|
bool m_useRegex;
|
||||||
bool m_fullPath;
|
bool m_fullPath;
|
||||||
|
|
||||||
|
bool m_quick;
|
||||||
bool m_recursive;
|
bool m_recursive;
|
||||||
bool m_printTree;
|
bool m_printTree;
|
||||||
|
|
||||||
bool m_depSort;
|
|
||||||
|
|
||||||
string m_alternateConfigFile;
|
string m_alternateConfigFile;
|
||||||
string m_pkgmkArgs;
|
string m_pkgmkArgs;
|
||||||
string m_pkgaddArgs;
|
string m_pkgaddArgs;
|
||||||
string m_pkgrmArgs;
|
string m_pkgrmArgs;
|
||||||
string m_sortArgs;
|
|
||||||
string m_filter;
|
string m_filter;
|
||||||
string m_commandName;
|
string m_commandName;
|
||||||
string m_unknownOption;
|
string m_unknownOption;
|
||||||
@ -136,7 +139,8 @@ private:
|
|||||||
|
|
||||||
int m_verbose;
|
int m_verbose;
|
||||||
|
|
||||||
list<char*> m_otherArgs;
|
string m_sortArgs;
|
||||||
|
list<string> m_otherArgs;
|
||||||
|
|
||||||
list< pair<char*, ConfigArgType> > m_configData;
|
list< pair<char*, ConfigArgType> > m_configData;
|
||||||
};
|
};
|
||||||
|
@ -27,6 +27,7 @@ using namespace std;
|
|||||||
#include "pkgdb.h"
|
#include "pkgdb.h"
|
||||||
#include "stringhelper.h"
|
#include "stringhelper.h"
|
||||||
#include "argparser.h"
|
#include "argparser.h"
|
||||||
|
#include "versioncomparator.h"
|
||||||
#include "process.h"
|
#include "process.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
@ -71,38 +72,6 @@ InstallTransaction::InstallTransaction( const list<string>& names,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
Create a nice InstallTransaction
|
|
||||||
\param names a list of port names to be installed
|
|
||||||
\param repo the repository to look for packages
|
|
||||||
\param pkgDB the pkgDB with already installed packages
|
|
||||||
*/
|
|
||||||
InstallTransaction::InstallTransaction( const list<char*>& names,
|
|
||||||
const Repository* repo,
|
|
||||||
PkgDB* pkgDB,
|
|
||||||
const Configuration* config )
|
|
||||||
: m_pkgDB( pkgDB ),
|
|
||||||
m_resolver(),
|
|
||||||
m_repo( repo ),
|
|
||||||
m_depCalced( false ),
|
|
||||||
m_installedPackages(),
|
|
||||||
m_alreadyInstalledPackages(),
|
|
||||||
m_ignoredPackages(),
|
|
||||||
m_depNameList(),
|
|
||||||
m_depList(),
|
|
||||||
m_missingPackages(),
|
|
||||||
m_installErrors(),
|
|
||||||
m_config( config )
|
|
||||||
{
|
|
||||||
list<char*>::const_iterator it = names.begin();
|
|
||||||
for ( ; it != names.end(); ++it ) {
|
|
||||||
m_packages.push_back( make_pair( *it, m_repo->getPackage( *it ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Create a nice InstallTransaction
|
Create a nice InstallTransaction
|
||||||
\param names a list of port names to be installed
|
\param names a list of port names to be installed
|
||||||
@ -142,18 +111,17 @@ InstallTransaction::installError() const
|
|||||||
/*!
|
/*!
|
||||||
install (commit) a transaction
|
install (commit) a transaction
|
||||||
\param parser the argument parser
|
\param parser the argument parser
|
||||||
\param update whether this is an update operation
|
|
||||||
\param group whether this is a group transaction (stops transaction on error)
|
|
||||||
\return returns an InstallResult telling whether installation worked
|
\return returns an InstallResult telling whether installation worked
|
||||||
*/
|
*/
|
||||||
InstallTransaction::InstallResult
|
InstallTransaction::InstallResult
|
||||||
InstallTransaction::install( const ArgParser* parser,
|
InstallTransaction::install( const ArgParser* parser )
|
||||||
bool update )
|
|
||||||
{
|
{
|
||||||
if ( m_packages.empty() ) {
|
if ( m_packages.empty() ) {
|
||||||
return NO_PACKAGE_GIVEN;
|
return NO_PACKAGE_GIVEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool update;
|
||||||
|
const string forceRebuild = "-fr";
|
||||||
list<string> ignoredPackages;
|
list<string> ignoredPackages;
|
||||||
StringHelper::split(parser->ignore(), ',', ignoredPackages);
|
StringHelper::split(parser->ignore(), ',', ignoredPackages);
|
||||||
|
|
||||||
@ -176,11 +144,27 @@ InstallTransaction::install( const ArgParser* parser,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// consider aliases here, but don't show them specifically
|
// Set the update flag if the package is installed and out of date,
|
||||||
if ( !update && m_pkgDB->isInstalled( package->name(), true ) ) {
|
// or if the user has forced a rebuild.
|
||||||
// ignore
|
// Proceed to the next target if package is installed and up to date.
|
||||||
|
if ( m_pkgDB->isInstalled( package->name(), false ) ) {
|
||||||
|
VersionComparator::COMP_RESULT
|
||||||
|
rpDiff = VersionComparator::compareVersions(
|
||||||
|
m_repo->getPackageVersion( package->name() ),
|
||||||
|
m_pkgDB->getPackageVersion( package->name() ) );
|
||||||
|
if ( rpDiff == VersionComparator::EQUAL &&
|
||||||
|
parser->pkgmkArgs().find(forceRebuild) == string::npos ) {
|
||||||
m_alreadyInstalledPackages.push_back( package->name() );
|
m_alreadyInstalledPackages.push_back( package->name() );
|
||||||
continue;
|
continue;
|
||||||
|
} else if ( (! m_config->preferHigher())
|
||||||
|
|| parser->strictDiff()
|
||||||
|
|| rpDiff == VersionComparator::GREATER
|
||||||
|
|| parser->pkgmkArgs().find(forceRebuild) !=
|
||||||
|
string::npos ) {
|
||||||
|
update = true;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InstallTransaction::InstallResult result;
|
InstallTransaction::InstallResult result;
|
||||||
@ -191,13 +175,12 @@ InstallTransaction::install( const ArgParser* parser,
|
|||||||
m_installedPackages.push_back( make_pair( package->name(), info));
|
m_installedPackages.push_back( make_pair( package->name(), info));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// log failures are critical
|
// log failures and pkgdest errors are critical,
|
||||||
|
// don't proceed to the next install target if encountered
|
||||||
if ( result == LOG_DIR_FAILURE ||
|
if ( result == LOG_DIR_FAILURE ||
|
||||||
result == LOG_FILE_FAILURE ||
|
result == LOG_FILE_FAILURE ||
|
||||||
result == NO_LOG_FILE ||
|
result == NO_LOG_FILE ||
|
||||||
result == CANT_LOCK_LOG_FILE ||
|
result == CANT_LOCK_LOG_FILE ||
|
||||||
|
|
||||||
// or pkgdest
|
|
||||||
result == PKGDEST_ERROR ) {
|
result == PKGDEST_ERROR ) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -224,8 +207,7 @@ InstallTransaction::installPackage( const Package* package,
|
|||||||
const ArgParser* parser,
|
const ArgParser* parser,
|
||||||
bool update,
|
bool update,
|
||||||
InstallTransaction::InstallInfo& info )
|
InstallTransaction::InstallInfo& info )
|
||||||
const
|
const {
|
||||||
{
|
|
||||||
|
|
||||||
InstallTransaction::InstallResult result = SUCCESS;
|
InstallTransaction::InstallResult result = SUCCESS;
|
||||||
#ifdef USE_LOCKING
|
#ifdef USE_LOCKING
|
||||||
@ -241,7 +223,7 @@ InstallTransaction::installPackage( const Package* package,
|
|||||||
commandName = "prt-cache";
|
commandName = "prt-cache";
|
||||||
}
|
}
|
||||||
|
|
||||||
// - initial information about the package to be build
|
// - initial information about the package to be built
|
||||||
string message;
|
string message;
|
||||||
message = commandName + ": ";
|
message = commandName + ": ";
|
||||||
if (update) {
|
if (update) {
|
||||||
@ -299,8 +281,8 @@ InstallTransaction::installPackage( const Package* package,
|
|||||||
write( fdlog, timestamp.c_str(), timestamp.length());
|
write( fdlog, timestamp.c_str(), timestamp.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
string pkgdir = package->path() + "/" + package->name();
|
string portdir = package->path() + "/" + package->name();
|
||||||
chdir( pkgdir.c_str() );
|
chdir( portdir.c_str() );
|
||||||
|
|
||||||
string runscriptCommand = "sh";
|
string runscriptCommand = "sh";
|
||||||
if (m_config->runscriptCommand() != "") {
|
if (m_config->runscriptCommand() != "") {
|
||||||
@ -308,11 +290,11 @@ InstallTransaction::installPackage( const Package* package,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -- pre-install
|
// -- pre-install
|
||||||
struct stat statData;
|
struct stat statData; struct stat fstatData;
|
||||||
if ((parser->execPreInstall() || m_config->runScripts()) &&
|
if ((parser->execPreInstall() || m_config->runScripts()) &&
|
||||||
stat((pkgdir + "/" + "pre-install").c_str(), &statData) == 0) {
|
stat((portdir + "/pre-install").c_str(), &statData) == 0) {
|
||||||
Process preProc( runscriptCommand,
|
Process preProc( runscriptCommand,
|
||||||
pkgdir + "/" + "pre-install",
|
portdir + "/pre-install",
|
||||||
fdlog );
|
fdlog );
|
||||||
if (preProc.executeShell()) {
|
if (preProc.executeShell()) {
|
||||||
info.preState = FAILED;
|
info.preState = FAILED;
|
||||||
@ -322,22 +304,32 @@ InstallTransaction::installPackage( const Package* package,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -- build
|
// -- build
|
||||||
|
string pkgdest = getPkgmkPackageDir();
|
||||||
|
const string builtPkg = package->name() + "#" + package->version() + "-" +
|
||||||
|
package->release() + ".pkg.tar." + getPkgmkCompressionMode();
|
||||||
|
string builtPkgPath = ( pkgdest != "" ) ? pkgdest + "/" + builtPkg :
|
||||||
|
portdir + "/" + builtPkg ;
|
||||||
string cmd = PKGMK_DEFAULT_COMMAND;
|
string cmd = PKGMK_DEFAULT_COMMAND;
|
||||||
if (m_config->makeCommand() != "") {
|
if (m_config->makeCommand() != "") {
|
||||||
cmd = m_config->makeCommand();
|
cmd = m_config->makeCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// skip the build if a package exists newer than Pkgfile
|
||||||
|
// (e.g., created by running pkgmk manually)
|
||||||
|
if ( stat(builtPkgPath.c_str(), &statData) +
|
||||||
|
stat((portdir + "/Pkgfile").c_str(), &fstatData) == 0) {
|
||||||
|
time_t pkgMtime = statData.st_mtime;
|
||||||
|
time_t pfMtime = fstatData.st_mtime;
|
||||||
|
if ( difftime(pkgMtime,pfMtime) > 0 ) { cmd = "/bin/true"; }
|
||||||
|
}
|
||||||
|
|
||||||
string args = "-d " + parser->pkgmkArgs();
|
string args = "-d " + parser->pkgmkArgs();
|
||||||
Process makeProc( cmd, args, fdlog );
|
Process makeProc( cmd, args, fdlog );
|
||||||
if ( makeProc.executeShell() ) {
|
if ( makeProc.executeShell() ) {
|
||||||
result = PKGMK_FAILURE;
|
result = PKGMK_FAILURE;
|
||||||
} else {
|
} else {
|
||||||
// -- update
|
string message = ( pkgdest == "" ) ? "" :
|
||||||
string pkgdest = getPkgmkPackageDir();
|
commandName + ": Using PKGMK_PACKAGE_DIR " + pkgdest;
|
||||||
if ( pkgdest != "" ) {
|
|
||||||
// TODO: don't manipulate pkgdir
|
|
||||||
pkgdir = pkgdest;
|
|
||||||
string message = "prt-get: Using PKGMK_PACKAGE_DIR: " + pkgdir;
|
|
||||||
if (parser->verbose() > 0) {
|
if (parser->verbose() > 0) {
|
||||||
cout << message << endl;
|
cout << message << endl;
|
||||||
}
|
}
|
||||||
@ -347,10 +339,7 @@ InstallTransaction::installPackage( const Package* package,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// the following chdir is a noop if usePkgDest() returns false
|
// no need to chdir if we provide absolute paths to pkgadd
|
||||||
if ( chdir( pkgdir.c_str() ) != 0 ) {
|
|
||||||
result = PKGDEST_ERROR;
|
|
||||||
} else {
|
|
||||||
cmd = PKGADD_DEFAULT_COMMAND;
|
cmd = PKGADD_DEFAULT_COMMAND;
|
||||||
if (m_config->addCommand() != "") {
|
if (m_config->addCommand() != "") {
|
||||||
cmd = m_config->addCommand();
|
cmd = m_config->addCommand();
|
||||||
@ -361,25 +350,20 @@ InstallTransaction::installPackage( const Package* package,
|
|||||||
args = "-r " + parser->installRoot() + " ";
|
args = "-r " + parser->installRoot() + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( update ) {
|
if ( update ) {
|
||||||
args += "-u ";
|
args += "-u ";
|
||||||
}
|
}
|
||||||
if ( !parser->pkgaddArgs().empty() ) {
|
if ( !parser->pkgaddArgs().empty() ) {
|
||||||
args += parser->pkgaddArgs() + " ";
|
args += parser->pkgaddArgs() + " ";
|
||||||
}
|
}
|
||||||
args +=
|
args += builtPkgPath;
|
||||||
package->name() + "#" +
|
|
||||||
package->version() + "-" +
|
|
||||||
package->release() + ".pkg.tar." + getPkgmkCompressionMode();
|
|
||||||
|
|
||||||
|
|
||||||
// - inform the user about what's happening
|
// - inform the user about what's happening
|
||||||
string fullCommand = commandName + ": " + cmd + " " + args;
|
string fullCommand = commandName + ": " + cmd + args;
|
||||||
string summary;
|
string summary;
|
||||||
if (update) {
|
if (update) {
|
||||||
string from = m_pkgDB->getPackageVersion(package->name());
|
string from = m_pkgDB->getPackageVersion(package->name());
|
||||||
string to = package->version() + "-" + package->release();
|
string to = m_repo->getPackageVersion(package->name());
|
||||||
if (from == to) {
|
if (from == to) {
|
||||||
summary = commandName + ": " + "reinstalling " +
|
summary = commandName + ": " + "reinstalling " +
|
||||||
package->name() + " " + to;
|
package->name() + " " + to;
|
||||||
@ -388,9 +372,8 @@ InstallTransaction::installPackage( const Package* package,
|
|||||||
package->name() + " from " + from + " to " + to;
|
package->name() + " from " + from + " to " + to;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
summary = commandName + ": " + "installing " +
|
summary = commandName + ": " + "installing " + package->name() +
|
||||||
package->name() + " " +
|
" " + package->version() + "-" + package->release();
|
||||||
package->version() + "-" + package->release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - print and log
|
// - print and log
|
||||||
@ -418,14 +401,9 @@ InstallTransaction::installPackage( const Package* package,
|
|||||||
} else {
|
} else {
|
||||||
// exec post install
|
// exec post install
|
||||||
if ((parser->execPostInstall() || m_config->runScripts() ) &&
|
if ((parser->execPostInstall() || m_config->runScripts() ) &&
|
||||||
stat((package->path() + "/" + package->name() +
|
stat((portdir + "/post-install").c_str(), &statData) == 0) {
|
||||||
"/" + "post-install").c_str(), &statData)
|
|
||||||
== 0) {
|
|
||||||
// Work around the pkgdir variable change
|
|
||||||
Process postProc( runscriptCommand,
|
Process postProc( runscriptCommand,
|
||||||
package->path() + "/" + package->name()+
|
portdir + "/post-install", fdlog );
|
||||||
"/" + "post-install",
|
|
||||||
fdlog );
|
|
||||||
if (postProc.executeShell()) {
|
if (postProc.executeShell()) {
|
||||||
info.postState = FAILED;
|
info.postState = FAILED;
|
||||||
} else {
|
} else {
|
||||||
@ -433,8 +411,6 @@ InstallTransaction::installPackage( const Package* package,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_config->writeLog() ) {
|
if ( m_config->writeLog() ) {
|
||||||
|
|
||||||
@ -568,7 +544,7 @@ void InstallTransaction::checkDependencies( bool greedy,
|
|||||||
if ( pos != string::npos && (pos+1) < softdep.length() ) {
|
if ( pos != string::npos && (pos+1) < softdep.length() ) {
|
||||||
softdep = softdep.substr( pos + 1 );
|
softdep = softdep.substr( pos + 1 );
|
||||||
}
|
}
|
||||||
if ( m_pkgDB->isInstalled(softdep, true) ) {
|
if ( m_pkgDB->isInstalled(softdep, false) or isRequested(softdep) ) {
|
||||||
const Package* p = m_repo->getPackage( softdep );
|
const Package* p = m_repo->getPackage( softdep );
|
||||||
if ( p ) {
|
if ( p ) {
|
||||||
checkDependencies( true, p, index );
|
checkDependencies( true, p, index );
|
||||||
@ -586,6 +562,16 @@ void InstallTransaction::checkDependencies( bool greedy,
|
|||||||
treeWalk.pop_back();
|
treeWalk.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Method to determine whether a package was passed on the command line
|
||||||
|
*/
|
||||||
|
bool InstallTransaction::isRequested(const string pname) {
|
||||||
|
list< pair<string, const Package*> >::iterator it = m_packages.begin();
|
||||||
|
for ( ; it != m_packages.end(); ++it ) {
|
||||||
|
if ( it->first == pname ) { return true; }
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
This method returns a list of packages which should be installed to
|
This method returns a list of packages which should be installed to
|
||||||
@ -638,11 +624,11 @@ InstallTransaction::installedPackages() const
|
|||||||
/*!
|
/*!
|
||||||
calculate dependendencies for this package
|
calculate dependendencies for this package
|
||||||
*/
|
*/
|
||||||
InstallTransaction::InstallResult
|
bool InstallTransaction::calcDependencies( )
|
||||||
InstallTransaction::calcDependencies( )
|
|
||||||
{
|
{
|
||||||
if ( m_packages.empty() ) {
|
if ( m_packages.empty() ) {
|
||||||
return NO_PACKAGE_GIVEN;
|
cout << "No packages given for this transaction" << endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool validPackages = false;
|
bool validPackages = false;
|
||||||
@ -656,13 +642,15 @@ InstallTransaction::calcDependencies( )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !validPackages ) {
|
if ( !validPackages ) {
|
||||||
return PACKAGE_NOT_FOUND;
|
cout << "No valid packages in this transaction" << endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !calculateDependencies() ) {
|
if ( !calculateDependencies() ) {
|
||||||
return CYCLIC_DEPEND;
|
cout << "Could not resolve dependencies for this transaction" << endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return SUCCESS;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,10 +33,6 @@ class Configuration;
|
|||||||
class InstallTransaction
|
class InstallTransaction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InstallTransaction( const list<char*>& names,
|
|
||||||
const Repository* repo,
|
|
||||||
PkgDB* pkgDB,
|
|
||||||
const Configuration* config );
|
|
||||||
InstallTransaction( const list<string>& names,
|
InstallTransaction( const list<string>& names,
|
||||||
const Repository* repo,
|
const Repository* repo,
|
||||||
PkgDB* pkgDB,
|
PkgDB* pkgDB,
|
||||||
@ -54,7 +50,7 @@ public:
|
|||||||
/*! Result of an installation */
|
/*! Result of an installation */
|
||||||
enum InstallResult {
|
enum InstallResult {
|
||||||
SUCCESS, /*!< yeah, success */
|
SUCCESS, /*!< yeah, success */
|
||||||
NO_PACKAGE_GIVEN, /*!< no package give to install */
|
NO_PACKAGE_GIVEN, /*!< no package given to install */
|
||||||
PACKAGE_NOT_FOUND, /*!< package not found */
|
PACKAGE_NOT_FOUND, /*!< package not found */
|
||||||
PKGMK_EXEC_ERROR, /*!< can't execute pkgmk */
|
PKGMK_EXEC_ERROR, /*!< can't execute pkgmk */
|
||||||
PKGMK_FAILURE, /*!< error while pkgmk */
|
PKGMK_FAILURE, /*!< error while pkgmk */
|
||||||
@ -84,15 +80,13 @@ public:
|
|||||||
bool hasReadme;
|
bool hasReadme;
|
||||||
};
|
};
|
||||||
|
|
||||||
InstallResult install( const ArgParser* parser,
|
InstallResult install( const ArgParser* parser );
|
||||||
bool update );
|
bool calcDependencies();
|
||||||
InstallResult calcDependencies();
|
|
||||||
|
|
||||||
const list< pair<string, InstallInfo> >& installedPackages() const;
|
const list< pair<string, InstallInfo> >& installedPackages() const;
|
||||||
const list<string>& alreadyInstalledPackages() const;
|
const list<string>& alreadyInstalledPackages() const;
|
||||||
const list<string>& ignoredPackages() const;
|
const list<string>& ignoredPackages() const;
|
||||||
|
|
||||||
|
|
||||||
const list<string>& dependencies() const;
|
const list<string>& dependencies() const;
|
||||||
const list< pair<string,string> >& missing() const;
|
const list< pair<string,string> >& missing() const;
|
||||||
const list< pair<string, InstallInfo> >& installError() const;
|
const list< pair<string, InstallInfo> >& installError() const;
|
||||||
@ -108,6 +102,7 @@ private:
|
|||||||
const ArgParser* parser,
|
const ArgParser* parser,
|
||||||
bool update,
|
bool update,
|
||||||
InstallInfo& info ) const;
|
InstallInfo& info ) const;
|
||||||
|
bool isRequested(const string pname);
|
||||||
|
|
||||||
static string getPkgmkSetting(const string& setting);
|
static string getPkgmkSetting(const string& setting);
|
||||||
static string getPkgmkSettingFromFile(const string& setting,
|
static string getPkgmkSettingFromFile(const string& setting,
|
||||||
|
55
src/main.cpp
55
src/main.cpp
@ -57,17 +57,13 @@ int main( int argc, char** argv )
|
|||||||
|
|
||||||
|
|
||||||
ArgParser::Type command = argParser.commandType();
|
ArgParser::Type command = argParser.commandType();
|
||||||
switch ( command )
|
switch ( command ) {
|
||||||
{
|
|
||||||
case ArgParser::HELP:
|
case ArgParser::HELP:
|
||||||
prtGet.printUsage();
|
prtGet.printUsage();
|
||||||
break;
|
break;
|
||||||
case ArgParser::SHOW_VERSION:
|
case ArgParser::SHOW_VERSION:
|
||||||
prtGet.printVersion();
|
prtGet.printVersion();
|
||||||
break;
|
break;
|
||||||
case ArgParser::LIST:
|
|
||||||
prtGet.listPackages();
|
|
||||||
break;
|
|
||||||
case ArgParser::DUP:
|
case ArgParser::DUP:
|
||||||
prtGet.listShadowed();
|
prtGet.listShadowed();
|
||||||
break;
|
break;
|
||||||
@ -84,25 +80,16 @@ int main( int argc, char** argv )
|
|||||||
prtGet.isInstalled();
|
prtGet.isInstalled();
|
||||||
break;
|
break;
|
||||||
case ArgParser::INSTALL:
|
case ArgParser::INSTALL:
|
||||||
prtGet.install();
|
prtGet.install( argParser.depSort() );
|
||||||
break;
|
|
||||||
case ArgParser::DEPINST:
|
|
||||||
prtGet.install( false, true );
|
|
||||||
break;
|
break;
|
||||||
case ArgParser::DEPENDS:
|
case ArgParser::DEPENDS:
|
||||||
prtGet.printDepends();
|
prtGet.printDepends( argParser.quick() );
|
||||||
break;
|
break;
|
||||||
case ArgParser::QUICKDEP:
|
case ArgParser::DEPTREE:
|
||||||
prtGet.printDepends( true );
|
prtGet.printDepTree();
|
||||||
break;
|
|
||||||
case ArgParser::UPDATE:
|
|
||||||
prtGet.install( true );
|
|
||||||
break;
|
break;
|
||||||
case ArgParser::DIFF:
|
case ArgParser::DIFF:
|
||||||
prtGet.printDiff();
|
prtGet.printDiff( argParser.quick() );
|
||||||
break;
|
|
||||||
case ArgParser::QUICKDIFF:
|
|
||||||
prtGet.printQuickDiff();
|
|
||||||
break;
|
break;
|
||||||
case ArgParser::CREATE_CACHE:
|
case ArgParser::CREATE_CACHE:
|
||||||
prtGet.createCache();
|
prtGet.createCache();
|
||||||
@ -110,36 +97,36 @@ int main( int argc, char** argv )
|
|||||||
case ArgParser::PATH:
|
case ArgParser::PATH:
|
||||||
prtGet.printPath();
|
prtGet.printPath();
|
||||||
break;
|
break;
|
||||||
case ArgParser::LISTINST:
|
|
||||||
prtGet.listInstalled();
|
|
||||||
break;
|
|
||||||
case ArgParser::PRINTF:
|
case ArgParser::PRINTF:
|
||||||
prtGet.printf();
|
prtGet.printf();
|
||||||
break;
|
break;
|
||||||
case ArgParser::README:
|
case ArgParser::README:
|
||||||
prtGet.readme();
|
prtGet.readme();
|
||||||
break;
|
break;
|
||||||
case ArgParser::DEPENDENT:
|
|
||||||
prtGet.printDependent();
|
|
||||||
break;
|
|
||||||
case ArgParser::SYSUP:
|
|
||||||
prtGet.sysup();
|
|
||||||
break;
|
|
||||||
case ArgParser::CURRENT:
|
case ArgParser::CURRENT:
|
||||||
prtGet.current();
|
prtGet.current();
|
||||||
break;
|
break;
|
||||||
case ArgParser::FSEARCH:
|
case ArgParser::FSEARCH:
|
||||||
prtGet.fsearch();
|
prtGet.fsearch();
|
||||||
break;
|
break;
|
||||||
|
case ArgParser::LIST:
|
||||||
|
prtGet.listPackages();
|
||||||
|
break;
|
||||||
|
case ArgParser::LISTINST:
|
||||||
|
prtGet.listInstalled();
|
||||||
|
break;
|
||||||
|
case ArgParser::LISTORPHANS:
|
||||||
|
prtGet.listOrphans();
|
||||||
|
break;
|
||||||
|
case ArgParser::LISTLOCKED:
|
||||||
|
prtGet.listLocked();
|
||||||
|
break;
|
||||||
case ArgParser::LOCK:
|
case ArgParser::LOCK:
|
||||||
prtGet.setLock( true );
|
prtGet.setLock( true );
|
||||||
break;
|
break;
|
||||||
case ArgParser::UNLOCK:
|
case ArgParser::UNLOCK:
|
||||||
prtGet.setLock( false );
|
prtGet.setLock( false );
|
||||||
break;
|
break;
|
||||||
case ArgParser::LISTLOCKED:
|
|
||||||
prtGet.listLocked();
|
|
||||||
break;
|
|
||||||
case ArgParser::CAT:
|
case ArgParser::CAT:
|
||||||
prtGet.cat();
|
prtGet.cat();
|
||||||
break;
|
break;
|
||||||
@ -152,15 +139,9 @@ int main( int argc, char** argv )
|
|||||||
case ArgParser::REMOVE:
|
case ArgParser::REMOVE:
|
||||||
prtGet.remove();
|
prtGet.remove();
|
||||||
break;
|
break;
|
||||||
case ArgParser::DEPTREE:
|
|
||||||
prtGet.printDependTree();
|
|
||||||
break;
|
|
||||||
case ArgParser::DUMPCONFIG:
|
case ArgParser::DUMPCONFIG:
|
||||||
prtGet.dumpConfig();
|
prtGet.dumpConfig();
|
||||||
break;
|
break;
|
||||||
case ArgParser::LISTORPHANS:
|
|
||||||
prtGet.listOrphans();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
cerr << "unknown command" << endl;
|
cerr << "unknown command" << endl;
|
||||||
break;
|
break;
|
||||||
|
@ -32,6 +32,7 @@ public:
|
|||||||
bool useAlias = false,
|
bool useAlias = false,
|
||||||
bool* isAlias = 0,
|
bool* isAlias = 0,
|
||||||
string* aliasOrignalName = 0 ) const;
|
string* aliasOrignalName = 0 ) const;
|
||||||
|
bool isOutdated( const std::string& name ) const;
|
||||||
|
|
||||||
|
|
||||||
std::string getPackageVersion( const std::string& name ) const;
|
std::string getPackageVersion( const std::string& name ) const;
|
||||||
|
918
src/prtget.cpp
918
src/prtget.cpp
File diff suppressed because it is too large
Load Diff
38
src/prtget.h
38
src/prtget.h
@ -55,22 +55,25 @@ public:
|
|||||||
void listPackages();
|
void listPackages();
|
||||||
void listShadowed();
|
void listShadowed();
|
||||||
void listInstalled();
|
void listInstalled();
|
||||||
|
void listOrphans();
|
||||||
|
void listLocked();
|
||||||
|
void setLock( bool lock );
|
||||||
|
|
||||||
void searchPackages( bool searchDesc=false );
|
void searchPackages( bool searchDesc=false );
|
||||||
|
void fsearch();
|
||||||
|
|
||||||
void printInfo();
|
void printInfo();
|
||||||
void isInstalled();
|
void isInstalled();
|
||||||
|
bool isOutdated();
|
||||||
|
void current();
|
||||||
void readme();
|
void readme();
|
||||||
|
|
||||||
void install( bool update=false,
|
void install( bool dependencies=false );
|
||||||
bool dependencies=false );
|
void remove();
|
||||||
void sysup();
|
|
||||||
void current();
|
|
||||||
void printDepends( bool simpleListing=false );
|
void printDepends( bool simpleListing=false );
|
||||||
void printDependTree();
|
void printDiff( bool simpleListing=false );
|
||||||
void printDependent();
|
void printDepTree();
|
||||||
void printDiff();
|
|
||||||
void printQuickDiff();
|
|
||||||
void listOrphans();
|
|
||||||
|
|
||||||
void createCache();
|
void createCache();
|
||||||
|
|
||||||
@ -80,14 +83,6 @@ public:
|
|||||||
void cat();
|
void cat();
|
||||||
void ls();
|
void ls();
|
||||||
void edit();
|
void edit();
|
||||||
|
|
||||||
void remove();
|
|
||||||
|
|
||||||
void setLock( bool lock );
|
|
||||||
void listLocked();
|
|
||||||
|
|
||||||
void fsearch();
|
|
||||||
|
|
||||||
void dumpConfig();
|
void dumpConfig();
|
||||||
|
|
||||||
int returnValue() const;
|
int returnValue() const;
|
||||||
@ -96,14 +91,10 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void printDepsLevel(int indent, const Package* package, bool greedy);
|
void printDepsLevel(int level, const Package* package, bool greedy);
|
||||||
|
|
||||||
void printDependent(const std::string& dep, int level);
|
void executeTransaction( InstallTransaction& transaction );
|
||||||
|
|
||||||
void executeTransaction( InstallTransaction& transaction,
|
|
||||||
bool update );
|
|
||||||
void evaluateResult( InstallTransaction& transaction,
|
void evaluateResult( InstallTransaction& transaction,
|
||||||
bool update,
|
|
||||||
bool interrupted=false );
|
bool interrupted=false );
|
||||||
void reportPrePost(const InstallTransaction::InstallInfo& info);
|
void reportPrePost(const InstallTransaction::InstallInfo& info);
|
||||||
|
|
||||||
@ -122,7 +113,6 @@ protected:
|
|||||||
const string& version2,
|
const string& version2,
|
||||||
bool locked);
|
bool locked);
|
||||||
|
|
||||||
|
|
||||||
Repository* m_repo;
|
Repository* m_repo;
|
||||||
PkgDB* m_pkgDB;
|
PkgDB* m_pkgDB;
|
||||||
Configuration* m_config;
|
Configuration* m_config;
|
||||||
|
@ -86,12 +86,26 @@ const Package* Repository::getPackage( const string& name ) const
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\param name the package name to be matched
|
||||||
|
\return the version-release in the repository
|
||||||
|
*/
|
||||||
|
std::string Repository::getPackageVersion( const string& name ) const
|
||||||
|
{
|
||||||
|
map<string, Package*>::const_iterator it = m_packageMap.find( name );
|
||||||
|
if ( it == m_packageMap.end() ) {
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
const Package* p = it->second;
|
||||||
|
string result = p->version()+"-"+p->release();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Search packages for a match of \a pattern in name, and description of
|
Search packages for a match of \a pattern in name, or in description if
|
||||||
\a searchDesc is true.
|
\a searchDesc is true.
|
||||||
\note Name searches can often done without opening the Pkgfiles, but not
|
\note Name searches can often be done without opening the Pkgfiles, but not
|
||||||
description search. Therefore, the later is much slower
|
description search. Therefore, the latter is much slower
|
||||||
|
|
||||||
\param pattern the pattern to be found
|
\param pattern the pattern to be found
|
||||||
\param searchDesc whether descriptions should be searched as well
|
\param searchDesc whether descriptions should be searched as well
|
||||||
@ -188,11 +202,10 @@ void Repository::initFromFS( const list< pair<string, string> >& rootList,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: think about whether it would be faster (more
|
// TODO: think about whether it would be faster (more efficient)
|
||||||
// efficient) to put all packages into a map, and the iterate
|
// to put all packages into a map, and then iterate
|
||||||
// over the list of allowed packages and copy them
|
// over the list of allowed packages and copy them over.
|
||||||
// over. depending in the efficiency of find(), this might be
|
// Depending on the efficiency of find(), this might be faster.
|
||||||
// faster
|
|
||||||
d = opendir( path.c_str() );
|
d = opendir( path.c_str() );
|
||||||
while ( ( de = readdir( d ) ) != NULL ) {
|
while ( ( de = readdir( d ) ) != NULL ) {
|
||||||
name = de->d_name;
|
name = de->d_name;
|
||||||
@ -390,6 +403,37 @@ bool Repository::createOutputDir( const string& path )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
look for any port mentioning \a pattern as a dependency or soft dependency.
|
||||||
|
searchOptionals=false (the default) only searches the "Depends on:" line.
|
||||||
|
The output will need to be trimmed afterward, because in this namespace we
|
||||||
|
can't check whether the matching ports are installed.
|
||||||
|
*/
|
||||||
|
void Repository::getDependentPackages( const string& pattern,
|
||||||
|
list<Package*>& target,
|
||||||
|
bool searchOptionals ) const {
|
||||||
|
|
||||||
|
map<string, Package*>::const_iterator im = m_packageMap.begin();
|
||||||
|
for ( ; im != m_packageMap.end(); ++im ) {
|
||||||
|
Package* q = im->second; string s;
|
||||||
|
if (searchOptionals) {
|
||||||
|
s = toLowerCase(q->optionals());
|
||||||
|
} else {
|
||||||
|
s = toLowerCase(q->dependencies());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( s.find( pattern ) != string::npos ) {
|
||||||
|
list<string> tokens;
|
||||||
|
split( s, ',', tokens );
|
||||||
|
list<string>::iterator ik = find( tokens.begin(),
|
||||||
|
tokens.end(), pattern );
|
||||||
|
if ( ik != tokens.end() ) {
|
||||||
|
target.push_back( q );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Search packages for a match of \a pattern in name. The name can
|
Search packages for a match of \a pattern in name. The name can
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "package.h"
|
#include "package.h"
|
||||||
|
#include "stringhelper.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Repository
|
\class Repository
|
||||||
@ -33,6 +34,7 @@ public:
|
|||||||
~Repository();
|
~Repository();
|
||||||
|
|
||||||
const Package* getPackage( const string& name ) const;
|
const Package* getPackage( const string& name ) const;
|
||||||
|
std::string getPackageVersion( const string& name ) const;
|
||||||
const map<string, Package*>& packages() const;
|
const map<string, Package*>& packages() const;
|
||||||
const list<pair<Package*, Package*> >& shadowedPackages() const;
|
const list<pair<Package*, Package*> >& shadowedPackages() const;
|
||||||
|
|
||||||
@ -40,6 +42,10 @@ public:
|
|||||||
list<Package*>& target,
|
list<Package*>& target,
|
||||||
bool searchDesc ) const;
|
bool searchDesc ) const;
|
||||||
|
|
||||||
|
void getDependentPackages( const string& pattern,
|
||||||
|
list<Package*>& target,
|
||||||
|
bool searchOptionals ) const;
|
||||||
|
|
||||||
void getMatchingPackages( const string& pattern,
|
void getMatchingPackages( const string& pattern,
|
||||||
list<Package*>& target ) const;
|
list<Package*>& target ) const;
|
||||||
|
|
||||||
|
@ -155,5 +155,4 @@ string replaceAll( string& in,
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}; // Namespace
|
}; // Namespace
|
||||||
|
Loading…
Reference in New Issue
Block a user