]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - usr.sbin/etcupdate/etcupdate.8
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / usr.sbin / etcupdate / etcupdate.8
1 .\" Copyright (c) 2010-2012 Advanced Computing Technologies LLC
2 .\" Written by: John H. Baldwin <jhb@FreeBSD.org>
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD$
27 .\"
28 .Dd March 16, 2012
29 .Dt ETCUPDATE 8
30 .Os
31 .Sh NAME
32 .Nm etcupdate
33 .Nd "manage updates to system files not updated by installworld"
34 .Sh SYNOPSIS
35 .Nm
36 .Op Fl nBF
37 .Op Fl d Ar workdir
38 .Op Fl r | Fl s Ar source | Fl t Ar tarball
39 .Op Fl A Ar patterns
40 .Op Fl D Ar destdir
41 .Op Fl I Ar patterns
42 .Op Fl L Ar logfile
43 .Op Fl M Ar options
44 .Nm
45 .Cm build
46 .Op Fl B
47 .Op Fl d Ar workdir
48 .Op Fl s Ar source
49 .Op Fl L Ar logfile
50 .Op Fl M Ar options
51 .Ar tarball
52 .Nm
53 .Cm diff
54 .Op Fl d Ar workdir
55 .Op Fl D Ar destdir
56 .Op Fl I Ar patterns
57 .Op Fl L Ar logfile
58 .Nm
59 .Cm extract
60 .Op Fl B
61 .Op Fl d Ar workdir
62 .Op Fl s Ar source | Fl t Ar tarball
63 .Op Fl L Ar logfile
64 .Op Fl M Ar options
65 .Nm
66 .Cm resolve
67 .Op Fl d Ar workdir
68 .Op Fl D Ar destdir
69 .Op Fl L Ar logfile
70 .Nm
71 .Cm status
72 .Op Fl d Ar workdir
73 .Op Fl D Ar destdir
74 .Sh DESCRIPTION
75 The
76 .Nm
77 utility is a tool for managing updates to files that are not updated as
78 part of
79 .Sq make installworld
80 such as files in
81 .Pa /etc .
82 It manages updates by doing a three-way merge of changes made to these
83 files against the local versions.
84 It is also designed to minimize the amount of user intervention with
85 the goal of simplifying upgrades for clusters of machines.
86 .Pp
87 To perform a three-way merge,
88 .Nm
89 keeps copies of the current and previous versions of files that it manages.
90 These copies are stored in two trees known as the
91 .Dq current
92 and
93 .Dq previous
94 trees.
95 During a merge,
96 .Nm
97 compares the
98 .Dq current
99 and
100 .Dq previous
101 copies of each file to determine which changes need to be merged into the
102 local version of each file.
103 If a file can be updated without generating a conflict,
104 .Nm
105 will update the file automatically.
106 If the local changes to a file conflict with the changes made to a file in
107 the source tree,
108 then a merge conflict is generated.
109 The conflict must be resolved after the merge has finished.
110 The
111 .Nm
112 utility will not perform a new merge until all conflicts from an earlier
113 merge are resolved.
114 .Sh MODES
115 The
116 .Nm
117 utility supports several modes of operation.
118 The mode is specified via an optional command argument.
119 If present, the command must be the first argument on the command line.
120 If a command is not specified, the default mode is used.
121 .Ss Default Mode
122 The default mode merges changes from the source tree to the destination
123 directory.
124 First,
125 it updates the
126 .Dq current
127 and
128 .Dq previous
129 trees.
130 Next,
131 it compares the two trees merging changes into the destination directory.
132 Finally,
133 it displays warnings for any conditions it could not handle automatically.
134 .Pp
135 If the
136 .Fl r
137 option is not specified,
138 then the first step taken is to update the
139 .Dq current
140 and
141 .Dq previous
142 trees.
143 If a
144 .Dq current
145 tree already exists,
146 then that tree is saved as the
147 .Dq previous
148 tree.
149 An older
150 .Dq previous
151 tree is removed if it exists.
152 By default the new
153 .Dq current
154 tree is built from a source tree.
155 However,
156 if a tarball is specified via the
157 .Fl t
158 option,
159 then the tree is extracted from that tarball instead.
160 .Pp
161 Next,
162 .Nm
163 compares the files in the
164 .Dq current
165 and
166 .Dq previous
167 trees.
168 If a file was removed from the
169 .Dq current
170 tree,
171 then it will be removed from the destination directory only if it
172 does not have any local modifications.
173 If a file was added to the
174 .Dq current
175 tree,
176 then it will be copied to the destination directory only if it
177 would not clobber an existing file.
178 If a file is changed in the
179 .Dq current
180 tree,
181 then
182 .Nm
183 will attempt to merge the changes into the version of the file in the
184 destination directory.
185 If the merge encounters conflicts,
186 then a version of the file with conflict markers will be saved for
187 future resolution.
188 If the merge does not encounter conflicts,
189 then the merged version of the file will be saved in the destination
190 directory.
191 If
192 .Nm
193 is not able to safely merge in changes to a file other than a merge conflict,
194 it will generate a warning.
195 .Pp
196 For each file that is updated a line will be output with a leading character
197 to indicate the action taken.
198 The possible actions follow:
199 .Pp
200 .Bl -tag -width "A" -compact -offset indent
201 .It A
202 Added
203 .It C
204 Conflict
205 .It D
206 Deleted
207 .It M
208 Merged
209 .It U
210 Updated
211 .El
212 .Pp
213 Finally,
214 if any warnings were encountered they are displayed after the merge has
215 completed.
216 .Pp
217 Note that for certain files
218 .Nm
219 will perform post-install actions any time that the file is updated.
220 Specifically,
221 .Xr pwd_mkdb 8
222 is invoked if
223 .Pa /etc/master.passwd
224 is changed,
225 .Xr cap_mkdb 1
226 is invoked to update
227 .Pa /etc/login.conf.db
228 if
229 .Pa /etc/login.conf
230 is changed,
231 .Xr newaliases 1
232 is invoked if
233 .Pa /etc/mail/aliases
234 is changed,
235 and
236 .Pa /etc/rc.d/motd
237 is invoked if
238 .Pa /etc/motd
239 is changed.
240 One exception is that if
241 .Pa /etc/mail/aliases
242 is changed and the destination directory is not the default,
243 then a warning will be issued instead.
244 This is due to a limitation of the
245 .Xr newaliases 1
246 command.
247 Similarly,
248 if
249 .Pa /etc/motd
250 is changed and the destination directory is not the default,
251 then
252 .Pa /etc/rc.d/motd
253 will not be executed due to a limitation of that script.
254 In this case no warning is issued as the result of
255 .Pa /etc/rc.d/motd
256 is merely cosmetic and will be corrected on the next reboot.
257 .Ss Build Mode
258 The
259 .Cm build
260 mode is used to build a tarball that contains a snapshot of a
261 .Dq current
262 tree.
263 This tarball can be used by the default and extract modes.
264 Using a tarball can allow
265 .Nm
266 to perform a merge without requiring a source tree that matches the
267 currently installed world.
268 The
269 .Fa tarball
270 argument specifies the name of the file to create.
271 The file will be a
272 .Xr tar 5
273 file compressed with
274 .Xr bzip2 1 .
275 .Ss Diff Mode
276 The
277 .Cm diff
278 mode compares the versions of files in the destination directory to the
279 .Dq current
280 tree and generates a unified format diff of the changes.
281 This can be used to determine which files have been locally modified and how.
282 Note that
283 .Nm
284 does not manage files that are not maintained in the source tree such as
285 .Pa /etc/fstab
286 and
287 .Pa /etc/rc.conf .
288 .Ss Extract Mode
289 The
290 .Cm extract
291 mode generates a new
292 .Dq current
293 tree.
294 Unlike the default mode,
295 it does not save any existing
296 .Dq current
297 tree and does not modify any existing
298 .Dq previous
299 tree.
300 The new
301 .Dq current
302 tree can either be built from a source tree or extracted from a tarball.
303 .Ss Resolve Mode
304 The
305 .Cm resolve
306 mode is used to resolve any conflicts encountered during a merge.
307 In this mode,
308 .Nm
309 iterates over any existing conflicts prompting the user for actions to take
310 on each conflicted file.
311 For each file, the following actions are available:
312 .Pp
313 .Bl -tag -width "(tf) theirs-full" -compact
314 .It (p)  postpone
315 Ignore this conflict for now.
316 .It (df) diff-full
317 Show all changes made to the merged file as a unified diff.
318 .It (e)  edit
319 Change the merged file in an editor.
320 .It (r)  resolved
321 Install the merged version of the file into the destination directory.
322 .It (mf) mine-full
323 Use the version of the file in the destination directory and ignore any
324 changes made to the file in the
325 .Dq current
326 tree.
327 .It (tf) theirs-full
328 Use the version of the file from the
329 .Dq current
330 tree and discard any local changes made to the file.
331 .It (h)  help
332 Display the list of commands.
333 .El
334 .Ss Status Mode
335 The
336 .Cm status
337 mode shows a summary of the results of the most recent merge.
338 First it lists any files for which there are unresolved conflicts.
339 Next it lists any warnings generated during the last merge.
340 If the last merge did not generate any conflicts or warnings,
341 then nothing will be output.
342 .Sh OPTIONS
343 The following options are available.
344 Note that most options do not apply to all modes.
345 .Bl -tag -width ".Fl d Ar workdir"
346 .It Fl B
347 Do not build generated files in a private object tree.
348 Instead,
349 reuse the generated files from a previously built object tree that matches
350 the source tree.
351 This can be useful to avoid gratuitous conflicts in
352 .Xr sendmail 8
353 configuration
354 files when bootstrapping.
355 It can also be useful for building a tarball that matches a specific
356 world build.
357 .It Fl d Ar workdir
358 Specify an alternate directory to use as the work directory.
359 The work directory is used to store the
360 .Dq current
361 and
362 .Dq previous
363 trees as well as unresolved conflicts.
364 The default work directory is
365 .Pa <destdir>/var/db/etcupdate .
366 .It Fl A Ar patterns
367 Always install the new version of any files that match any of the patterns
368 listed in
369 .Ar patterns .
370 Each pattern is evaluated as an
371 .Xr sh 1
372 shell pattern.
373 This option may be specified multiple times to specify multiple patterns.
374 Multiple space-separated patterns may also be specified in a single
375 option.
376 Note that ignored files specified via the
377 .Ev IGNORE_FILES
378 variable or the
379 .Fl I
380 option will not be installed.
381 .It Fl D Ar destdir
382 Specify an alternate destination directory as the target of a merge.
383 This is analogous to the
384 .Dv DESTDIR
385 variable used with
386 .Sq make installworld .
387 The default destination directory is an empty string which results in
388 merges updating
389 .Pa /etc
390 on the local machine.
391 .It Fl F
392 Ignore changes in the FreeBSD ID string when comparing files in the
393 destination directory to files in either of the
394 .Dq current
395 or
396 .Dq previous
397 trees.
398 In
399 .Cm diff
400 mode,
401 this reduces noise due to FreeBSD ID string changes in the output.
402 During an update this can simplify handling for harmless conflicts caused
403 by FreeBSD ID string changes.
404 .Pp
405 Specifically,
406 if a file in the destination directory is identical to the same file in the
407 .Dq previous
408 tree modulo the FreeBSD ID string,
409 then the file is treated as if it was unmodified and the
410 .Dq current
411 version of the file will be installed.
412 Similarly,
413 if a file in the destination directory is identical to the same file in the
414 .Dq current
415 tree modulo the FreeBSD ID string,
416 then the
417 .Dq current
418 version of the file will be installed to update the ID string.
419 If the
420 .Dq previous
421 and
422 .Dq current
423 versions of the file are identical,
424 then
425 .Nm
426 will not change the file in the destination directory.
427 .Pp
428 Due to limitations in the
429 .Xr diff 1
430 command,
431 this option may not have an effect if there are other changes in a file that
432 are close to the FreeBSD ID string.
433 .It Fl I Ar patterns
434 Ignore any files that match any of the patterns listed in
435 .Ar patterns .
436 No warnings or other messages will be generated for those files during a
437 merge.
438 Each pattern is evaluated as an
439 .Xr sh 1
440 shell pattern.
441 This option may be specified multiple times to specify multiple patterns.
442 Multiple space-separated patterns may also be specified in a single
443 option.
444 .It Fl L Ar logfile
445 Specify an alternate path for the log file.
446 The
447 .Nm
448 utility logs each command that it invokes along with the standard output
449 and standard error to this file.
450 By default the log file is stored in a file named
451 .Pa log
452 in the work directory.
453 .It Fl M Ar options
454 Pass
455 .Ar options
456 as additional parameters to
457 .Xr make 1
458 when building a
459 .Dq current
460 tree.
461 This can be used for to set the
462 .Dv TARGET
463 or
464 .Dv TARGET_ARCH
465 variables for a cross-build.
466 .It Fl n
467 Enable
468 .Dq dry-run
469 mode.
470 Do not merge any changes to the destination directory.
471 Instead,
472 report what actions would be taken during a merge.
473 Note that the existing
474 .Dq current
475 and
476 .Dq previous
477 trees will not be changed.
478 If the
479 .Fl r
480 option is not specified,
481 then a temporary
482 .Dq current
483 tree will be extracted to perform the comparison.
484 .It Fl r
485 Do not update the
486 .Dq current
487 and
488 .Dq previous
489 trees during a merge.
490 This can be used to
491 .Dq re-run
492 a previous merge operation.
493 .It Fl s Ar source
494 Specify an alternate source tree to use when building or extracting a
495 .Dq current
496 tree.
497 The default source tree is
498 .Pa /usr/src .
499 .It Fl t Ar tarball
500 Extract a new
501 .Dq current
502 tree from a tarball previously generated by the
503 .Cm build
504 command rather than building the tree from a source tree.
505 .El
506 .Sh CONFIG FILE
507 The
508 .Nm
509 utility can also be configured by setting variables in an optional
510 configuration file named
511 .Pa /etc/etcupdate.conf .
512 Note that command line options override settings in the configuration file.
513 The configuration file is executed by
514 .Xr sh 1 ,
515 so it uses that syntax to set configuration variables.
516 The following variables can be set:
517 .Bl -tag -width ".Ev ALWAYS_INSTALL"
518 .It Ev ALWAYS_INSTALL
519 Always install files that match any of the patterns listed in this variable
520 similar to the
521 .Fl A
522 option.
523 .It Ev DESTDIR
524 Specify an alternate destination directory similar to the
525 .Fl D
526 option.
527 .It Ev EDITOR
528 Specify a program to edit merge conflicts.
529 .It Ev FREEBSD_ID
530 Ignore changes in the FreeBSD ID string similar to the
531 .Fl F
532 option.
533 This is enabled by setting the variable to a non-empty value.
534 .It Ev IGNORE_FILES
535 Ignore files that match any of the patterns listed in this variable
536 similar to the
537 .Fl I
538 option.
539 .It Ev LOGFILE
540 Specify an alternate path for the log file similar to the
541 .Fl L
542 option.
543 .It Ev MAKE_OPTIONS
544 Pass additional options to
545 .Xr make 1
546 when building a
547 .Dq current
548 tree similar to the
549 .Fl M
550 option.
551 .It Ev SRCDIR
552 Specify an alternate source tree similar to the
553 .Fl s
554 option.
555 .It Ev WORKDIR
556 Specify an alternate work directory similar to the
557 .Fl d
558 option.
559 .El
560 .Sh ENVIRONMENT
561 The
562 .Nm
563 utility uses the program identified in the
564 .Ev EDITOR
565 environment variable to edit merge conflicts.
566 If
567 .Ev EDITOR
568 is not set,
569 .Xr vi 1
570 is used as the default editor.
571 .Sh FILES
572 .Bl -tag -width ".Pa /var/db/etcupdate/log" -compact
573 .It Pa /etc/etcupdate.conf
574 Optional config file.
575 .It Pa /var/db/etcupdate
576 Default work directory used to store trees and other data.
577 .It Pa /var/db/etcupdate/log
578 Default log file.
579 .El
580 .Sh EXIT STATUS
581 .Ex -std
582 .Sh EXAMPLES
583 If the source tree matches the currently installed world,
584 then the following can be used to bootstrap
585 .Nm
586 so that it can be used for future upgrades:
587 .Pp
588 .Dl "etcupdate extract"
589 .Pp
590 To merge changes after an upgrade via the buildworld and installworld process:
591 .Pp
592 .Dl "etcupdate"
593 .Pp
594 To resolve any conflicts generated during a merge:
595 .Pp
596 .Dl "etcupdate resolve"
597 .Sh DIAGNOSTICS
598 The following warning messages may be generated during a merge.
599 Note that several of these warnings cover obscure cases that should occur
600 rarely if at all in practice.
601 For example,
602 if a file changes from a file to a directory in the
603 .Dq current
604 tree
605 and the file was modified in the destination directory,
606 then a warning will be triggered.
607 In general,
608 when a warning references a pathname,
609 the corresponding file in the destination directory is not changed by a
610 merge operation.
611 .Bl -diag
612 .It "Directory mismatch: <path> (<type>)"
613 An attempt was made to create a directory at
614 .Pa path
615 but an existing file of type
616 .Dq type
617 already exists for that path name.
618 .It "Modified link changed: <file> (<old> became <new>)"
619 The target of a symbolic link named
620 .Pa file
621 was changed from
622 .Dq old
623 to
624 .Dq new
625 in the
626 .Dq current
627 tree.
628 The symbolic link has been modified to point to a target that is neither
629 .Dq old
630 nor
631 .Dq new
632 in the destination directory.
633 .It "Modified mismatch: <file> (<new> vs <dest>)"
634 A file named
635 .Pa file
636 of type
637 .Dq new
638 was modified in the
639 .Dq current
640 tree,
641 but the file exists as a different type
642 .Dq dest
643 in the destination directory.
644 .It "Modified <type> changed: <file> (<old> became <new>)"
645 A file named
646 .Pa file
647 changed type from
648 .Dq old
649 in the
650 .Dq previous
651 tree to type
652 .Dq new
653 in the
654 .Dq current
655 tree.
656 The file in the destination directory of type
657 .Dq type
658 has been modified,
659 so it could not be merged automatically.
660 .It "Modified <type> remains: <file>"
661 The file of type
662 .Dq type
663 named
664 .Pa file
665 has been removed from the
666 .Dq current
667 tree,
668 but it has been locally modified.
669 The modified version of the file remains in the destination directory.
670 .It "Needs update: /etc/mail/aliases.db (required manual update via newaliases(1))"
671 The file
672 .Pa /etc/mail/aliases
673 was updated during a merge with a non-empty destination directory.
674 Due to a limitation of the
675 .Xr newaliases 1
676 command,
677 .Nm
678 was not able to automatically update the corresponding aliases database.
679 .It "New file mismatch: <file> (<new> vs <dest>)"
680 A new file named
681 .Pa file
682 of type
683 .Dq new
684 has been added to the
685 .Dq current
686 tree.
687 A file of that name already exists in the destination directory,
688 but it is of a different type
689 .Dq dest .
690 .It "New link conflict: <file> (<new> vs <dest>)"
691 A symbolic link named
692 .Pa file
693 has been added to the
694 .Dq current
695 tree that links to
696 .Dq new .
697 A symbolic link of the same name already exists in the destination
698 directory,
699 but it links to a different target
700 .Dq dest .
701 .It "Non-empty directory remains: <file>"
702 The directory
703 .Pa file
704 was removed from the
705 .Dq current
706 tree,
707 but it contains additional files in the destination directory.
708 These additional files as well as the directory remain.
709 .It "Remove mismatch: <file> (<old> became <new>)"
710 A file named
711 .Pa file
712 changed from type
713 .Dq old
714 in the
715 .Dq previous
716 tree to type
717 .Dq new
718 in the
719 .Dq current
720 tree,
721 but it has been removed in the destination directory.
722 .It "Removed file changed: <file>"
723 A file named
724 .Pa file
725 was modified in the
726 .Dq current
727 tree,
728 but it has been removed in the destination directory.
729 .It "Removed link changed: <file> (<old> became <new>)"
730 The target of a symbolic link named
731 .Pa file
732 was changed from
733 .Dq old
734 to
735 .Dq new
736 in the
737 .Dq current
738 tree,
739 but it has been removed in the destination directory.
740 .El
741 .Sh SEE ALSO
742 .Xr cap_mkdb 1 ,
743 .Xr diff 1 ,
744 .Xr make 1 ,
745 .Xr newaliases 1 ,
746 .Xr sh 1 ,
747 .Xr pwd_mkdb 8
748 .Sh HISTORY
749 The
750 .Nm
751 utility first appeared in
752 .Fx 10.0 .
753 .Sh AUTHORS
754 The
755 .Nm
756 utility was written by
757 .An John Baldwin Aq jhb@FreeBSD.org .
758 .Sh BUGS
759 Rerunning a merge does not automatically delete conflicts left over from a
760 previous merge.
761 Any conflicts must be resolved before the merge can be rerun.
762 It it is not clear if this is a feature or a bug.
763 .Pp
764 There is no way to easily automate conflict resolution for specific files.
765 For example, one can imagine a syntax along the lines of
766 .Pp
767 .Dl "etcupdate resolve tf /some/file"
768 .Pp
769 to resolve a specific conflict in an automated fashion.
770 .Pp
771 It might be nice to have something like a
772 .Sq revert
773 command to replace a locally modified version of a file with the stock
774 version of the file.
775 For example:
776 .Pp
777 .Dl "etcupdate revert /etc/mail/freebsd.cf"
778 .Pp
779 Bootstrapping
780 .Nm
781 often results in gratuitous diffs in
782 .Pa /etc/mail/*.cf
783 that cause conflicts in the first merge.
784 If an object tree that matches the source tree is present when bootstrapping,
785 then passing the
786 .Fl B
787 flag to the
788 .Cm extract
789 command can work around this.