Project

General

Profile

Bug #2527 » 0001-Makefile.inc-Rework-automatic-backup-bug-2527.patch

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

View differences:

Makefile
# of the system for DragonFly. ex. two compilers
# most - Build user commands, no libraries or include files.
# installmost - Install user commands, no libraries or include files.
# backupworld - Copies /bin /sbin /usr/bin /usr/sbin /usr/lib
# /usr/libexec to manual backup dir.
# restoreworld - Installs binaries from manual backup dir to world.
# restoreworld-auto - Installs binaries from auto-backup dir to world;
# installworld target makes backup to auto-backup dir.
# backup-auto-clean - Delete backup from auto-backup dir.
# backup-clean - Delete backup from manual backup dir.
#
# This makefile is simple by design. The DragonFly make automatically reads
# /usr/share/mk/sys.mk unless the -m argument is specified on the
......
reinstallkernel installmost installworld libraries lint maninstall \
manlint mk most obj objlink regress rerelease tags \
backupworld restoreworld restoreworld-auto \
backup-clean backup-auto-clean \
_obj _includes _libraries _depend _worldtmp \
_bootstrap-tools _build-tools _cross-tools
Makefile.inc1
# realquickworld - skip the glue and depend stages and just build the meat
# crossworld - only build the glue (particularly the cross-build environment)
# installworld- install everything built by "buildworld"
# backupworld - copies /bin /sbin /usr/bin /usr/sbin /libexec to backup dir
# restoreworld- installs binaries from backup dir to world
# backupworld - copies /bin /sbin /usr/bin /usr/sbin /usr/lib /usr/libexec
# to manual backup dir
# restoreworld- installs binaries from manual backup dir to world
# restoreworld-auto - installs binaries from auto-backup dir to world
# most - build user commands, no libraries or include files
# installmost - install user commands, no libraries or include files
# backup-clean - delete backup from manual backup dir
# backup-auto-clean - delete backup from auto-backup dir
#
# Standard targets (not defined here) are documented in the makefiles in
# /usr/share/mk. These include:
......
# Set the backup parameters if they are not already defined
#
WORLD_BACKUP?= /var/backups/world_backup
AUTO_BACKUP= ${OBJTREE}/world_backup
AUTO_BACKUP?= ${OBJTREE}/world_backup/${DESTDIR}
# temporary until everybody has converted to x86_64
.if ${MACHINE_ARCH} == "amd64"
......
@echo ">>> stage 4d: building everything.."
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${WMAKE} all
@rm -f ${AUTO_BACKUP}/installstamp
# note: buildworld no longer depends on _cleanobj because we rm -rf the
# entire object tree and built the bootstrap tools in a different location.
......
xmakeenv:
@echo '${XMAKEENV} /bin/sh'
backupworld:
backupworld: backup-clean
@mkdir -p ${WORLD_BACKUP}
@chflags -R noschg ${WORLD_BACKUP}
@rm -rf ${WORLD_BACKUP}/sbin ${WORLD_BACKUP}/bin \
${WORLD_BACKUP}/usr.sbin ${WORLD_BACKUP}/usr.bin \
${WORLD_BACKUP}/usr.libexec
cp -RpP /bin ${WORLD_BACKUP}/bin
cp -RpP /sbin ${WORLD_BACKUP}/sbin
cp -RpP /usr/bin ${WORLD_BACKUP}/usr.bin
cp -RpP /usr/lib ${WORLD_BACKUP}/usr.lib
cp -RpP /usr/sbin ${WORLD_BACKUP}/usr.sbin
cp -RpP /usr/libexec ${WORLD_BACKUP}/usr.libexec
.if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
tar -czf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
--options gzip:compression-level=1 \
sbin bin usr/sbin usr/bin usr/lib usr/libexec
.endif
backupworld-auto:
.if !exists(${AUTO_BACKUP}/installstamp)
.if !defined(NO_BACKUP)
rm -f ${AUTO_BACKUP}/binaries.tar.gz
@mkdir -p ${AUTO_BACKUP}
@chflags -R noschg ${AUTO_BACKUP}
@rm -rf ${AUTO_BACKUP}/sbin ${AUTO_BACKUP}/bin \
${AUTO_BACKUP}/usr.sbin ${AUTO_BACKUP}/usr.bin \
${AUTO_BACKUP}/usr.libexec
cp -RpP /bin ${AUTO_BACKUP}/bin
cp -RpP /sbin ${AUTO_BACKUP}/sbin
cp -RpP /usr/bin ${AUTO_BACKUP}/usr.bin
cp -RpP /usr/lib ${AUTO_BACKUP}/usr.lib
cp -RpP /usr/sbin ${AUTO_BACKUP}/usr.sbin
cp -RpP /usr/libexec ${AUTO_BACKUP}/usr.libexec
@date '+%Y-%m-%d %H:%M:%S' > ${AUTO_BACKUP}/installstamp
.if (exists(${DESTDIR}/sbin) && exists(${DESTDIR}/bin) && \
exists(${DESTDIR}/usr/sbin) && exists(${DESTDIR}/usr/bin) && \
exists(${DESTDIR}/usr/lib) && exists(${DESTDIR}/usr/libexec))
tar -czf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/ \
--options gzip:compression-level=1 \
sbin bin usr/sbin usr/bin usr/lib usr/libexec
.endif
.endif
backup-auto-clean:
rm -f ${AUTO_BACKUP}/binaries.tar.gz
backup-clean:
rm -f ${WORLD_BACKUP}/binaries.tar.gz
restoreworld:
.if !(exists(${WORLD_BACKUP}/sbin) && exists(${WORLD_BACKUP}/bin) && \
exists(${WORLD_BACKUP}/usr.sbin) && exists(${WORLD_BACKUP}/usr.bin) && \
exists(${WORLD_BACKUP}/usr.lib) && exists(${WORLD_BACKUP}/usr.libexec))
.if !exists(${WORLD_BACKUP}/binaries.tar.gz)
@echo "There does not seem to be a valid archive present."
.else
@echo "Restoring system binaries from manual backup archive..."
@rm -f /tmp/rs.tmp
.for BX in sbin bin usr.sbin usr.bin usr.lib usr.libexec
@chflags -R noschg /${BX:S/./\//}
@cd ${WORLD_BACKUP}/${BX} && find * -type f -perm +700 -exec \
echo cp ${WORLD_BACKUP}/${BX}/{} /${BX:S/./\//}/{} >> /tmp/rs.tmp \;
.endfor
@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)$$' \
/tmp/rs.tmp > /tmp/restore.script
@/bin/sh /tmp/restore.script
@rm /tmp/rs.tmp /tmp/restore.script
@echo "These files were not restored from ${WORLD_BACKUP}:"
@echo " /bin/cp"
@echo " /bin/sh"
@echo " /usr/bin/make"
@echo " /usr/libexec/ld-elf.so.2"
@chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
tar -xzf ${WORLD_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
.endif
restoreworld-auto:
.if !(exists(${AUTO_BACKUP}/sbin) && exists(${AUTO_BACKUP}/bin) && \
exists(${AUTO_BACKUP}/usr.sbin) && exists(${AUTO_BACKUP}/usr.bin) && \
exists(${AUTO_BACKUP}/usr.lib) && exists(${AUTO_BACKUP}/usr.libexec))
.if !exists(${AUTO_BACKUP}/binaries.tar.gz)
@echo "There does not seem to be a valid archive present."
.else
@echo "Restoring system binaries from auto-backup archive..."
@rm -f /tmp/rs.tmp
.for BX in sbin bin usr.sbin usr.bin usr.lib usr.libexec
@chflags -R noschg /${BX:S/./\//}
@cd ${AUTO_BACKUP}/${BX} && find * -type f -perm +700 -exec \
echo cp ${AUTO_BACKUP}/${BX}/{} /${BX:S/./\//}/{} >> /tmp/rs.tmp \;
.endfor
@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)$$' \
/tmp/rs.tmp > /tmp/restore.script
@/bin/sh /tmp/restore.script
@rm /tmp/rs.tmp /tmp/restore.script
@echo "These files were not restored from ${AUTO_BACKUP}:"
@echo " /bin/cp"
@echo " /bin/sh"
@echo " /usr/bin/make"
@echo " /usr/libexec/ld-elf.so.2"
@chflags -R noschg ${DESTDIR}/sbin ${DESTDIR}/bin \
${DESTDIR}/usr/sbin ${DESTDIR}/usr/bin \
${DESTDIR}/usr/lib ${DESTDIR}/usr/libexec
tar -xzf ${AUTO_BACKUP}/binaries.tar.gz -C ${DESTDIR}/
.endif
# Take advantage of bmake error response
etc/defaults/make.conf
# Compare before install
#INSTALL=install -C
#
# Inhibit the automatic backup during installworld
#NO_BACKUP= true
#
# To build ppp with normal permissions
#PPP_NOSUID= true
#
share/man/man5/make.conf.5
.\"
.\" $FreeBSD: src/share/man/man5/make.conf.5,v 1.12.2.30 2003/05/18 17:05:55 brueffer Exp $
.\"
.Dd February 17, 2013
.Dd April 16, 2013
.Dt MAKE.CONF 5
.Os
.Sh NAME
......
.Bd -literal -offset indent
INSTALL="install -C"
.Ed
.It Va NO_BACKUP
.Pq Vt str
Inhibit automatic backup of world binaries as port of
.Dq installworld
.Xr make 1
target.
Default is unset.
.It Va WORLD_BACKUP
.Pq Vt str
defines where system binaries will be backed up for the
.Dq make backupworld
target. The default value is
.Dq backupworld
.Xr make 1
target.
The default is
.Dq /var/backups/world_backup .
.It Va AUTO_BACKUP
.Pq Vt str
defines where system binaries will be backed up automatically
as part of the
.Dq installworld
.Xr make 1
target.
The default is
.Dq Ev MAKEOBJDIRPREFIX Ns /world_binaries/ Ns Ev DESTDIR .
.It Va LOCAL_DIRS
.Pq Vt str
List any directories that should be entered when running make
.Pa /usr/src
in this variable.
List of directories that should be entered when running
.Xr make 1
in
.Pa /usr/src .
.It Va MAKE_SHELL
.Pq Vt str
Controls the shell used internally by
share/man/man7/build.7
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/share/man/man7/build.7,v 1.19.2.1 2002/03/18 08:33:02 murray Exp $
.\" $DragonFly: src/share/man/man7/build.7,v 1.18 2008/11/14 15:04:42 swildner Exp $
.\"
.Dd April 12, 2009
.Dd April 16, 2013
.Dt BUILD 7
.Os
.Sh NAME
......
The other
.Pa /usr/src
make targets are:
.Bl -tag -width ".Cm reinstallkernel"
.Bl -tag -width ".Cm backup-auto-clean"
.It Cm buildworld
Rebuild everything but the kernel.
.It Cm quickworld
......
Build user commands, no libraries or include files.
.It Cm installmost
Install user commands, no libraries or include files.
.It Cm backupworld
Manually archive binaries from installed world to location specified by
.Ev WORLD_BACKUP .
.It Cm backup-clean
Delete archive created by
.Cm backupworld .
.It Cm backup-auto-clean
Delete archive created automatically during
.Cm installworld .
.It Cm restoreworld
Restore binaries from archive created by
.Cm backupworld .
.It Cm restoreworld-auto
Restore binaries from archive created automatically during
.Cm installworld .
The archive location is specified by
.Ev AUTO_BACKUP .
.El
.Sh ENVIRONMENT
.Bl -tag -width ".Ev MAKEOBJDIRPREFIX"
......
.Ev DESTKERNDIR .
This overrides the effect of
.Ev DESTLABEL .
.It Ev WORLD_BACKUP
Directory for manual backup of binaries of installed world (default:
.Pa /var/backups/world_backup ) .
.It Ev AUTO_BACKUP
Directory for automatic backup of binaries of installed world (default:
.Ev MAKEOBJDIRPREFIX Ns /world_binaries/ Ns Ev DESTDIR ) .
.It Ev NO_BACKUP
When defined, the automatic backup feature of
.Cm installworld
is inhibited.
.El
.Sh FILES
.Bl -tag -width ".Pa /usr/src/Makefile_upgrade.inc" -compact
(2-2/2)