1#!/bin/sh 2 3# mergemaster 4 5# Compare files created by /usr/src/etc/Makefile (or the directory 6# the user specifies) with the currently installed copies. 7 8# Copyright 1998-2011 Douglas Barton 9# dougb@FreeBSD.org 10 |
11# $FreeBSD: stable/9/usr.sbin/mergemaster/mergemaster.sh 227145 2011-11-06 07:47:38Z dougb $ |
12 13PATH=/bin:/usr/bin:/usr/sbin 14 15display_usage () { 16 VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4` 17 echo "mergemaster version ${VERSION_NUMBER}" |
18 echo 'Usage: mergemaster [-scrvhpCP] [-a|[-iFU]] [--run-updates=always|never]' |
19 echo ' [-m /path] [-t /path] [-d] [-u N] [-w N] [-A arch] [-D /path]' 20 echo "Options:" 21 echo " -s Strict comparison (diff every pair of files)" 22 echo " -c Use context diff instead of unified diff" 23 echo " -r Re-run on a previously cleaned directory (skip temproot creation)" 24 echo " -v Be more verbose about the process, include additional checks" 25 echo " -a Leave all files that differ to merge by hand" 26 echo " -h Display more complete help" 27 echo ' -i Automatically install files that do not exist in destination directory' 28 echo ' -p Pre-buildworld mode, only compares crucial files' 29 echo ' -F Install files that differ only by revision control Id ($FreeBSD)' 30 echo ' -C Compare local rc.conf variables to the defaults' 31 echo ' -P Preserve files that are overwritten' 32 echo " -U Attempt to auto upgrade files that have not been user modified" 33 echo ' ***DANGEROUS***' |
34 echo ' --run-updates= Specify always or never to run newalises, pwd_mkdb, etc.' |
35 echo '' 36 echo " -m /path/directory Specify location of source to do the make in" 37 echo " -t /path/directory Specify temp root directory" 38 echo " -d Add date and time to directory name (e.g., /var/tmp/temproot.`date +%m%d.%H.%M`)" 39 echo " -u N Specify a numeric umask" 40 echo " -w N Specify a screen width in columns to sdiff" 41 echo " -A architecture Alternative architecture name to pass to make" 42 echo ' -D /path/directory Specify the destination directory to install files to' --- 215 unchanged lines hidden (view full) --- 258fi 259 260# Read .mergemasterrc before command line so CLI can override 261# 262if [ -r "$HOME/.mergemasterrc" ]; then 263 . "$HOME/.mergemasterrc" 264fi 265 |
266for var in "$@" ; do 267 case "$var" in 268 --run-updates*) 269 RUN_UPDATES=`echo ${var#--run-updates=} | tr [:upper:] [:lower:]` 270 ;; 271 *) 272 newopts="$newopts $var" 273 ;; 274 esac 275done 276 277set -- $newopts 278unset var newopts 279 |
280# Check the command line options 281# 282while getopts ":ascrvhipCPm:t:du:w:D:A:FU" COMMAND_LINE_ARGUMENT ; do 283 case "${COMMAND_LINE_ARGUMENT}" in 284 A) 285 ARCHSTRING='TARGET_ARCH='${OPTARG} 286 ;; 287 F) --- 946 unchanged lines hidden (view full) --- 1234 echo ' not alter on your system. The following were upgraded for you:' 1235 echo "${AUTO_UPGRADED_FILES}" 1236 ;; 1237 esac 1238 ;; 1239esac 1240 1241run_it_now () { |
1242 [ -n "$AUTO_RUN" ] && return |
1243 |
1244 local answer 1245 1246 echo '' 1247 while : ; do 1248 if [ "$RUN_UPDATES" = always ]; then 1249 answer=y 1250 elif [ "$RUN_UPDATES" = never ]; then 1251 answer=n 1252 else 1253 echo -n ' Would you like to run it now? y or n [n] ' 1254 read answer 1255 fi 1256 1257 case "$answer" in |
1258 y) 1259 echo " Running ${1}" 1260 echo '' 1261 eval "${1}" |
1262 return |
1263 ;; 1264 ''|n) |
1265 if [ ! "$RUN_UPDATES" = never ]; then 1266 echo '' 1267 echo " *** Cancelled" 1268 echo '' 1269 fi |
1270 echo " Make sure to run ${1} yourself" |
1271 return |
1272 ;; 1273 *) 1274 echo '' |
1275 echo " *** Sorry, I do not understand your answer (${answer})" |
1276 echo '' |
1277 esac |
1278 done |
1279} 1280 1281case "${NEED_NEWALIASES}" in 1282'') ;; 1283*) 1284 echo '' 1285 if [ -n "${DESTDIR}" ]; then 1286 echo "*** You installed a new aliases file into ${DESTDIR}/etc/mail, but" --- 42 unchanged lines hidden (view full) --- 1329 else 1330 echo " '/usr/sbin/pwd_mkdb -p /etc/master.passwd'" 1331 echo " to rebuild your password files" 1332 run_it_now '/usr/sbin/pwd_mkdb -p /etc/master.passwd' 1333 fi 1334 ;; 1335esac 1336 |
1337if [ -e "${DESTDIR}/etc/localtime" ]; then # Ignore if TZ == UTC 1338 echo '' 1339 if [ -f "${DESTDIR}/var/db/zoneinfo" ]; then 1340 echo "*** Reinstalling `cat ${DESTDIR}/var/db/zoneinfo` as ${DESTDIR}/etc/localtime" 1341 [ -n "${DESTDIR}" ] && tzs_args="-C ${DESTDIR}" 1342 tzsetup $tzs_args -r 1343 else 1344 echo "*** There is no ${DESTDIR}/var/db/zoneinfo file to update ${DESTDIR}/etc/localtime." 1345 echo ' You should run tzsetup' 1346 run_it_now tzsetup 1347 fi 1348fi 1349 |
1350echo '' 1351 1352if [ -r "${MM_EXIT_SCRIPT}" ]; then 1353 . "${MM_EXIT_SCRIPT}" 1354fi 1355 1356case "${COMP_CONFS}" in 1357'') ;; --- 51 unchanged lines hidden --- |