Added pkgtools in base
This commit is contained in:
parent
5050084a66
commit
e9b869aa6a
14 changed files with 3188 additions and 0 deletions
|
@ -66,6 +66,7 @@ tar
|
|||
sysklogd
|
||||
gawk
|
||||
sed
|
||||
pkgtools
|
||||
zip
|
||||
unzip
|
||||
popt
|
||||
|
|
41
base/pkgtools/manpages/explodepkg.8
Normal file
41
base/pkgtools/manpages/explodepkg.8
Normal file
|
@ -0,0 +1,41 @@
|
|||
.\" -*- nroff -*-
|
||||
.ds g \" empty
|
||||
.ds G \" empty
|
||||
.\" Like TP, but if specified indent is more than half
|
||||
.\" the current line-length - indent, use the default indent.
|
||||
.de Tp
|
||||
.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
|
||||
.el .TP "\\$1"
|
||||
..
|
||||
.TH EXPLODEPKG 8 "21 May 1994" "Slackware Version 2.0.0"
|
||||
.SH NAME
|
||||
explodepkg \- Extract the contents of a tar+compression package (such as a Slackware
|
||||
software package) in the current directory.
|
||||
.SH SYNOPSIS
|
||||
.B explodepkg
|
||||
.BI package
|
||||
.BI [
|
||||
.BI package2,
|
||||
.BI package3,
|
||||
.BI ...
|
||||
.BI ]
|
||||
.SH DESCRIPTION
|
||||
.B explodepkg
|
||||
uncompresses and untars Slackware *.tgz (or .tbz, .tlz, .txz) packages (or any archive
|
||||
that was created by
|
||||
compressing a tarfile with one of the supported compression utilities) in the current directory. It is not usually
|
||||
used to install packages, since it doesn't execute the installation scripts
|
||||
in ./install or ./var/log/setup. The primary use for
|
||||
.B explodepkg
|
||||
is in package maintenance - exploding a package in a subdirectory, making fixes
|
||||
to it or upgrading the software, and then building the updated package with
|
||||
.B makepkg.
|
||||
.SH AUTHOR
|
||||
Patrick J. Volkerding <volkerdi@slackware.com>
|
||||
.SH "SEE ALSO"
|
||||
.BR tar(1),
|
||||
.BR gzip(1),
|
||||
.BR installpkg(8),
|
||||
.BR makepkg(8),
|
||||
.BR pkgtool(8),
|
||||
.BR upgradepkg(8)
|
111
base/pkgtools/manpages/installpkg.8
Normal file
111
base/pkgtools/manpages/installpkg.8
Normal file
|
@ -0,0 +1,111 @@
|
|||
.\" -*- nroff -*-
|
||||
.ds g \" empty
|
||||
.ds G \" empty
|
||||
.\" Like TP, but if specified indent is more than half
|
||||
.\" the current line-length - indent, use the default indent.
|
||||
.de Tp
|
||||
.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
|
||||
.el .TP "\\$1"
|
||||
..
|
||||
.TH INSTALLPKG 8 "22 Nov 2001" "Slackware Version 8.1.0"
|
||||
.SH NAME
|
||||
installpkg \- install Slackware packages.
|
||||
.SH SYNOPSIS
|
||||
.B installpkg
|
||||
[
|
||||
.B \--warn
|
||||
]
|
||||
[
|
||||
.B \--md5sum
|
||||
]
|
||||
[
|
||||
.B \--root /otherroot
|
||||
]
|
||||
[
|
||||
.B \--infobox
|
||||
]
|
||||
[
|
||||
.B \--menu
|
||||
]
|
||||
[
|
||||
.B \--terse
|
||||
]
|
||||
[
|
||||
.B \--ask
|
||||
]
|
||||
[
|
||||
.B \--priority ADD|REC|OPT|SKP
|
||||
]
|
||||
[
|
||||
.B \--tagfile /somedir/tagfile
|
||||
]
|
||||
.BI packagename
|
||||
[
|
||||
.B packagename2 ...
|
||||
]
|
||||
.SH DESCRIPTION
|
||||
.B installpkg
|
||||
installs single or multiple *.tgz (or .tbz, .tlz, .txz) binary packages designed
|
||||
for use with the Slackware Linux distribution onto your system.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \--warn packagename
|
||||
Generate a list of files that would be overwritten to the standard output, but do
|
||||
not actually install the package. The list is formatted in a suitable fashion to
|
||||
use as a list of files to backup.
|
||||
.TP
|
||||
.B \--md5sum packagename
|
||||
Record the package md5sum in the metadata written in /var/log/packages.
|
||||
.TP
|
||||
.B \--root /otherroot
|
||||
Install using a location other than / (the default) as the root of the
|
||||
filesystem to install on. In the example given, use /otherroot instead. Setting
|
||||
the ROOT environment variable does the same thing.
|
||||
.TP
|
||||
.B \--infobox
|
||||
Use /bin/dialog to display an informational dialog as the package is installed.
|
||||
Primarily used when installpkg is called from other scripts.
|
||||
.TP
|
||||
.B \--menu
|
||||
Use /bin/dialog to display a menu asking the user if they would like to install the
|
||||
package(s) or not. Generally used when installpkg is called from other scripts.
|
||||
.TP
|
||||
.B \--terse
|
||||
Install the package displaying only a single description line to stdout.
|
||||
.TP
|
||||
.B \--ask
|
||||
Used with -menu mode. When selected, always ask if a package should be
|
||||
installed regardless of what the package's priority is.
|
||||
.TP
|
||||
.B \--priority ADD|REC|OPT|SKP
|
||||
When installing with the \-menu option, package priority levels (found in the file
|
||||
"tagfile" in the package directory) are used to automatically install (ADD) or
|
||||
skip (SKP) a package, or to suggest recommended (REC) or optional (OPT) to the user
|
||||
if a menu is displayed. If a priority is set on the command line, it will override
|
||||
the values set in the tagfile for the entire package list.
|
||||
.TP
|
||||
.B \--tagfile /somedir/tagfile
|
||||
Specify a different file to use for package priorities (in this example, /somedir/tagfile
|
||||
will be used). The default is "tagfile" in the package's directory.
|
||||
.SH EXAMPLES
|
||||
.TP
|
||||
.B Install a font package for X:
|
||||
.P
|
||||
installpkg font-bh-ttf-1.0.3-noarch-1.txz
|
||||
.P
|
||||
Note that if a package is already installed, upgradepkg(8) should be used instead.
|
||||
.TP
|
||||
.B Create a backup of the files that would be overwritten if the package is installed:
|
||||
.P
|
||||
.nf
|
||||
tar czvf /tmp/backup.tar.gz \\
|
||||
$(installpkg --warn font-bh-ttf-1.0.3-noarch-1.txz)
|
||||
.fi
|
||||
.SH AUTHOR
|
||||
Patrick J. Volkerding <volkerdi@slackware.com>
|
||||
.SH "SEE ALSO"
|
||||
.BR makepkg(8),
|
||||
.BR removepkg(8),
|
||||
.BR explodepkg(8),
|
||||
.BR pkgtool(8),
|
||||
.BR upgradepkg(8)
|
135
base/pkgtools/manpages/makepkg.8
Normal file
135
base/pkgtools/manpages/makepkg.8
Normal file
|
@ -0,0 +1,135 @@
|
|||
.\" -*- nroff -*-
|
||||
.ds g \" empty
|
||||
.ds G \" empty
|
||||
.\" Like TP, but if specified indent is more than half
|
||||
.\" the current line-length - indent, use the default indent.
|
||||
.de Tp
|
||||
.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
|
||||
.el .TP "\\$1"
|
||||
..
|
||||
.TH MAKEPKG 8 "21 May 1994" "Slackware Version 2.0.0"
|
||||
.SH NAME
|
||||
makepkg \- make Slackware packages.
|
||||
.SH SYNOPSIS
|
||||
.B makepkg
|
||||
[
|
||||
.B -l, --linkadd y|n
|
||||
]
|
||||
[
|
||||
.B -c, --chown y|n
|
||||
]
|
||||
.BI packagename
|
||||
.SH DESCRIPTION
|
||||
.B makepkg
|
||||
creates a new Slackware compatible package.
|
||||
The package is constructed using the contents of the current directory and
|
||||
all subdirectories. If symbolic links exist, they will be converted to script
|
||||
code to recreate them when the package is installed. This code will be
|
||||
appended to the primary installation script
|
||||
.B ( install/doinst.sh )
|
||||
, or, if that script does not exist it will be created with those contents.
|
||||
The package will be written out to the file
|
||||
.BI packagename
|
||||
which should be the full name, including the extension. This is usually .tgz,
|
||||
but .tbz, .tlz, and .txz are also accepted. The proper compression utility
|
||||
(gzip, bzip2, lzma, or xz) needs to be installed on the machine.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-l, --linkadd y|n
|
||||
If y, add any symbolic links found to the install script (doinst.sh) and
|
||||
delete them. This is the recommended action. If this option is not used,
|
||||
makepkg will prompt if symbolic links are found.
|
||||
.TP
|
||||
.B \-p, --prepend
|
||||
If this option is given, then any symbolic links added to doinst.sh will be
|
||||
prepended to the existing script. This is useful for packages that contain
|
||||
shared libraries that need to be linked first because programs will use them
|
||||
later in the doinst.sh script.
|
||||
.TP
|
||||
.B \-c, --chown y|n
|
||||
If y, makepkg will reset all directory permissions to 755 and ownership to root:root.
|
||||
In general, you should have the permissions and ownerships worked out yourself, so
|
||||
relying on setting this option to y is somewhat sloppy. It is not the default. If an
|
||||
option is not provided, makepkg will prompt.
|
||||
.SH INSTALLATION SCRIPTS
|
||||
There are 3 types of installation scripts supported in the Slackware package
|
||||
system.
|
||||
.TP
|
||||
The first is the
|
||||
.B primary
|
||||
installation script. This is found in the subdirectory
|
||||
.B ./install
|
||||
and must have the name
|
||||
.B doinst.sh
|
||||
in order to be recognized. This ( and other install scripts ) should be written
|
||||
using the basic Bourne shell syntax recognized by the
|
||||
.B ash
|
||||
shell, since this is the shell that will be used to execute the script when
|
||||
installing from a Slackware install floppy. This is a common trap - beware of
|
||||
using
|
||||
.B bash
|
||||
syntax extensions, because the script will work fine when installed from the
|
||||
hard drive, but will bomb out when installed from floppy. If the package is
|
||||
for personal use, this isn't a problem. Be careful, though, if you plan to
|
||||
share your package with other users. The
|
||||
.B primary installation script
|
||||
is executed immediately after the package is installed with
|
||||
.B installpkg, pkgtool,
|
||||
or
|
||||
.B setup.
|
||||
.TP
|
||||
The second type of script is the
|
||||
.B configuration
|
||||
script. This is found in the subdirectory
|
||||
.B ./var/log/setup
|
||||
and must have a name that starts with
|
||||
.B setup.
|
||||
in order to be recongnized. An example is the timezone script:
|
||||
.B /var/log/setup/setup.timeconfig.
|
||||
These scripts are executed during the
|
||||
.B CONFIGURE
|
||||
phase of
|
||||
.B setup,
|
||||
and are re-executed each time the user runs the
|
||||
.B CONFIGURE
|
||||
option from
|
||||
.B setup
|
||||
from then on.
|
||||
Typically, the user will go through this phase of setup following the
|
||||
installation of all the packages. Anything that needs to be interactive
|
||||
should go in one of these scripts to avoid halting the package installation
|
||||
process during
|
||||
.B setup.
|
||||
.TP
|
||||
The third type of script is the
|
||||
.B onlyonce
|
||||
script. Like the name suggests, these are executed only once after the package
|
||||
is installed, in contrast to the standard
|
||||
.B configuration
|
||||
script. These scripts are also found in the
|
||||
.B ./var/log/setup
|
||||
directory and must have a name that starts with
|
||||
.B setup.,
|
||||
but in addition the name must contain the string
|
||||
.B onlyonce.
|
||||
An example might be a script with the name
|
||||
.B /var/log/setup/setup.onlyonce.testscript
|
||||
.SH PACKAGE FORMAT
|
||||
.B makepkg
|
||||
uses GNU tar plus GNU gzip to create its packages. A simple way to
|
||||
extract the contents of a package (without executing the installation
|
||||
scripts, of course) is to use a command like this:
|
||||
.TP
|
||||
explodepkg package.tgz
|
||||
.TP
|
||||
Or, something like this:
|
||||
.TP
|
||||
gzip -dc package.tgz | tar xvvf -
|
||||
.SH AUTHOR
|
||||
Patrick J. Volkerding <volkerdi@slackware.com>
|
||||
.SH "SEE ALSO"
|
||||
.BR installpkg(8),
|
||||
.BR explodepkg(8),
|
||||
.BR removepkg(8),
|
||||
.BR pkgtool(8),
|
||||
.BR upgradepkg(8)
|
95
base/pkgtools/manpages/pkgtool.8
Normal file
95
base/pkgtools/manpages/pkgtool.8
Normal file
|
@ -0,0 +1,95 @@
|
|||
.\" -*- nroff -*-
|
||||
.ds g \" empty
|
||||
.ds G \" empty
|
||||
.\" Like TP, but if specified indent is more than half
|
||||
.\" the current line-length - indent, use the default indent.
|
||||
.de Tp
|
||||
.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
|
||||
.el .TP "\\$1"
|
||||
..
|
||||
.TH PKGTOOL 8 "24 Nov 1995" "Slackware Version 3.1.0"
|
||||
.SH NAME
|
||||
pkgtool \- software package maintenance tool.
|
||||
.SH SYNOPSIS
|
||||
.B pkgtool
|
||||
.LP
|
||||
.B pkgtool
|
||||
[
|
||||
.B --sets #a#b#c#
|
||||
]
|
||||
[
|
||||
.B --source_mounted
|
||||
]
|
||||
[
|
||||
.B --ignore_tagfiles
|
||||
]
|
||||
[
|
||||
.B --tagfile tagfile
|
||||
]
|
||||
[
|
||||
.B --source_dir directory
|
||||
]
|
||||
[
|
||||
.B --target_dir directory
|
||||
]
|
||||
[
|
||||
.B --source_device device
|
||||
]
|
||||
.SH DESCRIPTION
|
||||
.B pkgtool
|
||||
is a menu-driven package maintenance tool provided with the Slackware Linux
|
||||
distribution. It allows the user to install, remove, or view
|
||||
software packages through an interactive
|
||||
system. Pkgtool can also be used to re-run the menu-driven scripts normally
|
||||
executed at the end of a Slackware installation. This is useful for doing
|
||||
basic reconfiguration (like changing the mouse type).
|
||||
.SH OPTIONS
|
||||
Most users will not want to use any options when running
|
||||
.B pkgtool.
|
||||
These are generally used only when
|
||||
.B pkgtool
|
||||
is run during the initial system installation.
|
||||
Feel free to try them, but be careful.
|
||||
.TP
|
||||
.B \--sets #A#B#C#
|
||||
Install the disk sets A, B, C. Seperate the disk set names by '#' symbols.
|
||||
.TP
|
||||
.B \--source_mounted
|
||||
When this flag is present,
|
||||
.B pkgtool
|
||||
will not attempt to unmount and remount the source device with each disk.
|
||||
.TP
|
||||
.B \--ignore_tagfiles
|
||||
When this flag is present,
|
||||
.B pkgtool
|
||||
will install every package encountered no matter what the tagfiles say.
|
||||
.TP
|
||||
.B \--tagfile tagfile
|
||||
This flag is used to specify from the command line which tagfile should be
|
||||
used for the installation.
|
||||
.TP
|
||||
.B \--source_dir directory
|
||||
Used when installing multiple packages from disk sets. This is the directory
|
||||
in which the subdirectories for each disk are found. This isn't used when
|
||||
installing from floppy.
|
||||
.TP
|
||||
.B \--target_dir directory
|
||||
The directory where the target root directory is located. This is '/' when
|
||||
installing on the hard drive, or typically '/mnt' when installing from an
|
||||
install disk.
|
||||
.TP
|
||||
.B \--source_device device
|
||||
The source device to install from. This is not used if you've provided the
|
||||
.B \--source_mounted
|
||||
flag. It's usually used when installing from floppy, as in:
|
||||
\--source_device /dev/fd0u1440
|
||||
or
|
||||
\--source_device /dev/fd1h1200.
|
||||
.SH AUTHOR
|
||||
Patrick J. Volkerding <volkerdi@slackware.com>
|
||||
.SH "SEE ALSO"
|
||||
.BR makepkg(8),
|
||||
.BR explodepkg(8),
|
||||
.BR installpkg(8),
|
||||
.BR removepkg(8),
|
||||
.BR upgradepkg(8)
|
108
base/pkgtools/manpages/removepkg.8
Normal file
108
base/pkgtools/manpages/removepkg.8
Normal file
|
@ -0,0 +1,108 @@
|
|||
.\" -*- nroff -*-
|
||||
.ds g \" empty
|
||||
.ds G \" empty
|
||||
.\" Like TP, but if specified indent is more than half
|
||||
.\" the current line-length - indent, use the default indent.
|
||||
.de Tp
|
||||
.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
|
||||
.el .TP "\\$1"
|
||||
..
|
||||
.TH REMOVEPKG 8 "23 Nov 2001" "Slackware Version 8.1.0"
|
||||
.SH NAME
|
||||
removepkg \- remove Slackware packages.
|
||||
.SH SYNOPSIS
|
||||
.B removepkg
|
||||
.BI packagename
|
||||
.LP
|
||||
[
|
||||
.B ROOT=/mnt
|
||||
]
|
||||
.B removepkg
|
||||
[
|
||||
.B \-copy
|
||||
]
|
||||
[
|
||||
.B \-keep
|
||||
]
|
||||
[
|
||||
.B \-preserve
|
||||
]
|
||||
[
|
||||
.B \-warn
|
||||
]
|
||||
.BI packagename
|
||||
.SH DESCRIPTION
|
||||
.B removepkg
|
||||
removes a previously installed Slackware package, while writing a progress
|
||||
report to the standard output. A package may be specified either by the
|
||||
full package name (as you'd see listed in /var/log/packages/), or by the
|
||||
base package name. For example, the package foo-1.0-i486-1.tgz may be removed
|
||||
with any of the following commands:
|
||||
|
||||
removepkg foo-1.0-i486-1.tgz (also recognized: .tbz, .tlz, .txz)
|
||||
|
||||
removepkg foo-1.0-i486-1
|
||||
|
||||
removepkg foo.tgz
|
||||
|
||||
removepkg foo
|
||||
|
||||
When deleting files,
|
||||
.B removepkg
|
||||
will analyze the contents of the other packages installed on your system, and
|
||||
will only delete the files that are unique to the package being removed.
|
||||
Similarly, the installation scripts for all the other packages will be
|
||||
considered when deciding whether or not to delete symbolic links from the
|
||||
package.
|
||||
.LP
|
||||
Removing a package (as well as installing one) can be a dangerous undertaking.
|
||||
For this reason, there is the
|
||||
.B \-warn
|
||||
option available. When you use this,
|
||||
.B removepkg
|
||||
will not actually remove any files or links, but will output a detailed report
|
||||
of what it would do if you actually did remove the package. It's suggested that
|
||||
you do this (and maybe pipe the output to
|
||||
.B less
|
||||
) before removing packages to make sure you've backed up anything that might
|
||||
be important.
|
||||
.LP
|
||||
When removing a package, it's original file index will be moved from
|
||||
/var/log/packages to /var/log/removed_packages. Likewise, it's installation
|
||||
script will be moved from /var/log/scripts to /var/log/removed_scripts.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-warn packagename
|
||||
Generate a report to the standard output about which files and directories
|
||||
would be removed, but does not actually remove the package.
|
||||
.TP
|
||||
.B \-preserve packagename
|
||||
If specified, the complete package subtree is reconstructed in
|
||||
/var/log/setup/tmp/preserved_packages/packagename.
|
||||
.TP
|
||||
.B \-copy packagename
|
||||
Construct a copy of the package under /var/log/setup/tmp/preserved_packages/packagename,
|
||||
but don't remove it. (same effect as \-warn \-preserve)
|
||||
.TP
|
||||
.B \-keep
|
||||
Save the intermediate files created by removepkg (delete_list,
|
||||
required_files, uniq_list, del_link_list, required_links,
|
||||
required_list). Mostly useful for debugging purposes.
|
||||
.SH " "
|
||||
It's possible to remove a package from a filesystem
|
||||
other than / by supplying
|
||||
.B removepkg
|
||||
with a
|
||||
.B ROOT
|
||||
environment variable:
|
||||
.TP
|
||||
.B ROOT=/mnt removepkg package
|
||||
|
||||
.SH AUTHORS
|
||||
Patrick J. Volkerding <volkerdi@slackware.com>,
|
||||
with enhancements by Christian Franke <c.franke@acm.org>
|
||||
.SH "SEE ALSO"
|
||||
.BR installpkg(8),
|
||||
.BR makepkg(8),
|
||||
.BR pkgtool(8),
|
||||
.BR upgradepkg(8)
|
98
base/pkgtools/manpages/upgradepkg.8
Normal file
98
base/pkgtools/manpages/upgradepkg.8
Normal file
|
@ -0,0 +1,98 @@
|
|||
.\" -*- nroff -*-
|
||||
.ds g \" empty
|
||||
.ds G \" empty
|
||||
.\" Like TP, but if specified indent is more than half
|
||||
.\" the current line-length - indent, use the default indent.
|
||||
.de Tp
|
||||
.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
|
||||
.el .TP "\\$1"
|
||||
..
|
||||
.TH UPGRADEPKG 8 "31 May 2002" "Slackware Version 8.1.0"
|
||||
.SH NAME
|
||||
upgradepkg \- upgrade Slackware packages.
|
||||
.SH SYNOPSIS
|
||||
.B upgradepkg
|
||||
[
|
||||
.B --dry-run
|
||||
]
|
||||
[
|
||||
.B --install-new
|
||||
]
|
||||
[
|
||||
.B --reinstall
|
||||
]
|
||||
[
|
||||
.B --verbose
|
||||
]
|
||||
.BI newpackagename
|
||||
.BI [ newpackagename2 ]
|
||||
.LP
|
||||
.B upgradepkg
|
||||
[
|
||||
.B --dry-run
|
||||
]
|
||||
[
|
||||
.B --install-new
|
||||
]
|
||||
[
|
||||
.B --reinstall
|
||||
]
|
||||
[
|
||||
.B --verbose
|
||||
]
|
||||
.BI oldpackagename%newpackagename
|
||||
.BI [ old2%new2 ]
|
||||
.SH DESCRIPTION
|
||||
.B upgradepkg
|
||||
upgrades a Slackware package from an older version to a
|
||||
newer one. It does this by
|
||||
.B INSTALLING
|
||||
the new package onto the system, and then
|
||||
.B REMOVING
|
||||
any files from the old package that aren't in the new package.
|
||||
If the old and new packages have the same name, a single argument is all that
|
||||
is required. If the packages have different names, supply the name of the
|
||||
old package followed by a percent symbol (%), then the name of the new package.
|
||||
Do not add any extra whitespace between pairs of old/new package names.
|
||||
|
||||
If upgradepkg finds more than one installed package matching the old package's
|
||||
name, it will remove them all.
|
||||
.TP
|
||||
To upgrade in a directory other than / (such as /mnt):
|
||||
.TP
|
||||
ROOT=/mnt upgradepkg package.tgz (or .tbz, .tlz, .txz)
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \--dry-run
|
||||
Output a report about which packages would be installed or upgraded
|
||||
but don't actually perform the upgrades.
|
||||
.TP
|
||||
.B \--install-new
|
||||
Normally upgradepkg only upgrades packages that are already installed on the system, and
|
||||
will skip any packages that do not already have a version installed.
|
||||
If
|
||||
.B --install-new
|
||||
is specified, the behavior is modified to install new packages in addition to upgrading
|
||||
existing ones.
|
||||
.TP
|
||||
.B \--reinstall
|
||||
Upgradepkg usually skips packages if the exact same package
|
||||
(matching name, version, arch, and build number) is already installed on the system.
|
||||
Use the --reinstall option if you want to upgrade all packages even if the same
|
||||
version is already installed.
|
||||
.TP
|
||||
.B \--verbose
|
||||
Show all the gory details of the upgrade.
|
||||
.SH BUGS
|
||||
Before upgrading a package, save any configuration files (such as in /etc)
|
||||
that you wish to keep. Sometimes these will be preserved, but it depends on
|
||||
the package structure. If you want to force new versions of the config files
|
||||
to be installed, remove the old ones manually prior to running upgradepkg.
|
||||
.SH AUTHOR
|
||||
Patrick J. Volkerding <volkerdi@slackware.com>
|
||||
.SH "SEE ALSO"
|
||||
.BR makepkg(8),
|
||||
.BR installpkg(8),
|
||||
.BR removepkg(8),
|
||||
.BR explodepkg(8),
|
||||
.BR pkgtool(8)
|
43
base/pkgtools/pkgtools.SMBuild
Executable file
43
base/pkgtools/pkgtools.SMBuild
Executable file
|
@ -0,0 +1,43 @@
|
|||
APP=pkgtools
|
||||
VERSION=14.2
|
||||
BUILD=1sml
|
||||
HOMEPAGE="https://slackware.uk/slackware/slackware-14.2/source/a/pkgtools/"
|
||||
DOWNLOAD="https://slackware.uk/slackware/slackware-14.2/source/a/pkgtools/"
|
||||
DESC="The Slackware package maintenance system, modified for SMLinux"
|
||||
REQUIRES="tar grep gawk sed bash util-linux coreutils"
|
||||
ARCH=noarch
|
||||
SM_SKIPCHECKSUM=1
|
||||
|
||||
build() {
|
||||
mkandenterbuilddir
|
||||
rm -rf $APP-$VERSION
|
||||
|
||||
# Install Slackware script manpages:
|
||||
( cd $SRCDIR/manpages
|
||||
mkdir -p $PKG/share/man/man8
|
||||
for page in explodepkg.8 installpkg.8 makepkg.8 upgradepkg.8 pkgtool.8 \
|
||||
removepkg.8 ; do
|
||||
cat $page | gzip -9c > $PKG/share/man/man8/$page.gz
|
||||
done
|
||||
)
|
||||
|
||||
# Install Slackware scripts:
|
||||
( cd $SRCDIR/scripts
|
||||
# Install the core Slackware package tools:
|
||||
mkdir -p $PKG/bin
|
||||
for file in explodepkg installpkg makepkg pkgtool removepkg upgradepkg ; do
|
||||
cp -a $SRCDIR/scripts/$file $PKG/bin
|
||||
done
|
||||
chown root:root $PKG/bin/*
|
||||
chmod 755 $PKG/bin/*
|
||||
)
|
||||
|
||||
mkfinalpkg
|
||||
}
|
||||
|
||||
|
||||
#cd $PKG
|
||||
#/bin/makepkg -l y -c n $PKGDEST/$APP-$VERSION-$ARCH-$BUILD.$PKGEXT
|
||||
#[ "$?" = "0" ] && SM_PKGSTATUS=0
|
||||
SHA512SUMS="
|
||||
"
|
97
base/pkgtools/scripts/explodepkg
Executable file
97
base/pkgtools/scripts/explodepkg
Executable file
|
@ -0,0 +1,97 @@
|
|||
#!/bin/sh
|
||||
# Copyright 1994, 1998, 2000 Patrick Volkerding, Concord, CA, USA
|
||||
# Copyright 2001, 2003 Slackware Linux, Inc., Concord, CA, USA
|
||||
# Copyright 2007, 2009 Patrick Volkerding, Sebeka, MN, USA
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use of this script, with or without modification, is
|
||||
# permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of this script must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
TAR=tar-1.13
|
||||
$TAR --help 1> /dev/null 2> /dev/null
|
||||
if [ ! $? = 0 ]; then
|
||||
TAR=tar
|
||||
fi
|
||||
if [ ! "`LC_MESSAGES=C $TAR --version`" = "tar (GNU tar) 1.13
|
||||
|
||||
Copyright (C) 1988, 92,93,94,95,96,97,98, 1999 Free Software Foundation, Inc.
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
Written by John Gilmore and Jay Fenlason." ]; then
|
||||
echo "WARNING: pkgtools are unstable with tar > 1.13."
|
||||
echo " You should provide a \"tar-1.13\" in your \$PATH."
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
if [ $# = 0 ]; then
|
||||
cat << EOF
|
||||
Usage: explodepkg package_name [package_name2, ...]
|
||||
|
||||
Explodes a Slackware compatible software package
|
||||
(or any tar+{gzip,bzip2,lzma,xz archive) in the current directory.
|
||||
Equivalent to (for each package listed):
|
||||
|
||||
( umask 000 ; cat package_name | COMPRESSOR -dc | tar xvf package_name )
|
||||
|
||||
Note: This should only be used for debugging or examining packages, not for
|
||||
installing them. It doesn't execute installation scripts or update the package
|
||||
indexes in /var/log/packages and /var/log/scripts.
|
||||
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Main loop:
|
||||
for PKG in $* ; do
|
||||
echo "Exploding package $PKG in current directory:"
|
||||
# Determine extension:
|
||||
packageext="$( echo $PKG | rev | cut -f 1 -d . | rev)"
|
||||
# Determine compression utility:
|
||||
case $packageext in
|
||||
'tgz' )
|
||||
packagecompression=gzip
|
||||
;;
|
||||
'gz' )
|
||||
packagecompression=gzip
|
||||
;;
|
||||
'tbz' )
|
||||
packagecompression=bzip2
|
||||
;;
|
||||
'bz2' )
|
||||
packagecompression=bzip2
|
||||
;;
|
||||
'tlz' )
|
||||
packagecompression=lzma
|
||||
;;
|
||||
'lzma' )
|
||||
packagecompression=lzma
|
||||
;;
|
||||
'txz' )
|
||||
packagecompression=xz
|
||||
;;
|
||||
'xz' )
|
||||
packagecompression=xz
|
||||
;;
|
||||
esac
|
||||
( umask 000 ; cat $PKG | $packagecompression -dc | $TAR xvf - 2> /dev/null )
|
||||
if [ -r install/doinst.sh ]; then
|
||||
echo
|
||||
echo "An installation script was detected in ./install/doinst.sh, but"
|
||||
echo "was not executed."
|
||||
fi
|
||||
done
|
||||
|
554
base/pkgtools/scripts/installpkg
Executable file
554
base/pkgtools/scripts/installpkg
Executable file
|
@ -0,0 +1,554 @@
|
|||
#!/bin/sh
|
||||
# Copyright 1994, 1998, 2000 Patrick Volkerding, Concord, CA, USA
|
||||
# Copyright 2001, 2003 Slackware Linux, Inc., Concord, CA, USA
|
||||
# Copyright 2007, 2009, 2011 Patrick Volkerding, Sebeka, MN, USA
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use of this script, with or without modification, is
|
||||
# permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of this script must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Sun Sep 6 21:58:36 BST 2009
|
||||
# Replaced usage of "cat" with STDIN redirection or file name parameters
|
||||
# to speed up execution on ARM.
|
||||
# Replaced pkgbase & package_name code with 'sed' script by Jim Hawkins.
|
||||
#
|
||||
# Sat Apr 25 21:18:53 UTC 2009
|
||||
# Converted to use new pkgbase() function to remove pathname and
|
||||
# valid package extensions.
|
||||
#
|
||||
# Sat Apr 4 22:58:06 CDT 2009
|
||||
# Support additional compression formats if the supporting utilities exist:
|
||||
# .tbz - bzip2
|
||||
# .tlz - lzip
|
||||
# .txz - xz (also LZMA)
|
||||
# And of course, .tgz (gzip) is not going anywhere. :-) <volkerdi>
|
||||
# Add command switches to determine the uncompressed package size even if
|
||||
# that will slow things down, and to add the package's md5sum to the
|
||||
# metadata stored in /var/log/packages/.
|
||||
#
|
||||
# Fri Dec 21 17:21:35 CST 2007
|
||||
# Added a patch from Johnny Morano to work around package removal issues
|
||||
# caused by packages that do not comply with FHS combined with a grep
|
||||
# regex error in installpkg. Any package with a single-letter top-
|
||||
# level directory could not be removed.
|
||||
#
|
||||
# Shortened some of the top-line dialog output to avoid overflowing the
|
||||
# textbox (needed as some of the packages, especially in X, have very
|
||||
# long base package names now). <pjv>
|
||||
#
|
||||
# Sun Nov 26 12:38:25 CST 1995
|
||||
# Added patch from Glenn Moloney <glenn@physics.unimelb.edu.au> to allow
|
||||
# packages to be installed to directories other than /.
|
||||
#
|
||||
# Wed Mar 18 15:15:51 CST 1998
|
||||
# Changed $TMP directory to /var/log/setup/tmp, and chmod'ed it 700 to close
|
||||
# some security holes.
|
||||
|
||||
# A stronger formula is needed to regularize output that will be parsed.
|
||||
unset LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
|
||||
LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT \
|
||||
LC_IDENTIFICATION LC_ALL
|
||||
LANG=C
|
||||
export LANG
|
||||
|
||||
# Return a package name that has been stripped of the dirname portion
|
||||
# and any of the valid extensions (only):
|
||||
pkgbase() {
|
||||
# basename + strip extensions .tbz, .tgz, .tlz and .txz
|
||||
echo "$1" | sed 's?.*/??;s/\.t[bglx]z$//'
|
||||
}
|
||||
|
||||
# If installpkg encounters a problem, it will return a non-zero error code.
|
||||
# If it finds more than one problem (i.e. with a list of packages) you'll only
|
||||
# hear about the most recent one. :)
|
||||
# 1 = tar returned error code
|
||||
# 2 = corrupt compression envelope
|
||||
# 3 = does not end in .tgz
|
||||
# 4 = no such file
|
||||
# 5 = external compression utility missing
|
||||
# 99 = user abort from menu mode
|
||||
EXITSTATUS=0
|
||||
|
||||
# Do not store md5sums by default:
|
||||
MD5SUM=0
|
||||
|
||||
# So that we know what to expect...
|
||||
umask 022
|
||||
TAR=tar-1.13
|
||||
$TAR --help 1> /dev/null 2> /dev/null
|
||||
if [ ! $? = 0 ]; then
|
||||
TAR=tar
|
||||
fi
|
||||
if [ ! "$(LC_MESSAGES=C $TAR --version)" = "tar (GNU tar) 1.13
|
||||
|
||||
Copyright (C) 1988, 92,93,94,95,96,97,98, 1999 Free Software Foundation, Inc.
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
Written by John Gilmore and Jay Fenlason." ]; then
|
||||
echo "WARNING: pkgtools are unstable with tar > 1.13."
|
||||
echo " You should provide a \"tar-1.13\" in your \$PATH."
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
Usage: installpkg [options] <package_filename>
|
||||
|
||||
Installpkg is used to install a .t{gz,bz,lz,xz} package like this:
|
||||
installpkg slackware-package-1.0.0-i486-1.tgz (or .tbz, .tlz, .txz)
|
||||
|
||||
options: --warn (warn if files will be overwritten, but do not install)
|
||||
--root /mnt (install someplace else, like /mnt)
|
||||
--infobox (use dialog to draw an info box)
|
||||
--terse (display a one-line short description for install)
|
||||
--menu (confirm package installation with a menu, unless
|
||||
the priority is [required] or ADD)
|
||||
--ask (used with menu mode: always ask if a package should be
|
||||
installed regardless of what the package's priority is)
|
||||
--priority ADD|REC|OPT|SKP (provide a priority for the entire
|
||||
package list to use instead of the priority in the
|
||||
tagfile)
|
||||
--tagfile /somedir/tagfile (specify a different file to use
|
||||
for package priorities. The default is "tagfile" in
|
||||
the package's directory)
|
||||
--md5sum (record the package's md5sum in the metadata file)
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# Eliminate whitespace function:
|
||||
crunch() {
|
||||
while read FOO ; do
|
||||
echo $FOO
|
||||
done
|
||||
}
|
||||
|
||||
# Strip version, architecture and build from the end of the name
|
||||
package_name() {
|
||||
pkgbase $1 | sed 's?-[^-]*-[^-]*-[^-]*$??'
|
||||
}
|
||||
|
||||
# Parse options:
|
||||
MODE=install # standard text-mode
|
||||
while [ 0 ]; do
|
||||
if [ "$1" = "-warn" -o "$1" = "--warn" ]; then
|
||||
MODE=warn
|
||||
shift 1
|
||||
elif [ "$1" = "-md5sum" -o "$1" = "--md5sum" ]; then
|
||||
MD5SUM=1
|
||||
shift 1
|
||||
elif [ "$1" = "-infobox" -o "$1" = "--infobox" ]; then
|
||||
MODE=infobox
|
||||
shift 1
|
||||
elif [ "$1" = "-terse" -o "$1" = "--terse" ]; then
|
||||
MODE=terse
|
||||
shift 1
|
||||
elif [ "$1" = "-menu" -o "$1" = "--menu" ]; then
|
||||
MODE=menu
|
||||
shift 1
|
||||
elif [ "$1" = "-ask" -o "$1" = "--ask" ]; then
|
||||
ALWAYSASK="yes"
|
||||
shift 1
|
||||
elif [ "$1" = "-tagfile" -o "$1" = "--tagfile" ]; then
|
||||
if [ -r "$2" ]; then
|
||||
USERTAGFILE="$2"
|
||||
elif [ -r "$(pwd)/$2" ]; then
|
||||
USERTAGFILE="$(pwd)/$2"
|
||||
else
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
shift 2
|
||||
elif [ "$1" = "-priority" -o "$1" = "--priority" ]; then
|
||||
if [ "$2" = "" ]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
USERPRIORITY="$2"
|
||||
shift 2
|
||||
elif [ "$1" = "-root" -o "$1" = "--root" ]; then
|
||||
if [ "$2" = "" ]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
ROOT="$2"
|
||||
shift 2
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Set the prefix for the package database directories (packages, scripts).
|
||||
ADM_DIR="$ROOT/var/log"
|
||||
# If the directories don't exist, "initialize" the package database:
|
||||
for PKGDBDIR in packages removed_packages removed_scripts scripts setup ; do
|
||||
if [ ! -d $ADM_DIR/$PKGDBDIR ]; then
|
||||
rm -rf $ADM_DIR/$PKGDBDIR # make sure it's not a symlink or something stupid
|
||||
mkdir -p $ADM_DIR/$PKGDBDIR
|
||||
chmod 755 $ADM_DIR/$PKGDBDIR
|
||||
fi
|
||||
done
|
||||
|
||||
# Make sure there's a proper temp directory:
|
||||
TMP=$ADM_DIR/setup/tmp
|
||||
# If the $TMP directory doesn't exist, create it:
|
||||
if [ ! -d $TMP ]; then
|
||||
rm -rf $TMP # make sure it's not a symlink or something stupid
|
||||
mkdir -p $TMP
|
||||
chmod 700 $TMP # no need to leave it open
|
||||
fi
|
||||
|
||||
# usage(), exit if called with no arguments:
|
||||
if [ $# = 0 ]; then
|
||||
usage;
|
||||
exit
|
||||
fi
|
||||
|
||||
# If -warn mode was requested, produce the output and then exit:
|
||||
if [ "$MODE" = "warn" ]; then
|
||||
while [ -f "$1" ]; do
|
||||
mkdir -p $TMP/scan$$
|
||||
# Determine extension:
|
||||
packageext="$( echo $1 | rev | cut -f 1 -d . | rev)"
|
||||
# Determine compressor utility:
|
||||
case $packageext in
|
||||
'tgz' )
|
||||
packagecompression=gzip
|
||||
;;
|
||||
'tbz' )
|
||||
packagecompression=bzip2
|
||||
;;
|
||||
'tlz' )
|
||||
packagecompression=lzip
|
||||
;;
|
||||
'txz' )
|
||||
packagecompression=xz
|
||||
;;
|
||||
esac
|
||||
( cd $TMP/scan$$ ; $packagecompression -dc | $TAR xf - install ) < $1 2> /dev/null
|
||||
if [ -r $TMP/scan$$/install/doinst.sh ]; then
|
||||
if grep ' rm -rf ' $TMP/scan$$/install/doinst.sh 1>/dev/null 2>/dev/null ; then
|
||||
grep ' rm -rf ' $TMP/scan$$/install/doinst.sh > $TMP/scan$$/install/delete
|
||||
for f in `cat $TMP/scan$$/install/delete | cut -f 3,7 -d ' ' | tr ' ' '/'`; do
|
||||
f="/$f"
|
||||
if [ -f "$f" -o -L "$f" ]; then
|
||||
echo "$f"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ -d $TMP/scan$$ ]; then
|
||||
( cd $TMP/scan$$ ; rm -rf install ) 2> /dev/null
|
||||
( cd $TMP ; rmdir scan$$ ) 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
for f in `( $packagecompression -dc | $TAR tf - ) < $1 | grep -v 'drwx'`; do
|
||||
f="/$f"
|
||||
if [ -f "$f" -o -L "$f" ]; then
|
||||
echo "$f"
|
||||
fi
|
||||
done
|
||||
shift 1
|
||||
done
|
||||
exit
|
||||
fi
|
||||
|
||||
# Main loop:
|
||||
for package in $* ; do
|
||||
|
||||
# Simple package integrity check:
|
||||
if [ ! -f $package ]; then
|
||||
EXITSTATUS=4
|
||||
if [ "$MODE" = "install" ]; then
|
||||
echo "Cannot install $package: file not found"
|
||||
fi
|
||||
continue;
|
||||
fi
|
||||
|
||||
# "shortname" isn't really THAT short...
|
||||
# it's just the full name without ".t{gz,bz,lz,xz}"
|
||||
shortname="$(pkgbase $package)"
|
||||
packagedir="$(dirname $package)"
|
||||
# This is the base package name, used for grepping tagfiles and descriptions:
|
||||
packagebase="$(package_name $shortname)"
|
||||
|
||||
# Reject package if it does not end in '.t{gz,bz,lz,xz}':
|
||||
if [ "$shortname" = "$(basename $package)" ]; then
|
||||
EXITSTATUS=3
|
||||
if [ "$MODE" = "install" ]; then
|
||||
echo "Cannot install $package: file does not end in .tgz, .tbz, .tlz, or .txz"
|
||||
fi
|
||||
continue;
|
||||
fi
|
||||
|
||||
# Determine extension:
|
||||
packageext="$(echo $package | rev | cut -f 1 -d . | rev)"
|
||||
|
||||
# Determine compressor utility:
|
||||
case $packageext in
|
||||
'tgz' )
|
||||
packagecompression=gzip
|
||||
;;
|
||||
'tbz' )
|
||||
packagecompression=bzip2
|
||||
;;
|
||||
'tlz' )
|
||||
packagecompression=lzip
|
||||
;;
|
||||
'txz' )
|
||||
packagecompression=xz
|
||||
;;
|
||||
esac
|
||||
|
||||
# Test presence of external compression utility:
|
||||
if ! $packagecompression --help 1> /dev/null 2> /dev/null ; then
|
||||
EXITSTATUS=5
|
||||
if [ "$MODE" = "install" ]; then
|
||||
echo "Cannot install $package: external compression utility $packagecompression missing"
|
||||
fi
|
||||
continue;
|
||||
fi
|
||||
|
||||
# Determine package's priority:
|
||||
unset PRIORITY
|
||||
if [ "$USERTAGFILE" = "" ]; then
|
||||
TAGFILE="$packagedir/tagfile"
|
||||
else
|
||||
TAGFILE="$USERTAGFILE"
|
||||
fi
|
||||
if [ ! -r "$TAGFILE" ]; then
|
||||
TAGFILE=/dev/null
|
||||
fi
|
||||
if grep "^$packagebase:" "$TAGFILE" | grep ADD > /dev/null 2> /dev/null ; then
|
||||
PRIORITY="ADD"
|
||||
elif grep "^$packagebase:" "$TAGFILE" | grep REC > /dev/null 2> /dev/null ; then
|
||||
PRIORITY="REC"
|
||||
elif grep "^$packagebase:" "$TAGFILE" | grep OPT > /dev/null 2> /dev/null ; then
|
||||
PRIORITY="OPT"
|
||||
elif grep "^$packagebase:" "$TAGFILE" | grep SKP > /dev/null 2> /dev/null ; then
|
||||
PRIORITY="SKP"
|
||||
fi
|
||||
if [ "$PRIORITY" = "ADD" ]; then
|
||||
PMSG="[ADD]"
|
||||
elif [ "$PRIORITY" = "REC" ]; then
|
||||
PMSG="[REC]"
|
||||
elif [ "$PRIORITY" = "OPT" ]; then
|
||||
PMSG="[OPT]"
|
||||
elif [ "$PRIORITY" = "SKP" ]; then
|
||||
PMSG="[SKP]"
|
||||
else
|
||||
PMSG=""
|
||||
fi
|
||||
|
||||
# If a tagfile wants this package to be skipped, do that now before
|
||||
# wasting any more CPU on it:
|
||||
if [ "$PRIORITY" = "SKP" -a ! "$ALWAYSASK" = "yes" ]; then
|
||||
continue # next package
|
||||
fi
|
||||
|
||||
# Figure out some package information, like the compressed and uncompressed
|
||||
# sizes, and where to find the package description:
|
||||
COMPRESSED="$(/bin/du -sh "$(readlink -f $package)" | cut -f 1)"
|
||||
DESCRIPTION=""
|
||||
# First check for .txt file next to the package, since this is faster:
|
||||
if grep "^$packagebase:" "$packagedir/$shortname.txt" 1> /dev/null 2> /dev/null ; then
|
||||
DESCRIPTION="$packagedir/$shortname.txt"
|
||||
elif grep "^$shortname:" "$packagedir/$shortname.txt" 1> /dev/null 2> /dev/null ; then
|
||||
DESCRIPTION="$packagedir/$shortname.txt"
|
||||
fi
|
||||
|
||||
# Test tarball integrity and get uncompressed package size:
|
||||
if [ "$MODE" = "install" ]; then
|
||||
echo "Verifying package $(basename $package)."
|
||||
fi
|
||||
cat $package | $packagecompression -dc | dd 2> $TMP/tmpsize$$ | $TAR tf - 1> $TMP/tmplist$$ 2> /dev/null
|
||||
TARERROR=$?
|
||||
if [ ! "$TARERROR" = "0" ]; then
|
||||
EXITSTATUS=1 # tar file corrupt
|
||||
if [ "$MODE" = "install" ]; then
|
||||
echo "Unable to install $package: tar archive is corrupt (tar returned error code $TARERROR)"
|
||||
fi
|
||||
rm -f $TMP/tmplist$$ $TMP/tmpsize$$
|
||||
continue
|
||||
fi
|
||||
UNCOMPRESSED="$(cat $TMP/tmpsize$$ | tail -n 1 | cut -f 1 -d ' ' | numfmt --to=iec)"
|
||||
rm -f $TMP/tmpsize$$
|
||||
|
||||
# If we still don't have a package description, look inside the package.
|
||||
# This requires a costly untar.
|
||||
if [ "$DESCRIPTION" = "" ]; then
|
||||
mkdir -p $TMP/scan$$
|
||||
( cd $TMP/scan$$ ; $packagecompression -dc | $TAR xf - install ) < $package 2> /dev/null
|
||||
if grep "^$packagebase:" "$TMP/scan$$/install/slack-desc" 1> /dev/null 2> /dev/null ; then
|
||||
DESCRIPTION="$TMP/scan$$/install/slack-desc"
|
||||
elif grep "^$shortname:" "$TMP/scan$$/install/slack-desc" 1> /dev/null 2> /dev/null ; then
|
||||
DESCRIPTION="$TMP/scan$$/install/slack-desc"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$DESCRIPTION" = "" ]; then
|
||||
#echo "WARNING NO SLACK-DESC"
|
||||
DESCRIPTION="/dev/null"
|
||||
fi
|
||||
|
||||
# Gather package infomation into a temporary file:
|
||||
grep "^$packagebase:" $DESCRIPTION | cut -f 2- -d : | cut -b2- 1> $TMP/tmpmsg$$ 2> /dev/null
|
||||
if [ "$shortname" != "$packagebase" ]; then
|
||||
grep "^$shortname:" $DESCRIPTION | cut -f 2- -d : | cut -b2- 1>> $TMP/tmpmsg$$ 2> /dev/null
|
||||
fi
|
||||
# Adjust the length here. This allows a slack-desc to be any size up to 13 lines instead of fixed at 11.
|
||||
LENGTH=$(wc -l < $TMP/tmpmsg$$ )
|
||||
while [ $LENGTH -lt 12 ]; do
|
||||
echo >> $TMP/tmpmsg$$
|
||||
LENGTH=$(expr $LENGTH + 1)
|
||||
done
|
||||
echo "Size: Compressed: ${COMPRESSED}, uncompressed: ${UNCOMPRESSED}." >> $TMP/tmpmsg$$
|
||||
# For recent versions of dialog it is necessary to add \n to the end of each line
|
||||
# or it will remove repeating spaces and mess up our careful formatting:
|
||||
cat << EOF > $TMP/controlns$$
|
||||
\n
|
||||
\n
|
||||
\n
|
||||
\n
|
||||
\n
|
||||
\n
|
||||
\n
|
||||
\n
|
||||
\n
|
||||
\n
|
||||
\n
|
||||
\n
|
||||
\n
|
||||
EOF
|
||||
paste -d "" $TMP/tmpmsg$$ $TMP/controlns$$ > $TMP/pasted$$
|
||||
rm -f $TMP/controlns$$
|
||||
mv $TMP/pasted$$ $TMP/tmpmsg$$
|
||||
# Emit information to the console:
|
||||
if [ "$MODE" = "install" ]; then
|
||||
if [ "$PMSG" = "" ]; then
|
||||
echo "Installing package $(basename $package):"
|
||||
else
|
||||
echo "Installing package $(basename $package) $PMSG:"
|
||||
fi
|
||||
echo "PACKAGE DESCRIPTION:"
|
||||
grep "^$packagebase:" $DESCRIPTION | uniq | sed "s/^$packagebase:/#/g"
|
||||
if [ "$shortname" != "$packagebase" ]; then
|
||||
grep "^$shortname:" $DESCRIPTION | uniq | sed "s/^$shortname:/#/g"
|
||||
fi
|
||||
elif [ "$MODE" = "terse" ]; then # emit a single description line
|
||||
printf "%-72s %-6s\n" "$(echo $shortname: $(echo $(cat $DESCRIPTION | grep "^$packagebase:" | sed "s/^$packagebase: //g" | head -n 1 | tr -d '()' | sed "s/^$packagebase //g" ) $(echo " ......................................................................")) | cut -b1-72)" "[${UNCOMPRESSED}]" | cut -b1-80
|
||||
elif [ "$MODE" = "infobox" ]; then # install infobox package
|
||||
dialog --title "Installing package $shortname $PMSG" --infobox "$(cat $TMP/tmpmsg$$)" 0 0
|
||||
elif [ "$MODE" = "menu" -a "$PRIORITY" = "ADD" -a ! "$ALWAYSASK" = "yes" ]; then # ADD overrides menu mode unless -ask was used
|
||||
dialog --title "Installing package $shortname $PMSG" --infobox "$(cat $TMP/tmpmsg$$)" 0 0
|
||||
elif [ "$MODE" = "menu" -a "$USERPRIORITY" = "ADD" ]; then # install no matter what $PRIORITY
|
||||
dialog --title "Installing package $shortname $PMSG" --infobox "$(cat $TMP/tmpmsg$$)" 0 0
|
||||
else # we must need a full menu:
|
||||
dialog --title "Package Name: $shortname $PMSG" --menu "$(cat $TMP/tmpmsg$$)" 0 0 3 \
|
||||
"Yes" "Install package $shortname" \
|
||||
"No" "Do not install package $shortname" \
|
||||
"Quit" "Abort software installation completely" 2> $TMP/reply$$
|
||||
if [ ! $? = 0 ]; then
|
||||
echo "No" > $TMP/reply$$
|
||||
fi
|
||||
REPLY="$(cat $TMP/reply$$)"
|
||||
rm -f $TMP/reply$$ $TMP/tmpmsg$$
|
||||
if [ "$REPLY" = "Quit" ]; then
|
||||
exit 99 # EXIT STATUS 99 = ABORT!
|
||||
elif [ "$REPLY" = "No" ]; then
|
||||
continue # skip the package
|
||||
fi
|
||||
fi
|
||||
|
||||
# Make sure there are no symbolic links sitting in the way of
|
||||
# incoming package files:
|
||||
grep -v "/$" $TMP/tmplist$$ | while read file ; do
|
||||
if [ -L "$ROOT/$file" ]; then
|
||||
rm -f "$ROOT/$file"
|
||||
fi
|
||||
done
|
||||
rm -f $TMP/tmplist$$
|
||||
|
||||
# Write the package file database entry and install the package:
|
||||
echo "PACKAGE NAME: $shortname" > $ADM_DIR/packages/$shortname
|
||||
echo "COMPRESSED PACKAGE SIZE: $COMPRESSED" >> $ADM_DIR/packages/$shortname
|
||||
echo "UNCOMPRESSED PACKAGE SIZE: $UNCOMPRESSED" >> $ADM_DIR/packages/$shortname
|
||||
echo "PACKAGE LOCATION: $package" >> $ADM_DIR/packages/$shortname
|
||||
# Record the md5sum if that's a selected option:
|
||||
if [ $MD5SUM = 1 ]; then
|
||||
echo "PACKAGE MD5SUM: $(md5sum $package | cut -f 1 -d ' ')" >> $ADM_DIR/packages/$shortname
|
||||
fi
|
||||
echo "PACKAGE DESCRIPTION:" >> $ADM_DIR/packages/$shortname
|
||||
grep "^$packagebase:" $DESCRIPTION >> $ADM_DIR/packages/$shortname 2> /dev/null
|
||||
if [ "$shortname" != "$packagebase" ]; then
|
||||
grep "^$shortname:" $DESCRIPTION >> $ADM_DIR/packages/$shortname 2> /dev/null
|
||||
fi
|
||||
echo "FILE LIST:" >> $ADM_DIR/packages/$shortname
|
||||
( cd $ROOT/ ; $packagecompression -dc | $TAR -xlUpvf - | sort ) < $package >> $TMP/$shortname 2> /dev/null
|
||||
if [ "$( grep '^\./' $TMP/$shortname | wc -l | tr -d ' ')" = "1" ]; then
|
||||
# Good. We have a package that meets the Slackware spec.
|
||||
cat $TMP/$shortname >> $ADM_DIR/packages/$shortname
|
||||
else
|
||||
# Some dumb bunny built a package with something other than makepkg. Bad!
|
||||
# Oh well. Bound to happen. Par for the course. Fix it and move on...
|
||||
echo "WARNING: Package has not been created with 'makepkg'"
|
||||
echo './' >> $ADM_DIR/packages/$shortname
|
||||
cat $TMP/$shortname >> $ADM_DIR/packages/$shortname
|
||||
fi
|
||||
rm -f $TMP/$shortname
|
||||
|
||||
# It's a good idea to make sure those newly installed libraries
|
||||
# are properly activated for use:
|
||||
if [ -x /sbin/ldconfig ]; then
|
||||
/sbin/ldconfig
|
||||
fi
|
||||
|
||||
if [ -f $ROOT/install/doinst.sh ]; then
|
||||
if [ "$MODE" = "install" ]; then
|
||||
echo "Executing install script for $(basename $package)."
|
||||
fi
|
||||
# If bash is available, use sed to convert the install script to use pushd/popd
|
||||
# rather than spawning subshells which is slow on ARM. This will also speed up
|
||||
# install script processing on any platform.
|
||||
if [ -x /bin/bash ]; then
|
||||
( cd $ROOT/ ; sed -e's?^( cd \([^;]*\);\(.*\) )$?pushd \1 \&\> /dev/null ; \2 ; popd \&\> /dev/null?g ' install/doinst.sh | /bin/bash ; )
|
||||
else
|
||||
( cd $ROOT/ ; sh install/doinst.sh ; )
|
||||
fi
|
||||
fi
|
||||
# Clean up the mess...
|
||||
if [ -d $ROOT/install ]; then
|
||||
if [ -r $ROOT/install/doinst.sh ]; then
|
||||
cp $ROOT/install/doinst.sh $ADM_DIR/scripts/$shortname
|
||||
chmod 755 $ADM_DIR/scripts/$shortname
|
||||
fi
|
||||
# /install/doinst.sh and /install/slack-* are reserved locations for the package system.
|
||||
( cd $ROOT/install ; rm -f doinst.sh slack-* 1> /dev/null 2>&1 )
|
||||
rmdir $ROOT/install 1> /dev/null 2>&1
|
||||
fi
|
||||
# If we used a scan directory, get rid of it:
|
||||
if [ -d "$TMP/scan$$" ]; then
|
||||
rm -rf "$TMP/scan$$"
|
||||
fi
|
||||
rm -f $TMP/tmpmsg$$ $TMP/reply$$
|
||||
if [ "$MODE" = "install" ]; then
|
||||
echo "Package $(basename $package) installed."
|
||||
echo
|
||||
fi
|
||||
done
|
||||
|
||||
exit $EXITSTATUS
|
399
base/pkgtools/scripts/makepkg
Executable file
399
base/pkgtools/scripts/makepkg
Executable file
|
@ -0,0 +1,399 @@
|
|||
#!/bin/sh
|
||||
# Copyright 1994, 1998, 2008 Patrick Volkerding, Moorhead, Minnesota USA
|
||||
# Copyright 2003 Slackware Linux, Inc. Concord, CA USA
|
||||
# Copyright 2009, 2015 Patrick J. Volkerding, Sebeka, MN, USA
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use of this script, with or without modification, is
|
||||
# permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of this script must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Wed Sep 23 18:36:43 UTC 2015
|
||||
# Support spaces in file/directory names. <alphageek>
|
||||
#
|
||||
# Sun Apr 5 21:23:26 CDT 2009
|
||||
# Support .tgz, .tbz, .tlz, and .txz packages. <volkerdi>
|
||||
#
|
||||
# Fri Nov 26 13:53:36 GMT 2004
|
||||
# Patched to chmod 755 the package's root directory if needed, then restore
|
||||
# previous permissions after the package has been created. <sw>
|
||||
#
|
||||
# Wed Mar 18 15:32:33 CST 1998
|
||||
# Patched to avoid possible symlink attacks in /tmp.
|
||||
|
||||
CWD=$(pwd)
|
||||
|
||||
TAR=tar-1.13
|
||||
umask 022
|
||||
$TAR --help 1> /dev/null 2> /dev/null
|
||||
if [ ! $? = 0 ]; then
|
||||
TAR=tar
|
||||
fi
|
||||
if [ ! "$(LC_MESSAGES=C $TAR --version)" = "tar (GNU tar) 1.13
|
||||
|
||||
Copyright (C) 1988, 92,93,94,95,96,97,98, 1999 Free Software Foundation, Inc.
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
Written by John Gilmore and Jay Fenlason." ]; then
|
||||
echo "WARNING: pkgtools are unstable with tar > 1.13."
|
||||
echo " You should provide a \"tar-1.13\" in your \$PATH."
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
make_install_script() {
|
||||
TAB="$(echo -e "\t")"
|
||||
cat "$1" | while read LINE; do
|
||||
if [ "$LINE" = "" ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
# Field 1 is the symlink
|
||||
F1=${LINE%%${TAB}*}
|
||||
# Field 2 is what it points to
|
||||
F2=${LINE##*${TAB}}
|
||||
|
||||
# Simulate dirname with ugly, unreadable, but *fast* POSIX string
|
||||
# manipulation code. First, delete everything after the last /
|
||||
LINKGOESIN=${F1%/*}
|
||||
# If there was no /, nothing got deleted, so dirname should return "."
|
||||
[ "$LINKGOESIN" = "$F1" ] && LINKGOESIN="."
|
||||
|
||||
# Simulate basename (delete everything up to the last /)
|
||||
LINKNAMEIS=${F1##*/}
|
||||
|
||||
LINKPOINTSTO="$F2"
|
||||
echo "( cd $LINKGOESIN ; rm -rf $LINKNAMEIS )"
|
||||
echo "( cd $LINKGOESIN ; ln -sf $LINKPOINTSTO $LINKNAMEIS )"
|
||||
COUNT=$(expr $COUNT + 1)
|
||||
done
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
|
||||
Usage: makepkg package_name.tgz
|
||||
(or: package_name.tbz, package_name.tlz, package_name.txz)
|
||||
|
||||
Makes a Slackware compatible package containing the contents of the current
|
||||
and all subdirectories. If symbolic links exist, they will be removed and
|
||||
an installation script will be made to recreate them later. This script will
|
||||
be called "install/doinst.sh". You may add any of your own ash-compatible
|
||||
shell scripts to this file and rebuild the package if you wish.
|
||||
|
||||
options: -l, --linkadd y|n (moves symlinks into doinst.sh: recommended)
|
||||
-p, --prepend (prepend rather than append symlinks to an existing
|
||||
doinst.sh. Useful to link libraries needed by
|
||||
programs in the doinst.sh script)
|
||||
-c, --chown y|n (resets all permissions to root:root 755
|
||||
- not generally recommended)
|
||||
|
||||
If these options are not set, makepkg will prompt as appropriate.
|
||||
EOF
|
||||
}
|
||||
|
||||
TMP=/tmp # This can be a hole, but I'm going to be careful about file
|
||||
# creation in there, so don't panic. :^)
|
||||
|
||||
# Parse options
|
||||
while [ 0 ]; do
|
||||
if [ "$1" = "--linkadd" -o "$1" = "-l" ]; then
|
||||
if [ "$2" = "y" ]; then
|
||||
LINKADD=y
|
||||
elif [ "$2" = "n" ]; then
|
||||
LINKADD=n
|
||||
else
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
shift 2
|
||||
elif [ "$1" = "--chown" -o "$1" = "-c" ]; then
|
||||
if [ "$2" = "y" ]; then
|
||||
CHOWN=y
|
||||
elif [ "$2" = "n" ]; then
|
||||
CHOWN=n
|
||||
else
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
shift 2
|
||||
elif [ "$1" = "-p" -o "$1" = "--prepend" ]; then
|
||||
PREPEND=y
|
||||
shift 1
|
||||
elif [ "$1" = "-h" -o "$1" = "-H" -o "$1" = "--help" -o $# = 0 ]; then
|
||||
usage
|
||||
exit 0
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
PACKAGE_NAME="$1"
|
||||
TARGET_NAME="$(dirname $PACKAGE_NAME)"
|
||||
PACKAGE_NAME="$(basename $PACKAGE_NAME)"
|
||||
|
||||
# Identify package extension:
|
||||
if [ ! "$(basename $PACKAGE_NAME .tgz)" = "$PACKAGE_NAME" ]; then
|
||||
EXTENSION="tgz"
|
||||
elif [ ! "$(basename $PACKAGE_NAME .tar.gz)" = "$PACKAGE_NAME" ]; then
|
||||
# .tar.compression is also supported, although the resulting "packages" will
|
||||
# not be installable by installpkg without the correct 3 letter extension
|
||||
# instead.
|
||||
EXTENSION="tar.gz"
|
||||
elif [ ! "$(basename $PACKAGE_NAME .tbz)" = "$PACKAGE_NAME" ]; then
|
||||
EXTENSION="tbz"
|
||||
elif [ ! "$(basename $PACKAGE_NAME .tar.bz2)" = "$PACKAGE_NAME" ]; then
|
||||
EXTENSION="tar.bz2"
|
||||
elif [ ! "$(basename $PACKAGE_NAME .tlz)" = "$PACKAGE_NAME" ]; then
|
||||
EXTENSION="tlz"
|
||||
elif [ ! "$(basename $PACKAGE_NAME .tar.lz)" = "$PACKAGE_NAME" ]; then
|
||||
EXTENSION="tar.lz"
|
||||
elif [ ! "$(basename $PACKAGE_NAME .txz)" = "$PACKAGE_NAME" ]; then
|
||||
EXTENSION="txz"
|
||||
elif [ ! "$(basename $PACKAGE_NAME .tar.xz)" = "$PACKAGE_NAME" ]; then
|
||||
EXTENSION="tar.xz"
|
||||
else
|
||||
EXTENSION="$(echo $PACKAGE_NAME | rev | cut -f 1 -d . | rev)"
|
||||
echo "ERROR: Package extension .$EXTENSION is not supported."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TAR_NAME="$(basename $PACKAGE_NAME .$EXTENSION)"
|
||||
|
||||
# Sanity check -- we can't make the package in the current directory:
|
||||
if [ "$CWD" = "$TARGET_NAME" -o "." = "$TARGET_NAME" ]; then
|
||||
echo "ERROR: Can't make output package in current directory."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Make sure external compression utility is available:
|
||||
case $EXTENSION in
|
||||
'tgz' | 'tar.gz' )
|
||||
if ! which gzip 1> /dev/null 2> /dev/null ; then
|
||||
echo "ERROR: gzip compression utility not found in \$PATH."
|
||||
exit 3
|
||||
fi
|
||||
;;
|
||||
'tbz' | 'tar.bz2' )
|
||||
if ! which bzip2 1> /dev/null 2> /dev/null ; then
|
||||
echo "ERROR: bzip2 compression utility not found in \$PATH."
|
||||
exit 3
|
||||
fi
|
||||
;;
|
||||
'tlz' | 'tar.lz' )
|
||||
if ! which lzip 1> /dev/null 2> /dev/null ; then
|
||||
echo "ERROR: lzip compression utility not found in \$PATH."
|
||||
exit 3
|
||||
fi
|
||||
;;
|
||||
'txz' | 'tar.xz' )
|
||||
if ! which xz 1> /dev/null 2> /dev/null ; then
|
||||
echo "ERROR: xz compression utility not found in \$PATH."
|
||||
exit 3
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
echo
|
||||
echo "Slackware package maker, version 3.141593."
|
||||
echo
|
||||
echo "Searching for symbolic links:"
|
||||
# Get rid of possible pre-existing trouble:
|
||||
INST=$(mktemp $TMP/makepkg.XXXXXX)
|
||||
find . -type l -printf "%p\t%l\n" | sed 's,^\./,, ; s, ,\\ ,g' | tee $INST
|
||||
if [ ! "$(cat $INST)" = "" ]; then
|
||||
echo
|
||||
echo "Making symbolic link creation script:"
|
||||
make_install_script $INST | tee doinst.sh
|
||||
fi
|
||||
echo
|
||||
if [ ! "$(cat $INST)" = "" ]; then
|
||||
if [ -r install/doinst.sh ]; then
|
||||
echo "Unless your existing installation script already contains the code"
|
||||
echo "to create these links, you should append these lines to your existing"
|
||||
echo "install script. Now's your chance. :^)"
|
||||
echo
|
||||
echo "Would you like to add this stuff to the existing install script and"
|
||||
echo -n "remove the symbolic links ([y]es, [n]o)? "
|
||||
else
|
||||
echo "It is recommended that you make these lines your new installation script."
|
||||
echo
|
||||
echo "Would you like to make this stuff the install script for this package"
|
||||
echo -n "and remove the symbolic links ([y]es, [n]o)? "
|
||||
fi
|
||||
if [ ! "$LINKADD" ]; then
|
||||
read LINKADD;
|
||||
echo
|
||||
else
|
||||
echo $LINKADD
|
||||
echo
|
||||
fi
|
||||
if [ "$LINKADD" = "y" ]; then
|
||||
if [ -r install/doinst.sh ]; then
|
||||
UPDATE="t"
|
||||
if [ "$PREPEND" = "y" ]; then
|
||||
touch install/doinst.sh
|
||||
mv install/doinst.sh install/doinst.sh.shipped
|
||||
cat doinst.sh > install/doinst.sh
|
||||
echo "" >> install/doinst.sh
|
||||
cat install/doinst.sh.shipped >> install/doinst.sh
|
||||
rm -f install/doinst.sh.shipped
|
||||
else
|
||||
cat doinst.sh >> install/doinst.sh
|
||||
fi
|
||||
else
|
||||
mkdir -p install
|
||||
cat doinst.sh > install/doinst.sh
|
||||
fi
|
||||
echo
|
||||
echo "Removing symbolic links:"
|
||||
find . -type l -exec rm -v {} \+
|
||||
echo
|
||||
if [ "$UPDATE" = "t" ]; then
|
||||
if [ "$PREPEND" = "y" ]; then
|
||||
echo "Updating your ./install/doinst.sh (prepending symlinks)..."
|
||||
else
|
||||
echo "Updating your ./install/doinst.sh..."
|
||||
fi
|
||||
else
|
||||
echo "Creating your new ./install/doinst.sh..."
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "No symbolic links were found, so we won't make an installation script."
|
||||
echo "You can make your own later in ./install/doinst.sh and rebuild the"
|
||||
echo "package if you like."
|
||||
fi
|
||||
rm -f doinst.sh $INST
|
||||
echo
|
||||
echo "This next step is optional - you can set the directories in your package"
|
||||
echo "to some sane permissions. If any of the directories in your package have"
|
||||
echo "special permissions, then DO NOT reset them here!"
|
||||
echo
|
||||
echo "Would you like to reset all directory permissions to 755 (drwxr-xr-x) and"
|
||||
echo -n "directory ownerships to root.root ([y]es, [n]o)? "
|
||||
if [ ! "$CHOWN" ]; then
|
||||
read CHOWN;
|
||||
echo
|
||||
else
|
||||
echo $CHOWN
|
||||
echo
|
||||
fi
|
||||
if [ "$CHOWN" = "y" ]; then
|
||||
find . -type d -exec chmod -v 755 {} \;
|
||||
find . -type d -exec chown -v root.root {} \;
|
||||
fi
|
||||
|
||||
# Ensure that the 'root' of the package is chmod 755 because
|
||||
# the / of your filesystem will inherit these permissions.
|
||||
# If it's anything tighter than 755 then bad things happen such as users
|
||||
# not being able to login, users already logged in can no longer run commands
|
||||
# and so on.
|
||||
OLDROOTPERMS="$(find -name . -printf "%m\n")"
|
||||
if [ $OLDROOTPERMS -ne 755 ]; then
|
||||
echo "WARNING: $PWD is chmod $OLDROOTPERMS"
|
||||
echo " temporarily changing to chmod 755"
|
||||
chmod 755 .
|
||||
fi
|
||||
|
||||
echo "Creating Slackware package: ${TARGET_NAME}/${TAR_NAME}.${EXTENSION}"
|
||||
echo
|
||||
rm -f ${TARGET_NAME}/${TAR_NAME}.${EXTENSION}
|
||||
case $EXTENSION in
|
||||
'tgz' | 'tar.gz' )
|
||||
# If $COMPRESSOPTS has not been exported and set by buildvars, try default compression levels
|
||||
[ -z "$COMPRESSOPTS" ] && COMPRESSOPTS="-9c"
|
||||
# Try pigz for parallel compression
|
||||
if which pigz > /dev/null 2>&1 ; then
|
||||
$TAR cvf - . | pigz $COMPRESSOPTS > ${TARGET_NAME}/${TAR_NAME}.${EXTENSION}
|
||||
else
|
||||
$TAR cvf - . | gzip $COMPRESSOPTS > ${TARGET_NAME}/${TAR_NAME}.${EXTENSION}
|
||||
fi
|
||||
ERRCODE=$?
|
||||
if [ ! $? = 0 ]; then
|
||||
echo "ERROR: gzip returned error code $? -- makepkg failed."
|
||||
fi
|
||||
;;
|
||||
'tbz' | 'tar.bz2' )
|
||||
[ -z "$COMPRESSOPTS" ] && COMPRESSOPTS="-9c"
|
||||
$TAR cvf - . | bzip2 $COMPRESSOPTS > ${TARGET_NAME}/${TAR_NAME}.${EXTENSION}
|
||||
ERRCODE=$?
|
||||
if [ ! $ERRCODE = 0 ]; then
|
||||
echo "ERROR: bzip2 returned error code $ERRCODE -- makepkg failed."
|
||||
fi
|
||||
;;
|
||||
'tlz' | 'tar.lz' )
|
||||
[ -z "$COMPRESSOPTS" ] && COMPRESSOPTS="-0c"
|
||||
# Try plzip for parallel compression
|
||||
if which plzip > /dev/null 2>&1 ; then
|
||||
$TAR cvf - . | plzip $COMPRESSOPTS > ${TARGET_NAME}/${TAR_NAME}.${EXTENSION}
|
||||
else
|
||||
$TAR cvf - . | lzip $COMPRESSOPTS > ${TARGET_NAME}/${TAR_NAME}.${EXTENSION}
|
||||
fi
|
||||
ERRCODE=$?
|
||||
if [ ! $ERRCODE = 0 ]; then
|
||||
echo "ERROR: (p)lzip returned error code $ERRCODE -- makepkg failed."
|
||||
fi
|
||||
;;
|
||||
'txz' | 'tar.xz' )
|
||||
[ -z "$COMPRESSOPTS" ] && COMPRESSOPTS="-c"
|
||||
$TAR cvf - . | xz $COMPRESSOPTS > ${TARGET_NAME}/${TAR_NAME}.${EXTENSION}
|
||||
ERRCODE=$?
|
||||
if [ ! $ERRCODE = 0 ]; then
|
||||
echo "ERROR: xz returned error code $ERRCODE -- makepkg failed."
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# Warn of zero-length files:
|
||||
find . -type f -size 0c | while read file ; do
|
||||
echo "WARNING: zero length file $(echo $file | cut -b3-)"
|
||||
done
|
||||
|
||||
# Warn of corrupt or empty gzip files:
|
||||
find . -type f -name '*.gz' | while read file ; do
|
||||
if ! gzip -t $file 1> /dev/null 2> /dev/null ; then
|
||||
echo "WARNING: gzip test failed on $(echo $file | cut -b3-)"
|
||||
else
|
||||
if [ "$(gzip -l $file | tail -n 1 | tr -s ' ' | cut -f 3 -d ' ')" -eq 0 ]; then
|
||||
echo "WARNING: $(echo $file | cut -b3-) is an empty gzipped file"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Some more handy warnings:
|
||||
if [ -d usr/share/man ]; then
|
||||
echo "WARNING: /usr/share/man (with possibly not gzipped man pages) detected"
|
||||
fi
|
||||
|
||||
if [ -d usr/share/info ]; then
|
||||
echo "WARNING: /usr/share/info (with possibly not gzipped info pages) detected"
|
||||
fi
|
||||
|
||||
if find . | grep site_perl 1> /dev/null ; then
|
||||
echo "WARNING: site_perl directory detected (this is fine for a local package build)"
|
||||
fi
|
||||
|
||||
# Restore the old permissions if they previously weren't chmod 755
|
||||
if [ $OLDROOTPERMS -ne 755 ]; then
|
||||
echo
|
||||
echo "Restoring permissions of $PWD to chmod $OLDROOTPERMS"
|
||||
chmod $OLDROOTPERMS .
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Slackware package ${TARGET_NAME}/${TAR_NAME}.${EXTENSION} created."
|
||||
echo
|
763
base/pkgtools/scripts/pkgtool
Executable file
763
base/pkgtools/scripts/pkgtool
Executable file
|
@ -0,0 +1,763 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999 Patrick Volkerding, Moorhead, MN USA
|
||||
# Copyright 2001, 2004 Slackware Linux, Inc., Concord, CA USA
|
||||
# All rights reserved.
|
||||
# Copyright 2007, 2009, 2010, 2011, 2013, 2015 Patrick Volkerding, Sebeka, MN, USA
|
||||
#
|
||||
# Redistribution and use of this script, with or without modification, is
|
||||
# permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of this script must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
# Sat Apr 25 21:18:53 UTC 2009
|
||||
# Converted to use new pkgbase() function to remove pathname and
|
||||
# valid package extensions.
|
||||
#
|
||||
# Wed Oct 31 16:28:46 CDT 2007
|
||||
# * Thanks to Gabriele Inghirami for a patch allowing this script to work
|
||||
# with much larger numbers of installed packages.
|
||||
# Wed, 27 Apr 1994 00:06:50 -0700 (PDT)
|
||||
# * Optimization by David Hinds.
|
||||
# Sun Oct 24 23:11:40 BST 2004
|
||||
# * Further optimisations by Jim Hawkins <jawkins@armedslack.org>
|
||||
# - dramatically improved the speed of the "View" option
|
||||
# Thu Nov 04 12:19:56 BST 2004
|
||||
# * More optimisations by Jim Hawkins
|
||||
# - improved "Remove" speed in a similar manner to "View"
|
||||
# Wed Jan 12 16:53:48 GMT 2005
|
||||
# * Fixed quoting bug thanks to Lasse Collin
|
||||
# Wed Jan 26 23:06:22 GMT 2005
|
||||
# * Fix for non-standard package descriptions by Jim Hawkins
|
||||
|
||||
# Avoid problems if any files in /var/log/packages and /var/log/scripts
|
||||
# might contain any broken UTF-8 sequences. This was once known to cause
|
||||
# dialog to crash.
|
||||
unset LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
|
||||
LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT \
|
||||
LC_IDENTIFICATION LC_ALL
|
||||
LANG=C
|
||||
export LANG
|
||||
|
||||
# Return a package name that has been stripped of the dirname portion
|
||||
# and any of the valid extensions (only):
|
||||
pkgbase() {
|
||||
PKGEXT=$(echo $1 | rev | cut -f 1 -d . | rev)
|
||||
case $PKGEXT in
|
||||
'tgz' )
|
||||
PKGRETURN=$(basename $1 .tgz)
|
||||
;;
|
||||
'tbz' )
|
||||
PKGRETURN=$(basename $1 .tbz)
|
||||
;;
|
||||
'tlz' )
|
||||
PKGRETURN=$(basename $1 .tlz)
|
||||
;;
|
||||
'txz' )
|
||||
PKGRETURN=$(basename $1 .txz)
|
||||
;;
|
||||
*)
|
||||
PKGRETURN=$(basename $1)
|
||||
;;
|
||||
esac
|
||||
echo $PKGRETURN
|
||||
}
|
||||
|
||||
SOURCE_DIR=/var/log/mount
|
||||
ASK="tagfiles"
|
||||
if [ -L /bin/chmod -a -L /bin/chown ]; then # probably on the bootdisk using busybox
|
||||
TARGET_DIR=/mnt
|
||||
rootdevice="$(mount | grep ' on /mnt ' | tail -n 1 | cut -f 1 -d ' ' 2> /dev/null)"
|
||||
TMP=/mnt/var/log/setup/tmp
|
||||
if ! mount | grep ' on /mnt ' 1> /dev/null 2> /dev/null ; then
|
||||
echo
|
||||
echo
|
||||
echo "You can't run pkgtool from the rootdisk until you've mounted your Linux"
|
||||
echo "partitions beneath /mnt. Here are some examples:"
|
||||
echo
|
||||
echo "If your root partition is /dev/sda1 you would type:"
|
||||
echo "mount /dev/sda1 /mnt"
|
||||
echo
|
||||
echo "Now you can find a list of all your partitions in /mnt/etc/fstab."
|
||||
echo
|
||||
echo "Then, supposing your /usr partition is /dev/sda2, you must do this:"
|
||||
echo "mount /dev/sda2 /mnt/usr"
|
||||
echo
|
||||
echo "Please mount your Linux partitions and then run pkgtool again."
|
||||
echo
|
||||
exit
|
||||
fi
|
||||
else
|
||||
TARGET_DIR=/
|
||||
rootdevice="$(mount | grep ' on / ' | tail -n 1 | cut -f 1 -d ' ')"
|
||||
TMP=/var/log/setup/tmp
|
||||
fi
|
||||
if [ ! -d $TMP ]; then
|
||||
mkdir -p $TMP
|
||||
chmod 700 $TMP
|
||||
fi
|
||||
ADM_DIR=$TARGET_DIR/var/log
|
||||
LOG=$TMP/PKGTOOL.REMOVED
|
||||
|
||||
# remove whitespace
|
||||
crunch() {
|
||||
while read FOO ; do
|
||||
echo $FOO
|
||||
done
|
||||
}
|
||||
|
||||
package_name() {
|
||||
STRING=$(pkgbase $1)
|
||||
# Check for old style package name with one segment:
|
||||
if [ "$(echo $STRING | cut -f 1 -d -)" = "$(echo $STRING | cut -f 2 -d -)" ]; then
|
||||
echo $STRING
|
||||
else # has more than one dash delimited segment
|
||||
# Count number of segments:
|
||||
INDEX=1
|
||||
while [ ! "$(echo $STRING | cut -f $INDEX -d -)" = "" ]; do
|
||||
INDEX=$(expr $INDEX + 1)
|
||||
done
|
||||
INDEX=$(expr $INDEX - 1) # don't include the null value
|
||||
# If we don't have four segments, return the old-style (or out of spec) package name:
|
||||
if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then
|
||||
echo $STRING
|
||||
else # we have four or more segments, so we'll consider this a new-style name:
|
||||
NAME=$(expr $INDEX - 3)
|
||||
NAME="$(echo $STRING | cut -f 1-$NAME -d -)"
|
||||
echo $NAME
|
||||
# cruft for later ;)
|
||||
#VER=$(expr $INDEX - 2)
|
||||
#VER="$(echo $STRING | cut -f $VER -d -)"
|
||||
#ARCH=$(expr $INDEX - 1)
|
||||
#ARCH="$(echo $STRING | cut -f $ARCH -d -)"
|
||||
#BUILD="$(echo $STRING | cut -f $INDEX -d -)"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
remove_packages() {
|
||||
for pkg_name in $(cat $TMP/return | tr -d "\042")
|
||||
do
|
||||
if [ -r $ADM_DIR/packages/$pkg_name ]; then
|
||||
dialog --title "PACKAGE REMOVAL IN PROGRESS" --cr-wrap --infobox \
|
||||
"\nRemoving package $pkg_name.\n\
|
||||
\n\
|
||||
Since each file must be checked \
|
||||
against the contents of every other installed package to avoid wiping out \
|
||||
areas of overlap, this process can take quite some time. If you'd like to \
|
||||
watch the progress, flip over to another virtual console and type:\n\
|
||||
\n\
|
||||
tail -f $TMP/PKGTOOL.REMOVED\n" 13 60
|
||||
export ROOT=$TARGET_DIR
|
||||
removepkg $pkg_name >> $LOG 2> /dev/null
|
||||
else
|
||||
echo "No such package: $pkg_name. Can't remove." >> $LOG
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
create_list_of_installed_packages()
|
||||
{
|
||||
FILES=$(ls $ADM_DIR/packages)
|
||||
if [ -n "$FILES" ]; then
|
||||
cd $ADM_DIR/packages
|
||||
{ grep '^PACKAGE DESCRIPTION:$' -Z -H -m1 -A1 $FILES; echo; } \
|
||||
| sed -n 'h;n;/\x00/{h;n;};x;s/ */ /g;s/ $//;s/[\"`$]/\\&/g
|
||||
s/\(.*\)\x00\([^:]*:\)\? *\(.*\)/ "\1" "\3" "View information about package \1" \\/;p' > $TMP/list_of_installed_packages \
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
create_list_of_files_to_remove ()
|
||||
{
|
||||
FILES=$(ls $ADM_DIR/packages)
|
||||
if [ -n "$FILES" ]; then
|
||||
cd $ADM_DIR/packages
|
||||
{ grep '^PACKAGE DESCRIPTION:$' -Z -H -m1 -A1 $FILES; echo; } \
|
||||
| sed -n 'h;n;/\x00/{h;n;};x;s/ */ /g;s/ $//;s/[\"`$]/\\&/g
|
||||
s/\(.*\)\x00\([^:]*:\)\? *\(.*\)/ "\1" "\3" off "Select\/Unselect removing package \1" \\/;p' > $TMP/temporary_list \
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
# Here, we read the list of arguments passed to the pkgtool script.
|
||||
if [ $# -gt 0 ]; then # there are arguments to the command
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-sets | --sets)
|
||||
DISK_SETS=$(echo $2 | tr "[A-Z]" "[a-z]") ; shift 2 ;;
|
||||
-source_mounted | --source-mounted)
|
||||
SOURCE_MOUNTED="always" ; shift 1 ;;
|
||||
-ignore_tagfiles | --ignore-tagfiles)
|
||||
ASK="never" ; shift 1 ;;
|
||||
-tagfile | --tagfile)
|
||||
USETAG=$2 ; shift 2 ;;
|
||||
-source_dir | --source_dir)
|
||||
SOURCE_DIR=$2 ; shift 2 ;;
|
||||
-target_dir | --target_dir)
|
||||
TARGET_DIR=$2
|
||||
ADM_DIR=$TARGET_DIR/var/log
|
||||
shift 2 ;;
|
||||
-source_device | --source_device)
|
||||
SOURCE_DEVICE=$2 ; shift 2 ;;
|
||||
esac
|
||||
done
|
||||
else # there were no arguments, so we'll get the needed information from the
|
||||
# user and then go on.
|
||||
CMD_START="true"
|
||||
rm -f $TMP/SeT*
|
||||
while [ 0 ]; do
|
||||
dialog --title "Slackware Package Tool (pkgtool version 14.2)" \
|
||||
--menu "\nWelcome to the Slackware package tool.\n\
|
||||
\nWhich option would you like?\n" 17 75 7 \
|
||||
"Current" "Install packages from the current directory" \
|
||||
"Other" "Install packages from some other directory" \
|
||||
"Floppy" "Install packages from floppy disks" \
|
||||
"Remove" "Remove packages that are currently installed" \
|
||||
"View" "View the list of files contained in a package" \
|
||||
"Setup" "Choose Slackware installation scripts to run again" \
|
||||
"Exit" "Exit Pkgtool" 2> $TMP/reply
|
||||
if [ ! $? = 0 ]; then
|
||||
rm -f $TMP/reply
|
||||
dialog --clear
|
||||
exit
|
||||
fi
|
||||
REPLY="$(cat $TMP/reply)"
|
||||
rm -f $TMP/reply
|
||||
if [ "$REPLY" = "Exit" ]; then
|
||||
dialog --clear
|
||||
exit
|
||||
fi
|
||||
if [ "$REPLY" = "Setup" ]; then
|
||||
echo 'dialog --title "SELECT SYSTEM SETUP SCRIPTS" --item-help --checklist \
|
||||
"Please use the spacebar to select the setup scripts to run. Hit enter when you \
|
||||
are done selecting to run the scripts." 17 70 9 \' > $TMP/setupscr
|
||||
for script in $ADM_DIR/setup/setup.* ; do
|
||||
BLURB=$(grep '#BLURB' $script | cut -b8-)
|
||||
if [ "$BLURB" = "" ]; then
|
||||
BLURB="\"\""
|
||||
fi
|
||||
echo " \"$(basename $script | cut -f2- -d .)\" $BLURB \"no\" $BLURB \\" >> $TMP/setupscr
|
||||
done
|
||||
echo "2> $TMP/return" >> $TMP/setupscr
|
||||
. $TMP/setupscr
|
||||
if [ ! "$(cat $TMP/return)" = "" ]; then
|
||||
# Run each script:
|
||||
for script in $(cat $TMP/return) ; do
|
||||
scrpath=$ADM_DIR/setup/setup.$(echo $script | tr -d \")
|
||||
( COLOR=on ; cd $TARGET_DIR ; . $scrpath $TARGET_DIR $rootdevice )
|
||||
done
|
||||
fi
|
||||
rm -f $TMP/return $TMP/setupscr
|
||||
continue
|
||||
fi # end Setup
|
||||
|
||||
if [ "$REPLY" = "View" ]; then
|
||||
create_list_of_installed_packages
|
||||
DEFITEM=""
|
||||
export DEFITEM
|
||||
#dialog --title "SCANNING" --infobox "Please wait while \
|
||||
#Pkgtool scans your system to determine which packages you have \
|
||||
#installed and prepares a list for you." 0 0
|
||||
(
|
||||
echo 'dialog $DEFITEM --item-help --menu "Please select the package you wish to view." 17 68 10 \
|
||||
--file $TMP/list_of_installed_packages \'
|
||||
echo "2> $TMP/return"
|
||||
) > $TMP/viewscr
|
||||
while [ 0 ]; do
|
||||
. $TMP/viewscr
|
||||
if [ ! "$(cat $TMP/return)" = "" ]; then
|
||||
DEFITEM="--default-item $(cat $TMP/return)"
|
||||
dialog --title "CONTENTS OF PACKAGE: $(cat $TMP/return)" --no-shadow --textbox "$ADM_DIR/packages/$(cat $TMP/return)" \
|
||||
0 0 2> /dev/null
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
rm -f $TMP/return $TMP/viewscr $TMP/tmpmsg $TMP/list_of_installed_packages
|
||||
# This will clean up after most defective packages:
|
||||
chmod 755 /
|
||||
chmod 1777 /tmp
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$REPLY" = "Remove" ]; then
|
||||
#dialog --title "SCANNING" --infobox "Please wait while Pkgtool scans \
|
||||
#your system to determine which packages you have installed and prepares \
|
||||
#a list for you." 0 0
|
||||
# end section
|
||||
(
|
||||
create_list_of_files_to_remove #call the function to create a list of installed packages
|
||||
cat << EOF
|
||||
dialog --title "SELECT PACKAGES TO REMOVE" --item-help --checklist \
|
||||
"Please select the \
|
||||
packages you wish to Remove. Use the \
|
||||
spacebar to select packages to delete, and the UP/DOWN arrow keys to \
|
||||
scroll up and down through the entire list." 20 75 11 \
|
||||
--file $TMP/temporary_list \\
|
||||
EOF
|
||||
echo "2> $TMP/return"
|
||||
) > $TMP/rmscript
|
||||
if [ -L $LOG -o -r $LOG ]; then
|
||||
rm -f $LOG
|
||||
fi
|
||||
cat /dev/null > $LOG
|
||||
chmod 600 $LOG
|
||||
chmod 700 $TMP/rmscript
|
||||
export ADM_DIR;
|
||||
$TMP/rmscript
|
||||
remove_packages
|
||||
if [ "$(cat $TMP/PKGTOOL.REMOVED)" = "" ]; then
|
||||
rm -f $TMP/PKGTOOL.REMOVED
|
||||
dialog --title "NO PACKAGES REMOVED" --msgbox "Hit OK to return \
|
||||
to the main menu." 5 40
|
||||
else
|
||||
dialog --title "PACKAGE REMOVAL COMPLETE" --msgbox "The packages have \
|
||||
been removed. A complete log of the files that were removed has been created \
|
||||
in $TMP: PKGTOOL.REMOVED." 0 0
|
||||
fi
|
||||
rm -f $TMP/rmscript $TMP/return $TMP/tmpmsg $TMP/SeT* $TMP/temporary_list
|
||||
chmod 755 /
|
||||
chmod 1777 /tmp
|
||||
# No, return to the main menu:
|
||||
# exit
|
||||
elif [ "$REPLY" = "Floppy" ]; then
|
||||
dialog --title "SELECT FLOPPY DRIVE" --menu "Which floppy drive would \
|
||||
you like to install from?" \
|
||||
11 70 4 \
|
||||
"/dev/fd0u1440" "1.44 MB first floppy drive" \
|
||||
"/dev/fd1u1440" "1.44 MB second floppy drive" \
|
||||
"/dev/fd0h1200" "1.2 MB first floppy drive" \
|
||||
"/dev/fd1h1200" "1.2 MB second floppy drive" 2> $TMP/wdrive
|
||||
if [ $? = 1 ]; then
|
||||
dialog --clear
|
||||
exit
|
||||
fi
|
||||
SOURCE_DEVICE="$(cat $TMP/wdrive)"
|
||||
rm -f $TMP/wdrive
|
||||
cat << EOF > $TMP/tmpmsg
|
||||
|
||||
Enter the names of any disk sets you would like to install.
|
||||
Separate the sets with a space, like this: a b oi x
|
||||
|
||||
To install packages from one disk, hit [enter] without typing
|
||||
anything.
|
||||
|
||||
EOF
|
||||
dialog --title "SOFTWARE SELECTION" --inputbox "$(cat $TMP/tmpmsg)" 13 70 2> $TMP/sets
|
||||
DISK_SETS="$(cat $TMP/sets)"
|
||||
rm -f $TMP/sets
|
||||
if [ "$DISK_SETS" = "" ]; then
|
||||
DISK_SETS="disk"
|
||||
else
|
||||
DISK_SETS=$(echo $DISK_SETS | sed 's/ /#/g')
|
||||
DISK_SETS="#$DISK_SETS"
|
||||
fi
|
||||
break;
|
||||
elif [ "$REPLY" = "Other" ]; then
|
||||
dialog --title "SELECT SOURCE DIRECTORY" --inputbox "Please enter the name of the directory that you wish to \
|
||||
install packages from:" 10 50 2> $TMP/pkgdir
|
||||
if [ $? = 1 ]; then
|
||||
rm -f $TMP/pkgdir $TMP/SeT*
|
||||
dialog --clear
|
||||
exit
|
||||
fi
|
||||
SOURCE_DIR="$(cat $TMP/pkgdir)"
|
||||
SOURCE_MOUNTED="always"
|
||||
DISK_SETS="disk"
|
||||
chmod 755 $TARGET_DIR
|
||||
chmod 1777 $TARGET_DIR/tmp
|
||||
rm -f $TMP/pkgdir
|
||||
if [ ! -d $SOURCE_DIR ]; then
|
||||
dialog --title "DIRECTORY NOT FOUND" --msgbox "The directory you want to \
|
||||
install from ($SOURCE_DIR) \
|
||||
does not seem to exist. Please check the directory and then try again." \
|
||||
10 50
|
||||
dialog --clear
|
||||
exit
|
||||
fi
|
||||
break;
|
||||
else # installing from current directory
|
||||
SOURCE_MOUNTED="always"
|
||||
SOURCE_DIR="$PWD"
|
||||
DISK_SETS="disk"
|
||||
chmod 755 $TARGET_DIR
|
||||
chmod 1777 $TARGET_DIR/tmp
|
||||
break;
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ "$DISK_SETS" = "disk" ]; then
|
||||
ASK="always"
|
||||
fi
|
||||
|
||||
mount_the_source() {
|
||||
# is the source supposed to be mounted already?
|
||||
if [ "$SOURCE_MOUNTED" = "always" ]; then
|
||||
# The source should already be mounted, so we test it
|
||||
if [ ! -d $SOURCE_DIR ]; then # the directory is missing
|
||||
cat << EOF > $TMP/tmpmsg
|
||||
|
||||
Your source device cannot be accessed properly.
|
||||
|
||||
Please be sure that it is mounted on $SOURCE_DIR,
|
||||
and that the Slackware disks are found in subdirectories
|
||||
of $SOURCE_DIR like specified.
|
||||
|
||||
EOF
|
||||
dialog --title "MOUNT ERROR" --msgbox "$(cat $TMP/tmpmsg)" 11 67
|
||||
rm -f $TMP/tmpmsg
|
||||
exit 1;
|
||||
fi
|
||||
return 0;
|
||||
fi
|
||||
dialog --title "INSERT DISK" --menu "Please insert disk $1 and \
|
||||
press ENTER to continue." \
|
||||
11 50 3 \
|
||||
"Continue" "Continue with the installation" \
|
||||
"Skip" "Skip the current disk series" \
|
||||
"Quit" "Abort the installation process" 2> $TMP/reply
|
||||
if [ ! $? = 0 ]; then
|
||||
REPLY="Quit"
|
||||
else
|
||||
REPLY="$(cat $TMP/reply)"
|
||||
fi
|
||||
rm -f $TMP/reply
|
||||
if [ "$REPLY" = "Skip" ]; then
|
||||
return 1;
|
||||
fi
|
||||
if [ "$REPLY" = "Quit" ]; then
|
||||
dialog --title "ABORTING" --msgbox "Aborting software installation." 5 50
|
||||
chmod 755 $TARGET_DIR
|
||||
chmod 1777 $TARGET_DIR/tmp
|
||||
exit 1;
|
||||
fi;
|
||||
# Old line:
|
||||
# mount -r -t msdos $SOURCE_DEVICE $SOURCE_DIR
|
||||
# New ones: (thanks to Andy Schwierskott!)
|
||||
go_on=y
|
||||
not_successfull_mounted=1
|
||||
while [ "$go_on" = y -a "$not_successfull_mounted" = 1 ]; do
|
||||
mount -r -t msdos $SOURCE_DEVICE $SOURCE_DIR
|
||||
not_successfull_mounted=$?
|
||||
if [ "$not_successfull_mounted" = 1 ]; then
|
||||
mount_answer=x
|
||||
while [ "$mount_answer" != "y" -a "$mount_answer" != "q" ] ; do
|
||||
dialog --title "MOUNT PROBLEM" --menu "Media was not successfully \
|
||||
mounted! Do you want to \
|
||||
retry, or quit?" 10 60 2 \
|
||||
"Yes" "Try to mount the disk again" \
|
||||
"No" "No, abort." 2> $TMP/mntans
|
||||
mount_answer="$(cat $TMP/mntans)"
|
||||
rm -f $TMP/mntans
|
||||
if [ "$mount_answer" = "Yes" ]; then
|
||||
mount_answer="y"
|
||||
else
|
||||
mount_answer="q"
|
||||
fi
|
||||
done
|
||||
go_on=$mount_answer
|
||||
fi
|
||||
done
|
||||
test $not_successfull_mounted = 0
|
||||
}
|
||||
|
||||
umount_the_source() {
|
||||
if [ ! "$SOURCE_MOUNTED" = "always" ]; then
|
||||
umount $SOURCE_DEVICE 1> /dev/null 2> /dev/null
|
||||
fi;
|
||||
}
|
||||
|
||||
install_disk() {
|
||||
mount_the_source $1
|
||||
if [ $? = 1 ]; then
|
||||
umount_the_source;
|
||||
return 1;
|
||||
fi
|
||||
CURRENT_DISK_NAME="$1"
|
||||
PACKAGE_DIR=$SOURCE_DIR
|
||||
if [ "$SOURCE_MOUNTED" = "always" -a ! "$DISK_SETS" = "disk" ]; then
|
||||
PACKAGE_DIR=$PACKAGE_DIR/$1
|
||||
fi
|
||||
|
||||
# If this directory is missing or contains no *.t?z files, bail.
|
||||
if [ ! -d $PACKAGE_DIR ]; then
|
||||
return 1
|
||||
fi
|
||||
if ! ls $PACKAGE_DIR/*.t?z 1> /dev/null 2> /dev/null ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
#
|
||||
# look for tagfile for this series and copy into $TMP/tagfile
|
||||
#
|
||||
touch $TMP/tagfile
|
||||
if [ ! "$DISK_SETS" = "disk" ]; then
|
||||
if [ -r $TMP/SeTtagext ]; then
|
||||
if [ -r $PACKAGE_DIR/tagfile$(cat $TMP/SeTtagext) ]; then
|
||||
cat $PACKAGE_DIR/tagfile$(cat $TMP/SeTtagext) >> $TMP/tagfile
|
||||
else
|
||||
if [ -r $PACKAGE_DIR/tagfile ]; then
|
||||
cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Do we need to follow a custom path to the tagfiles?
|
||||
#
|
||||
elif [ -r $TMP/SeTtagpath ]; then
|
||||
custom_path=$(cat $TMP/SeTtagpath)
|
||||
short_path=$(basename $PACKAGE_DIR)
|
||||
|
||||
# If tagfile exists at the specified custom path, copy it over.
|
||||
if [ -r $custom_path/$short_path/tagfile ]; then
|
||||
cat $custom_path/$short_path/tagfile >> $TMP/tagfile
|
||||
|
||||
else # well, I guess we'll use the default one then.
|
||||
if [ -r $PACKAGE_DIR/tagfile ]; then
|
||||
cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
|
||||
fi
|
||||
fi
|
||||
#
|
||||
# We seem to be testing for this too often... maybe this code should
|
||||
# be optimized a little...
|
||||
#
|
||||
elif [ -r $PACKAGE_DIR/tagfile ]; then
|
||||
cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
|
||||
fi
|
||||
|
||||
#
|
||||
# Execute menus if in QUICK mode:
|
||||
#
|
||||
if [ -r $TMP/SeTQUICK -a -r $PACKAGE_DIR/maketag ]; then
|
||||
if [ ! "$MAKETAG" = "" -a -r $PACKAGE_DIR/$MAKETAG ]; then # use alternate maketag
|
||||
sh $PACKAGE_DIR/$MAKETAG
|
||||
else
|
||||
sh $PACKAGE_DIR/maketag
|
||||
fi
|
||||
if [ -r $TMP/SeTnewtag ]; then
|
||||
mv $TMP/SeTnewtag $TMP/tagfile
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Protect tagfile from hacker attack:
|
||||
#
|
||||
if [ -r $TMP/tagfile ]; then
|
||||
chmod 600 $TMP/tagfile
|
||||
fi
|
||||
|
||||
fi # ! "$DISK_SETS" = "disk"
|
||||
|
||||
# It's possible that the tagfile was specified on the command line. If that's
|
||||
# the case, then we'll just override whatever we figured out up above.
|
||||
if [ ! "$USETAG" = "" ]; then
|
||||
cat $USETAG > $TMP/tagfile
|
||||
fi
|
||||
|
||||
# If there's a catalog file present, use it to check for missing files.
|
||||
# If not, forget about that and install whatever's there.
|
||||
if [ "$1" = "single_disk" -o -r $PACKAGE_DIR/disk$1 -o -r $PACKAGE_DIR/package-list.txt ]; then
|
||||
if [ -r $PACKAGE_DIR/package-list.txt ]; then
|
||||
CATALOG_FILE=$PACKAGE_DIR/package-list.txt
|
||||
else
|
||||
CATALOG_FILE=$(basename $PACKAGE_DIR/disk*);
|
||||
fi
|
||||
if [ -r $PACKAGE_DIR/$CATALOG_FILE -a ! -d $PACKAGE_DIR/$CATALOG_FILE ]; then
|
||||
if grep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE 1> /dev/null 2> /dev/null ; then
|
||||
# First we check for missing packages...
|
||||
for PKGTEST in $(grep "^CONTENTS:" $PACKAGE_DIR/$CATALOG_FILE | cut -f2- -d : 2> /dev/null) ; do
|
||||
# This is not a perfect test. (say emacs is missing but emacs-nox is not)
|
||||
if ls $PACKAGE_DIR/$PKGTEST*.t?z 1> /dev/null 2> /dev/null ; then # found something like it
|
||||
true
|
||||
else
|
||||
cat << EOF > $TMP/tmpmsg
|
||||
|
||||
WARNING!!!
|
||||
|
||||
While looking through your index file ($CATALOG_FILE),
|
||||
I noticed that you might be missing a package:
|
||||
|
||||
$PKGTEST-\*-\*-\*.t?z
|
||||
|
||||
that is supposed to be on this disk (disk $1). You may go
|
||||
on with the installation if you wish, but if this is a
|
||||
crucial file I'm making no promises that your machine will
|
||||
boot.
|
||||
|
||||
EOF
|
||||
dialog --title "FILE MISSING FROM YOUR DISK" --msgbox \
|
||||
"$(cat $TMP/tmpmsg)" 17 67
|
||||
fi
|
||||
done # checking for missing packages
|
||||
# Now we test for extra packages:
|
||||
ALLOWED="$(grep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE | cut -b10- 2> /dev/null)"
|
||||
for PACKAGE_FILENAME in $PACKAGE_DIR/*.t?z; do
|
||||
BASE=$(pkgbase $PACKAGE_FILENAME)
|
||||
BASE="$(package_name $BASE)"
|
||||
if echo $ALLOWED | grep $BASE 1> /dev/null 2> /dev/null ; then
|
||||
true
|
||||
else
|
||||
cat << EOF > $TMP/tmpmsg
|
||||
|
||||
WARNING!!!
|
||||
|
||||
While looking through your index file ($CATALOG_FILE),
|
||||
I noticed that you have this extra package:
|
||||
|
||||
($BASE.t?z)
|
||||
|
||||
that I don't recognize. Please be sure this package is
|
||||
really supposed to be here, and is not left over from an
|
||||
old version of Slackware. Sometimes this can happen at the
|
||||
archive sites.
|
||||
|
||||
EOF
|
||||
dialog --title "EXTRA FILE FOUND ON YOUR DISK" \
|
||||
--msgbox "$(cat $TMP/tmpmsg)" 17 67
|
||||
rm -f $TMP/tmpmsg
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
fi # check for missing/extra packages
|
||||
|
||||
# Install the packages:
|
||||
for PACKAGE_FILENAME in $PACKAGE_DIR/*.t?z; do
|
||||
if [ "$PACKAGE_FILENAME" = "$PACKAGE_DIR/*.t?z" ]; then
|
||||
continue;
|
||||
fi
|
||||
if [ "$ASK" = "never" ]; then # install the package
|
||||
installpkg -root $TARGET_DIR -infobox -tagfile $TMP/tagfile $PACKAGE_FILENAME
|
||||
ERROR=$?
|
||||
elif [ "$ASK" = "tagfiles" ]; then
|
||||
installpkg -root $TARGET_DIR -menu -tagfile $TMP/tagfile $PACKAGE_FILENAME
|
||||
ERROR=$?
|
||||
else # ASK should be = always here, and that's how we'll treat it
|
||||
installpkg -root $TARGET_DIR -menu -ask -tagfile $TMP/tagfile $PACKAGE_FILENAME
|
||||
ERROR=$?
|
||||
fi
|
||||
# Check for abort:
|
||||
if [ "$ERROR" = "99" ]; then
|
||||
umount_the_source;
|
||||
chmod 755 $TARGET_DIR
|
||||
chmod 1777 $TARGET_DIR/tmp
|
||||
exit 1;
|
||||
fi
|
||||
done
|
||||
OUTTAHERE="false"
|
||||
if [ -r $PACKAGE_DIR/install.end ]; then
|
||||
OUTTAHERE="true"
|
||||
fi
|
||||
umount_the_source;
|
||||
if [ "$OUTTAHERE" = "true" ]; then
|
||||
return 1;
|
||||
fi
|
||||
}
|
||||
|
||||
install_disk_set() { # accepts one argument: the series name in lowercase.
|
||||
SERIES_NAME=$1
|
||||
CURRENT_DISK_NUMBER="1";
|
||||
while [ 0 ]; do
|
||||
# Don't start numbering the directories until 2:
|
||||
if [ $CURRENT_DISK_NUMBER = 1 ]; then
|
||||
DISKTOINSTALL=$SERIES_NAME
|
||||
else
|
||||
DISKTOINSTALL=$SERIES_NAME$CURRENT_DISK_NUMBER
|
||||
fi
|
||||
install_disk $DISKTOINSTALL
|
||||
if [ ! $? = 0 ]; then # install.end was found, or the user chose
|
||||
# to quit installing packages.
|
||||
return 0;
|
||||
fi
|
||||
CURRENT_DISK_NUMBER=$(expr $CURRENT_DISK_NUMBER + 1)
|
||||
done;
|
||||
}
|
||||
|
||||
# /* main() */ ;)
|
||||
if [ "$DISK_SETS" = "disk" ]; then
|
||||
install_disk single_disk;
|
||||
ASK="always"
|
||||
else
|
||||
touch $TMP/tagfile
|
||||
chmod 600 $TMP/tagfile
|
||||
if echo $DISK_SETS | grep "#a#" 1> /dev/null 2> /dev/null ; then
|
||||
A_IS_NEEDED="true"
|
||||
else
|
||||
A_IS_NEEDED="false"
|
||||
fi
|
||||
while [ 0 ];
|
||||
do
|
||||
while [ 0 ]; # strip leading '#'s
|
||||
do
|
||||
if [ "$(echo $DISK_SETS | cut -b1)" = "#" ]; then
|
||||
DISK_SETS="$(echo $DISK_SETS | cut -b2-)"
|
||||
else
|
||||
break;
|
||||
fi
|
||||
done
|
||||
if [ "$A_IS_NEEDED" = "true" ]; then
|
||||
cat << EOF > $TMP/tmpmsg
|
||||
|
||||
--- Installing package series ==>a<==
|
||||
|
||||
EOF
|
||||
dialog --infobox "$(cat $TMP/tmpmsg)" 5 45
|
||||
sleep 1
|
||||
rm -f $TMP/tmpmsg
|
||||
install_disk_set a;
|
||||
A_IS_NEEDED="false"
|
||||
fi
|
||||
count="1"
|
||||
if [ "$(echo $DISK_SETS | cut -b$count)" = "" ]; then
|
||||
break; # we be done here :^)
|
||||
else
|
||||
count="2"
|
||||
while [ 0 ]; do
|
||||
if [ "$(echo $DISK_SETS | cut -b$count)" = "" -o "$(echo $DISK_SETS | cut -b$count)" = "#" ]; then
|
||||
count="$(expr $count - 1)"
|
||||
break;
|
||||
else
|
||||
count="$(expr $count + 1)"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
diskset="$(echo $DISK_SETS | cut -b1-$count)"
|
||||
count="$(expr $count + 1)"
|
||||
DISK_SETS="$(echo $DISK_SETS | cut -b$count-)"
|
||||
if [ "$diskset" = "a" ]; then
|
||||
continue; # we expect this to be done elsewhere
|
||||
fi
|
||||
cat << EOF > $TMP/tmpmsg
|
||||
|
||||
Installing package series ==>$diskset<==
|
||||
|
||||
EOF
|
||||
dialog --infobox "$(cat $TMP/tmpmsg)" 5 45
|
||||
sleep 1
|
||||
rm -f $TMP/tmpmsg
|
||||
install_disk_set $diskset;
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$DISK_SETS" = "disk" -o "$CMD_START" = "true" ]; then
|
||||
if [ -r $TMP/tagfile ]; then
|
||||
rm $TMP/tagfile
|
||||
fi
|
||||
dialog --clear
|
||||
fi
|
||||
chmod 755 $TARGET_DIR $TARGET_DIR/var $TARGET_DIR/usr
|
||||
chmod 1777 $TARGET_DIR/tmp
|
395
base/pkgtools/scripts/removepkg
Executable file
395
base/pkgtools/scripts/removepkg
Executable file
|
@ -0,0 +1,395 @@
|
|||
#!/bin/sh
|
||||
# Slackware remove package script
|
||||
#
|
||||
# Thu Sep 24 03:31:58 UTC 2015 <alphageek>
|
||||
# extract_links() sed adjusted to handle symlinks with spaces.
|
||||
#
|
||||
# Sun Sep 6 21:58:36 BST 2009
|
||||
# Replaced pkgbase & package_name code with 'sed' script by Jim Hawkins.
|
||||
#
|
||||
# Sat Apr 25 21:18:53 UTC 2009 (12.34567890b)
|
||||
# Converted to use new pkgbase() function to remove pathname and
|
||||
# valid package extensions.
|
||||
#
|
||||
# Revision 12.34567890 Sun Apr 5 20:59:32 CDT 2009 <volkerdi>
|
||||
# - Support packages with the extensions: .tgz, .tbz, .tlz, .txz
|
||||
#
|
||||
# Revision 1.9 Wed Oct 31 14:04:28 CDT 2007 volkerding
|
||||
# - Fix problem removing packages with a large number of fields.
|
||||
# Thanks to Niki Kovacs for noticing this, and to Piter Punk
|
||||
# for the patch.
|
||||
# - Use LC_ALL=C locale, which is much faster with "sort".
|
||||
# Thanks to Tsomi.
|
||||
# - Don't try to remove any package that starts with '-'. This
|
||||
# is not a proper package name (usually a typo), and results
|
||||
# in the package database being broken. Thanks to Jef Oliver.
|
||||
# - Patched cat_except() to allow the last Slackware package on
|
||||
# a partition to be removed (using ROOT=, of course)
|
||||
# Thanks to Selkfoster for the patch, and to everyone else who
|
||||
# proposed solutions before. This issue really wasn't given
|
||||
# the highest priority before, but I figured while I'm in here...
|
||||
#
|
||||
# Revision 1.8 Thu Nov 22 14:00:13 PST 2001 volkerding Rel $
|
||||
# - Move $TMP underneath $ROOT
|
||||
# - Understand the idea of a base package name, so that packages
|
||||
# can be removed with any of these notations:
|
||||
# removepkg foo-1.0-i386-1.tgz
|
||||
# removepkg foo-1.0-i386-1
|
||||
# removepkg foo.tgz
|
||||
# removepkg foo
|
||||
#
|
||||
# Revision 1.7 2001/03/30 12:36:28 volkerding
|
||||
# - Strip extra ".tgz" from input names.
|
||||
#
|
||||
# Revision 1.6 1999/03/25 18:26:41 volkerding
|
||||
# - Use external $ROOT variable, like installpkg.
|
||||
#
|
||||
# Revision 1.5.1 1998/03/18 15:37:28 volkerding
|
||||
# - Since removepkg is always run by root, the temp directory has been
|
||||
# moved from /tmp to a private directory to avoid symlink attacks from
|
||||
# malicious users.
|
||||
#
|
||||
# Revision 1.5 1997/06/26 12:09:53 franke
|
||||
# - Fixed old bug in TRIGGER regex setting
|
||||
# - -preserve/-copy options now preserve non-unique files
|
||||
# and empty directories also
|
||||
#
|
||||
# Revision 1.4 1997/06/09 13:21:36 franke
|
||||
# - Package file preserve (-preserve, -copy) added.
|
||||
# - Don't execute "rm -rf" lines from doinst.sh, removing links explicit.
|
||||
# - Warning on no longer existing files added.
|
||||
# - Warning on files changed after package installation added.
|
||||
# - Intermediate file preserve (-keep) added.
|
||||
# - Check for required files/links now done on a combined list.
|
||||
# - Write access to /var/log/{packages,scripts} no longer necessary for -warn.
|
||||
#
|
||||
# Revision 1.3 1997/06/08 13:03:05 franke
|
||||
# Merged with revision 1.1.1.1
|
||||
#
|
||||
# Revision 1.2 1996/06/01 20:04:26 franke
|
||||
# Delete empty directories & formated manual pages added
|
||||
#
|
||||
# Revision 1.1.1.1 1995/12/18 21:20:42 volkerding
|
||||
# Original Version from Slackware 3.1
|
||||
#
|
||||
# Revision 1.1 1995/06/05 22:49:11 volkerding
|
||||
# Original Version from Slackware 3.0
|
||||
#
|
||||
|
||||
# Copyright 1994, 1995, 1998 Patrick Volkerding, Moorhead, Minnesota USA
|
||||
# Copyright 2001, Slackware Linux, Inc., Concord, CA USA
|
||||
# Copyright 2009, 2015 Patrick J. Volkerding, Sebeka, MN, USA
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use of this script, with or without modification, is
|
||||
# permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of this script must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
# Return a package name that has been stripped of the dirname portion
|
||||
# and any of the valid extensions (only):
|
||||
pkgbase() {
|
||||
# basename + strip extensions .tbz, .tgz, .tlz and .txz
|
||||
echo "$1" | sed 's?.*/??;s/\.t[bglx]z$//'
|
||||
}
|
||||
|
||||
# This makes "sort" run much faster:
|
||||
export LC_ALL=C
|
||||
|
||||
# Make sure there's a proper temp directory:
|
||||
TMP=$ROOT/var/log/setup/tmp
|
||||
# If the $TMP directory doesn't exist, create it:
|
||||
if [ ! -d $TMP ]; then
|
||||
rm -rf $TMP # make sure it's not a symlink or something stupid
|
||||
mkdir -p $TMP
|
||||
chmod 700 $TMP # no need to leave it open
|
||||
fi
|
||||
ADM_DIR=$ROOT/var/log
|
||||
PRES_DIR=$TMP/preserved_packages
|
||||
|
||||
# This simple cat_except() should be used on the installer,
|
||||
# since the busybox "find" can't handle the complex find
|
||||
# syntax:
|
||||
#cat_except() {
|
||||
# ( cd "$1" && cat $(ls * | sed "/^$2\$/d"))
|
||||
#}
|
||||
|
||||
# This version of cat_except() allows the last package to be
|
||||
# removed when ROOT= is used:
|
||||
cat_except() {
|
||||
( cd "$1" && \
|
||||
if [ $(find . -type f -maxdepth 1 | wc -l) -ne 1 ]; then
|
||||
cat $(find . -type f -maxdepth 1 | grep -v "$2")
|
||||
fi
|
||||
)
|
||||
}
|
||||
|
||||
extract_links() {
|
||||
sed -n 's,^[ ]*( [ ]*cd[ ]* \(.*\) [ ]*; [ ]*rm [ ]*-rf[ ]* \(.*\) [ ]*)[ ]*$,\1/\2,p'
|
||||
}
|
||||
|
||||
preserve_file() {
|
||||
if [ "$PRESERVE" = "true" ]; then
|
||||
F="$(basename "$1")"
|
||||
D="$(dirname "$1")"
|
||||
if [ ! -d "$PRES_DIR/$PKGNAME/$D" ]; then
|
||||
mkdir -p "$PRES_DIR/$PKGNAME/$D" || return 1
|
||||
fi
|
||||
cp -p "$ROOT/$D/$F" "$PRES_DIR/$PKGNAME/$D" || return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
preserve_dir() {
|
||||
if [ "$PRESERVE" = "true" ]; then
|
||||
if [ ! -d "$PRES_DIR/$PKGNAME/$1" ]; then
|
||||
mkdir -p "$PRES_DIR/$PKGNAME/$1" || return 1
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
keep_files() {
|
||||
while read FILE ; do
|
||||
if [ ! -d "$ROOT/$FILE" ]; then
|
||||
if [ -r "$ROOT/$FILE" ]; then
|
||||
echo " --> $ROOT/$FILE was found in another package. Skipping."
|
||||
preserve_file "$FILE"
|
||||
else
|
||||
if [ "$(echo $FILE | cut -b1-8)" != "install/" ]; then
|
||||
echo "WARNING: Nonexistent $ROOT/$FILE was found in another package. Skipping."
|
||||
fi
|
||||
fi
|
||||
else
|
||||
preserve_dir "$FILE"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
keep_links() {
|
||||
while read LINK ; do
|
||||
if [ -L "$ROOT/$LINK" ]; then
|
||||
echo " --> $ROOT/$LINK (symlink) was found in another package. Skipping."
|
||||
else
|
||||
echo "WARNING: Nonexistent $ROOT/$LINK (symlink) was found in another package. Skipping."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
delete_files() {
|
||||
while read FILE ; do
|
||||
if [ ! -d "$ROOT/$FILE" ]; then
|
||||
if [ -r "$ROOT/$FILE" ]; then
|
||||
if [ "$ROOT/$FILE" -nt "$ADM_DIR/packages/$PKGNAME" ]; then
|
||||
echo "WARNING: $ROOT/$FILE changed after package installation."
|
||||
fi
|
||||
if [ ! "$WARN" = "true" ]; then
|
||||
echo " --> Deleting $ROOT/$FILE"
|
||||
preserve_file "$FILE" && rm -f "$ROOT/$FILE"
|
||||
else
|
||||
echo " --> $ROOT/$FILE would be deleted"
|
||||
preserve_file "$FILE"
|
||||
fi
|
||||
else
|
||||
echo " --> $ROOT/$FILE no longer exists. Skipping."
|
||||
fi
|
||||
else
|
||||
preserve_dir "$FILE"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
delete_links() {
|
||||
while read LINK ; do
|
||||
if [ -L "$ROOT/$LINK" ]; then
|
||||
if [ ! "$WARN" = "true" ]; then
|
||||
echo " --> Deleting symlink $ROOT/$LINK"
|
||||
rm -f "$ROOT/$LINK"
|
||||
else
|
||||
echo " --> $ROOT/$LINK (symlink) would be deleted"
|
||||
fi
|
||||
else
|
||||
echo " --> $ROOT/$LINK (symlink) no longer exists. Skipping."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
delete_dirs() {
|
||||
sort -r | \
|
||||
while read DIR ; do
|
||||
if [ -d "$ROOT/$DIR" ]; then
|
||||
if [ ! "$WARN" = "true" ]; then
|
||||
if [ $(ls -a "$ROOT/$DIR" | wc -l) -eq 2 ]; then
|
||||
echo " --> Deleting empty directory $ROOT/$DIR"
|
||||
rmdir "$ROOT/$DIR"
|
||||
else
|
||||
echo "WARNING: Unique directory $ROOT/$DIR contains new files"
|
||||
fi
|
||||
else
|
||||
echo " --> $ROOT/$DIR (dir) would be deleted if empty"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
delete_cats() {
|
||||
sed -n 's,/man\(./[^/]*$\),/cat\1,p' | \
|
||||
while read FILE ; do
|
||||
if [ -f "$ROOT/$FILE" ]; then
|
||||
if [ ! "$WARN" = "true" ]; then
|
||||
echo " --> Deleting $ROOT/$FILE (fmt man page)"
|
||||
rm -f $ROOT/$FILE
|
||||
else
|
||||
echo " --> $ROOT/$FILE (fmt man page) would be deleted"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
package_name() {
|
||||
STRING=$(pkgbase $1 | sed 's?-[^-]*-[^-]*-[^-]*$??')
|
||||
# If we don't do this, commands run later will take the '-' to be an option
|
||||
# and will destroy the package database. Packages should not contain spaces
|
||||
# in them. Normally this type of problem results from a command line typo.
|
||||
if [ "$(echo $STRING | cut -b 1)" = "-" ]; then
|
||||
STRING="malformed-package-name-detected"
|
||||
fi
|
||||
echo $STRING
|
||||
}
|
||||
|
||||
# Conversion to 'comm' utility by Mark Wisdom.
|
||||
# is pretty nifty! :^)
|
||||
remove_packages() {
|
||||
for PKGLIST in $*
|
||||
do
|
||||
PKGNAME=$(pkgbase $PKGLIST)
|
||||
echo
|
||||
# If we don't have a package match here, then we will attempt to find
|
||||
# a package using the long name format (name-version-arch-build) for
|
||||
# which the base package name was given. On a properly-managed machine,
|
||||
# there should only be one package installed with a given basename, but
|
||||
# we don't enforce this policy. If there's more than one, only one will
|
||||
# be removed. If you want to remove them all, you'll need to run
|
||||
# removepkg again until it removes all the same-named packages.
|
||||
if [ ! -e $ADM_DIR/packages/$PKGNAME ]; then
|
||||
SHORT="$(package_name $PKGNAME)"
|
||||
for long_package in $ADM_DIR/packages/${PKGNAME}* ; do
|
||||
if [ "$SHORT" = "$(package_name $long_package)" ]; then
|
||||
PKGNAME="$(basename $long_package)"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ ! -e $ADM_DIR/packages/$PKGNAME ]; then
|
||||
long_package=$(ls -1 $ADM_DIR/packages/${PKGNAME}* | grep -m 1 "^${PKGNAME}-[^-]*-[^-]*-[^-]*$")
|
||||
if [ -e "$long_package" ]; then
|
||||
PKGNAME=$(basename $long_package)
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -r $ADM_DIR/packages/$PKGNAME ]; then
|
||||
if [ ! "$WARN" = true ]; then
|
||||
echo "Removing package $ADM_DIR/packages/$PKGNAME..."
|
||||
fi
|
||||
if fgrep "./" $ADM_DIR/packages/$PKGNAME 1> /dev/null 2>&1; then
|
||||
TRIGGER="^\.\/"
|
||||
else
|
||||
TRIGGER="FILE LIST:"
|
||||
fi
|
||||
if [ ! "$WARN" = true ]; then
|
||||
echo "Removing files:"
|
||||
fi
|
||||
sed -n "/$TRIGGER/,/^$/p" < $ADM_DIR/packages/$PKGNAME | \
|
||||
fgrep -v "FILE LIST:" | sort -u > $TMP/delete_list$$
|
||||
# Pat's new-new && improved pre-removal routine.
|
||||
cat_except $ADM_DIR/packages $PKGNAME | sort -u > $TMP/required_list$$
|
||||
if [ -r $ADM_DIR/scripts/$PKGNAME ]; then
|
||||
extract_links < $ADM_DIR/scripts/$PKGNAME | sort -u > $TMP/del_link_list$$
|
||||
cat_except $ADM_DIR/scripts $PKGNAME | extract_links | \
|
||||
sort -u > $TMP/required_links$$
|
||||
mv $TMP/required_list$$ $TMP/required_files$$
|
||||
sort -u $TMP/required_links$$ $TMP/required_files$$ > $TMP/required_list$$
|
||||
comm -12 $TMP/del_link_list$$ $TMP/required_list$$ | keep_links
|
||||
comm -23 $TMP/del_link_list$$ $TMP/required_list$$ | delete_links
|
||||
else
|
||||
cat $ADM_DIR/scripts/* | extract_links | \
|
||||
sort -u > $TMP/required_links$$
|
||||
mv $TMP/required_list$$ $TMP/required_files$$
|
||||
sort -u $TMP/required_links$$ $TMP/required_files$$ >$TMP/required_list$$
|
||||
fi
|
||||
comm -12 $TMP/delete_list$$ $TMP/required_list$$ | keep_files
|
||||
comm -23 $TMP/delete_list$$ $TMP/required_list$$ > $TMP/uniq_list$$
|
||||
delete_files < $TMP/uniq_list$$
|
||||
delete_dirs < $TMP/uniq_list$$
|
||||
delete_cats < $TMP/uniq_list$$
|
||||
if [ ! "$KEEP" = "true" ]; then
|
||||
rm -f $TMP/delete_list$$ $TMP/required_files$$ $TMP/uniq_list$$
|
||||
rm -f $TMP/del_link_list$$ $TMP/required_links$$ $TMP/required_list$$
|
||||
fi
|
||||
if [ "$PRESERVE" = "true" ]; then
|
||||
if [ -r $ADM_DIR/scripts/$PKGNAME ]; then
|
||||
if [ ! -d "$PRES_DIR/$PKGNAME/install" ]; then
|
||||
mkdir -p "$PRES_DIR/$PKGNAME/install"
|
||||
fi
|
||||
cp -p $ADM_DIR/scripts/$PKGNAME $PRES_DIR/$PKGNAME/install/doinst.sh
|
||||
fi
|
||||
fi
|
||||
if [ ! "$WARN" = "true" ]; then
|
||||
for DIR in $ADM_DIR/removed_packages $ADM_DIR/removed_scripts ; do
|
||||
if [ ! -d $DIR ] ; then mkdir -p $DIR ; chmod 755 $DIR ; fi
|
||||
done
|
||||
mv $ADM_DIR/packages/$PKGNAME $ADM_DIR/removed_packages
|
||||
if [ -r $ADM_DIR/scripts/$PKGNAME ]; then
|
||||
mv $ADM_DIR/scripts/$PKGNAME $ADM_DIR/removed_scripts
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "No such package: $ADM_DIR/packages/$PKGNAME. Can't remove."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$#" = "0" ]; then
|
||||
echo "Usage: $(basename $0) [-copy] [-keep] [-preserve] [-warn] packagename ..."; exit 1
|
||||
fi
|
||||
|
||||
while : ; do
|
||||
case "$1" in
|
||||
-copy | --copy) WARN=true; PRESERVE=true; shift;;
|
||||
-keep | --keep) KEEP=true; shift;;
|
||||
-preserve | --preserve) PRESERVE=true; shift;;
|
||||
-warn | --warn) WARN=true; shift;;
|
||||
-* | --*) echo "Usage: $(basename $0) [-copy] [-keep] [-preserve] [-warn] packagename ..."; exit 1;;
|
||||
*) break
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$WARN" = "true" ]; then
|
||||
echo "Only warning... not actually removing any files."
|
||||
if [ "$PRESERVE" = "true" ]; then
|
||||
echo "Package contents is copied to $PRES_DIR."
|
||||
fi
|
||||
echo "Here's what would be removed (and left behind) if you"
|
||||
echo "removed the package(s):"
|
||||
echo
|
||||
else
|
||||
if [ "$PRESERVE" = "true" ]; then
|
||||
echo "Package contents is copied to $PRES_DIR."
|
||||
fi
|
||||
fi
|
||||
|
||||
remove_packages $*
|
||||
|
348
base/pkgtools/scripts/upgradepkg
Executable file
348
base/pkgtools/scripts/upgradepkg
Executable file
|
@ -0,0 +1,348 @@
|
|||
#!/bin/bash
|
||||
# Copyright 1999 Patrick Volkerding, Moorhead, Minnesota, USA
|
||||
# Copyright 2001, 2002, 2003 Slackware Linux, Inc., Concord, California, USA
|
||||
# Copyright 2009, 2015 Patrick J. Volkerding, Sebeka, MN, USA
|
||||
# Copyright 2015 Michal Nazarewicz <mina86@mina86.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use of this script, with or without modification, is
|
||||
# permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of this script must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Modified to handle either old 8.3 or new package-version-arch-build.tgz
|
||||
# packages, Sat Nov 17 14:25:58 PST 2001 volkerdi
|
||||
#
|
||||
# Rewritten to clean out _all_ old packages of a given basename, not just
|
||||
# the first one found, Thu Apr 4 01:01:05 PST 2002 volkerdi
|
||||
#
|
||||
# Added --install-new and --reinstall, Fri May 31 14:11:14 PDT 2002 volkerdi
|
||||
# Added --dry-run, Sat Apr 26 18:13:29 PDT 2003
|
||||
#
|
||||
# Sat Apr 25 21:18:53 UTC 2009
|
||||
# Support new compression types and package extensions.
|
||||
# Converted to use new pkgbase() function to remove pathname and
|
||||
# valid package extensions.
|
||||
#
|
||||
# Sat 17 Jan 16:21:32 UTC 2015 mina86
|
||||
# Various optimisation mostly resolving around avoiding having to fork
|
||||
# and call cut, basename and other helper commands. Slight
|
||||
# refactoring of code calling removepkg.
|
||||
|
||||
# Return a package name that has been stripped of the dirname portion
|
||||
# and any of the valid extensions (only):
|
||||
pkgbase() {
|
||||
PKGRETURN=${1##*/}
|
||||
case "$PKGRETURN" in *.t[gblx]z)
|
||||
PKGRETURN=${PKGRETURN%.*}
|
||||
esac
|
||||
echo "$PKGRETURN"
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
|
||||
Usage: upgradepkg newpackage [newpackage2 ... ]
|
||||
upgradepkg oldpackage%newpackage [oldpackage2%newpackage2 ... ]
|
||||
|
||||
Upgradepkg upgrades a Slackware package (.tgz, .tbz, .tlz, .txz) from an
|
||||
older version to a newer one. It does this by INSTALLING the new package
|
||||
onto the system, and then REMOVING any files from the old package that
|
||||
aren't in the new package. If the old and new packages have the same
|
||||
name, a single argument is all that is required. If the packages have
|
||||
different names, supply the name of the old package followed by a percent
|
||||
symbol (%), then the name of the new package. Do not add any extra
|
||||
whitespace between pairs of old/new package names.
|
||||
|
||||
Before upgrading a package, save any configuration files (such as in /etc)
|
||||
that you wish to keep. Sometimes these will be preserved, but it depends
|
||||
on the package. If you want to force new versions of the config files
|
||||
to be installed, remove the old ones manually prior to running upgradepkg.
|
||||
|
||||
To upgrade in a directory other than / (such as /mnt):
|
||||
|
||||
ROOT=/mnt upgradepkg package.tgz (or .tbz, .tlz, .txz)
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# Make sure there's a proper temp directory:
|
||||
TMP=$ROOT/var/log/setup/tmp
|
||||
# If the $TMP directory doesn't exist, create it:
|
||||
if [ ! -d $TMP ]; then
|
||||
rm -rf $TMP # make sure it's not a symlink or something stupid
|
||||
mkdir $TMP
|
||||
chmod 700 $TMP # no need to leave it open
|
||||
fi
|
||||
|
||||
# This script expects an 022 umask:
|
||||
umask 022
|
||||
|
||||
# $ROOT defined?
|
||||
if [ -d "$ROOT" ]; then
|
||||
export ROOT
|
||||
else
|
||||
unset ROOT
|
||||
fi
|
||||
|
||||
# --help or no args?
|
||||
if [ "$1" = "" -o "$1" = "--help" -o "$1" = "-?" ]; then
|
||||
usage;
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Arg processing loop. These must come before any packages are listed.
|
||||
while [ 0 ]; do
|
||||
if [ "$1" = "--no-paranoia" ]; then
|
||||
# Enable --no-paranoia mode. This is so not-recommended that we're
|
||||
# not even going to document it. ;) If a file used to be directly
|
||||
# managed and now is moved into place, using --no-paranoia will cause
|
||||
# it to improperly disappear. It does slightly speed things up, though.
|
||||
# Don't use it.
|
||||
NOT_PARANOID="true"
|
||||
shift 1
|
||||
elif [ "$1" = "--install-new" ]; then
|
||||
# Install packages that do not already have an installed version.
|
||||
# The usual default is to skip them.
|
||||
INSTALL_NEW="yes"
|
||||
shift 1
|
||||
elif [ "$1" = "--reinstall" ]; then
|
||||
# Reinstall packages even if the installed one is the same version.
|
||||
REINSTALL="true"
|
||||
shift 1
|
||||
elif [ "$1" = "--verbose" -o "$1" = "-v" ]; then
|
||||
# We're adding a --verbose mode that doesn't filter removepkg as much
|
||||
VERBOSE="verbose"
|
||||
shift 1
|
||||
elif [ "$1" = "--dry-run" ]; then
|
||||
# Output a report about which packages would be installed or upgraded
|
||||
# but don't actually perform the upgrades.
|
||||
DRY_RUN="true"
|
||||
shift 1
|
||||
else # no more args
|
||||
break;
|
||||
fi
|
||||
done # processing args
|
||||
|
||||
# Here's a function to figure out the package name from one of those
|
||||
# new long filenames. We'll need this to double check the name of the
|
||||
# old package.
|
||||
|
||||
package_name() {
|
||||
STRING=$(pkgbase "$1")
|
||||
case "$STRING" in
|
||||
*-*-*-*)
|
||||
# At least four segments, strip version arch and build and return name:
|
||||
echo "${STRING%-*-*-*}"
|
||||
# cruft for later ;)
|
||||
# BUILD=${STRING##*-}
|
||||
# STRING=${STRING%*-}
|
||||
# ARCH=${STRING##*-}
|
||||
# STRING=${STRING%*-}
|
||||
# VER=${STRING%*-}
|
||||
;;
|
||||
*)
|
||||
# Old style package name with one segment or we don't have four
|
||||
# segments: return the old-style (or out of spec) package name.
|
||||
echo $STRING
|
||||
esac
|
||||
}
|
||||
|
||||
ERRCODE=0
|
||||
|
||||
# Main processing loop:
|
||||
for ARG; do
|
||||
OLD=${ARG%'%'*} # first segment, = $ARG if no %
|
||||
NEW=${ARG#*'%'} # second segment, = $ARG if no %
|
||||
|
||||
# Simple package integrity check:
|
||||
if ! [ -f "$NEW" ]; then
|
||||
ERRCODE=4
|
||||
echo "Cannot install $ARG: file not found"
|
||||
continue;
|
||||
fi
|
||||
|
||||
# Figure out the names of the old and new packages:
|
||||
INCOMINGDIR=$(dirname $NEW)
|
||||
# These are the package names with the extension:
|
||||
NNAME=${NEW##*/}
|
||||
ONAME=${OLD##*/}
|
||||
# These are the package names without the extension:
|
||||
OLD=$(pkgbase $OLD)
|
||||
NEW=$(pkgbase $NEW)
|
||||
|
||||
# Make sure the extension is valid:
|
||||
if [ "$NNAME" = "$NEW" ]; then
|
||||
# We won't throw an ERRCODE for this, but the package is skipped:
|
||||
echo "Cannot install $OLD: invalid package extension"
|
||||
continue;
|
||||
fi
|
||||
|
||||
# Check and fix the old package name:
|
||||
SHORT="$(package_name $OLD)"
|
||||
if [ ! -r $ROOT/var/log/packages/$OLD ]; then
|
||||
if ls $ROOT/var/log/packages/$SHORT* 1> /dev/null 2> /dev/null ; then
|
||||
for installed_package in $ROOT/var/log/packages/$SHORT* ; do
|
||||
if [ "$(package_name $installed_package)" = "$SHORT" ]; then # found one
|
||||
OLD="${installed_package##*/}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
# Test to see if both the old and new packages are where we expect them
|
||||
# to be -- skip to the next package (or package pair) if anything's wrong:
|
||||
|
||||
if [ ! -r $ROOT/var/log/packages/$OLD ]; then
|
||||
if [ ! "$INSTALL_NEW" = "yes" ]; then
|
||||
if [ "$DRY_RUN" = "true" ]; then
|
||||
echo "$OLD would not be upgraded (no installed package named $SHORT)."
|
||||
else
|
||||
echo
|
||||
echo "Error: there is no installed package named $OLD."
|
||||
echo " (looking for $ROOT/var/log/packages/$OLD)"
|
||||
echo
|
||||
fi
|
||||
ERRCODE=1
|
||||
else # --install-new was given, so install the new package:
|
||||
if [ "$DRY_RUN" = "true" ]; then
|
||||
echo "$NEW would be installed (new package)."
|
||||
else
|
||||
cat << EOF
|
||||
|
||||
+==============================================================================
|
||||
| Installing new package $INCOMINGDIR/$NNAME
|
||||
+==============================================================================
|
||||
|
||||
EOF
|
||||
/sbin/installpkg $INCOMINGDIR/$NNAME
|
||||
fi
|
||||
fi
|
||||
continue;
|
||||
elif [ ! -r "$INCOMINGDIR/$NNAME" ]; then
|
||||
if [ "$DRY_RUN" = "true" ]; then
|
||||
echo "$NEW incoming package not found (command line)."
|
||||
else
|
||||
echo
|
||||
echo "Error: incoming package $INCOMINGDIR/$NNAME not found."
|
||||
echo
|
||||
fi
|
||||
ERRCODE=1
|
||||
continue;
|
||||
fi
|
||||
|
||||
# Unless --reinstall was given, compare the package names
|
||||
# and skip any exact matches:
|
||||
if [ ! "$REINSTALL" = "true" ]; then
|
||||
if [ "$OLD" = "$NEW" ]; then
|
||||
if [ "$DRY_RUN" = "true" ]; then
|
||||
echo "$NEW would be skipped (already installed)."
|
||||
else
|
||||
cat << EOF
|
||||
|
||||
+==============================================================================
|
||||
| Skipping package $NEW (already installed)
|
||||
+==============================================================================
|
||||
|
||||
EOF
|
||||
fi
|
||||
continue;
|
||||
fi
|
||||
fi
|
||||
|
||||
# Showtime. Let's do the upgrade. First, we will rename all the
|
||||
# installed packages with this basename to make them easy to remove later:
|
||||
|
||||
TIMESTAMP=$(date +%Y-%m-%d,%T)
|
||||
SHORT="$(package_name $OLD)"
|
||||
if [ "$DRY_RUN" = "true" ]; then
|
||||
echo -n "$NEW would upgrade: "
|
||||
for installed_package in $ROOT/var/log/packages/$SHORT* ; do
|
||||
if [ "$(package_name $installed_package)" = "$SHORT" ]; then
|
||||
echo -n "$(pkgbase $installed_package)"
|
||||
fi
|
||||
done
|
||||
echo
|
||||
continue
|
||||
fi
|
||||
for installed_package in $ROOT/var/log/packages/$SHORT* ; do
|
||||
if [ "$(package_name $installed_package)" = "$SHORT" ]; then
|
||||
mv $installed_package ${installed_package}-upgraded-$TIMESTAMP
|
||||
fi
|
||||
done
|
||||
for installed_script in $ROOT/var/log/scripts/$SHORT* ; do
|
||||
if [ "$(package_name $installed_script)" = "$SHORT" ]; then
|
||||
if [ -r $installed_script ]; then
|
||||
mv $installed_script ${installed_script}-upgraded-$TIMESTAMP
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Print a banner for the current upgrade:
|
||||
cat << EOF
|
||||
|
||||
+==============================================================================
|
||||
| Upgrading $OLD package using $INCOMINGDIR/$NNAME
|
||||
+==============================================================================
|
||||
|
||||
EOF
|
||||
|
||||
# Next, the new package is pre-installed:
|
||||
if [ "$VERBOSE" = "verbose" ]; then
|
||||
/sbin/installpkg $INCOMINGDIR/$NNAME
|
||||
RETCODE=$?
|
||||
else
|
||||
echo "Pre-installing package $NEW..."
|
||||
/sbin/installpkg $INCOMINGDIR/$NNAME 1> /dev/null
|
||||
RETCODE=$?
|
||||
fi
|
||||
# Make sure that worked:
|
||||
if [ ! $RETCODE = 0 ]; then
|
||||
echo "ERROR: Package $INCOMINGDIR/$NNAME did not install"
|
||||
echo "correctly. You may need to reinstall your old package"
|
||||
echo "to avoid problems. Make sure the new package is not"
|
||||
echo "corrupted."
|
||||
sleep 30
|
||||
# Skip this package, but still try to proceed. Good luck...
|
||||
continue;
|
||||
fi
|
||||
|
||||
# Now, the leftovers from the old package(s) can go. Pretty simple, huh? :)
|
||||
for rempkg in "$ROOT/var/log/packages/"*"-$TIMESTAMP"; do
|
||||
if [ "$VERBOSE" = "verbose" ]; then
|
||||
/sbin/removepkg "${rempkg##*/}"
|
||||
else
|
||||
/sbin/removepkg "${rempkg##*/}" | grep -v 'Skipping\.\|Removing files:'
|
||||
fi
|
||||
done
|
||||
echo
|
||||
|
||||
# Again! Again!
|
||||
# Seriously, the reinstalling of a package can be crucial if any files
|
||||
# shift location, so we should always reinstall as the final step:
|
||||
if [ ! "$NOT_PARANOID" = "true" ]; then
|
||||
/sbin/installpkg $INCOMINGDIR/$NNAME
|
||||
fi
|
||||
|
||||
echo "Package $OLD upgraded with new package $INCOMINGDIR/$NNAME."
|
||||
ERRCODE=0
|
||||
done
|
||||
|
||||
if [ ! "$DRY_RUN" = "true" ]; then
|
||||
echo
|
||||
fi
|
||||
exit $ERRCODE
|
||||
|
Loading…
Reference in a new issue