X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/blobdiff_plain/34483efcd245c6c0ca04de596876445bfb8ab5e4..7bee86c0ec635f688e37b15e7aa203a961ec4c84:/Makefile.inc1 diff --git a/Makefile.inc1 b/Makefile.inc1 index 198d336b73..304796a331 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -10,6 +10,8 @@ # 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 # @@ -123,6 +125,20 @@ WORLD_CCVER?= gcc47 WORLD_LDVER?= ld.bfd WORLD_BINUTILSVER?= binutils222 +# Set the backup parameters if they are not already defined +# +WORLD_BACKUP?= /var/backups/world_binaries +DAYS_BACKUP?= 28 +.if exists(${WORLD_BACKUP}/lastbackup) +BK_REFERENCE!= date +'%s' +BK_EXPIRES!= expr ${DAYS_BACKUP} \* 86400 + `cat ${WORLD_BACKUP}/lastbackup` +. if ${BK_REFERENCE} > ${BK_EXPIRES} +BACKUP_EXPIRED= yes +. endif +.else +NEVER_BACKED_UP= yes +.endif + # temporary until everybody has converted to x86_64 .if ${MACHINE_ARCH} == "amd64" MACHINE_ARCH= x86_64 @@ -463,6 +479,16 @@ installcheck: .if !defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/" @case `uname -r` in 1.2*|1.3-*|1.3.*|1.4.*|1.5.0-*|1.5.1-*|1.5.2-*|1.5.3-*) echo "You must upgrade your kernel to at least 1.5.4 and reboot before you can safely installworld, due to libc/system call ABI changes" ; /usr/bin/false ; esac .endif +.if !defined(NO_BACKUP) +. if defined(NEVER_BACKED_UP) + @echo "Run 'make backupworld' or set NO_BACKUP first" + /usr/bin/false +. elif defined(BACKUP_EXPIRED) + @echo "More than ${DAYS_BACKUP} days have passed since last backup." + @echo "Run 'make backupworld' or set NO_BACKUP first" + /usr/bin/false +. endif +.endif # # installworld # @@ -1044,6 +1070,43 @@ xmake: xmakeenv: @echo '${XMAKEENV} /bin/sh' +backupworld: + @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 -a /sbin ${WORLD_BACKUP}/sbin + cp -a /bin ${WORLD_BACKUP}/bin + cp -a /usr/sbin ${WORLD_BACKUP}/usr.sbin + cp -a /usr/bin ${WORLD_BACKUP}/usr.bin + cp -a /usr/libexec ${WORLD_BACKUP}/usr.libexec + @date +'%s' > ${WORLD_BACKUP}/lastbackup + +restoreworld: +.if !(exists(${WORLD_BACKUP}/sbin) && exists(${WORLD_BACKUP}/bin) && \ + exists(${WORLD_BACKUP}/usr.sbin) && exists(${WORLD_BACKUP}/usr.bin) && \ + exists(${WORLD_BACKUP}/usr.libexec)) + @echo "There does not seem to be a valid archive present." +.else + @echo "Restoring system binaries from backup archive..." + @rm -f /tmp/rs.tmp +.for BX in sbin bin usr.sbin usr.bin 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" +.endif + # Take advantage of bmake error response # MAKE_PRINT_VAR_ON_ERROR= \