1#!/bin/mksh 2# $MirOS: src/distrib/baselive/mklocatedb.sh,v 1.11 2009/03/29 13:04:12 tg Exp $ 3#- 4# Copyright (c) 2006, 2007 5# Thorsten Glaser <tg@mirbsd.de> 6# 7# Provided that these terms and disclaimer and all copyright notices 8# are retained or reproduced in an accompanying document, permission 9# is granted to deal in this work without restriction, including un- 10# limited rights to use, publicly perform, distribute, sell, modify, 11# merge, give away, or sublicence. 12# 13# This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to 14# the utmost extent permitted by applicable law, neither express nor 15# implied; without malicious intent or gross negligence. In no event 16# may a licensor, author or contributor be held liable for indirect, 17# direct, other damage, loss, or other issues arising in any way out 18# of dealing in the work, even if advised of the possibility of such 19# damage or existence of a defect, except proven that it results out 20# of said person's immediate fault when using the work as intended. 21 22function cleanup 23{ 24 set -x 25 cd $root 26 set +e 27 umount $root/var 28 umount $root/usr/X11R6/lib/X11 29 umount $root/tmp 30 umount $root/home 31 umount $root/etc 32 umount $root/dev 33 vnconfig -u svnd0 34 rm -f $root/../locatedb.tmp $root/../locatedb.vnd 35 exit ${1:-1} 36} 37 38set -x 39set -e 40root=$(realpath .) 41set +e 42rm -f $root/../locatedb.tmp $root/../locatedb.vnd 43[[ -e $root/../locatedb.tmp ]] && exit 1 44[[ -e $root/../locatedb.vnd ]] && exit 1 45set -e 46sync 47cp "$1" $root/../locatedb.vnd 48sync 49vnconfig svnd0 $root/../locatedb.vnd 50set +e 51cd $root 52mount /dev/svnd0a dev || cleanup 53rm -f dev/.rs 54ln -s rd0a dev/root 55mount_mfs -s 20480 swap $root/etc || cleanup 56mount_mfs -s 300000 swap $root/home || cleanup 57mount_mfs -s 600000 swap $root/tmp || cleanup 58mount_mfs -s 20480 swap $root/usr/X11R6/lib/X11 || cleanup 59mount_mfs -s 300000 swap $root/var || cleanup 60gzip -dc stand/fsrw.dat | pax -r -pe || cleanup 61cp -r etc/skel home/live || cleanup 62chown -R 32762:32762 home/live || cleanup 63chroot $root /usr/libexec/locate.updatedb --fcodes=- --tmpdir=/var/tmp \ 64 --filesystems='ffs ufs mfs' >$root/../locatedb.tmp 65if [[ -s $root/../locatedb.tmp ]]; then 66 cp $root/../locatedb.tmp $root/stand/locate.database 67 chmod 444 $root/stand/locate.database 68 chown root:wheel $root/stand/locate.database 69 rv=0 70else 71 rv=1 72fi 73rm -f $root/../locatedb.tmp 74cleanup $rv 75