Project

General

Profile

Bug #2527 » backupworld.update.20130406.patch

thomas.nikolajsen, 04/06/2013 03:32 PM

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 /lib /libexec
# to manual backup dir.
# backupworld-auto-clean - Delete backup from auto-backup dir.
# backupworld-auto-clean-all - Delete all backups from auto-backup dir.
# backupworld-clean - Delete backup from 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.
#
# This makefile is simple by design. The DragonFly make automatically reads
# /usr/share/mk/sys.mk unless the -m argument is specified on the
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
# 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 /lib /libexec to manual backup dir
# backupworld-auto-clean - delete backup from auto-backup dir
# backupworld-auto-clean-all - delete all backups from auto-backup dir
# backupworld-clean - delete backup from manual backup dir
# restoreworld- installs binaries from manual backup dir to world
# restoreworld-auto - installs binaries from auto-backup dir to world
#
# Standard targets (not defined here) are documented in the makefiles in
# /usr/share/mk. These include:
......
WORLD_LDVER?= ld.bfd
WORLD_BINUTILSVER?= binutils222
# Set the backup parameters if they are not already defined
#
WORLD_BACKUP?= /var/backups/world_backup
AUTO_BACKUP= ${OBJTREE}/world_backup
# temporary until everybody has converted to x86_64
.if ${MACHINE_ARCH} == "amd64"
MACHINE_ARCH= x86_64
......
.endif
.endif
# Set the backup parameters if they are not already defined
#
WORLD_BACKUP?= /var/backups/world_backup
HOSTNAME!= hostname
AUTO_BACKUP_BASE= ${OBJTREE}/world_backup
AUTO_BACKUP= ${AUTO_BACKUP_BASE}/${HOSTNAME}/${TARGET_ARCH}/${DESTDIR}
THREAD_LIB?= thread_xu
.if ${THREAD_LIB} == "c_r"
.if defined(NO_LIBC_R)
......
@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: backupworld-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(BACKUPWORLD_AUTO)
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
backupworld-auto-clean:
rm -f ${AUTO_BACKUP}/binaries.tar.gz
backupworld-auto-clean-all:
rm -rf ${AUTO_BACKUP_BASE}
backupworld-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
#
# To backup old world binaries as part of installworld
#BACKUPWORLD_AUTO= 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 6, 2013
.Dt MAKE.CONF 5
.Os
.Sh NAME
......
.Bd -literal -offset indent
INSTALL="install -C"
.Ed
.It Va BACKUPWORLD_AUTO
.Pq Vt str
Enable backup of old world binaries as part 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 /var/backups/world_backup .
.Dq backupworld
.Xr make 1
target.
The default value is
.Dq Pa /var/backups/world_backup .
.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 6, 2013
.Dt BUILD 7
.Os
.Sh NAME
......
Build user commands, no libraries or include files.
.It Cm installmost
Install user commands, no libraries or include files.
.It Cm backupworld
Backup binaries from installed world to location specified in
.Ev WORLD_BACKUP .
.It Cm backupworld-auto
Backup binaries from installed world to auto-backup directory.
This is only done if
.Ev BACKUPWORLD_AUTO
is defined.
Auto-backup directory is:
.Ev MAKEOBJDIRPREFIX Ns Pa /world_binaries/ Ns Ao Ar hostname Ac Ns / Ns Ev TARGET_ARCH Ns / Ns Ev DESTDIR .
This is executed as initial part of
.Cm installworld .
.It Cm backupworld-auto-clean
Delete backup from auto-backup directory.
See
.Cm backupworld-auto .
.It Cm backupworld-auto-clean-all
Delete all backups from auto-backup base directory:
.Ev MAKEOBJDIRPREFIX Ns Pa /world_binaries .
.It Cm restoreworld
Restore binaries to installed world from location specified in
.Ev WORLD_BACKUP .
.It Cm restoreworld-auto
Restore binaries to installed world from auto-backup directory.
See
.Cm backupworld-auto .
.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 (the default is
.Pa /var/backups/world_backup ) .
.El
.Sh FILES
.Bl -tag -width ".Pa /usr/src/Makefile_upgrade.inc" -compact
(1-1/2)