diff -Nru dpkg-www-2.60/debian/changelog dpkg-www-2.61/debian/changelog --- dpkg-www-2.60/debian/changelog 2019-10-13 21:41:18.000000000 +0000 +++ dpkg-www-2.61/debian/changelog 2020-12-30 01:18:20.000000000 +0000 @@ -1,3 +1,16 @@ +dpkg-www (2.61) unstable; urgency=medium + + * Switch to debhelper compatibility level 13. + * Switch to Standards-Version 4.5.1 (no changes needed). + * Mark dpkg-www package as Multi-Arch: foreign. + * Use dpkg-parsechangelog in upstream build system. + * Do not replace version in source dpkg CGI script at build time, instead + create a replaced file to install. + * Rewrite man pages from groff to POD. + * Update copyright years. + + -- Guillem Jover Wed, 30 Dec 2020 02:18:20 +0100 + dpkg-www (2.60) unstable; urgency=medium * Bump Standards-Version to 4.4.1 (no changes needed). diff -Nru dpkg-www-2.60/debian/control dpkg-www-2.61/debian/control --- dpkg-www-2.60/debian/control 2019-10-13 21:41:18.000000000 +0000 +++ dpkg-www-2.61/debian/control 2020-12-30 01:18:20.000000000 +0000 @@ -7,12 +7,13 @@ Vcs-Browser: https://git.dpkg.org/git/dpkg/dpkg-www.git Rules-Requires-Root: no Build-Depends: - debhelper-compat (= 12), + debhelper-compat (= 13), dh-apache2, -Standards-Version: 4.4.1 +Standards-Version: 4.5.1 Package: dpkg-www Architecture: all +Multi-Arch: foreign Depends: ${misc:Depends}, dpkg (>= 1.19.3), diff -Nru dpkg-www-2.60/debian/copyright dpkg-www-2.61/debian/copyright --- dpkg-www-2.60/debian/copyright 2019-10-13 21:41:18.000000000 +0000 +++ dpkg-www-2.61/debian/copyright 2020-12-30 01:18:20.000000000 +0000 @@ -6,7 +6,7 @@ 1999-2006 Massimo Dal Zotto 2008 Raphael Geissert 2015 Jean-Michel Nirgal Vourgère - 2017, 2019 Guillem Jover + 2017, 2019-2020 Guillem Jover License: GPL-2+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff -Nru dpkg-www-2.60/Makefile dpkg-www-2.61/Makefile --- dpkg-www-2.60/Makefile 2019-10-13 21:41:18.000000000 +0000 +++ dpkg-www-2.61/Makefile 2020-12-30 01:18:20.000000000 +0000 @@ -1,16 +1,33 @@ # Makefile -PKGNAME = $(shell head -1 debian/changelog | sed 's/ .*//') -VERSION = $(shell head -1 debian/changelog | sed 's/.*(//;s/).*//;s/-.*//') +PKGNAME = $(shell dpkg-parsechangelog -SSource) +VERSION = $(shell dpkg-parsechangelog -SVersion) +RELTIME = $(shell dpkg-parsechangelog -STimestamp) +PODDATE = $(shell TZ=UTC0 LC_ALL=C date '+%F' --date="@$(RELTIME)") -all: +POD2MAN = pod2man + +MANS = src/dpkg-www.1 src/dpkg-www.8 + +all: src/dpkg $(MANS) + +src/dpkg: src/dpkg-cgi # Update program version from changelog - if ! grep -q "^PROG_VERSION=$(VERSION)$$" src/dpkg; then \ - sed '/^PROG_VERSION=/s/^.*$$/PROG_VERSION=$(VERSION)/' \ - < src/dpkg > src/dpkg.new; \ - mv -f src/dpkg.new src/dpkg; \ - chmod 755 src/dpkg; \ - fi + sed '/^PROG_VERSION=/s/^.*$$/PROG_VERSION=$(VERSION)/' <$< >$@ + chmod 755 $@ + +%: %.pod + $(POD2MAN) \ + --section=$(subst .,,$(suffix $@)) \ + --name=$(basename $@) \ + --center="Debian Project" \ + --date="$(PODDATE)" \ + --release="$(VERSION)" \ + $< >$@ + +clean: + $(RM) src/dpkg + $(RM) $(MANS) dist: git archive \ diff -Nru dpkg-www-2.60/src/dpkg dpkg-www-2.61/src/dpkg --- dpkg-www-2.60/src/dpkg 2019-10-13 21:41:18.000000000 +0000 +++ dpkg-www-2.61/src/dpkg 1970-01-01 00:00:00.000000000 +0000 @@ -1,1473 +0,0 @@ -#!/bin/bash -# -# CGI interface to dpkg. Show information about debian packages. -# -# Copyright © 1999-2006 Massimo Dal Zotto -# Copyright © 2017, 2019 Guillem Jover -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -PROG_VERSION=2.60 -SELF=${0##*/}; export SELF -HELP_PAGE="/usr/share/man/man8/dpkg-www.8.gz" -COLUMNS=256; export COLUMNS -SECTION_DESCRIPTIONS=" -admin Administrative utilities (install software, manage users, etc) -base Basic needed utilities of every Debian system -cli-mono Mono and the Common Language Infrastructure -comm Programs for faxmodems and other communication devices -database Database servers and tools -debug Debug symbols -devel Utilities and programs for software development -doc Documentation and specialized programs for viewing documentation -editors Text editors and word processors -education Software, documentation or data related to educational activities -electronics Programs for working with circuits and electronics -embedded Programs for embedded systems -fonts Fonts and font utilities -games Games, toys, and fun programs -gnome The GNOME Desktop Environment -gnu-r The GNU R statistical computation and graphics system -gnustep The GNUstep Environment -golang Go programming language, libraries, and development tools -graphics Utilities to create, view, and edit graphics files -hamradio Software for ham radio operators -haskell Haskell programming language and libraries -httpd Webservers and their modules -interpreters Interpreters for interpreted languages and macro processors -introspection Introspection support for programming languages -java Java programming language and libraries -javascript JavaScript programming language, libraries, and development tools -kde The KDE Desktop Environment -kernel Kernel and kernel modules -libdevel Development files for libraries -libs Collections of software routines -lisp Lisp programming language and libraries -localization Language packs -mail Programs to write, send, and route email messages -math Numeric analysis and other mathematics-related software -metapackages Packages which solely depend on other packages -misc Miscellaneous software -net Programs to connect to and provide various services -news Usenet clients and servers -ocaml OCaml programming language and libraries -oldlibs Obsolete libraries -otherosfs Emulators and software to read foreign filesystems -perl Perl programming language and libraries -php PHP programming language and libraries -python Python programming language and libraries -ruby Ruby programming language and libraries -rust Rust programming language, library crates, and development tools -science Software for scientific work -shells Command shells and alternative console environments -sound Utilities to play and record sound -tex The TeX typesetting system -text Text processing utilities -utils Various system utilities -vcs Version control systems -video Utilities to record, view, edit, and stream video files -web Web browsers, servers, proxies, and other tools -x11 The X window system and related software -xfce The Xfce Desktop Environment -zope Zope/Plone framework -" - -TASK_DESCRIPTIONS=" -basic-desktop X window system -c-dev C and C++ -chinese-s simplified Chinese environment -chinese-t traditional Chinese environment -cyrillic Cyrillic environment -database-server SQL database -desktop desktop environment -dialup dialup system -dns-server DNS server -file-server file server -fortran-dev fortran -french French environment -games games -german German environment -japanese Japanese environment -junior Debian Jr. -korean Korean environment -laptop laptop system -mail-server mail server -news-server usenet news server -polish Polish environment -print-server print server -python-dev Python -russian Russian environment -science scientific applications -spanish Spanish environment -tcltk-dev Tcl/Tk -tex TeX/LaTeX environment -unix-server conventional unix server -web-server web server -" - -# Configuration defaults, can be overridden in /etc/dpkg-www.conf -# -SHOW_LOCAL_FILES=auto # Show local files directly (automatic) -LIST_UNAVAILABLE=0 # List also unavailable packages -LIST_DOCUMENTATION=1 # List registered package documentation -DPKG=auto # Select the dpkg program (automatic) -MAN=auto # Select the man program (automatic) -DEBIAN_CONTENTS= # List of Contents-xxx.gz files -INSTALLED_ONLY=0 # Only installed packages -TASK_DESCRIPTIONS_FILE=/usr/share/tasksel/debian-tasks.desc -APT_CACHE_OPTS="-o APT::Cache::AllVersions=0" -CHECK_PACKAGE_VERSION=true -DPKG_WWW_BROWSER_HACK=false -GREP_DCTRL_OPTS="-i" -BGCOLOR="#c0c0c0" -KEEP_INPUT=0 -DEBUG=0 -DWWW_PATH="/cgi-bin/dwww" -INFO2WWW_PATH="/cgi-bin/info2www" - -# Install buttons support. This require that users define the following -# mime action in their netscape mailcap file: -# -# application/dpkg-www-installer;/usr/sbin/dpkg-www-installer -f '%s' -# -CHECK_BUTTONS=0 # Enable install check-buttons in package list -INSTALL_BUTTON=0 # Enable install button in package info - -# Source optional local configuration file -test -e /etc/dpkg-www.conf && . /etc/dpkg-www.conf 2>/dev/null -set -o noglob - -HOSTNAME_FULL="$(hostname -f)" -HOSTNAME="${HOSTNAME_FULL%%.*}" - -# Use dlocate, if installed, to speedup certain queries -if [ ! "$DPKG" -o "$DPKG" = auto ]; then - if [ -x /usr/bin/dlocate ]; then - DPKG=dlocate - else - DPKG=dpkg-query - fi -fi - -# Select the Manpage to HTML translator -if [ "$MAN" = dwww ]; then - MAN="${DWWW_PATH}?type=man\\\\&location=" -fi -if [ "$MAN" = man2html ]; then - if [ -x /usr/lib/cgi-bin/man/man2html ]; then - MAN="/cgi-bin/man/man2html?" - elif [ -x /usr/lib/cgi-bin/man2html ]; then - MAN="/cgi-bin/man2html?" - else - MAN="${DWWW_PATH}?type=man\\\\&location=" - fi -fi -if [ ! "$MAN" -o "$MAN" = auto ]; then - if [ -x /usr/lib/cgi-bin/man/man2html ]; then - MAN="/cgi-bin/man/man2html?" - elif [ -x /usr/lib/cgi-bin/man2html ]; then - MAN="/cgi-bin/man2html?" - else - MAN="${DWWW_PATH}?type=man\\\\&location=" - fi -fi - -# If remote host is localhost generate local URL's for local files -case "$REMOTE_HOST" in - localhost|$HOSTNAME|$HOSTNAME_FULL) - if [ ! "$SHOW_LOCAL_FILES" -o "$SHOW_LOCAL_FILES" = auto ]; then - SHOW_LOCAL_FILES=true - fi - if [ "$HTTP_USER_AGENT" != "${HTTP_USER_AGENT#*Mozilla/[56]}" ]; then - # It seems that Mozilla/5.0 refuses to access local files from - # a web page for security reasons. - SHOW_LOCAL_FILES=false - fi - ;; - *) - SHOW_LOCAL_FILES=false - ;; -esac - -# Print a short help for the cgi-program -usage() { - cat <<- EOF -

- You can query information about Debian packages and installed files. - The search argument can be: -

- -
- ? - show this help page -
- * - list all packages available on your system -
- <empty> - list all packages installed on your system -
- <space> - print only the input form, for use from wm menus -
- package - list the required package and its owned files -
- list of packages - list required packages concisely -
- wildcard expression - list matching packages concisely -
- absolute pathname - list packages owning pathname -
- field=value - list packages with control field matching value -
- =value - list packages with any field matching value -
- section=? - list available package sections -
- task=? - list available tasks -
- recent=[<N>] - list packages installed in last N days (default 1) -
-

-

Examples:

-

-

- -
- * - list all packages available on your system -
- <empty> - list all packages installed on your system -
- binutils - list verbosely the package binutils -
- dpkg apt - list the dpkg and apt packages -
- jpeg* - list packages with name beginning with "jpeg" -
- *jpeg* - list packages with name containing "jpeg" -
- /usr/bin/tail - list packages owning the file /usr/bin/tail -
- /.*/postfix - list packages owning any file named "postfix" (1) -
- /.*pbm.* - list packages owning any file matching *pbm* (1) -
- maintainer=Joey Hess - list packages with maintainer Joey Hess (2) -
- section=net - list packages with section net (2) -
- =firewall - list packages with any field matching "firewall" (2) -
- section=? - list available package sections -
- task=? - list available tasks -
- recent=2 - list packages installed in last 2 days -
- - - - package hello - install the package hello (3) -
- - - - package hello - remove the package hello (3) -
-
-

- (1) The regexp form can be used to query also packages owning files - not installed on your system. However this works only if you have - properly configured the variable DEBIAN_CONTENTS in the - configuration file /etc/dpkg-www.conf. - This query can be used to find which package you should install - in order to get some missing command or file. - Note that the leading '/' is required to distinguish filename - queries from package queries. -

- (2) This works only if the - grep-dctrl package is installed. -

- (3) This works only if INSTALL_BUTTON=1 has been set in the - configuration file /etc/dpkg-www.conf, your browser has - been configured to handle web installation requests and, of course, - you know the root password. - See dpkg-www(8) - man page for more information. -

-EOF -} - -debug() { - test_flag "$DEBUG" && echo "$(escape_html "$*")
" -} - -test_flag() { - case "$1" in - 0|false|n|no|"") return 1 ;; - *) return 0 ;; - esac -} - -# Sanity check on input values -checkInput() { - if echo "$*" | grep -q '[(){}<>$%#&!|\\;`]'; then - printError "Error: invalid input" - exit - fi -} - -# Execute the query -doQuery() { - debug "doQuery $1" - local query="$1" - case "${query%/}" in - \?|-\?|-h|-help|--help) - usage - ;; - " ") - return - ;; - -*) - printError "Invalid keyword: $query" - exit - ;; - /*) - queryOwners "$query" - ;; - *=*) - queryPackagesByField "$query" - ;; - *) - checkInput "$query" - queryPackages "$query" - ;; - esac -} - -# Query one or more packages -queryPackages() { - debug "queryPackages $*" - local packages="$*" - local package="${packages%% *}" - if [ ! "$packages" ]; then - # No argument, show the package list - debug "no arguments" - listPackages - elif [ "$package" != "$packages" -o "$packages" != "${packages#*[\[*?]}" ] - then - # Package list or wildcard, list packages concisely - debug "package list" - listPackages $packages - else - # One package, show package information - debug "one package" - listPackage $package - fi -} - -# Query one or more packages by control field value -queryPackagesByField() { - field="${*%%=*}"; arg="${*#$field}"; arg="${arg#=}" - field="${field## }"; field="${field%% }" - arg="${arg## }"; arg="${arg%% }" - if [ "$field" = section -a "$arg" = "?" ]; then - listSections - return - fi - if [ "$field" = task -a "$arg" = "?" ]; then - listTasks - return - fi - if [ "$field" = recent -o "$field" = new ]; then - listRecentPackages $arg - return - fi - if [ "$field" != "" -a ! -x /usr/bin/grep-dctrl ]; then - echo "
"
-	echo -n "Error: the "
-	echo -n "grep-dctrl"
-	echo " command is not installed on your system"
-	echo "
" - return - fi - echo "
"
-    echo "Packages with $(escape_html "${field:-any field matching} $arg")"
-    echo ""
-    {
-	if [ -x /usr/bin/grep-dctrl ]; then
-	    ( dpkg-query -s; dpkg-query -p ) \
-	       | grep-dctrl $GREP_DCTRL_OPTS -s Package -F "$field" "$arg"
-	else
-	    apt-cache search "$arg" | sed 's/ .*//;s/^/Package: /'
-	fi
-	dpkg-query -l "*" 2>&1
-    } \
-    | awk '
-	/^Package:/ { p[$2]=1; NR=0; next }
-	(NR <= 5) { print }
-	(p[$2] != 1) { next }
-	{ print }' \
-    | listFilter
-    echo "
" -} - -# List available sections -listSections() { - sections=$( - ( dpkg-query -s; dpkg-query -p ) | grep -h "^Section:" \ - | sed 's|.*:[ ]*||; s|.*/||' | sort | uniq | grep -v "^non-" - ) - echo "
"
-    echo "Available sections:"
-    echo ""
-    for s in $sections; do
-	desc=$(
-	    echo "$SECTION_DESCRIPTIONS" | sed "/^$s/!d; s/^$s[	 ]*//;q"
-	)
-	desc=${desc:="no description available"}
-	x=$(printf "%$[16-${#s}]s" " ")
-	echo "  ${s}${x} ${desc}"
-    done
-    echo "
" -} - -# List available tasks -listTasks() { - tasks=$( - ( dpkg-query -s; dpkg-query -p ) | grep -h "^Task:" \ - | sed 's|.*:[ ]*||; s|,[ ]*|\ -|g' | sort | uniq - ) - echo "
"
-    echo "Available tasks:"
-    echo ""
-    for t in $tasks; do
-	desc=$(
-	    if [ -e "$TASK_DESCRIPTIONS_FILE" ]; then
-		cat "$TASK_DESCRIPTIONS_FILE" 2>/dev/null | awk -v t="$t" '
-		    /^Task:/ { task = $2 }
-		    /^Description:/ && (task == t) {
-			sub($1"[ ]*",""); print; exit
-		    }'
-	    else
-		echo "$TASK_DESCRIPTIONS" | sed "/^$t/!d; s/^$t[ 	]*//;q"
-	    fi
-	)
-	desc=${desc:="no description available"}
-	x=$(printf "%$[16-${#t}]s" " ")
-	echo "  ${t}${x} ${desc}"
-    done
-    echo "
" -} - -# List recent packages -listRecentPackages() { - n=${1:-1} - s=$( - N=$n perl -MTime::Piece -MTime::Seconds -E '\ - my $o = localtime->truncate(to => "day") - \ - Time::Seconds->new($ARGV[0] * ONE_DAY); \ - print $o->epoch;' \ - ) - packages=$( - dpkg-query -f '${db-fsys:Last-Modified} ${binary:Package}\n' -W \ - | S=$s perl -n -E '(@field) = split " "; \ - print "$field[1] " if $field[0] > $ENV{S};' \ - ) - if [ "$packages" ]; then - echo "
"
-	echo "Recent packages in last $n days:"
-	echo ""
-	dpkg-query -l $packages 2>&1 | listFilter
-	echo "
" - else - echo "
"
-	echo "No recent packages in last $n days"
-	echo "
" - fi -} - -# List one or more packages concisely -listPackages() { - debug "listPackages $*" - echo "
"
-    dpkg-query -l "$@" 2>&1 | listFilter
-    echo "
" -} - -# List a single package -# -listPackage() { - debug "listPackage $*" - local package="$1" - local installed - local status - local version - local latest - local priority - local essential - - pkg_info="$(dpkg-query -s $package)" - if [ ! "$pkg_info" ]; then - # Unknown package or virtual package - listVirtualPackage $package || listUnknownPackage $package - return 1 - fi - - status="$(echo "$pkg_info" | awk '/^Status:/ {print $4}')" - # installed The package is unpacked and configured OK. - # half-installed The installation has started but not completed. - # not-installed The package is not installed on your system. - # unpacked The package is unpacked, but not configured. - # half-configured The package configuration has not completed. - # config-files Only the config files exist on the system. - # Handle unknown package - if [ ! "$status" ]; then - listUnknownPackage $package - return 1 - fi - - if [ "$status" = not-installed -o "$status" = config-files ]; then - if [ -x /usr/bin/apt-cache ]; then - pkg_info="$( - echo "$pkg_info" \ - | grep "^\(Package\|Status\|Priority\|Section\):" - apt-cache $APT_CACHE_OPTS show $package 2>/dev/null \ - | sed 's/^installed-size:/Installed-Size:/' \ - | grep -v -e "^\(Package\|Status\|Priority\|Section\):" \ - -e "^\(Filename\|MD5sum\|Size\):" - )" - else - pkg_info="$( - echo "$pkg_info" \ - | grep "^\(Package\|Status\|Priority\|Section\):" - dpkg-query --print-avail $package 2>/dev/null \ - | grep -v -e "^\(Package\|Status\|Priority\|Section\):" \ - -e "^\(Filename\|MD5sum\|Size\):" - )" - fi - fi - - # Check for newer version of installed package - if [ "$status" = installed ]; then - version="$(echo "$pkg_info" | awk '/^Version:/ {print $2}')" - priority="$(echo "$pkg_info" | grep ^Priority: | awk '{print $2}')" - essential="$(echo "$pkg_info" | grep ^Essential: | awk '{print $2}')" - if test_flag "$CHECK_PACKAGE_VERSION"; then - latest=$( - apt-cache $APT_CACHE_OPTS show $package \ - | grep ^Version: | awk '{print $2}' - ); latest=${latest:-$version} - if dpkg --compare-versions "$latest" gt "$version"; then - pkg_info="$( - echo "$pkg_info" \ - | sed "/^Version:/s/\$/ (latest is $latest)/" - )" - fi - else - latest="$version" - fi - fi - - echo "
"
-
-    # Print package info
-    echo "$pkg_info" | packageFilter $package
-
-    if [ "$INSTALL_BUTTON" = "top" ]; then
-	addButtons
-    fi
-
-    # Print documentation and file list
-    if [ "$status" != not-installed ]; then
-	listPackageDocumentation $package
-	listPackageFiles $package
-    fi
-
-    if [ "$INSTALL_BUTTON" != "top" ]; then
-	addButtons
-    fi
-
-    echo "
" -} - -# Add "Install", "Update" and "Remove" buttons if enabled. -addButtons() { - if [ "$status" = installed ]; then - if [ "$priority" = required -o "$essential" = yes ]; then - if [ "$version" != "$latest" ]; then - addUpgradeButton $package $latest - fi - else - if [ "$version" != "$latest" ]; then - addRemoveUpgradeButtons $package $latest - else - addRemoveButton $package - fi - fi - else - addInstallButton $package - fi -} - -# Print a "Package not installed" message and add the "Install" button -# if enabled in the configuration file. -# -addInstallButton() { - debug "addInstallButton $*" - local package="$1" - local pkgname="$package" - if test_flag "$INSTALL_BUTTON"; then - echo "
" \ - "" - echo -n \ - "Package $(escape_html "$package") is not installed." \ - "" \ - "
" - else - echo "" - echo "Package $(escape_html "$package") is not installed." - fi -} - -# Add the "Remove" button if enabled in the configuration file. -# -addRemoveButton() { - debug "addRemoveButton $*" - local package="$1" - local pkgname="$package" - if test_flag "$INSTALL_BUTTON"; then - echo "
" \ - "" - echo -n \ - "" \ - "package $package" \ - "
" - fi -} - -# Add the "Upgrade" button if enabled in the configuration file. -# -addUpgradeButton() { - debug "addUpgradeButton $*" - local package="$1" - local latest="$2" - local pkgname="$package" - if test_flag "$INSTALL_BUTTON"; then - echo "
" \ - "" - echo -n \ - "" \ - "package $package to version $latest" \ - "
" - fi -} - -# Add the "Remove" and "Upgrade" buttons if enabled in the configuration file. -# -addRemoveUpgradeButtons() { - debug "addRemoveUpgradeButtons $*" - local package="$1" - local latest="$2" - local pkgname="$package" - if test_flag "$INSTALL_BUTTON"; then - echo "
" \ - "" - echo -n \ - "" \ - "package $package. " \ - "" \ - "to version $latest" \ - "
" - fi -} - -# List all packages providing a virtual package. -# -listVirtualPackage() { - debug "listVirtualPackage $*" - local package="$1" - local packages=$( - ( dpkg-query -s; dpkg-query -p ) \ - | awk -v package=$package ' - /^Package:/ { owner = $2 } - /^Provides:/ { - gsub(",","") - for (i=2; i<=NF; i++) { if ($i == package) { print owner } } - }' \ - | sort | uniq - ) - test "$packages" || return 1 - debug "is virtual package" - echo "
"
-    echo "Virtual package $(escape_html "$package") is provided by:"
-    echo "
" - listPackages $(echo $packages) -} - -listUnknownPackage() { - debug "listUnknownPackage $*" - local package="$(escape_html "$1")" - echo "
"
-    echo "Package $package is not installed and no info is available."
-    echo "
" -} - -listPackageFiles() { - debug "listPackageFiles $*" - local package="$1" - echo - echo "Files owned by package $(escape_html "$package"):" - echo - $DPKG -L $package | sort | fileFilter -} - -# This is really ugly but I don't know a better way since install-docs -# doesn't record package ownership of documents. -# -listPackageDocumentation() { - debug "listPackageDocumentation $*" - local package="$1" - local installdocs_files - local document_id - local f - test_flag "$LIST_DOCUMENTATION" || return - test -x /usr/sbin/install-docs || return - dpkg-query --control-list $package | grep -q postinst || return - installdocs_files=$( - dpkg-query --control-show $package postinst \ - | grep 'install-docs[ ]*-i' \ - | sed 's/.*install-docs[ ]*-i[ ]*//;s/[ ].*//' \ - | sort | uniq - ) - debug "installdocs_files=$installdocs_files" - test "$installdocs_files" || return - echo - echo "Documentation:" - echo - for f in $installdocs_files; do - # Hack for postinsts with `$package' in filenames - test ! -e $f && f="$(echo "$f" | sed "s/\$package/$package/i")" - # Get document_id (this can be different than file basename) - if [ -e $f ]; then - document_id="$(grep "^Document:" "$f" | sed 's/.*: //' | head -1)" - else - document_id="${f##*/}" - fi - debug "document_id=$document_id" - title="$( - /usr/sbin/install-docs -s "$document_id" 2>/dev/null \ - | awk '/^Title: / { sub("^Title: *",""); print $0 }' - )" - /usr/sbin/install-docs -s "$document_id" 2>/dev/null \ - | awk ' - /^Format:/ { format = $2 } - /^Index: / { print $2 "\t" format } - /^Files: / { if (!match($2,"\\*")) { print $2 "\t" format } }' \ - | sort | uniq | fileFilter "$title" | sed 's/^/ /' - done -} - -# Find all packages owning a file. Must be able to handle things like: -# -# /usr/lib/games/maelstrom/Maelstrom Fonts -# /usr/share/ucblogo/logolib/# -# /usr/share/ucblogo/logolib/` -# /etc/diskless-image/config.sh -# /bin/bash -# /.*/postfix -# /.*pbm.* -# -queryOwners() { - debug "queryOwners $*" - local file="${1%/}" - local owners=$( - # Must grep the exact filename when using dlocate - $DPKG -S "$file" 2>/dev/null | grep ": $file$" | cut -f1 -d: \ - | grep -v diversion | tr -d ',' - ) - if [ "$owners" ]; then - echo "
"
-	echo "Packages owning $(escape_html "$file"):"
-	echo "
" - listPackages $owners - return - fi - - if [ "$DEBIAN_CONTENTS" ]; then - owners=$( - zcat $DEBIAN_CONTENTS 2>/dev/null \ - | grep "^${file#/}[ ][ ]*[^ ]*\$" \ - | sed "s^${file#/}[ ][ ]*; s/,/\\ -/" | sed 's|.*/||' \ - | sort | uniq - ) - fi - if [ "$owners" ]; then - echo "
"
-	echo "Packages owning $(escape_html "$file"):"
-	echo "
" - listPackages $owners - return - fi - - echo "
"
-    echo "No package is owning $(escape_html "$file")"
-    echo "
" -} - -# Convert package info to html by adding hrefs to other packages. -# -packageFilter() { - local package="$1" - local uri="" - if [ "$DPKG_WWW_BROWSER_HACK" = true -a "$SHOW_LOCAL_FILES" ]; then - uri="$(packageURI "$package")" - test "$uri" = "${uri#file:/}" && uri="" - fi - awk -v SELF=$SELF -v package="$package" -v uri="$uri" ' - { gsub("<","\\<"); gsub(">","\\>") } - /^Package:/ { - # Add link to the Debian package page for this package - p = s = package; gsub("\\+", "%2B", s) - u = "https://packages.debian.org" - $2 = sprintf("%s", u,s,p) - } - /^Section:/ { - # Add link to package section list - s = t = r = $2 - gsub("\\+", "\\+", r) - gsub("\\+", "%2B", s) - sub(r, "" t "", $2) - } - /^Task:/ { - # Add links to package tasks list - for (f=2; f<=NF; f++) { - r = $f; - gsub(",", "", r) - s = t = r - gsub("\\+", "\\+", r) - gsub("\\+", "%2B", s) - sub(r, "" t "", $f) - } - } - /^Maintainer:/ { - # Add link to maintainer packages overview - m = $0; sub(".*: ","",m);sub(" <.*","",m);gsub("[()]","\\\\&",m) - e = $0; sub(".*<","",e);sub(">.*","",e) - u = "https://qa.debian.org/developer.php?login=" e - sub(m, "&") - - # Add link to Debian BTS page for this package - s = package; gsub("\\+", "%2B", s) - d = "[Debian Bug Report]" - u = "https://bugs.debian.org/cgi-bin/pkgreport.cgi" - h = sprintf("%s", u,s,d) - $0 = $0 " " h - } - /^(Depends|Pre-Depends|Conflicts|Replaces|Provides|Suggests|\ - |Recommends|Enhances):/\ - { - # Workaround for apt-cache missing space: - # Depends: python-slang(>= 0.2.0), python (>= 2.1) - gsub("\\(", " (") - for (f=2; f<=NF; f++) { - if ($f == "|") { - continue - } - if (match($f,"^\\(")) { - f++; - continue - } - r = $f; - gsub(",", "", r) - s = t = r - gsub("\\+", "\\+", r) - gsub("\\+", "%2B", s) - sub(r, "" t "", $f) - } - } - /^Description:/ { - if (uri != "") { - s = package - t = uri - gsub("\\+", "%2B", s) - gsub("^file:", "", t) - h = SELF "?browse=Browse&packages=" s - printf("Filename: %s\n", h, t) - } - } - /^Version:/ { - if (match($0, "latest is")) { - # Show latest version in bold - sub("\\(latest is", "(latest is"); sub("\\)", ")") - } - } - /^$/ { next} - /^ .$/ { $0 = " " } - { print }' -} - -# Convert a dpkg package list to html adding hrefs to package names. -# This is used for both file list and documentation list. -# -listFilter() { - awk -v SELF=$SELF \ - -v CHECK_BUTTONS=$CHECK_BUTTONS \ - -v DPKG_AVAILABLE=$DPKG_AVAILABLE \ - -v LIST_UNAVAILABLE=$LIST_UNAVAILABLE \ - -v INSTALLED_ONLY=$INSTALLED_ONLY ' - BEGIN { - is_hdr = 1 - statMax = 3 - nameMax = 10 - versMax = 10 - descMax = 10 - if (CHECK_BUTTONS) { - pkg_button = \ - "" - install_button = \ - "" - reset_button = \ - "" - buttonW = 2 - } - } - /^No packages found matching/ { - print $0 - missing++ - NR-- - next - } - (is_hdr) { - header[NR] = $0 - } - (is_hdr == 1) && ($1 == "||/") { - # ||/ Name Version Description - hstat = $1 - hname = $2 - hvers = $3 - hdesc = $4 - is_hdr = 2 - next - } - (is_hdr == 2) { - # +++-==============-==============-=============================== - split($0,A,"-") - statLen = length(A[1]) - nameLen = length(A[2]) - versLen = length(A[3]) - hsep = A[4] A[4] A[4] - is_hdr = 0 - next - } - (!is_hdr) { - # ii dpkg-www 2.52 package description ... - stat = substr($0,1,statLen) - name = substr($0,5,nameLen) - vers = substr($0,6+nameLen,versLen) - desc = substr($0,7+nameLen+versLen) - sub("[ ]+$","",name) - sub("[ ]+$","",vers) - sub("[ ]+$","",desc) - if (INSTALLED_ONLY && !match(stat,"^(i.|.c)")) { - next - } - # if (vers == "") { vers = "-" } - nameMax = max(nameMax, length(name)) - versMax = max(versMax, length(vers)) - descMax = max(descMax, length(desc)) - packages[NR,"stat"] = stat - packages[NR,"name"] = name - packages[NR,"vers"] = vers - packages[NR,"desc"] = desc - if (desc == "(no description available)") { - needs_desc = missing_desc[name] = NR - } - } - END { - if (needs_desc) { - update_descs() - } - if (NR < 6) { - if (!missing) { - print "no packages found" - } - exit - } - if (missing) { - print "" - } - if (CHECK_BUTTONS) { - printf "
" - } - for (i=1; i<=3; i++) { - print header[i] - } - descMax = max(descMax,80-statMax-nameMax-versMax-3) - printf("%s %s %s %s\n", \ - pad(hstat,statMax+buttonW), pad(hname,nameMax), \ - pad(hvers,versMax), hdesc) - printf("+++%s-%s-%s-%s\n", substr("--",1,buttonW), \ - pad(hsep,nameMax), pad(hsep,versMax), pad(hsep,descMax)) - nr = NR - npackages = 0 - for (i=6; i<=nr; i++) { - name = packages[i,"name"] - if (!name) { continue } - if (CHECK_BUTTONS) { - if (substr(packages[i,"stat"],2,1) == "n") { - stat = pad(packages[i,"stat"],statMax) - button = sprintf(pkg_button, name",") - install = 1 - } else { - stat = pad(packages[i,"stat"],statMax) - button = " " - } - } else { - stat = pad(packages[i,"stat"],statMax) - } - npad = pad("", nameMax-length(name)) - vers = escape(pad(packages[i,"vers"],versMax)) - desc = escape(packages[i,"desc"]) - if ((LIST_UNAVAILABLE == 0) && - (desc == "(no description available)")) { - NR-- - continue - } - href = link = name - gsub("\\+", "%2B", href) - href = "" link "" npad - printf("%s%s %s %s %s\n", stat, button, href, vers, desc) - npackages++ - } - if (npackages > 0) { - npad = statMax+2+buttonW+nameMax - print "" - printf(pad(sprintf("%d packages", npackages), npad)) - } - if (CHECK_BUTTONS) { - if (install) { - printf reset_button " " install_button "\n" - } - printf "
" - } - } - function escape(s) { - gsub("&","\\&",s) - gsub("<","\\<",s) - gsub(">","\\>",s) - return s - } - function pad(s,l) { - while (length(s) < l) { - s = s " " - } - return substr(s,1,l) - } - function max(x,y) { - return ((x > y) ? x : y) - } - function update_descs() { - while (getline < DPKG_AVAILABLE) { - if ($1 == "Package:") { - if ((nr=missing_desc[$2])) { - package = $2 - } else { - package = "" - } - } - if (package && ($1 == "Version:")) { - sub("Version: ",""); vers = $0 - packages[nr,"vers"] = vers - versMax = max(versMax, length(vers)) - } - if (package && ($1 == "Description:")) { - sub("Description: ",""); desc = $0 - packages[nr,"desc"] = desc - descMax = max(descMax, length(desc)) - } - } - }' -} - -# Convert a file list to html adding hrefs to files in /usr/{doc,info,man}. -# -fileFilter() { - awk -v title="$*" -v show_local_files="$SHOW_LOCAL_FILES" \ - -v man="$MAN" -v info2www="$INFO2WWW_PATH" -v dwww="$DWWW_PATH" ' - /\/usr\/(share\/)?([a-zA-Z0-9_+-]+\/)?man\/.*\..*/ { - if (title) { t = title } else { t = $1 } - if ($2) { t = t " [" $2 "]"; NF=1 } - r = s = $1 - gsub("\\+", "\\+", r); - gsub("\\+", "%2B", s); - gsub("\\$","\\$",r) - sub(r, "" t "") - print - next - } - /\/usr\/(share\/)?info\/.*\.gz/ { - if (title) { t = title } else { t = $1 } - if ($2) { t = t " [" $2 "]"; NF=1 } - r = s = $1 - gsub("\\+", "\\+", r); - gsub("\\+", "%2B", s); - gsub("\\$","\\$",r) - sub(r, "" t "") - print - next - } - /\/usr\/(doc|share\/(doc|gtk-doc|gnome\/(html|help)|RFC))\// { - if (title) { t = title } else { t = $1 } - if ($2) { t = t " [" $2 "]"; NF=1 } - r = s = $1 - gsub("\\+", "\\+", r); - gsub("\\+", "%2B", s); - gsub("\\$","\\$",r) - if (show_local_files == "true") { - sub(r, "" t "") - } else { - sub(r, ""\ - t "") - } - print - next - } - /^\/.$/ { next } - /^$/ { next } - /^[^\/]/ { sub("^"," ") } - { print }' -} - -packageURI() { - local package="$1" - local pkgcache=$(tempfile) - local srcpkgcache=$(tempfile) - trap "rm -f $pkgcache $srcpkgcache" 0 - apt-get -o "Debug::NoLocking=1" \ - -o "Dir::Cache=/tmp" \ - -o "Dir::Cache::pkgcache=$pkgcache" \ - -o "Dir::Cache::srcpkgcache=$srcpkgcache" \ - -o "Dir::Cache::archives=/var/cache/apt/archives" \ - install --reinstall --print-uris -y "$package" \ - | grep -F "/${package}_" \ - | sed "/^'/!d; s/^'//; s/'.*//" - rm -f $pkgcache $srcpkgcache 2>/dev/null -} - -printInstallRequest() { - local packages="$1" - local host="$HOSTNAME_FULL" - cat <<-EOF - -

dpkg-www Web Installation

-

- If you are reading this document on your browser or you have - been asked to save it to disk instead of running the installation - of the required packages this means that your browser has not - been set up correctly for dpkg-www web installation. - See dpkg-www(8) - man page for more information. -

-EOF -} - -printRemoveRequest() { - local packages="$1" - local host="$HOSTNAME_FULL" - cat <<-EOF - -

dpkg-www Web Deinstallation

-

- If you are reading this document on your browser or you have - been asked to save it to disk instead of running the installation - of the required packages this means that your browser has not - been set up correctly for dpkg-www web installation. - See dpkg-www(8) - man page for more information. -

-EOF -} - -printBrowseRequest() { - local package="$1" - local host="$HOSTNAME_FULL" - cat <<-EOF - -

dpkg-www Browse Request

-

- If you are reading this document on your browser or you have - been asked to save it to disk instead of running a browser - on the required packages this means that your browser has not - been set up correctly for dpkg-www web installation. - See dpkg-www(8) - man page for more information. -

-EOF -} - -# Get the value of a query argument -getValue() { - local key="$1" - test -x /usr/bin/perl || return - perl -e "use CGI; my \$q = new CGI(\$_); print scalar \$q->param('$key')" "$1" -} - -escape_html() { - echo "$*" | sed 's/&/\&/g; s/\"/\"/g; s//\>/g' -} - -printHtmlHeader() { - local title="${1:-Debian Packages}" - local content_type="${2:-text/html; charset=UTF-8}" - test "$html_header_done" && return - html_header_done=true - echo "Content-type: $content_type" - echo "Connection: close" - echo "" - if [ "$content_type" ]; then - echo "" - echo "" - echo "$title" - echo "" - echo "" - fi -} - -# Generate an input form or the tag -printInputForm() { - local default - local installed - test "$noheader" = true && return - test "$input_form_done" = true && return - test "$KEEP_INPUT" = 1 && default="$query" - test "$INSTALLED_ONLY" = 1 && installed="checked" - echo "

Debian packages on $HOSTNAME

" - if [ -x /usr/bin/perl ]; then - echo '

' - if [ "${HTTP_USER_AGENT#Lynx}" != "$HTTP_USER_AGENT" ]; then - echo "

" - echo "Search:" - echo '' - echo '' - echo '(? for help)
' - echo '' \ - 'only installed packages' '
 
' - echo '
' - else - echo "
" - echo '' - echo '' - echo '' - echo '' \ - 'only installed packages' - echo '
' - test "$query" != " " && echo '
' - fi - echo '

' - else - echo '

' - echo '' - echo '

' - fi - input_form_done=true -} - -# Print bottom info -printHtmlBottom() { - test "$noheader" = true && return - cat <<- EOF -

-


-
- Generated by - dpkg-www $PROG_VERSION -
-
-

- $(test "${tempfile}" && echo "
" && cat $tempfile | sed 's/")
-	
-	
-EOF
-}
-
-printError() {
-    local message="$*"
-    printHtmlHeader "$title"
-    printInputForm
-    echo "

" - echo "$(escape_html "$message")" - echo "

" - usage - printHtmlBottom -} - -#------------------------------------------------------------------------------ - -# Get the query arguments -if [ "$*" ]; then - # ISINDEX or interactive invocation - debug="" - query="$*" - help="" - install="" - remove="" - browse="" - packages="" - bgcolor="" - noheader="" - installed="" -else - # GET method - debug="$(getValue debug)" - query="$(getValue query)" - help="$(getValue help)" - install="$(getValue install)" - remove="$(getValue remove)" - browse="$(getValue browse)" - packages="$(getValue packages)" - bgcolor="$(getValue bgcolor)" - noheader="$(getValue noheader)" - installed="$(getValue installed)" -fi -test "$help" != "" && query="?" -test "$debug" != "" && DEBUG="$debug" -test "$bgcolor" != "" && BGCOLOR="$bgcolor" - -# Print debugging info -if test_flag "$DEBUG"; then - printHtmlHeader "$title" - cat <<- EOF -

-	$(env | sort)
-	SELF=$SELF
-	DPKG=$DPKG
-	SHOW_LOCAL_FILES=$SHOW_LOCAL_FILES
-	LIST_DOCUMENTATION=$LIST_DOCUMENTATION
-	CHECK_BUTTONS=$CHECK_BUTTONS
-	INSTALL_BUTTON=$INSTALL_BUTTON
-	PROG=$0
-	ARGC=$#
-	ARGV="$(escape_html "$*")"
-	query="$(escape_html "$query")"
-	install="$(escape_html "$install")"
-	remove="$(escape_html "$remove")"
-	browse="$(escape_html "$browse")"
-	packages="$(escape_html "$packages")"
-	bgcolor="$(escape_html "$bgcolor")"
-	noheader="$(escape_html "$noheader")"
-	installed="$(escape_html "$installed")"
-	debug="$(escape_html "$debug")"
-	
-EOF - tempfile=$(tempfile); trap "rm -f $tempfile" 0 - exec 2>$tempfile - set -x -fi - -# Sanity check on input values. $query is checked in doQuery. -checkInput "$install$remove$packages$debug" - -if [ "$install" -a "$remove" ]; then - printError "Error: invalid request" - exit -fi -if [ "$install$remove$browse" -a "$packages" = "" ]; then - printError "Error: invalid request" - exit -fi -if [ "$install$remove$browse" -a "$query" != "" ]; then - printError "Error: invalid request" - exit -fi -if [ "$install" -a "$install" != "Install" -a "$install" != "Upgrade" ]; then - printError "Error: invalid request" - exit -fi -if [ "$remove" -a "$remove" != "Remove" ]; then - printError "Error: invalid request" - exit -fi -if [ "$browse" -a "$browse" != "Browse" ]; then - printError "Error: invalid request" - exit -fi -if [ "$installed" != "" ]; then - if test_flag "$installed"; then - INSTALLED_ONLY=1 - else - INSTALLED_ONLY=0 - fi -fi - -title="Debian Packages${query:+: $query}" - -if [ "$install" ]; then - printHtmlHeader "Package Installation" application/dpkg-www-installer - printInstallRequest "$packages" - printHtmlBottom -elif [ "$remove" ]; then - printHtmlHeader "Package Deinstallation" application/dpkg-www-installer - printRemoveRequest "$packages" - printHtmlBottom -elif [ "$browse" ]; then - printHtmlHeader "Package Browser" application/dpkg-www-browser - printBrowseRequest "$packages" - printHtmlBottom -else - printHtmlHeader "$title" - printInputForm - doQuery "$query" - printHtmlBottom -fi - -# end of file diff -Nru dpkg-www-2.60/src/dpkg-cgi dpkg-www-2.61/src/dpkg-cgi --- dpkg-www-2.60/src/dpkg-cgi 1970-01-01 00:00:00.000000000 +0000 +++ dpkg-www-2.61/src/dpkg-cgi 2020-12-30 01:18:20.000000000 +0000 @@ -0,0 +1,1473 @@ +#!/bin/bash +# +# CGI interface to dpkg. Show information about debian packages. +# +# Copyright © 1999-2006 Massimo Dal Zotto +# Copyright © 2017, 2019 Guillem Jover +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +PROG_VERSION=2.x +SELF=${0##*/}; export SELF +HELP_PAGE="/usr/share/man/man8/dpkg-www.8.gz" +COLUMNS=256; export COLUMNS +SECTION_DESCRIPTIONS=" +admin Administrative utilities (install software, manage users, etc) +base Basic needed utilities of every Debian system +cli-mono Mono and the Common Language Infrastructure +comm Programs for faxmodems and other communication devices +database Database servers and tools +debug Debug symbols +devel Utilities and programs for software development +doc Documentation and specialized programs for viewing documentation +editors Text editors and word processors +education Software, documentation or data related to educational activities +electronics Programs for working with circuits and electronics +embedded Programs for embedded systems +fonts Fonts and font utilities +games Games, toys, and fun programs +gnome The GNOME Desktop Environment +gnu-r The GNU R statistical computation and graphics system +gnustep The GNUstep Environment +golang Go programming language, libraries, and development tools +graphics Utilities to create, view, and edit graphics files +hamradio Software for ham radio operators +haskell Haskell programming language and libraries +httpd Webservers and their modules +interpreters Interpreters for interpreted languages and macro processors +introspection Introspection support for programming languages +java Java programming language and libraries +javascript JavaScript programming language, libraries, and development tools +kde The KDE Desktop Environment +kernel Kernel and kernel modules +libdevel Development files for libraries +libs Collections of software routines +lisp Lisp programming language and libraries +localization Language packs +mail Programs to write, send, and route email messages +math Numeric analysis and other mathematics-related software +metapackages Packages which solely depend on other packages +misc Miscellaneous software +net Programs to connect to and provide various services +news Usenet clients and servers +ocaml OCaml programming language and libraries +oldlibs Obsolete libraries +otherosfs Emulators and software to read foreign filesystems +perl Perl programming language and libraries +php PHP programming language and libraries +python Python programming language and libraries +ruby Ruby programming language and libraries +rust Rust programming language, library crates, and development tools +science Software for scientific work +shells Command shells and alternative console environments +sound Utilities to play and record sound +tex The TeX typesetting system +text Text processing utilities +utils Various system utilities +vcs Version control systems +video Utilities to record, view, edit, and stream video files +web Web browsers, servers, proxies, and other tools +x11 The X window system and related software +xfce The Xfce Desktop Environment +zope Zope/Plone framework +" + +TASK_DESCRIPTIONS=" +basic-desktop X window system +c-dev C and C++ +chinese-s simplified Chinese environment +chinese-t traditional Chinese environment +cyrillic Cyrillic environment +database-server SQL database +desktop desktop environment +dialup dialup system +dns-server DNS server +file-server file server +fortran-dev fortran +french French environment +games games +german German environment +japanese Japanese environment +junior Debian Jr. +korean Korean environment +laptop laptop system +mail-server mail server +news-server usenet news server +polish Polish environment +print-server print server +python-dev Python +russian Russian environment +science scientific applications +spanish Spanish environment +tcltk-dev Tcl/Tk +tex TeX/LaTeX environment +unix-server conventional unix server +web-server web server +" + +# Configuration defaults, can be overridden in /etc/dpkg-www.conf +# +SHOW_LOCAL_FILES=auto # Show local files directly (automatic) +LIST_UNAVAILABLE=0 # List also unavailable packages +LIST_DOCUMENTATION=1 # List registered package documentation +DPKG=auto # Select the dpkg program (automatic) +MAN=auto # Select the man program (automatic) +DEBIAN_CONTENTS= # List of Contents-xxx.gz files +INSTALLED_ONLY=0 # Only installed packages +TASK_DESCRIPTIONS_FILE=/usr/share/tasksel/debian-tasks.desc +APT_CACHE_OPTS="-o APT::Cache::AllVersions=0" +CHECK_PACKAGE_VERSION=true +DPKG_WWW_BROWSER_HACK=false +GREP_DCTRL_OPTS="-i" +BGCOLOR="#c0c0c0" +KEEP_INPUT=0 +DEBUG=0 +DWWW_PATH="/cgi-bin/dwww" +INFO2WWW_PATH="/cgi-bin/info2www" + +# Install buttons support. This require that users define the following +# mime action in their netscape mailcap file: +# +# application/dpkg-www-installer;/usr/sbin/dpkg-www-installer -f '%s' +# +CHECK_BUTTONS=0 # Enable install check-buttons in package list +INSTALL_BUTTON=0 # Enable install button in package info + +# Source optional local configuration file +test -e /etc/dpkg-www.conf && . /etc/dpkg-www.conf 2>/dev/null +set -o noglob + +HOSTNAME_FULL="$(hostname -f)" +HOSTNAME="${HOSTNAME_FULL%%.*}" + +# Use dlocate, if installed, to speedup certain queries +if [ ! "$DPKG" -o "$DPKG" = auto ]; then + if [ -x /usr/bin/dlocate ]; then + DPKG=dlocate + else + DPKG=dpkg-query + fi +fi + +# Select the Manpage to HTML translator +if [ "$MAN" = dwww ]; then + MAN="${DWWW_PATH}?type=man\\\\&location=" +fi +if [ "$MAN" = man2html ]; then + if [ -x /usr/lib/cgi-bin/man/man2html ]; then + MAN="/cgi-bin/man/man2html?" + elif [ -x /usr/lib/cgi-bin/man2html ]; then + MAN="/cgi-bin/man2html?" + else + MAN="${DWWW_PATH}?type=man\\\\&location=" + fi +fi +if [ ! "$MAN" -o "$MAN" = auto ]; then + if [ -x /usr/lib/cgi-bin/man/man2html ]; then + MAN="/cgi-bin/man/man2html?" + elif [ -x /usr/lib/cgi-bin/man2html ]; then + MAN="/cgi-bin/man2html?" + else + MAN="${DWWW_PATH}?type=man\\\\&location=" + fi +fi + +# If remote host is localhost generate local URL's for local files +case "$REMOTE_HOST" in + localhost|$HOSTNAME|$HOSTNAME_FULL) + if [ ! "$SHOW_LOCAL_FILES" -o "$SHOW_LOCAL_FILES" = auto ]; then + SHOW_LOCAL_FILES=true + fi + if [ "$HTTP_USER_AGENT" != "${HTTP_USER_AGENT#*Mozilla/[56]}" ]; then + # It seems that Mozilla/5.0 refuses to access local files from + # a web page for security reasons. + SHOW_LOCAL_FILES=false + fi + ;; + *) + SHOW_LOCAL_FILES=false + ;; +esac + +# Print a short help for the cgi-program +usage() { + cat <<- EOF +

+ You can query information about Debian packages and installed files. + The search argument can be: +

+ +
+ ? + show this help page +
+ * + list all packages available on your system +
+ <empty> + list all packages installed on your system +
+ <space> + print only the input form, for use from wm menus +
+ package + list the required package and its owned files +
+ list of packages + list required packages concisely +
+ wildcard expression + list matching packages concisely +
+ absolute pathname + list packages owning pathname +
+ field=value + list packages with control field matching value +
+ =value + list packages with any field matching value +
+ section=? + list available package sections +
+ task=? + list available tasks +
+ recent=[<N>] + list packages installed in last N days (default 1) +
+

+

Examples:

+

+

+ +
+ * + list all packages available on your system +
+ <empty> + list all packages installed on your system +
+ binutils + list verbosely the package binutils +
+ dpkg apt + list the dpkg and apt packages +
+ jpeg* + list packages with name beginning with "jpeg" +
+ *jpeg* + list packages with name containing "jpeg" +
+ /usr/bin/tail + list packages owning the file /usr/bin/tail +
+ /.*/postfix + list packages owning any file named "postfix" (1) +
+ /.*pbm.* + list packages owning any file matching *pbm* (1) +
+ maintainer=Joey Hess + list packages with maintainer Joey Hess (2) +
+ section=net + list packages with section net (2) +
+ =firewall + list packages with any field matching "firewall" (2) +
+ section=? + list available package sections +
+ task=? + list available tasks +
+ recent=2 + list packages installed in last 2 days +
+ + + + package hello + install the package hello (3) +
+ + + + package hello + remove the package hello (3) +
+
+

+ (1) The regexp form can be used to query also packages owning files + not installed on your system. However this works only if you have + properly configured the variable DEBIAN_CONTENTS in the + configuration file /etc/dpkg-www.conf. + This query can be used to find which package you should install + in order to get some missing command or file. + Note that the leading '/' is required to distinguish filename + queries from package queries. +

+ (2) This works only if the + grep-dctrl package is installed. +

+ (3) This works only if INSTALL_BUTTON=1 has been set in the + configuration file /etc/dpkg-www.conf, your browser has + been configured to handle web installation requests and, of course, + you know the root password. + See dpkg-www(8) + man page for more information. +

+EOF +} + +debug() { + test_flag "$DEBUG" && echo "$(escape_html "$*")
" +} + +test_flag() { + case "$1" in + 0|false|n|no|"") return 1 ;; + *) return 0 ;; + esac +} + +# Sanity check on input values +checkInput() { + if echo "$*" | grep -q '[(){}<>$%#&!|\\;`]'; then + printError "Error: invalid input" + exit + fi +} + +# Execute the query +doQuery() { + debug "doQuery $1" + local query="$1" + case "${query%/}" in + \?|-\?|-h|-help|--help) + usage + ;; + " ") + return + ;; + -*) + printError "Invalid keyword: $query" + exit + ;; + /*) + queryOwners "$query" + ;; + *=*) + queryPackagesByField "$query" + ;; + *) + checkInput "$query" + queryPackages "$query" + ;; + esac +} + +# Query one or more packages +queryPackages() { + debug "queryPackages $*" + local packages="$*" + local package="${packages%% *}" + if [ ! "$packages" ]; then + # No argument, show the package list + debug "no arguments" + listPackages + elif [ "$package" != "$packages" -o "$packages" != "${packages#*[\[*?]}" ] + then + # Package list or wildcard, list packages concisely + debug "package list" + listPackages $packages + else + # One package, show package information + debug "one package" + listPackage $package + fi +} + +# Query one or more packages by control field value +queryPackagesByField() { + field="${*%%=*}"; arg="${*#$field}"; arg="${arg#=}" + field="${field## }"; field="${field%% }" + arg="${arg## }"; arg="${arg%% }" + if [ "$field" = section -a "$arg" = "?" ]; then + listSections + return + fi + if [ "$field" = task -a "$arg" = "?" ]; then + listTasks + return + fi + if [ "$field" = recent -o "$field" = new ]; then + listRecentPackages $arg + return + fi + if [ "$field" != "" -a ! -x /usr/bin/grep-dctrl ]; then + echo "
"
+	echo -n "Error: the "
+	echo -n "grep-dctrl"
+	echo " command is not installed on your system"
+	echo "
" + return + fi + echo "
"
+    echo "Packages with $(escape_html "${field:-any field matching} $arg")"
+    echo ""
+    {
+	if [ -x /usr/bin/grep-dctrl ]; then
+	    ( dpkg-query -s; dpkg-query -p ) \
+	       | grep-dctrl $GREP_DCTRL_OPTS -s Package -F "$field" "$arg"
+	else
+	    apt-cache search "$arg" | sed 's/ .*//;s/^/Package: /'
+	fi
+	dpkg-query -l "*" 2>&1
+    } \
+    | awk '
+	/^Package:/ { p[$2]=1; NR=0; next }
+	(NR <= 5) { print }
+	(p[$2] != 1) { next }
+	{ print }' \
+    | listFilter
+    echo "
" +} + +# List available sections +listSections() { + sections=$( + ( dpkg-query -s; dpkg-query -p ) | grep -h "^Section:" \ + | sed 's|.*:[ ]*||; s|.*/||' | sort | uniq | grep -v "^non-" + ) + echo "
"
+    echo "Available sections:"
+    echo ""
+    for s in $sections; do
+	desc=$(
+	    echo "$SECTION_DESCRIPTIONS" | sed "/^$s/!d; s/^$s[	 ]*//;q"
+	)
+	desc=${desc:="no description available"}
+	x=$(printf "%$[16-${#s}]s" " ")
+	echo "  ${s}${x} ${desc}"
+    done
+    echo "
" +} + +# List available tasks +listTasks() { + tasks=$( + ( dpkg-query -s; dpkg-query -p ) | grep -h "^Task:" \ + | sed 's|.*:[ ]*||; s|,[ ]*|\ +|g' | sort | uniq + ) + echo "
"
+    echo "Available tasks:"
+    echo ""
+    for t in $tasks; do
+	desc=$(
+	    if [ -e "$TASK_DESCRIPTIONS_FILE" ]; then
+		cat "$TASK_DESCRIPTIONS_FILE" 2>/dev/null | awk -v t="$t" '
+		    /^Task:/ { task = $2 }
+		    /^Description:/ && (task == t) {
+			sub($1"[ ]*",""); print; exit
+		    }'
+	    else
+		echo "$TASK_DESCRIPTIONS" | sed "/^$t/!d; s/^$t[ 	]*//;q"
+	    fi
+	)
+	desc=${desc:="no description available"}
+	x=$(printf "%$[16-${#t}]s" " ")
+	echo "  ${t}${x} ${desc}"
+    done
+    echo "
" +} + +# List recent packages +listRecentPackages() { + n=${1:-1} + s=$( + N=$n perl -MTime::Piece -MTime::Seconds -E '\ + my $o = localtime->truncate(to => "day") - \ + Time::Seconds->new($ARGV[0] * ONE_DAY); \ + print $o->epoch;' \ + ) + packages=$( + dpkg-query -f '${db-fsys:Last-Modified} ${binary:Package}\n' -W \ + | S=$s perl -n -E '(@field) = split " "; \ + print "$field[1] " if $field[0] > $ENV{S};' \ + ) + if [ "$packages" ]; then + echo "
"
+	echo "Recent packages in last $n days:"
+	echo ""
+	dpkg-query -l $packages 2>&1 | listFilter
+	echo "
" + else + echo "
"
+	echo "No recent packages in last $n days"
+	echo "
" + fi +} + +# List one or more packages concisely +listPackages() { + debug "listPackages $*" + echo "
"
+    dpkg-query -l "$@" 2>&1 | listFilter
+    echo "
" +} + +# List a single package +# +listPackage() { + debug "listPackage $*" + local package="$1" + local installed + local status + local version + local latest + local priority + local essential + + pkg_info="$(dpkg-query -s $package)" + if [ ! "$pkg_info" ]; then + # Unknown package or virtual package + listVirtualPackage $package || listUnknownPackage $package + return 1 + fi + + status="$(echo "$pkg_info" | awk '/^Status:/ {print $4}')" + # installed The package is unpacked and configured OK. + # half-installed The installation has started but not completed. + # not-installed The package is not installed on your system. + # unpacked The package is unpacked, but not configured. + # half-configured The package configuration has not completed. + # config-files Only the config files exist on the system. + # Handle unknown package + if [ ! "$status" ]; then + listUnknownPackage $package + return 1 + fi + + if [ "$status" = not-installed -o "$status" = config-files ]; then + if [ -x /usr/bin/apt-cache ]; then + pkg_info="$( + echo "$pkg_info" \ + | grep "^\(Package\|Status\|Priority\|Section\):" + apt-cache $APT_CACHE_OPTS show $package 2>/dev/null \ + | sed 's/^installed-size:/Installed-Size:/' \ + | grep -v -e "^\(Package\|Status\|Priority\|Section\):" \ + -e "^\(Filename\|MD5sum\|Size\):" + )" + else + pkg_info="$( + echo "$pkg_info" \ + | grep "^\(Package\|Status\|Priority\|Section\):" + dpkg-query --print-avail $package 2>/dev/null \ + | grep -v -e "^\(Package\|Status\|Priority\|Section\):" \ + -e "^\(Filename\|MD5sum\|Size\):" + )" + fi + fi + + # Check for newer version of installed package + if [ "$status" = installed ]; then + version="$(echo "$pkg_info" | awk '/^Version:/ {print $2}')" + priority="$(echo "$pkg_info" | grep ^Priority: | awk '{print $2}')" + essential="$(echo "$pkg_info" | grep ^Essential: | awk '{print $2}')" + if test_flag "$CHECK_PACKAGE_VERSION"; then + latest=$( + apt-cache $APT_CACHE_OPTS show $package \ + | grep ^Version: | awk '{print $2}' + ); latest=${latest:-$version} + if dpkg --compare-versions "$latest" gt "$version"; then + pkg_info="$( + echo "$pkg_info" \ + | sed "/^Version:/s/\$/ (latest is $latest)/" + )" + fi + else + latest="$version" + fi + fi + + echo "
"
+
+    # Print package info
+    echo "$pkg_info" | packageFilter $package
+
+    if [ "$INSTALL_BUTTON" = "top" ]; then
+	addButtons
+    fi
+
+    # Print documentation and file list
+    if [ "$status" != not-installed ]; then
+	listPackageDocumentation $package
+	listPackageFiles $package
+    fi
+
+    if [ "$INSTALL_BUTTON" != "top" ]; then
+	addButtons
+    fi
+
+    echo "
" +} + +# Add "Install", "Update" and "Remove" buttons if enabled. +addButtons() { + if [ "$status" = installed ]; then + if [ "$priority" = required -o "$essential" = yes ]; then + if [ "$version" != "$latest" ]; then + addUpgradeButton $package $latest + fi + else + if [ "$version" != "$latest" ]; then + addRemoveUpgradeButtons $package $latest + else + addRemoveButton $package + fi + fi + else + addInstallButton $package + fi +} + +# Print a "Package not installed" message and add the "Install" button +# if enabled in the configuration file. +# +addInstallButton() { + debug "addInstallButton $*" + local package="$1" + local pkgname="$package" + if test_flag "$INSTALL_BUTTON"; then + echo "
" \ + "" + echo -n \ + "Package $(escape_html "$package") is not installed." \ + "" \ + "
" + else + echo "" + echo "Package $(escape_html "$package") is not installed." + fi +} + +# Add the "Remove" button if enabled in the configuration file. +# +addRemoveButton() { + debug "addRemoveButton $*" + local package="$1" + local pkgname="$package" + if test_flag "$INSTALL_BUTTON"; then + echo "
" \ + "" + echo -n \ + "" \ + "package $package" \ + "
" + fi +} + +# Add the "Upgrade" button if enabled in the configuration file. +# +addUpgradeButton() { + debug "addUpgradeButton $*" + local package="$1" + local latest="$2" + local pkgname="$package" + if test_flag "$INSTALL_BUTTON"; then + echo "
" \ + "" + echo -n \ + "" \ + "package $package to version $latest" \ + "
" + fi +} + +# Add the "Remove" and "Upgrade" buttons if enabled in the configuration file. +# +addRemoveUpgradeButtons() { + debug "addRemoveUpgradeButtons $*" + local package="$1" + local latest="$2" + local pkgname="$package" + if test_flag "$INSTALL_BUTTON"; then + echo "
" \ + "" + echo -n \ + "" \ + "package $package. " \ + "" \ + "to version $latest" \ + "
" + fi +} + +# List all packages providing a virtual package. +# +listVirtualPackage() { + debug "listVirtualPackage $*" + local package="$1" + local packages=$( + ( dpkg-query -s; dpkg-query -p ) \ + | awk -v package=$package ' + /^Package:/ { owner = $2 } + /^Provides:/ { + gsub(",","") + for (i=2; i<=NF; i++) { if ($i == package) { print owner } } + }' \ + | sort | uniq + ) + test "$packages" || return 1 + debug "is virtual package" + echo "
"
+    echo "Virtual package $(escape_html "$package") is provided by:"
+    echo "
" + listPackages $(echo $packages) +} + +listUnknownPackage() { + debug "listUnknownPackage $*" + local package="$(escape_html "$1")" + echo "
"
+    echo "Package $package is not installed and no info is available."
+    echo "
" +} + +listPackageFiles() { + debug "listPackageFiles $*" + local package="$1" + echo + echo "Files owned by package $(escape_html "$package"):" + echo + $DPKG -L $package | sort | fileFilter +} + +# This is really ugly but I don't know a better way since install-docs +# doesn't record package ownership of documents. +# +listPackageDocumentation() { + debug "listPackageDocumentation $*" + local package="$1" + local installdocs_files + local document_id + local f + test_flag "$LIST_DOCUMENTATION" || return + test -x /usr/sbin/install-docs || return + dpkg-query --control-list $package | grep -q postinst || return + installdocs_files=$( + dpkg-query --control-show $package postinst \ + | grep 'install-docs[ ]*-i' \ + | sed 's/.*install-docs[ ]*-i[ ]*//;s/[ ].*//' \ + | sort | uniq + ) + debug "installdocs_files=$installdocs_files" + test "$installdocs_files" || return + echo + echo "Documentation:" + echo + for f in $installdocs_files; do + # Hack for postinsts with `$package' in filenames + test ! -e $f && f="$(echo "$f" | sed "s/\$package/$package/i")" + # Get document_id (this can be different than file basename) + if [ -e $f ]; then + document_id="$(grep "^Document:" "$f" | sed 's/.*: //' | head -1)" + else + document_id="${f##*/}" + fi + debug "document_id=$document_id" + title="$( + /usr/sbin/install-docs -s "$document_id" 2>/dev/null \ + | awk '/^Title: / { sub("^Title: *",""); print $0 }' + )" + /usr/sbin/install-docs -s "$document_id" 2>/dev/null \ + | awk ' + /^Format:/ { format = $2 } + /^Index: / { print $2 "\t" format } + /^Files: / { if (!match($2,"\\*")) { print $2 "\t" format } }' \ + | sort | uniq | fileFilter "$title" | sed 's/^/ /' + done +} + +# Find all packages owning a file. Must be able to handle things like: +# +# /usr/lib/games/maelstrom/Maelstrom Fonts +# /usr/share/ucblogo/logolib/# +# /usr/share/ucblogo/logolib/` +# /etc/diskless-image/config.sh +# /bin/bash +# /.*/postfix +# /.*pbm.* +# +queryOwners() { + debug "queryOwners $*" + local file="${1%/}" + local owners=$( + # Must grep the exact filename when using dlocate + $DPKG -S "$file" 2>/dev/null | grep ": $file$" | cut -f1 -d: \ + | grep -v diversion | tr -d ',' + ) + if [ "$owners" ]; then + echo "
"
+	echo "Packages owning $(escape_html "$file"):"
+	echo "
" + listPackages $owners + return + fi + + if [ "$DEBIAN_CONTENTS" ]; then + owners=$( + zcat $DEBIAN_CONTENTS 2>/dev/null \ + | grep "^${file#/}[ ][ ]*[^ ]*\$" \ + | sed "s^${file#/}[ ][ ]*; s/,/\\ +/" | sed 's|.*/||' \ + | sort | uniq + ) + fi + if [ "$owners" ]; then + echo "
"
+	echo "Packages owning $(escape_html "$file"):"
+	echo "
" + listPackages $owners + return + fi + + echo "
"
+    echo "No package is owning $(escape_html "$file")"
+    echo "
" +} + +# Convert package info to html by adding hrefs to other packages. +# +packageFilter() { + local package="$1" + local uri="" + if [ "$DPKG_WWW_BROWSER_HACK" = true -a "$SHOW_LOCAL_FILES" ]; then + uri="$(packageURI "$package")" + test "$uri" = "${uri#file:/}" && uri="" + fi + awk -v SELF=$SELF -v package="$package" -v uri="$uri" ' + { gsub("<","\\<"); gsub(">","\\>") } + /^Package:/ { + # Add link to the Debian package page for this package + p = s = package; gsub("\\+", "%2B", s) + u = "https://packages.debian.org" + $2 = sprintf("%s", u,s,p) + } + /^Section:/ { + # Add link to package section list + s = t = r = $2 + gsub("\\+", "\\+", r) + gsub("\\+", "%2B", s) + sub(r, "" t "", $2) + } + /^Task:/ { + # Add links to package tasks list + for (f=2; f<=NF; f++) { + r = $f; + gsub(",", "", r) + s = t = r + gsub("\\+", "\\+", r) + gsub("\\+", "%2B", s) + sub(r, "" t "", $f) + } + } + /^Maintainer:/ { + # Add link to maintainer packages overview + m = $0; sub(".*: ","",m);sub(" <.*","",m);gsub("[()]","\\\\&",m) + e = $0; sub(".*<","",e);sub(">.*","",e) + u = "https://qa.debian.org/developer.php?login=" e + sub(m, "&") + + # Add link to Debian BTS page for this package + s = package; gsub("\\+", "%2B", s) + d = "[Debian Bug Report]" + u = "https://bugs.debian.org/cgi-bin/pkgreport.cgi" + h = sprintf("%s", u,s,d) + $0 = $0 " " h + } + /^(Depends|Pre-Depends|Conflicts|Replaces|Provides|Suggests|\ + |Recommends|Enhances):/\ + { + # Workaround for apt-cache missing space: + # Depends: python-slang(>= 0.2.0), python (>= 2.1) + gsub("\\(", " (") + for (f=2; f<=NF; f++) { + if ($f == "|") { + continue + } + if (match($f,"^\\(")) { + f++; + continue + } + r = $f; + gsub(",", "", r) + s = t = r + gsub("\\+", "\\+", r) + gsub("\\+", "%2B", s) + sub(r, "" t "", $f) + } + } + /^Description:/ { + if (uri != "") { + s = package + t = uri + gsub("\\+", "%2B", s) + gsub("^file:", "", t) + h = SELF "?browse=Browse&packages=" s + printf("Filename: %s\n", h, t) + } + } + /^Version:/ { + if (match($0, "latest is")) { + # Show latest version in bold + sub("\\(latest is", "(latest is"); sub("\\)", ")") + } + } + /^$/ { next} + /^ .$/ { $0 = " " } + { print }' +} + +# Convert a dpkg package list to html adding hrefs to package names. +# This is used for both file list and documentation list. +# +listFilter() { + awk -v SELF=$SELF \ + -v CHECK_BUTTONS=$CHECK_BUTTONS \ + -v DPKG_AVAILABLE=$DPKG_AVAILABLE \ + -v LIST_UNAVAILABLE=$LIST_UNAVAILABLE \ + -v INSTALLED_ONLY=$INSTALLED_ONLY ' + BEGIN { + is_hdr = 1 + statMax = 3 + nameMax = 10 + versMax = 10 + descMax = 10 + if (CHECK_BUTTONS) { + pkg_button = \ + "" + install_button = \ + "" + reset_button = \ + "" + buttonW = 2 + } + } + /^No packages found matching/ { + print $0 + missing++ + NR-- + next + } + (is_hdr) { + header[NR] = $0 + } + (is_hdr == 1) && ($1 == "||/") { + # ||/ Name Version Description + hstat = $1 + hname = $2 + hvers = $3 + hdesc = $4 + is_hdr = 2 + next + } + (is_hdr == 2) { + # +++-==============-==============-=============================== + split($0,A,"-") + statLen = length(A[1]) + nameLen = length(A[2]) + versLen = length(A[3]) + hsep = A[4] A[4] A[4] + is_hdr = 0 + next + } + (!is_hdr) { + # ii dpkg-www 2.52 package description ... + stat = substr($0,1,statLen) + name = substr($0,5,nameLen) + vers = substr($0,6+nameLen,versLen) + desc = substr($0,7+nameLen+versLen) + sub("[ ]+$","",name) + sub("[ ]+$","",vers) + sub("[ ]+$","",desc) + if (INSTALLED_ONLY && !match(stat,"^(i.|.c)")) { + next + } + # if (vers == "") { vers = "-" } + nameMax = max(nameMax, length(name)) + versMax = max(versMax, length(vers)) + descMax = max(descMax, length(desc)) + packages[NR,"stat"] = stat + packages[NR,"name"] = name + packages[NR,"vers"] = vers + packages[NR,"desc"] = desc + if (desc == "(no description available)") { + needs_desc = missing_desc[name] = NR + } + } + END { + if (needs_desc) { + update_descs() + } + if (NR < 6) { + if (!missing) { + print "no packages found" + } + exit + } + if (missing) { + print "" + } + if (CHECK_BUTTONS) { + printf "
" + } + for (i=1; i<=3; i++) { + print header[i] + } + descMax = max(descMax,80-statMax-nameMax-versMax-3) + printf("%s %s %s %s\n", \ + pad(hstat,statMax+buttonW), pad(hname,nameMax), \ + pad(hvers,versMax), hdesc) + printf("+++%s-%s-%s-%s\n", substr("--",1,buttonW), \ + pad(hsep,nameMax), pad(hsep,versMax), pad(hsep,descMax)) + nr = NR + npackages = 0 + for (i=6; i<=nr; i++) { + name = packages[i,"name"] + if (!name) { continue } + if (CHECK_BUTTONS) { + if (substr(packages[i,"stat"],2,1) == "n") { + stat = pad(packages[i,"stat"],statMax) + button = sprintf(pkg_button, name",") + install = 1 + } else { + stat = pad(packages[i,"stat"],statMax) + button = " " + } + } else { + stat = pad(packages[i,"stat"],statMax) + } + npad = pad("", nameMax-length(name)) + vers = escape(pad(packages[i,"vers"],versMax)) + desc = escape(packages[i,"desc"]) + if ((LIST_UNAVAILABLE == 0) && + (desc == "(no description available)")) { + NR-- + continue + } + href = link = name + gsub("\\+", "%2B", href) + href = "" link "" npad + printf("%s%s %s %s %s\n", stat, button, href, vers, desc) + npackages++ + } + if (npackages > 0) { + npad = statMax+2+buttonW+nameMax + print "" + printf(pad(sprintf("%d packages", npackages), npad)) + } + if (CHECK_BUTTONS) { + if (install) { + printf reset_button " " install_button "\n" + } + printf "
" + } + } + function escape(s) { + gsub("&","\\&",s) + gsub("<","\\<",s) + gsub(">","\\>",s) + return s + } + function pad(s,l) { + while (length(s) < l) { + s = s " " + } + return substr(s,1,l) + } + function max(x,y) { + return ((x > y) ? x : y) + } + function update_descs() { + while (getline < DPKG_AVAILABLE) { + if ($1 == "Package:") { + if ((nr=missing_desc[$2])) { + package = $2 + } else { + package = "" + } + } + if (package && ($1 == "Version:")) { + sub("Version: ",""); vers = $0 + packages[nr,"vers"] = vers + versMax = max(versMax, length(vers)) + } + if (package && ($1 == "Description:")) { + sub("Description: ",""); desc = $0 + packages[nr,"desc"] = desc + descMax = max(descMax, length(desc)) + } + } + }' +} + +# Convert a file list to html adding hrefs to files in /usr/{doc,info,man}. +# +fileFilter() { + awk -v title="$*" -v show_local_files="$SHOW_LOCAL_FILES" \ + -v man="$MAN" -v info2www="$INFO2WWW_PATH" -v dwww="$DWWW_PATH" ' + /\/usr\/(share\/)?([a-zA-Z0-9_+-]+\/)?man\/.*\..*/ { + if (title) { t = title } else { t = $1 } + if ($2) { t = t " [" $2 "]"; NF=1 } + r = s = $1 + gsub("\\+", "\\+", r); + gsub("\\+", "%2B", s); + gsub("\\$","\\$",r) + sub(r, "" t "") + print + next + } + /\/usr\/(share\/)?info\/.*\.gz/ { + if (title) { t = title } else { t = $1 } + if ($2) { t = t " [" $2 "]"; NF=1 } + r = s = $1 + gsub("\\+", "\\+", r); + gsub("\\+", "%2B", s); + gsub("\\$","\\$",r) + sub(r, "" t "") + print + next + } + /\/usr\/(doc|share\/(doc|gtk-doc|gnome\/(html|help)|RFC))\// { + if (title) { t = title } else { t = $1 } + if ($2) { t = t " [" $2 "]"; NF=1 } + r = s = $1 + gsub("\\+", "\\+", r); + gsub("\\+", "%2B", s); + gsub("\\$","\\$",r) + if (show_local_files == "true") { + sub(r, "" t "") + } else { + sub(r, ""\ + t "") + } + print + next + } + /^\/.$/ { next } + /^$/ { next } + /^[^\/]/ { sub("^"," ") } + { print }' +} + +packageURI() { + local package="$1" + local pkgcache=$(tempfile) + local srcpkgcache=$(tempfile) + trap "rm -f $pkgcache $srcpkgcache" 0 + apt-get -o "Debug::NoLocking=1" \ + -o "Dir::Cache=/tmp" \ + -o "Dir::Cache::pkgcache=$pkgcache" \ + -o "Dir::Cache::srcpkgcache=$srcpkgcache" \ + -o "Dir::Cache::archives=/var/cache/apt/archives" \ + install --reinstall --print-uris -y "$package" \ + | grep -F "/${package}_" \ + | sed "/^'/!d; s/^'//; s/'.*//" + rm -f $pkgcache $srcpkgcache 2>/dev/null +} + +printInstallRequest() { + local packages="$1" + local host="$HOSTNAME_FULL" + cat <<-EOF + +

dpkg-www Web Installation

+

+ If you are reading this document on your browser or you have + been asked to save it to disk instead of running the installation + of the required packages this means that your browser has not + been set up correctly for dpkg-www web installation. + See dpkg-www(8) + man page for more information. +

+EOF +} + +printRemoveRequest() { + local packages="$1" + local host="$HOSTNAME_FULL" + cat <<-EOF + +

dpkg-www Web Deinstallation

+

+ If you are reading this document on your browser or you have + been asked to save it to disk instead of running the installation + of the required packages this means that your browser has not + been set up correctly for dpkg-www web installation. + See dpkg-www(8) + man page for more information. +

+EOF +} + +printBrowseRequest() { + local package="$1" + local host="$HOSTNAME_FULL" + cat <<-EOF + +

dpkg-www Browse Request

+

+ If you are reading this document on your browser or you have + been asked to save it to disk instead of running a browser + on the required packages this means that your browser has not + been set up correctly for dpkg-www web installation. + See dpkg-www(8) + man page for more information. +

+EOF +} + +# Get the value of a query argument +getValue() { + local key="$1" + test -x /usr/bin/perl || return + perl -e "use CGI; my \$q = new CGI(\$_); print scalar \$q->param('$key')" "$1" +} + +escape_html() { + echo "$*" | sed 's/&/\&/g; s/\"/\"/g; s//\>/g' +} + +printHtmlHeader() { + local title="${1:-Debian Packages}" + local content_type="${2:-text/html; charset=UTF-8}" + test "$html_header_done" && return + html_header_done=true + echo "Content-type: $content_type" + echo "Connection: close" + echo "" + if [ "$content_type" ]; then + echo "" + echo "" + echo "$title" + echo "" + echo "" + fi +} + +# Generate an input form or the tag +printInputForm() { + local default + local installed + test "$noheader" = true && return + test "$input_form_done" = true && return + test "$KEEP_INPUT" = 1 && default="$query" + test "$INSTALLED_ONLY" = 1 && installed="checked" + echo "

Debian packages on $HOSTNAME

" + if [ -x /usr/bin/perl ]; then + echo '

' + if [ "${HTTP_USER_AGENT#Lynx}" != "$HTTP_USER_AGENT" ]; then + echo "

" + echo "Search:" + echo '' + echo '' + echo '(? for help)
' + echo '' \ + 'only installed packages' '
 
' + echo '
' + else + echo "
" + echo '' + echo '' + echo '' + echo '' \ + 'only installed packages' + echo '
' + test "$query" != " " && echo '
' + fi + echo '

' + else + echo '

' + echo '' + echo '

' + fi + input_form_done=true +} + +# Print bottom info +printHtmlBottom() { + test "$noheader" = true && return + cat <<- EOF +

+


+
+ Generated by + dpkg-www $PROG_VERSION +
+
+

+ $(test "${tempfile}" && echo "
" && cat $tempfile | sed 's/")
+	
+	
+EOF
+}
+
+printError() {
+    local message="$*"
+    printHtmlHeader "$title"
+    printInputForm
+    echo "

" + echo "$(escape_html "$message")" + echo "

" + usage + printHtmlBottom +} + +#------------------------------------------------------------------------------ + +# Get the query arguments +if [ "$*" ]; then + # ISINDEX or interactive invocation + debug="" + query="$*" + help="" + install="" + remove="" + browse="" + packages="" + bgcolor="" + noheader="" + installed="" +else + # GET method + debug="$(getValue debug)" + query="$(getValue query)" + help="$(getValue help)" + install="$(getValue install)" + remove="$(getValue remove)" + browse="$(getValue browse)" + packages="$(getValue packages)" + bgcolor="$(getValue bgcolor)" + noheader="$(getValue noheader)" + installed="$(getValue installed)" +fi +test "$help" != "" && query="?" +test "$debug" != "" && DEBUG="$debug" +test "$bgcolor" != "" && BGCOLOR="$bgcolor" + +# Print debugging info +if test_flag "$DEBUG"; then + printHtmlHeader "$title" + cat <<- EOF +

+	$(env | sort)
+	SELF=$SELF
+	DPKG=$DPKG
+	SHOW_LOCAL_FILES=$SHOW_LOCAL_FILES
+	LIST_DOCUMENTATION=$LIST_DOCUMENTATION
+	CHECK_BUTTONS=$CHECK_BUTTONS
+	INSTALL_BUTTON=$INSTALL_BUTTON
+	PROG=$0
+	ARGC=$#
+	ARGV="$(escape_html "$*")"
+	query="$(escape_html "$query")"
+	install="$(escape_html "$install")"
+	remove="$(escape_html "$remove")"
+	browse="$(escape_html "$browse")"
+	packages="$(escape_html "$packages")"
+	bgcolor="$(escape_html "$bgcolor")"
+	noheader="$(escape_html "$noheader")"
+	installed="$(escape_html "$installed")"
+	debug="$(escape_html "$debug")"
+	
+EOF + tempfile=$(tempfile); trap "rm -f $tempfile" 0 + exec 2>$tempfile + set -x +fi + +# Sanity check on input values. $query is checked in doQuery. +checkInput "$install$remove$packages$debug" + +if [ "$install" -a "$remove" ]; then + printError "Error: invalid request" + exit +fi +if [ "$install$remove$browse" -a "$packages" = "" ]; then + printError "Error: invalid request" + exit +fi +if [ "$install$remove$browse" -a "$query" != "" ]; then + printError "Error: invalid request" + exit +fi +if [ "$install" -a "$install" != "Install" -a "$install" != "Upgrade" ]; then + printError "Error: invalid request" + exit +fi +if [ "$remove" -a "$remove" != "Remove" ]; then + printError "Error: invalid request" + exit +fi +if [ "$browse" -a "$browse" != "Browse" ]; then + printError "Error: invalid request" + exit +fi +if [ "$installed" != "" ]; then + if test_flag "$installed"; then + INSTALLED_ONLY=1 + else + INSTALLED_ONLY=0 + fi +fi + +title="Debian Packages${query:+: $query}" + +if [ "$install" ]; then + printHtmlHeader "Package Installation" application/dpkg-www-installer + printInstallRequest "$packages" + printHtmlBottom +elif [ "$remove" ]; then + printHtmlHeader "Package Deinstallation" application/dpkg-www-installer + printRemoveRequest "$packages" + printHtmlBottom +elif [ "$browse" ]; then + printHtmlHeader "Package Browser" application/dpkg-www-browser + printBrowseRequest "$packages" + printHtmlBottom +else + printHtmlHeader "$title" + printInputForm + doQuery "$query" + printHtmlBottom +fi + +# end of file diff -Nru dpkg-www-2.60/src/dpkg-www.1 dpkg-www-2.61/src/dpkg-www.1 --- dpkg-www-2.60/src/dpkg-www.1 2019-10-13 21:41:18.000000000 +0000 +++ dpkg-www-2.61/src/dpkg-www.1 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -.\" Copyright © 2002, 2005 Massimo Dal Zotto -.\" Copyright © 2017, 2019 Guillem Jover -.\" -.\" This is free software; you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation; either version 2 of the License, or -.\" (at your option) any later version. -.\" -.\" This is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see . -. -.TH DPKG\-WWW 1 "2019-02-26" - -.SH NAME -dpkg\-www \- program to remotely open a WWW Debian package browser - -.SH SYNOPSIS -.B dpkg-www -.RB [ \-s | \-\-stdout ] -.RB [ \-h | "\-\-host \fIhost\fP" ] -.RI [ query ] - -.SH DESCRIPTION -.B dpkg\-www -is used to remotely control a web browser and open a dpkg -URL on the localhost from an interactive shell or script. - -If the command is invoked while running under the X Window System the -script will try to find an installed X browser to open the specified URL. -If not running under X, it will try to use a text browser instead. - -If one of the known browsers is found and there is an instance already -running it will be asked to open the dpkg URL on localhost with the optional -.I query -supplied on the command line. -If there is no browser running, it will start automatically a new one. - -The functionality provided by this program is identical to running -a web browser with the -.B \-remote openURL(http://localhost/cgi\-bin/dpkg) -argument or opening the same URL from within the browser. - -.BR dpkg\-www\-installer (8) -is a helper application which can configured in the WWW browser for web -installation. It should never be invoked directly by the user. - -.SH OPTIONS -.TP -.BR \-s ", " \-\-stdout -Redirect output to stdout. Requires one of the text browsers (elinks, -links2, links or w3m) installed. -.TP -.BR \-h ", " \-\-host " \fIhost\fR" -Send the query to a remote host, where \fBdpkg\-www\fP must be installed. -.TP -.I query -Specifies an optional package name, an absolute pathname or a query -argument which is passed to the dpkg cgi\-bin. See -.BR dpkg\-www (8) -for more information about the use of the CGI. - -.SH FILES -.TP -.I /etc/dpkg\-www.conf -.TQ -.I ~/.dpkg\-www -Configuration files for \fBdpkg\-www\fP. -It is not necessary for these files to exist, there are sensible defaults -for everything, but you can specify your preferred www browser with the -.B DPKG_WWW_BROWSER -variable, for example -.BR DPKG_WWW_BROWSER=firefox . - -.SH EXAMPLES -.TP -.B dpkg\-www -This would open a dpkg URL on localhost listing all the installed packages. -.TP -.B dpkg\-www bash -This would open a dpkg URL asking info on the bash package. -.TP -.B dpkg\-www \-h pisolo bash -This would open a dpkg URL asking info on the bash package on host pisolo. -.TP -.B dpkg\-www 'dpkg*' -This would open a dpkg URL listing all packages matching -.IR dpkg* . -.TP -.B dpkg\-www /bin/bash -This would open a dpkg URL asking info on the package(s) -owning the file -.IR /bin/bash . -.TP -.B dpkg\-www depends=coreutils -This would open a dpkg URL listing all packages depending on coreutils. -.TP -.B dpkg\-www \-\-stdout depends=awk | grep ^ii -This would list on stdout all packages depending on awk and grep all -lines of installed packages. - -.SH SEE ALSO -.BR dpkg (1), -.BR dpkg\-www (8). diff -Nru dpkg-www-2.60/src/dpkg-www.1.pod dpkg-www-2.61/src/dpkg-www.1.pod --- dpkg-www-2.60/src/dpkg-www.1.pod 1970-01-01 00:00:00.000000000 +0000 +++ dpkg-www-2.61/src/dpkg-www.1.pod 2020-12-30 01:18:20.000000000 +0000 @@ -0,0 +1,124 @@ +# Copyright © 2002, 2005 Massimo Dal Zotto +# Copyright © 2017, 2019 Guillem Jover +# +# This is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +=encoding utf8 + +=head1 NAME + +dpkg-www - program to remotely open a WWW Debian package browser + +=head1 SYNOPSIS + +B [B<-s>|B<--stdout>] [B<-h>|B<--host> I] [I] + +=head1 DESCRIPTION + +B is used to remotely control a web browser and open a dpkg +URL on the localhost from an interactive shell or script. + +If the command is invoked while running under the X Window System the +script will try to find an installed X browser to open the specified URL. +If not running under X, it will try to use a text browser instead. + +If one of the known browsers is found and there is an instance already +running it will be asked to open the dpkg URL on localhost with the optional +I supplied on the command line. +If there is no browser running, it will start automatically a new one. + +The functionality provided by this program is identical to running +a web browser with the B<-remote openURL(http://localhost/cgi-bin/dpkg)> +argument or opening the same URL from within the browser. + +B(8) +is a helper application which can configured in the WWW browser for web +installation. It should never be invoked directly by the user. + +=head1 OPTIONS + +=over + +=item B<-s>, B<--stdout> + +Redirect output to stdout. Requires one of the text browsers (elinks, +links2, links or w3m) installed. + +=item B<-h>, B<--host> I + +Send the query to a remote host, where B must be installed. + +=item I + +Specifies an optional package name, an absolute pathname or a query +argument which is passed to the dpkg cgi-bin. See B(8) +for more information about the use of the CGI. + +=back + +=head1 FILES + +=over + +=item F + +=item F<~/.dpkg-www> + +Configuration files for B. +It is not necessary for these files to exist, there are sensible defaults +for everything, but you can specify your preferred www browser with the +B variable, for example B. + +=back + +=head1 EXAMPLES + +=over + +=item B + +This would open a dpkg URL on localhost listing all the installed packages. + +=item B + +This would open a dpkg URL asking info on the bash package. + +=item B + +This would open a dpkg URL asking info on the bash package on host I. + +=item B + +This would open a dpkg URL listing all packages matching I. + +=item B + +This would open a dpkg URL asking info on the package(s) owning the file +I. + +=item B + +This would open a dpkg URL listing all packages depending on I. + +=item B + +This would list on stdout all packages depending on I and I all +lines of installed packages. + +=back + +=head1 SEE ALSO + +B(1), +B(8). diff -Nru dpkg-www-2.60/src/dpkg-www.8 dpkg-www-2.61/src/dpkg-www.8 --- dpkg-www-2.60/src/dpkg-www.8 2019-10-13 21:41:18.000000000 +0000 +++ dpkg-www-2.61/src/dpkg-www.8 1970-01-01 00:00:00.000000000 +0000 @@ -1,392 +0,0 @@ -.\" Copyright © 2002, 2005 Massimo Dal Zotto -.\" Copyright © 2017, 2019 Guillem Jover -.\" -.\" This is free software; you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation; either version 2 of the License, or -.\" (at your option) any later version. -.\" -.\" This is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program. If not, see . -. -.TH DPKG\-WWW 8 "2019-02-26" - -.SH NAME -dpkg\-www, dpkg\-www-installer \- WWW Debian package browser - -.SH SYNOPSIS -https:///cgi-bin/dpkg - -.SH DESCRIPTION -A typical Debian system can have hundreds installed packages and thousands -available for installation. Information about installed and available -packages can usually be obtained with the -.BR dpkg (1) -command, but navigating through the package dependencies and the -documentation files can be a very frustrating and time-consuming task. - -.PP -With the -.B dpkg\-www -CGI you can instead browse Debian packages info with a web browser, -following package dependencies and locating documentation (man pages, -Info files, READMEs, and so on) with few mouse clicks. If you have -superuser privileges you can even install, upgrade or remove packages -from your web browser. -The output provided by -.B dpkg\-www -is basically that of -.BR dpkg (1) -with the addition of HREF's for packages dependencies and documentation -files. - -.PP -The CGI program can take an optional query argument which can be given in -the URL or entered in the query field of the html form. This can be: -.IP -list concisely all installed packages -.IP *\ (asterisk) -list concisely all installed and available packages -.IP -list concisely the requested packages -.IP -list concisely all packages whose name matches the expression, for -example '*image*' will find all packages which contain the string 'image'. -.IP -list verbosely a package and, if the package is installed, all its files. -If the package is not installed and the web installation is enabled you -can install it by clicking on the 'Install' button. If the package is -installed you can remove it or upgrade to a new version, if available, -by clicking on the respective buttons. -.IP -list all the packages owners of a file. This can be used for example to find -which package installed a program. -.IP / -list all the packages owners of a file. The regexp form can be used to find -which packages own a non installed file. -.IP = -list all the packages with control field matching value. If the field name is -omitted the value is searched in any control field. The default search is a -case-insensitive fixed substring match but it can be changed with the -.B GREP_DCTRL_OPTS -option in the config file. -This feature works only if the -.BR grep\-dctrl (1) -package is installed. -.IP ?\ (question\ mark) -show a concise help about the CGI usage. -.IP \ (a\ single\ space) -print only the input form, for use from window-manager menus. - -.SS Configuration -.B dpkg\-www -can be configured by the local system administrator via the optional -.I /etc/dpkg\-www.conf -file. -This file is a simple Bourne shell -.IR "" ( /bin/sh ) -script that defines some or all the following variables -(defaults are used if the file doesn't exist, or doesn't define the variable): -.TP -.B CHECK_BUTTONS -If this option is enabled -.B dpkw\-www -will add a small 'install' check-button for each package shown in the package -list. Default is 0 (disabled) because the resulting interface is not very nice. -The use of this option is therefore not recommended. -.TP -.B INSTALL_BUTTON -If this option is set the 'Install' or 'Upgrade' and 'Remove' buttons will -be added to the verbose info of a package. By clicking on these button you -will start the installation of removal the package as described in the section -.B Web Installation. -Since this option can potentially introduce security holes it is disabled (0) -by default. Use at your own risk. -If the variable is set to "top" the button will be located before the file -list, default is the bottom of the page. -.TP -.B SHOW_LOCAL_FILES -If this variable is set, \fBdpkg\-www\fP will use file:/ style URL's to -access html files -- bypassing the CGI script. This is faster -on slow machines. Default is not defined, which means use local files -for connection from localhost and https:// URL's for remote connections. -.TP -.B CHECK_PACKAGE_VERSION -If this variable is set, \fBdpkg\-www\fP will check if a newer version -of an installed package is available. -On slow machines you may want to set this option to -false since it can considerably slow down the execution. -.TP -.B LIST_UNAVAILABLE -This option enables listing also unavailable packages in the packages list. -Disabled by default. -.TP -.B LIST_DOCUMENTATION -This option enables the display of references to documents registered with -.BR install\-docs (8) -to the detailed package info, providing a quick path to relevant package -documentation. Unfortunately this feature is not totally reliable because -currently there is no way to find documents registered by a package with -.BR install\-docs (8) -and the search is done with an ugly hack. Hopefully things will change in -woody. This option is enabled (1) by default. -.TP -.B FORCE_SSH_PASSWD -This option forces ssh passwd prompt for package installation on a remote host -even if an ssh agent holds the private key. -.TP -.B GREP_DCTRL_OPTS -These options are passed to -.BR grep-dctrl (1) -when doing a query by field. Default is "\-i" for case-insensitive fixed -substring match. See -.BR grep-dctrl (1) -for more info. -.TP -.B DPKG -Command providing the -.BR dpkg (1) -query functionalities. This can be -.BR dpkg (1) -or -.BR dlocate (1), -or -.BR auto . -Default is -.BR auto , -meaning that the CGI will use -.BR dlocate (1) -if installed, otherwise revert to -.BR dpkg (1) -which should always be available on a Debian system. By specifying this -option you can force the use of one of the two program. -.TP -.B MAN -Manpage to HTML translation command. Can be -.BR dwww (7), -.B man2html -or -.B auto . -Default is -.BR auto , -meaning that the CGI will use -.B man2thml -if installed, otherwise revert to -.BR dwww (7). -By specifying this option you can force the use of one of the two program. -.TP -.B DEBIAN_CONTENTS -Optional list of one or more -.I Contents\-xxx.gz -files mapping each file available in the Debian system to -the package from which it originates. If available these files are used -to find the owner packages of non installed files. This can be useful for -quickly finding the package to install when a needed command is missing. -.TP -.B BGCOLOR -background color of the HTML body. -.TP -.B DEBUG -Internal option used only for debugging. Disabled by default since it is -useless for normal users. -.TP -.B DWWW_PATH -Path on webserver to \fBdwww\fP(7) cgi-bin. -.TP -.B INFO2WWW_PATH -Path on webserver to \fBinfo2www\fP(1) cgi-bin. - -.PP -The following is an exaple \fI/etc/dpkg-www.conf\fP file: - -.PP -.in +2 -# Enable install check-buttons in package list. -.br -CHECK_BUTTONS=0 -.br - -.br -# Enable install, upgrade and remove buttons in package info. -.br -INSTALL_BUTTON=1 -.br - -.br -# List registered package documentation. -.br -LIST_DOCUMENTATION=1 -.br - -.br -# Options passed to grep\-dctrl in queryPackagesByField() -.br -GREP_DCTRL_OPTS="\-i" -.br - -.br -# Show local files directly. Automatically set. -.br -SHOW_LOCAL_FILES=auto -.br - -.br -# Force ssh passwd prompt even if an ssh agent holds -.br -# the private key. -.br -FORCE_SSH_PASSWD=true -.br - -.br -# List of Contents\-xxx.gz files, if available. -.br -DEBIAN_CONTENTS=" -.br -\ \ \ \ \ \ \ \ /debian/dists/buster/Contents\-amd64.gz -.br -\ \ \ \ \ \ \ \ /debian/dists/buster-updates/Contents\-amd64.gz -\ \ \ \ \ \ \ \ /debian-security/dists/buster/updates/Contents\-amd64.gz" -.br - -.br -# Dpkg command (dpkg|dlocate|auto). Automatically detected. -.br -# DPKG=auto -.br - -.br -# Manpage conversion command (dwww|man2html|auto). Automatically detected. -.br -# MAN=auto -.br - -.br -# HTML background color. -.br -# BGCOLOR="#c0c0c0" -.br - -.br -# Enable CGI debugging. Not really useful. -.br -# DEBUG=1 -.PP - -.SS CGI access -The information provided by -.B dpkg\-www -and the ability to install or remove packages also remotely can potentially -give useful information to crackers and open security holes. For these reasons -access to this CGI program should be allowed only from localhost and trusted -hosts or domains. Unfortunately this configuration is dependent on the -particular installed web server. -The \fBdpkg\-www\fP package configures the \fBapache\fP -server, if installed, to allow access only from localhost. Other web servers -must be configured manually by the system administrator to restrict access -to trusted hosts. If you administer many Debian system on a local network -you may want to enable access to the CGI from your network and browse -packages on any host from any other machine. - -.SS Web installation -If this option is enabled in the -.I /etc/dpkg\-www.conf -file, the 'Install', 'Upgrade' and 'Remove' buttons are added to the info -page of installed or uninstalled packages. -By clicking on this button the system administrator, or more precisely any -user who has the ability to become system administrator (since you don't -want to run a web browser as root!), will be able to install or remove a -package on the fly, provided he has properly configured his browser for web -installation. - -.PP -For security reasons the installation is done entirely from the browser side, -so that you don't need to gain root privileges from the CGI program which is -run on the server. The only thing done on the server is to generate an -installation request which is downloaded to the browser for the execution, -which is started under control of the user and with his privileges. -The real installation is done by a small helper script run from the user's -browser when a document with content-type 'application/dpkg\-www\-installer' -is received from the web server. The helper script opens an XTerm on the -user's display and runs a script which becomes superuser, after asking the -root password, and execs an \fBapt\-get\fP(8) command to install the requested -packages. - -.PP -The web browser must have been configured to handle the above content-type -by running the command "\fB/usr/sbin/dpkg\-www\-installer \-x \-f '%s'\fP", -which must obviously be installed also on the client side if installing -remotely. -If the -.B dpkg-www -package is not installed on the browser client you can simply -copy the script \fI/usr/sbin/dpkg\-www\-installer\fP and hope it works... - -.PP -You can configure your -.B Firefox -browser from the General -> Application menu of the Preferences window. -You must add a new item with MIME type -"\fBapplication/dpkg\-www\-installer\fP" -and application "\fB/usr/sbin/dpkg\-www\-installer \-x \-f '%s'\fP". -This should add the following line to your Firefox mailcap file: -.PP -.in +2 -application/dpkg\-www\-installer;/usr/sbin/dpkg\-www\-installer \-x \-f '%s' -.PP -The -.B dpkg\-www -web installation has been successfully tested only with -.BR Firefox . -With other web browsers it is untested and it may not work correctly. - -.PP -In order to be able to install the packages the user must known the root -password asked for '\fBsu root\fP' when installing on the local server, -or have the ability to ssh as root to the remote host when installing -from a remote client. - -.PP -From the security point of view, executing a web installation is functionally -equivalent to opening a shell in an XTerm, becoming superuser after having -supplied the proper password and running \fBapt\-get\fP(8) as root to install -or remove the required packages. -Starting this from the web could be potentially vulnerable to -man-in-the-middle (MITM) attacks, but since it requires a password on the -client it seems quite safe. -If you are really paranoid connect to a secure server from an SSL-enabled -browser. - -.PP -The \fBdpkg\-www\fP web installation is not intended to replace the normal -use of \fBapt\-get\fP(8) from the shell. -It is provided only as a shortcut to allow the installation of a package -after having located it with the browser without needing to open a root -shell and run \fBapt\-get\fP(8) manually. -For normal package maintenance and system upgrade the use of -\fBapt\-get\fP(8) from the shell is recommended. - -.SH ENVIRONMENT -.TP -.B DPKG_WWW_HOST -The hostname to use. - -.SH FILES -.TP -.I /etc/dpkg-www.conf -Configuration file for \fBdpkg\-www\fP. -It is not necessary for this file to exist, -there are sensible defaults for everything. - -.SH SEE ALSO -.BR dpkg (1), -.BR dwww (1), -.BR dwww (7), -.BR dlocate (1), -.BR man2html (8), -.BR grep\-dctrl (1). diff -Nru dpkg-www-2.60/src/dpkg-www.8.pod dpkg-www-2.61/src/dpkg-www.8.pod --- dpkg-www-2.60/src/dpkg-www.8.pod 1970-01-01 00:00:00.000000000 +0000 +++ dpkg-www-2.61/src/dpkg-www.8.pod 2020-12-30 01:18:20.000000000 +0000 @@ -0,0 +1,364 @@ +# Copyright © 2002, 2005 Massimo Dal Zotto +# Copyright © 2017, 2019 Guillem Jover +# +# This is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +=head1 NAME + +dpkg-www, dpkg-www-installer - WWW Debian package browser + +=head1 SYNOPSIS + +https:///cgi-bin/dpkg + +=head1 DESCRIPTION + +A typical Debian system can have hundreds installed packages and thousands +available for installation. Information about installed and available +packages can usually be obtained with the B(1) +command, but navigating through the package dependencies and the +documentation files can be a very frustrating and time-consuming task. + +With the B +CGI you can instead browse Debian packages info with a web browser, +following package dependencies and locating documentation (man pages, +Info files, READMEs, and so on) with few mouse clicks. If you have +superuser privileges you can even install, upgrade or remove packages +from your web browser. +The output provided by B is basically that of B(1) +with the addition of HREF's for packages dependencies and documentation +files. + +The CGI program can take an optional query argument which can be given in +the URL or entered in the query field of the HTML form. This can be: + +=over + +=item I + +List concisely all installed packages. + +=item B<*> (asterisk) + +List concisely all installed and available packages. + +=item I + +List concisely the requested packages. + +=item I + +List concisely all packages whose name matches the expression, for +example '*image*' will find all packages which contain the string 'image'. + +=item I + +List verbosely a package and, if the package is installed, all its files. +If the package is not installed and the web installation is enabled you +can install it by clicking on the 'Install' button. If the package is +installed you can remove it or upgrade to a new version, if available, +by clicking on the respective buttons. + +=item I + +List all the packages owners of a file. This can be used for example to find +which package installed a program. + +=item BI + +List all the packages owners of a file. The regexp form can be used to find +which packages own a non installed file. + +=item IB<=>I + +List all the packages with control field matching value. If the field name is +omitted the value is searched in any control field. The default search is a +case-insensitive fixed substring match but it can be changed with the +B option in the config file. +This feature works only if the B(1) package is installed. + +=item B (question mark) + +Show a concise help about the CGI usage. + +=item I (a single space) + +Print only the input form, for use from window-manager menus. + +=back + +=head2 Configuration + +B can be configured by the local system administrator via the +optional F file. +This file is a simple Bourne shell (F) +script that defines some or all the following variables +(defaults are used if the file doesn't exist, or doesn't define the variable): + +=over + +=item B + +If this option is enabled B +will add a small 'install' check-button for each package shown in the package +list. Default is 0 (disabled) because the resulting interface is not very nice. +The use of this option is therefore not recommended. + +=item B + +If this option is set the 'Install' or 'Upgrade' and 'Remove' buttons will +be added to the verbose info of a package. By clicking on these button you +will start the installation of removal the package as described in the section +B. +Since this option can potentially introduce security holes it is disabled (0) +by default. Use at your own risk. +If the variable is set to "top" the button will be located before the file +list, default is the bottom of the page. + +=item B + +If this variable is set, B will use file:/ style URL's to +access html files -- bypassing the CGI script. This is faster +on slow machines. Default is not defined, which means use local files +for connection from localhost and https:// URL's for remote connections. + +=item B + +If this variable is set, B will check if a newer version +of an installed package is available. +On slow machines you may want to set this option to +false since it can considerably slow down the execution. + +=item B + +This option enables listing also unavailable packages in the packages list. +Disabled by default. + +=item B + +This option enables the display of references to documents registered with +B(8) +to the detailed package info, providing a quick path to relevant package +documentation. Unfortunately this feature is not totally reliable because +currently there is no way to find documents registered by a package with +B(8) +and the search is done with an ugly hack. Hopefully things will change in +woody. This option is enabled (1) by default. + +=item B + +This option forces ssh passwd prompt for package installation on a remote host +even if an ssh agent holds the private key. + +=item B + +These options are passed to B(1) +when doing a query by field. Default is "-i" for case-insensitive fixed +substring match. See B(1) for more info. + +=item B + +Command providing the B(1) query functionalities. This can be +B(1) or B(1), or B. +Default is B, meaning that the CGI will use B(1) +if installed, otherwise revert to B(1) +which should always be available on a Debian system. By specifying this +option you can force the use of one of the two program. + +=item B + +Man page to HTML translation command. Can be B(7), B +or B. +Default is B, meaning that the CGI will use B +if installed, otherwise revert to B(7). +By specifying this option you can force the use of one of the two program. + +=item B + +Optional list of one or more I +files mapping each file available in the Debian system to +the package from which it originates. If available these files are used +to find the owner packages of non installed files. This can be useful for +quickly finding the package to install when a needed command is missing. + +=item B + +Background color of the HTML body. + +=item B + +Internal option used only for debugging. Disabled by default since it is +useless for normal users. + +=item B + +Path on web server to B(7) cgi-bin. + +=item B + +Path on web server to B(1) cgi-bin. + +=back + +The following is an example F file: + + # Enable install check-buttons in package list. + CHECK_BUTTONS=0 + + # Enable install, upgrade and remove buttons in package info. + INSTALL_BUTTON=1 + + # List registered package documentation. + LIST_DOCUMENTATION=1 + + # Options passed to grep-dctrl in queryPackagesByField() + GREP_DCTRL_OPTS="-i" + + # Show local files directly. Automatically set. + SHOW_LOCAL_FILES=auto + + # Force ssh passwd prompt even if an ssh agent holds + # the private key. + FORCE_SSH_PASSWD=true + + # List of Contents-xxx.gz files, if available. + DEBIAN_CONTENTS=" + /debian/dists/buster/Contents-amd64.gz + /debian/dists/buster-updates/Contents-amd64.gz + /debian-security/dists/buster/updates/Contents-amd64.gz" + + # Dpkg command (dpkg|dlocate|auto). Automatically detected. + # DPKG=auto + + # Manpage conversion command (dwww|man2html|auto). Automatically detected. + # MAN=auto + + # HTML background color. + # BGCOLOR="#c0c0c0" + + # Enable CGI debugging. Not really useful. + # DEBUG=1 + +=head2 CGI access + +The information provided by B +and the ability to install or remove packages also remotely can potentially +give useful information to crackers and open security holes. For these reasons +access to this CGI program should be allowed only from localhost and trusted +hosts or domains. Unfortunately this configuration is dependent on the +particular installed web server. +The B package configures the B +server, if installed, to allow access only from localhost. Other web servers +must be configured manually by the system administrator to restrict access +to trusted hosts. If you administer many Debian system on a local network +you may want to enable access to the CGI from your network and browse +packages on any host from any other machine. + +=head2 Web installation + +If this option is enabled in the F +file, the 'Install', 'Upgrade' and 'Remove' buttons are added to the info +page of installed or uninstalled packages. +By clicking on this button the system administrator, or more precisely any +user who has the ability to become system administrator (since you don't +want to run a web browser as root!), will be able to install or remove a +package on the fly, provided he has properly configured his browser for web +installation. + +For security reasons the installation is done entirely from the browser side, +so that you don't need to gain root privileges from the CGI program which is +run on the server. The only thing done on the server is to generate an +installation request which is downloaded to the browser for the execution, +which is started under control of the user and with his privileges. +The real installation is done by a small helper script run from the user's +browser when a document with content-type 'application/dpkg-www-installer' +is received from the web server. The helper script opens an XTerm on the +user's display and runs a script which becomes superuser, after asking the +root password, and execs an B(8) command to install the requested +packages. + +The web browser must have been configured to handle the above content-type +by running the command "B", +which must obviously be installed also on the client side if installing +remotely. +If the B +package is not installed on the browser client you can simply +copy the script F and hope it works... + +You can configure your B +browser from the General -> Application menu of the Preferences window. +You must add a new item with MIME type +"B" +and application "B". +This should add the following line to your Firefox mailcap file: + + application/dpkg-www-installer;/usr/sbin/dpkg-www-installer -x -f '%s' + +The B web installation has been successfully tested only with +B. +With other web browsers it is untested and it may not work correctly. + +In order to be able to install the packages the user must known the root +password asked for 'B' when installing on the local server, +or have the ability to ssh as root to the remote host when installing +from a remote client. + +From the security point of view, executing a web installation is functionally +equivalent to opening a shell in an XTerm, becoming superuser after having +supplied the proper password and running B(8) as root to install +or remove the required packages. +Starting this from the web could be potentially vulnerable to +man-in-the-middle (MITM) attacks, but since it requires a password on the +client it seems quite safe. +If you are really paranoid connect to a secure server from an SSL-enabled +browser. + +The B web installation is not intended to replace the normal +use of B(8) from the shell. +It is provided only as a shortcut to allow the installation of a package +after having located it with the browser without needing to open a root +shell and run B(8) manually. +For normal package maintenance and system upgrade the use of +B(8) from the shell is recommended. + +=head1 ENVIRONMENT + +=over + +=item B + +The hostname to use. + +=back + +=head1 FILES + +=over + +=item F + +Configuration file for B. +It is not necessary for this file to exist, +there are sensible defaults for everything. + +=back + +=head1 SEE ALSO + +B(1), +B(1), +B(7), +B(1), +B(8), +B(1).