diff --git a/.gitignore b/.gitignore index 1944fd6..ae12459 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.tmp +*~ diff --git a/files/post-functions.sh b/files/post-functions.sh index 0339e00..177a337 100644 --- a/files/post-functions.sh +++ b/files/post-functions.sh @@ -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 +} diff --git a/files/slackpkg b/files/slackpkg index cc95bb0..7c9ba49 100644 --- a/files/slackpkg +++ b/files/slackpkg @@ -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 diff --git a/files/slackpkg.conf.5 b/files/slackpkg.conf.5 index e8ca95d..f67816e 100644 --- a/files/slackpkg.conf.5 +++ b/files/slackpkg.conf.5 @@ -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 @@ -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 @@ -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 diff --git a/files/slackpkg.conf.new b/files/slackpkg.conf.new index cbc845d..17225d5 100644 --- a/files/slackpkg.conf.new +++ b/files/slackpkg.conf.new @@ -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" @@ -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.