LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   slackpkg new-config not finding .new files (https://www.linuxquestions.org/questions/slackware-14/slackpkg-new-config-not-finding-new-files-4175581600/)

stoa 06-06-2016 04:16 PM

slackpkg new-config not finding .new files
 
Hi all:

I'm having a little problem with updating some config files. If I issue the command
Code:

root@slackware:~# slackpkg new-config


Searching for NEW configuration files
                No .new files found.

slackpkg tells me there are no .new files.

However,
Code:

root@slackware:~# find /etc -name "*.new"
/etc/passwd.new
/etc/shadow.new

says that there are.

I've looked through the /usr/sbin/slackpkg script, and the separate slackpkg functions file called by that script at /usr/libexec/slackpkg/core-functions.sh but I didn't find anything that would explain the above issue. I'm not that experienced at scripting, though.

I've also searched the net and this site without luck.

Any helpful ideas out there?

Richard Cranium 06-06-2016 04:19 PM

IIRC, if /etc/passwd.new has the exact same contents as /etc/passwd, you won't get the prompt. (Actually, I believe the md5sums of the files are compared for equality.) Actually, that's for all the *.new to * comparisons.

Wrong answer! See correct answers below.

keefaz 06-06-2016 04:20 PM

maybe they are blacklisted by slackpkg as it's highly unlikely one would want to let slackpkg update those files

edit: yes, try:
Code:

grep "shadow\|passwd" /usr/libexec/slackpkg/functions.d/*

ponce 06-06-2016 04:29 PM

Quote:

Originally Posted by stoa (Post 5556925)
Hi all:

I'm having a little problem with updating some config files. If I issue the command
Code:

root@slackware:~# slackpkg new-config


Searching for NEW configuration files
                No .new files found.

slackpkg tells me there are no .new files.

However,
Code:

root@slackware:~# find /etc -name "*.new"
/etc/passwd.new
/etc/shadow.new

says that there are.

I've looked through the /usr/sbin/slackpkg script, and the separate slackpkg functions file called by that script at /usr/libexec/slackpkg/core-functions.sh but I didn't find anything that would explain the above issue. I'm not that experienced at scripting, though.

I've also searched the net and this site without luck.

Any helpful ideas out there?

yes, as keefaz just wrote (beating me as I was writing the same thing!), those file are between the ones that are excluded when finding the *.new: see the file /usr/libexec/slackpkg/functions.d/post-functions.sh
Code:

        FILES=$(find /etc -name "*.new" ${ONLY_NEW_DOTNEW} \
                -not -name "rc.inet1.conf.new" \
                -not -name "group.new" \
                -not -name "passwd.new" \
                -not -name "shadow.new" \
                -not -name "gshadow.new" 2>/dev/null)


stoa 06-06-2016 04:54 PM

Always a most helpful group - it is much appreciated.

That "blacklist" in /usr/libexec/slackpkg/core-functions.sh was exactly what I was looking for in the two files I initially referenced.

If I could impose further, as my scripting is weak, how does that post-functions.sh file get called? I can't find a reference to it in either the slackpkg script or the /usr/libexec/slackpkg/core-functions.sh script it directly references.

Mr. Cranium: Thanks, I'll save that info for another day - /etc/passwd had in fact changed, so that wasn't the issue, at least not in this particular case.

allend 06-06-2016 05:49 PM

Quote:

how does that post-functions.sh file get called?
From /usr/sbin/slackpkg
Code:

#========================================================================
#
# READ EXTRA FUNCTIONS
#

# If you want a new function or need a rewrite of an existing
# feature, you can put your new function in a shell script under
# /usr/libexec/slackpkg/functions.d/
#
# Remember - the new function scripts need to be executable
#
for i in /usr/libexec/slackpkg/functions.d/*.sh; do
        if [ -x $i ]; then
                . $i
        fi
done

This is a neat feature that makes it easy to customise slackpkg.

Richard Cranium 06-06-2016 06:05 PM

Quote:

Originally Posted by stoa (Post 5556941)
Mr. Cranium: Thanks, I'll save that info for another day - /etc/passwd had in fact changed, so that wasn't the issue, at least not in this particular case.

What actually happens is that installpkg will remove the .new file if it is exact match of the file without the .new extension. So you shouldn't see a .new file in that case. :)

My earlier reply was pretty much spherically wrong: It is just as wrong no matter how you look at it.

stoa 06-06-2016 07:22 PM

Quote:

From /usr/sbin/slackpkg
aaand there it is! How many times I glossed right over that! Thank you so much.

bassmadrigal 06-07-2016 07:44 AM

Quote:

Originally Posted by Richard Cranium (Post 5556957)
What actually happens is that installpkg will remove the .new file if it is exact match of the file without the .new extension. So you shouldn't see a .new file in that case. :)

My earlier reply was pretty much spherically wrong: It is just as wrong no matter how you look at it.

For further clarification, in case any are wondering, it actually only happens if the package maintainer (whether that be Pat, Eric, Robby, or one of the SBo package maintainers) adds checks for those files in the doinst.sh file within the package. The check that occurs is the code below (below that, you would just call the config function with the .new file). Basically, if nothing exists, it will remove the .new extension. If the other file already exists, it will do an MD5 hash for both files, and if they match, it will just delete the .new. If they don't, the .new will stay until you decide what to do with it.

Code:

config() {
  NEW="$1"
  OLD="$(dirname $NEW)/$(basename $NEW .new)"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
    # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}


Richard Cranium 06-07-2016 11:37 AM

src2pkg, IIRC, will put that in for you.

Then again, maybe I should quit while I can still see daylight out of the hole.


All times are GMT -5. The time now is 10:56 PM.