Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep N last package metadata #34

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.tmp
*~
48 changes: 48 additions & 0 deletions files/post-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,51 @@ boot the appropriate kernel (after generating an initrd if required)."
fi
fi
}

lookoldpkgfiles() {
local PKGHISTORYLST PKGFILE CLEANLIST

if [ -n "${KEEP_N_LAST_PKG_METADATA}" ] && [ ${KEEP_N_LAST_PKG_METADATA} -gt 0 ]; then
echo -ne "Keep only the last ${KEEP_N_LAST_PKG_METADATA} package metadata versions... "
PKGHISTORYLIST=${TMPDIR}/pkghistory.lst
if [ -d /var/lib/pkgtools/removed_packages/ ]; then
PKGTOOLSDIR=/var/lib/pkgtools
else
PKGTOOLSDIR=/var/log
fi
# This could be simpler if we used the file timestamp to sort
# the list. But the timestamp at filename is safer to warranty
# the correct ordering.
ls -1 ${PKGTOOLSDIR}/removed_packages | awk '
/-upgraded-/ {
INPUT=$NF
fs=FS
FS="/" ; OFS="/"
$0=INPUT
FULLPACK=$NF
FS="-" ; OFS="-"
$0=FULLPACK
if ( NF > 3 ) {
DAYHOUR=$NF
MONTH=$(NF-1)
YEAR=$(NF-2)
NF=NF-7
NAME=$0
}
FS=fs
print YEAR"-"MONTH"-"DAYHOUR" "NAME" "FULLPACK
}' | sort -rn | awk '
{
COUNT[$2]+=1
if ( COUNT[$2] > '${KEEP_N_LAST_PKG_METADATA}' ) {
print $NF
}
}' > ${PKGHISTORYLIST}
for PKGFILE in $(cat ${PKGHISTORYLIST}); do
# Not all packages have scripts in the removed_scripts
# directory.
rm ${PKGTOOLSDIR}/removed_{packages,scripts}/$PKGFILE 2>/dev/null
done
echo "OK"
fi
}
1 change: 1 addition & 0 deletions files/slackpkg
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ for i in check-updates remove search file-search update info blacklist \
done

if [ "$POSTINST" != "off" ]; then
lookoldpkgfiles
lookkernel
looknew
fi
Expand Down
25 changes: 24 additions & 1 deletion files/slackpkg.conf.5
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH SLACKPKG.CONF 5 "March 2021" slackpkg-15.0.1 ""
.TH SLACKPKG.CONF 5 "June 2022" slackpkg-15.0.10 ""
.SH NAME
.B slackpkg.conf
\- Configuration data for slackpkg
Expand Down Expand Up @@ -98,6 +98,22 @@ The default value of
.B WORKDIR
is /var/lib/slackpkg.

.TP 5
.B DOWNLOADER
.br
Selects the download application slackpkg will use to fetch files.
Current options are "curl" or "wget".

The default value of
.B DOWNLOADER
is "wget"

.TP 5
.B CURLFLAGS
.br
Selects special options for curl. If you need to use multiple options,
remember to put them between double quotes.

.TP 5
.B WGETFLAGS
.br
Expand Down Expand Up @@ -344,6 +360,13 @@ is "on".
.br
From command line, you can use -spinning=value.

.TP 5
.B KEEP_N_LAST_PKG_METADATA
.br
When a package is upgraded, its old installation scripts and list of files
are kept under /var/lib/pkgtools. This variable sets how many of these
previous lists and scripts should be kept.

.SH FILES
.TP 5
.B /etc/slackpkg/slacpkg.conf
Expand Down
11 changes: 11 additions & 0 deletions files/slackpkg.conf.new
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ TEMP=/var/cache/packages
# Package lists, file lists, and others will be stored in WORKDIR:
WORKDIR=/var/lib/slackpkg

# Use curl or wget for downloading (wget is default)
DOWNLOADER=wget

# Special options for curl
#CURLFLAGS=

# Special options for wget (default is WGETFLAGS="--passive-ftp")
WGETFLAGS="--passive-ftp"

Expand Down Expand Up @@ -150,6 +156,11 @@ SPINNING=on
# Slackware 10.2)
DIALOG_MAXARGS=139000

# When a package is upgraded, its old installation scripts and list of files
# are kept under /var/lib/pkgtools. This variable sets how many of these
# previous lists and scripts should be kept.
#KEEP_N_LAST_PKG_METADATA=3

#
# The MIRROR is set from /etc/slackpkg/mirrors
# You only need to uncomment the selected mirror.
Expand Down