Add conversion script (johnsonm@rdhat.com).
CVS patchset: 3006 CVS date: 1999/04/16 23:06:17
This commit is contained in:
parent
2320364c77
commit
a36d27ad3a
|
@ -2,12 +2,12 @@
|
|||
|
||||
AUTOMAKE_OPTIONS = 1.4 foreign
|
||||
|
||||
EXTRA_DIST = find-lang.sh freshen.sh getpo.sh
|
||||
EXTRA_DIST = convertrpmrc.sh find-lang.sh freshen.sh getpo.sh
|
||||
|
||||
installprefix = $(DESTDIR)
|
||||
|
||||
all:
|
||||
|
||||
configdir = ${prefix}/lib/rpm
|
||||
config_SCRIPTS = find-lang.sh freshen.sh getpo.sh
|
||||
config_SCRIPTS = convertrpmrc.sh find-lang.sh freshen.sh getpo.sh
|
||||
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
#!/bin/sh
|
||||
|
||||
# prereq: awk fileutils textutils sh-utils mktemp
|
||||
|
||||
RPMRC=/etc/rpmrc
|
||||
MACROS=/etc/rpm/macros
|
||||
# for testing
|
||||
#RPMRC=/tmp/rpmrc
|
||||
#MACROS=/tmp/macros
|
||||
|
||||
[ -f $RPMRC ] || exit 0
|
||||
|
||||
[ -f $MACROS ] && {
|
||||
echo "$MACROS already exists 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
DIRN="`dirname $MACROS`"
|
||||
[ -d "$DIRN" ] || mkdir -p "$DIRN"
|
||||
[ -d "$DIRN" ] || {
|
||||
echo "$DIRN doesn't exist"
|
||||
exit 1
|
||||
}
|
||||
|
||||
TMP=$(mktemp rpmrc.XXXXXX) || {
|
||||
echo could not create temp file 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
awk 'BEGIN {
|
||||
macros="'"$MACROS"'"
|
||||
# direct translation except underscore prepended
|
||||
xlate["builddir"] = "_builddir"
|
||||
xlate["buildshell"] = "_buildshell"
|
||||
xlate["bzip2bin"] = "_bzip2bin"
|
||||
xlate["dbpath"] = "_dbpath"
|
||||
xlate["defaultdocdir"] = "_defaultdocdir"
|
||||
xlate["excludedocs"] = "_excludedocs"
|
||||
xlate["ftpport"] = "_ftpport"
|
||||
xlate["ftpproxy"] = "_ftpproxy"
|
||||
xlate["gzipbin"] = "_gzipbin"
|
||||
xlate["instchangelog"] = "_instchangelog"
|
||||
xlate["langpatt"] = "_langpatt"
|
||||
xlate["netsharedpath"] = "_netsharedpath"
|
||||
xlate["pgp_name"] = "_pgp_name"
|
||||
xlate["pgp_path"] = "_pgp_path"
|
||||
|
||||
# direct translation with no underscore at all
|
||||
xlate["buildroot"] = "buildroot"
|
||||
xlate["distribution"] = "distribution"
|
||||
xlate["packager"] = "packager"
|
||||
xlate["rpmdir"] = "rpmdir"
|
||||
xlate["rpmfilename"] = "rpmfilename"
|
||||
xlate["signature"] = "signature"
|
||||
xlate["sourcedir"] = "sourcedir"
|
||||
xlate["specdir"] = "specdir"
|
||||
xlate["srcrpmdir"] = "srcrpmdir"
|
||||
xlate["timecheck"] = "timecheck"
|
||||
xlate["tmppath"] = "tmppath"
|
||||
xlate["topdir"] = "topdir"
|
||||
xlate["vendor"] = "vendor"
|
||||
|
||||
# simply remove
|
||||
xlate["messagelevel"] = ""
|
||||
xlate["require_distribution"] = ""
|
||||
xlate["require_icon"] = ""
|
||||
xlate["require_vendor"] = ""
|
||||
}
|
||||
|
||||
{
|
||||
for (str in xlate) {
|
||||
ms = "^" str ":"
|
||||
print str >> "blah"
|
||||
if (match($1, ms)) {
|
||||
if (xlate[str]) {
|
||||
sub(ms, "%" xlate[str] " ")
|
||||
print >> macros
|
||||
}
|
||||
# else get ignore and thus get rid of obsolete items
|
||||
next
|
||||
}
|
||||
if (match ($1, "^fixperms:")) {
|
||||
sub("^fixperms:", "%_fixperms chmod -R ")
|
||||
print >> macros
|
||||
next
|
||||
}
|
||||
}
|
||||
print
|
||||
next
|
||||
}
|
||||
' < $RPMRC > $TMP || {
|
||||
echo "could not convert $RPMRC entries to $MACROS entries" 1>&2
|
||||
exit 1
|
||||
}
|
||||
if [ -s $TMP ] ; then
|
||||
# don't mess with timestamp unless we have actually changed something
|
||||
cat $TMP > $RPMRC && rm -f $TMP
|
||||
[ -f $TMP ] && { echo "could not overwrite $RPMRC" 1>&2 ; exit 1 ; }
|
||||
fi
|
||||
rm -f $TMP
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue