summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiterpunk <piterpunk@slackware.com>2021-06-04 17:11:13 -0300
committerRobby Workman <rworkman@slackware.com>2021-06-04 22:24:28 -0500
commitab871495224069440a9645899b500f279195250f (patch)
tree3d1f97d2be4de633b2b402e50ddab9891cdf276c
parent3c4c175de873a3ac5599da454bb693d2d5719811 (diff)
downloadslackpkg-ab871495224069440a9645899b500f279195250f.tar.xz
Added the new-config actions for specific files
- Added code to parse a list with the .new files and the default action to do. - Added post-functions.conf file to hold the aforementioned list and possible future configurations. - Updated the SlackBuild to install the post-functions.conf file
-rw-r--r--files/post-functions.conf-sample14
-rw-r--r--files/post-functions.sh28
-rwxr-xr-xslackpkg.SlackBuild3
3 files changed, 41 insertions, 4 deletions
diff --git a/files/post-functions.conf-sample b/files/post-functions.conf-sample
new file mode 100644
index 0000000..1cbe04a
--- /dev/null
+++ b/files/post-functions.conf-sample
@@ -0,0 +1,14 @@
+# You can list here the .new files and the default action
+# to do for each file. The list format is:
+#
+# /full/path/of/dot/new/file.new:action
+#
+# The action can be:
+#
+# O to Overwrite it with the new version
+# R to Remove the new file
+# K to Keep the current and the .new files
+#
+# E.g:
+#/etc/slackpkg/mirrors.new:K
+#/etc/ntp.conf.new:R
diff --git a/files/post-functions.sh b/files/post-functions.sh
index 9191766..e003643 100644
--- a/files/post-functions.sh
+++ b/files/post-functions.sh
@@ -137,6 +137,12 @@ looknew() {
ONLY_NEW_DOTNEW=""
fi
+ # if there is a /etc/slackpkg/post-functions.conf file, it will be
+ # used to take the pre-defined action to each file specified there.
+ if [ -f /etc/slackpkg/post-functions.conf ]; then
+ NEWCONFIG="/etc/slackpkg/post-functions.conf"
+ fi
+
printf "%s\n" "Searching for NEW configuration files..."
FILES=$( find \
@@ -179,8 +185,8 @@ What do you want (K/O/R/P)?
# No. of prompt etc. lines to print.
TEXTLINES=$(( $( printf %b "$PROMPTTEXT" | wc -l ) + 3 ))
- if [ $(( newcount + TEXTLINES )) -lt $ROWS ]; then
- # All files will fit on screen.
+ if [ $(( newcount + TEXTLINES )) -lt $ROWS ] || [ "${BATCH}" = "on" ]; then
+ # All files will fit on screen or is a batch execution.
printf "%s\n" "$FILES"
else
# Won't all fit, so scroll a screenfull at a time.
@@ -240,6 +246,9 @@ EOF
printf %b "$PROMPTTEXT"
answer
+ if [ "${BATCH}" = "on" ] && [ -n "${NEWCONFIG}" ]; then
+ ANSWER=P
+ fi
case $ANSWER in
K|k)
;;
@@ -256,11 +265,24 @@ EOF
P|p)
echo "Select what you want file-by-file"
for i in $FILES; do
+ if [ -n "${NEWCONFIG}" ]; then
+ AUTOANSWER="$(sed -ne 's#^'$i':\([ORK]\)#\1#p' $NEWCONFIG 2>/dev/null)"
+ fi
GOEX=0
while [ $GOEX -eq 0 ]; do
echo
showmenu $i "(K)eep" "(O)verwrite" "(R)emove" "(D)iff" "(M)erge" "(V)imdiff"
- read ANSWER
+ if [ -n "${AUTOANSWER}" ]; then
+ ANSWER=$AUTOANSWER
+ echo $ANSWER
+ else
+ if [ "${BATCH}" = "on" ]; then
+ ANSWER=K
+ echo $ANSWER
+ else
+ read ANSWER
+ fi
+ fi
case $ANSWER in
O|o)
overold $i
diff --git a/slackpkg.SlackBuild b/slackpkg.SlackBuild
index eae23f8..f4f7553 100755
--- a/slackpkg.SlackBuild
+++ b/slackpkg.SlackBuild
@@ -55,7 +55,8 @@ chown root:root $PKG/usr/sbin/slackpkg
# Prepare /etc directory:
mkdir -pv $PKG/etc/slackpkg
-cp -av blacklist.new slackpkg.conf.new $PKG/etc/slackpkg
+cp -av blacklist.new slackpkg.conf.new post-functions.conf-sample \
+ $PKG/etc/slackpkg
chmod 644 $PKG/etc/slackpkg/*
chown root:root $PKG/etc/slackpkg/*
mkdir -pv $PKG/etc/slackpkg/templates