source: extras/filelist@ dc526ea

experimental
Last change on this file since dc526ea was dc526ea, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Added original farce-002 scripts.

  • Property mode set to 100755
File size: 4.9 KB
Line 
1#!/bin/bash
2#
3# filelist - prepare a list of the files in a built system.
4# This is for use in comparing two builds, to answer the
5# question "can it build itself" ? Obviously, it can also be
6# used to compare two partial builds to see what changed.
7#
8# Call this script with the path to the root of the system.
9# If you are running the new system, the path is probably '/'.
10# Alternatively, the system might be mounted at /mnt/lfs, or
11# it might have been copied to ~/build1 or wherever.
12#
13# The output is a single file, filelist-CCYYMMDDhhmm
14# e.g. filelist-200510052108
15# which contains a list of the files to compare.
16# It excludes certain files which are not of interest (/tools,
17# /cross-tools, /home) together with any mounted filesystems.
18#
19# you should run this as a regular user - this will cause files
20# in e.g. /root to be ignored.
21#
22# I like to build a graphical desktop before using a new system
23# to see if it can build itself. Filelist supports this by allowing
24# you to list the files at any time. My normal process is:
25#
26# 1. Build an LFS system as normal.
27# 2. Build some extras before booting (nfs client, ntp, openssh,
28# lynx, dhcp client, etc).
29# 3. Boot the new (first) system, set up users, run filelist.
30# 4. Build X and whatever else I want to use.
31# 5. Build the second system.
32# 6. Build the same extras for the second system.
33# 7. Boot the second system, to prove it works.
34# 8. Reboot to the first system, mount the second system at /mnt/lfs,
35# then run filelist on /mnt/lfs and run the comparison.
36#
37# Copyright (C) 2005, 2006 Ken Moffat <ken@linuxfromscratch.org>
38#
39# All rights reserved.
40#
41# This program is free software; you can redistribute it and/or modify
42# it under the terms of the GNU General Public License as published by
43# the Free Software Foundation; either version 2 of the License, or (at
44# your option) any later version.
45#
46# This program is distributed in the hope that it will be useful, but
47# WITHOUT ANY WARRANTY; without even the implied warranty of
48# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
49# NON INFRINGEMENT. See the GNU General Public License for more
50# details.
51#
52# You should have received a copy of the GNU General Public License
53# along with this program; if not, write to the Free Software
54# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
55#
56
57VERSION="002"
58
59function error() {
60 echo "usage:"
61 echo " `basename $0` [--whole-build] path name for output file]"
62 echo " e.g. '/' or '/mnt/lfs' or 'build1'"
63 echo " use --whole-build to compare files from /tools or /cross-tools"
64 echo
65 echo "Error: $1"
66 exit 1
67}
68
69
70# process the argument, if there is one
71# normally, we exclude files in /tools and /cross-tools
72EXCLUDE=true
73
74case "$1" in
75
76--whole-build)
77 # do NOT exclude cross-tools and tools
78 EXCLUDE=
79 shift
80 ;;
81--*)
82 error "Bad option $1"
83 ;;
84
85esac
86
87
88if [ $# -lt 1 ]; then
89 error "no argument"
90elif [ $1 = "--version" ]; then
91 echo "$0 version $VERSION"
92 exit
93elif [ $# -gt 2 ]; then
94 error "more than two arguments"
95elif ! [ -d $1 ]; then
96 error "not a directory"
97fi
98if [ $# -eq 2 ]; then
99 OUTFILE=$2
100 if [ -e $2 ]; then
101 echo "output $2 already exists"
102 exit
103 fi
104else
105 NOW=`date +%Y%m%d%H%M`
106 OUTFILE=~/filelist-${NOW}
107fi
108
109if [ "$1" == "/" ]; then
110 LOC=$1
111else
112 # ensure the path or mountpoint ends with a slash
113 # because of the seds after the 'find'
114 LOC=`echo $1 | sed 's%[^/]$%&/%'`
115fi
116
117echo "will create file list in $OUTFILE"
118if [ -f $OUTFILE ]; then
119 echo "refusing to overwrite $OUTFILE"
120 exit 1
121fi
122
123# check we can indeed do this
124>$OUTFILE
125if [ $? -ne 0 ]; then
126 echo "error, cannot write to $OUTFILE"
127 exit 1
128fi
129
130# Explanation of the find command: we exclude any filesystems mounted below
131# this path (typically, you are looking at '/' so this excludes /proc /sys
132# /dev). We only care about files, not directories.
133# Exclusions - insert whatever we were given at the start of the pathes to
134# exclude - this might mean we have '//' in them, but that shouldn't matter.
135# /tools* /tools and also e.g. /tools.old if you rename an old version
136# /cross-tools* similar, for cross-lfs
137# /home/* - in case /home is not a separate filesystem
138# /sources/* - where the book thinks you should keep sources
139# /tmp/* - we really don't care about any junk left in here
140# /misc/* - where I keep buildscripts and stamps
141# we then sed it so that / or /mnt/lfs/ or whatever are all converted to '/'.
142
143# At one time, EXCLUDE contained the ! -path strings for cross-tools and tools
144# but htat didn't work, so now it is just a marker to control this logic.
145if [ -z "$EXCLUDE" ]; then
146 find $LOC -xdev -xtype f \
147 ! -path "${LOC}home/*" \
148 ! -path "${LOC}sources/*" ! -path "${LOC}tmp/*" \
149 ! -path "${LOC}misc/*" | sed "s%^${LOC}%/%" | sort >$OUTFILE
150else
151 find $LOC -xdev -xtype f \
152 ! -path "${LOC}cross-tools*/*" ! -path "${LOC}tools/*" \
153 ! -path "${LOC}home/*" \
154 ! -path "${LOC}sources/*" ! -path "${LOC}tmp/*" \
155 ! -path "${LOC}misc/*" | sed "s%^${LOC}%/%" | sort >$OUTFILE
156fi
157
158exit
159
160
161
Note: See TracBrowser for help on using the repository browser.