tech-misc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: postinstall and motd check




On 7-Mar-08, at 4:18 PM, Jeremy C. Reed wrote:

This doesn't look right. Why does this fail?

I noticed that the other day too.

Yesterday I did some debugging and finally decided that the most recent change to include the current proper URL was done blindly by some search-and-replace blast.

However even without the current URL being included the old logic fails miserably if the source directory (-s) is specified as the real source tree (as opposed to a directory where the *etc.tgz set(s) were unpacked).

The better fix would be to edit the old URL into the new one without grubbing about in any source directory for a new template file.

Furthermore the use of "mktemp" in the do_motd() function is also wrong. Postinstall sets up its own private (and much safer to use) scratch directory which all such functions should use for temporary files.

Perhaps it could be something like the following (untested and probably badly folded):

do_motd()
{
        [ -n "$1" ] || err 3 "Usage: do_motd fix|check"

if fgrep -i 'netbsd.org/Misc/send-pr.html' ${DEST_DIR}/etc/motd > / dev/null 2>&1; then
                result=1
                if [ "$1" = check ]; then
msg "NetBSD.org bug reporting URL needs updating to replace /Misc/ with /support/"
                else
sed 's|/Misc/|/support/|' < ${DEST_DIR}/etc/motd > ${SCRATCHDIR}/ motd.newURL
                        mv ${SCRATCHDIR}/motd.newURL ${DEST_DIR}/etc/motd && 
result=0
                fi
        else
                result=0
        fi

        return ${result}
}


--
                                        Greg A. Woods; Planix, Inc.
                                        <woods%planix.ca@localhost>





Home | Main Index | Thread Index | Old Index