0001-Makefile.inc-Rework-automatic-backup-bug-2527.patch

Tweaked TN patch - marino, 04/16/2013 01:06 AM

Download (12.5 KB)

View differences:

Makefile
29 29
#			of the system for DragonFly. ex. two compilers
30 30
# most                - Build user commands, no libraries or include files.
31 31
# installmost         - Install user commands, no libraries or include files.
32
# backupworld         - Copies /bin /sbin /usr/bin /usr/sbin /usr/lib
33
#                       /usr/libexec to manual backup dir.
34
# restoreworld        - Installs binaries from manual backup dir to world.
35
# restoreworld-auto   - Installs binaries from auto-backup dir to world;
36
#                       installworld target makes backup to auto-backup dir.
37
# backup-auto-clean   - Delete backup from auto-backup dir.
38
# backup-clean        - Delete backup from manual backup dir.
32 39
#
33 40
# This makefile is simple by design. The DragonFly make automatically reads
34 41
# /usr/share/mk/sys.mk unless the -m argument is specified on the 
......
76 83
	reinstallkernel installmost installworld libraries lint maninstall \
77 84
	manlint mk most obj objlink regress rerelease tags \
78 85
	backupworld restoreworld restoreworld-auto \
86
	backup-clean backup-auto-clean \
79 87
	_obj _includes _libraries _depend _worldtmp \
80 88
	_bootstrap-tools _build-tools _cross-tools
81 89

  
Makefile.inc1
10 10
# realquickworld - skip the glue and depend stages and just build the meat
11 11
# crossworld  - only build the glue (particularly the cross-build environment)
12 12
# installworld- install everything built by "buildworld"
13
# backupworld - copies /bin /sbin /usr/bin /usr/sbin /libexec to backup dir
14
# restoreworld- installs binaries from backup dir to world
13
# backupworld - copies /bin /sbin /usr/bin /usr/sbin /usr/lib /usr/libexec
14
#               to manual backup dir
15
# restoreworld- installs binaries from manual backup dir to world
16
# restoreworld-auto - installs binaries from auto-backup dir to world
15 17
# most        - build user commands, no libraries or include files
16 18
# installmost - install user commands, no libraries or include files
19
# backup-clean - delete backup from manual backup dir
20
# backup-auto-clean - delete backup from auto-backup dir
17 21
#
18 22
# Standard targets (not defined here) are documented in the makefiles in
19 23
# /usr/share/mk.  These include:
......
128 132
# Set the backup parameters if they are not already defined
129 133
#
130 134
WORLD_BACKUP?=		/var/backups/world_backup
131
AUTO_BACKUP=		${OBJTREE}/world_backup
135
AUTO_BACKUP?=		${OBJTREE}/world_backup/${DESTDIR}
132 136

  
133 137
# temporary until everybody has converted to x86_64
134 138
.if ${MACHINE_ARCH} == "amd64"
......
421 425
	@echo ">>> stage 4d: building everything.."
422 426
	@echo "--------------------------------------------------------------"
423 427
	cd ${.CURDIR}; ${WMAKE} all
424
	@rm -f ${AUTO_BACKUP}/installstamp
425 428

  
426 429
# note: buildworld no longer depends on _cleanobj because we rm -rf the
427 430
# entire object tree and built the bootstrap tools in a different location.
......
1053 1056
xmakeenv:
1054 1057
	@echo '${XMAKEENV} /bin/sh'
1055 1058

  
1056
backupworld:
1059
backupworld: backup-clean
1057 1060
	@mkdir -p ${WORLD_BACKUP}
1058
	@chflags -R noschg ${WORLD_BACKUP}
1059
	@rm -rf ${WORLD_BACKUP}/sbin ${WORLD_BACKUP}/bin \
1060
	        ${WORLD_BACKUP}/usr.sbin ${WORLD_BACKUP}/usr.bin \
1061
	        ${WORLD_BACKUP}/usr.libexec
1062
	cp -RpP /bin ${WORLD_BACKUP}/bin
1063
	cp -RpP /sbin ${WORLD_BACKUP}/sbin
1064
	cp -RpP /usr/bin ${WORLD_BACKUP}/usr.bin
1065
	cp -RpP /usr/lib ${WORLD_BACKUP}/usr.lib
1066
	cp -RpP /usr/sbin ${WORLD_BACKUP}/usr.sbin
1067
	cp -RpP /usr/libexec ${WORLD_BACKUP}/usr.libexec
1061
.if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
1062
     exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
1063
     exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
1064
	tar -czf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
1065
		--options gzip:compression-level=1 \
1066
		sbin bin usr/sbin usr/bin usr/lib usr/libexec
1067
.endif
1068 1068

  
1069 1069
backupworld-auto:
1070
.if !exists(${AUTO_BACKUP}/installstamp)
1070
.if !defined(NO_BACKUP)
1071
	rm -f ${AUTO_BACKUP}/binaries.tar.gz
1071 1072
	@mkdir -p ${AUTO_BACKUP}
1072
	@chflags -R noschg ${AUTO_BACKUP}
1073
	@rm -rf ${AUTO_BACKUP}/sbin ${AUTO_BACKUP}/bin \
1074
	        ${AUTO_BACKUP}/usr.sbin ${AUTO_BACKUP}/usr.bin \
1075
	        ${AUTO_BACKUP}/usr.libexec
1076
	cp -RpP /bin ${AUTO_BACKUP}/bin
1077
	cp -RpP /sbin ${AUTO_BACKUP}/sbin
1078
	cp -RpP /usr/bin ${AUTO_BACKUP}/usr.bin
1079
	cp -RpP /usr/lib ${AUTO_BACKUP}/usr.lib
1080
	cp -RpP /usr/sbin ${AUTO_BACKUP}/usr.sbin
1081
	cp -RpP /usr/libexec ${AUTO_BACKUP}/usr.libexec
1082
	@date '+%Y-%m-%d %H:%M:%S' > ${AUTO_BACKUP}/installstamp
1073
.if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
1074
     exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
1075
     exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
1076
	tar -czf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
1077
		--options gzip:compression-level=1 \
1078
		sbin bin usr/sbin usr/bin usr/lib usr/libexec
1079
.endif
1083 1080
.endif
1084 1081

  
1082
backup-auto-clean:
1083
	rm -f ${AUTO_BACKUP}/binaries.tar.gz
1084

  
1085
backup-clean:
1086
	rm -f ${WORLD_BACKUP}/binaries.tar.gz
1087

  
1085 1088
restoreworld:
1086
.if !(exists(${WORLD_BACKUP}/sbin) && exists(${WORLD_BACKUP}/bin) && \
1087
      exists(${WORLD_BACKUP}/usr.sbin) && exists(${WORLD_BACKUP}/usr.bin) && \
1088
      exists(${WORLD_BACKUP}/usr.lib) && exists(${WORLD_BACKUP}/usr.libexec))
1089
.if !exists(${WORLD_BACKUP}/binaries.tar.gz)
1089 1090
	@echo "There does not seem to be a valid archive present."
1090 1091
.else
1091 1092
	@echo "Restoring system binaries from manual backup archive..."
1092
	@rm -f /tmp/rs.tmp
1093
.for BX in sbin bin usr.sbin usr.bin usr.lib usr.libexec
1094
	@chflags -R noschg /${BX:S/./\//}
1095
	@cd ${WORLD_BACKUP}/${BX} && find * -type f -perm +700 -exec \
1096
	  echo cp ${WORLD_BACKUP}/${BX}/{} /${BX:S/./\//}/{} >> /tmp/rs.tmp \;
1097
.endfor
1098
	@grep -Ev ' (/bin/sh|/bin/cp|/sbin/init.bak|/usr/bin/make|/usr/libexec/ld-elf.so.2|/usr/libexec/ld-elf.so.2.old)$$' \
1099
	   /tmp/rs.tmp > /tmp/restore.script
1100
	@/bin/sh /tmp/restore.script
1101
	@rm /tmp/rs.tmp /tmp/restore.script
1102
	@echo "These files were not restored from ${WORLD_BACKUP}:"
1103
	@echo "   /bin/cp"
1104
	@echo "   /bin/sh"
1105
	@echo "   /usr/bin/make"
1106
	@echo "   /usr/libexec/ld-elf.so.2"
1093
	@chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
1094
		${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
1095
		${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
1096
	tar -xzf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
1107 1097
.endif
1108 1098

  
1109 1099
restoreworld-auto:
1110
.if !(exists(${AUTO_BACKUP}/sbin) && exists(${AUTO_BACKUP}/bin) && \
1111
      exists(${AUTO_BACKUP}/usr.sbin) && exists(${AUTO_BACKUP}/usr.bin) && \
1112
      exists(${AUTO_BACKUP}/usr.lib) && exists(${AUTO_BACKUP}/usr.libexec))
1100
.if !exists(${AUTO_BACKUP}/binaries.tar.gz)
1113 1101
	@echo "There does not seem to be a valid archive present."
1114 1102
.else
1115 1103
	@echo "Restoring system binaries from auto-backup archive..."
1116
	@rm -f /tmp/rs.tmp
1117
.for BX in sbin bin usr.sbin usr.bin usr.lib usr.libexec
1118
	@chflags -R noschg /${BX:S/./\//}
1119
	@cd ${AUTO_BACKUP}/${BX} && find * -type f -perm +700 -exec \
1120
	  echo cp ${AUTO_BACKUP}/${BX}/{} /${BX:S/./\//}/{} >> /tmp/rs.tmp \;
1121
.endfor
1122
	@grep -Ev ' (/bin/sh|/bin/cp|/sbin/init.bak|/usr/bin/make|/usr/libexec/ld-elf.so.2|/usr/libexec/ld-elf.so.2.old)$$' \
1123
	   /tmp/rs.tmp > /tmp/restore.script
1124
	@/bin/sh /tmp/restore.script
1125
	@rm /tmp/rs.tmp /tmp/restore.script
1126
	@echo "These files were not restored from ${AUTO_BACKUP}:"
1127
	@echo "   /bin/cp"
1128
	@echo "   /bin/sh"
1129
	@echo "   /usr/bin/make"
1130
	@echo "   /usr/libexec/ld-elf.so.2"
1104
	@chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
1105
		${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
1106
		${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
1107
	tar -xzf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
1131 1108
.endif
1132 1109

  
1133 1110
# Take advantage of bmake error response
etc/defaults/make.conf
81 81
# Compare before install
82 82
#INSTALL=install -C
83 83
#
84
# Inhibit the automatic backup during installworld
85
#NO_BACKUP= true
86
#
84 87
# To build ppp with normal permissions
85 88
#PPP_NOSUID=	true
86 89
#
share/man/man5/make.conf.5
24 24
.\"
25 25
.\" $FreeBSD: src/share/man/man5/make.conf.5,v 1.12.2.30 2003/05/18 17:05:55 brueffer Exp $
26 26
.\"
27
.Dd February 17, 2013
27
.Dd April 16, 2013
28 28
.Dt MAKE.CONF 5
29 29
.Os
30 30
.Sh NAME
......
212 212
.Bd -literal -offset indent
213 213
INSTALL="install -C"
214 214
.Ed
215
.It Va NO_BACKUP
216
.Pq Vt str
217
Inhibit automatic backup of world binaries as port of
218
.Dq installworld
219
.Xr make 1
220
target.
221
Default is unset.
215 222
.It Va WORLD_BACKUP
216 223
.Pq Vt str
217 224
defines where system binaries will be backed up for the
218
.Dq make backupworld
219
target.  The default value is
225
.Dq backupworld
226
.Xr make 1
227
target.
228
The default is
220 229
.Dq /var/backups/world_backup .
230
.It Va AUTO_BACKUP
231
.Pq Vt str
232
defines where system binaries will be backed up automatically
233
as part of the 
234
.Dq installworld
235
.Xr make 1
236
target.
237
The default is
238
.Dq Ev MAKEOBJDIRPREFIX Ns /world_binaries/ Ns Ev DESTDIR .
221 239
.It Va LOCAL_DIRS
222 240
.Pq Vt str
223
List any directories that should be entered when running make
224
.Pa /usr/src
225
in this variable.
241
List of directories that should be entered when running
242
.Xr make 1
243
in
244
.Pa /usr/src .
226 245
.It Va MAKE_SHELL
227 246
.Pq Vt str
228 247
Controls the shell used internally by
share/man/man7/build.7
23 23
.\" SUCH DAMAGE.
24 24
.\"
25 25
.\" $FreeBSD: src/share/man/man7/build.7,v 1.19.2.1 2002/03/18 08:33:02 murray Exp $
26
.\" $DragonFly: src/share/man/man7/build.7,v 1.18 2008/11/14 15:04:42 swildner Exp $
27 26
.\"
28
.Dd April 12, 2009
27
.Dd April 16, 2013
29 28
.Dt BUILD 7
30 29
.Os
31 30
.Sh NAME
......
77 76
The other
78 77
.Pa /usr/src
79 78
make targets are:
80
.Bl -tag -width ".Cm reinstallkernel"
79
.Bl -tag -width ".Cm backup-auto-clean"
81 80
.It Cm buildworld
82 81
Rebuild everything but the kernel.
83 82
.It Cm quickworld
......
132 131
Build user commands, no libraries or include files.
133 132
.It Cm installmost
134 133
Install user commands, no libraries or include files.
134
.It Cm backupworld
135
Manually archive binaries from installed world to location specified by
136
.Ev WORLD_BACKUP .
137
.It Cm backup-clean
138
Delete archive created by
139
.Cm backupworld .
140
.It Cm backup-auto-clean
141
Delete archive created automatically during
142
.Cm installworld .
143
.It Cm restoreworld
144
Restore binaries from archive created by
145
.Cm backupworld .
146
.It Cm restoreworld-auto
147
Restore binaries from archive created automatically during
148
.Cm installworld .
149
The archive location is specified by
150
.Ev AUTO_BACKUP .
135 151
.El
136 152
.Sh ENVIRONMENT
137 153
.Bl -tag -width ".Ev MAKEOBJDIRPREFIX"
......
208 224
.Ev DESTKERNDIR .
209 225
This overrides the effect of
210 226
.Ev DESTLABEL .
227
.It Ev WORLD_BACKUP
228
Directory for manual backup of binaries of installed world (default:
229
.Pa /var/backups/world_backup ) .
230
.It Ev AUTO_BACKUP
231
Directory for automatic backup of binaries of installed world (default:
232
.Ev MAKEOBJDIRPREFIX Ns /world_binaries/ Ns Ev DESTDIR ) .
233
.It Ev NO_BACKUP
234
When defined, the automatic backup feature of 
235
.Cm installworld
236
is inhibited.
211 237
.El
212 238
.Sh FILES
213 239
.Bl -tag -width ".Pa /usr/src/Makefile_upgrade.inc" -compact
214
-