Changeset f4f7d18 for extras/filelist
- Timestamp:
- 04/09/2006 06:07:03 PM (18 years ago)
- Branches:
- experimental
- Children:
- de313b3
- Parents:
- eddf89f5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extras/filelist
reddf89f5 rf4f7d18 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. 1 #!/bin/bash# 2 #$Id$ 3 4 # Acknowledgment: 5 # The following code is a modified version of an original work written by 6 # Ken Moffat for the "DIY Linux" project and is included here with his 7 # permission. 55 8 # 56 9 57 VERSION="002" 10 set -e 58 11 59 function 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 } 12 : <<inline_doc 13 desc: creates farce file lists 14 usage: filelist $DEST_FARCE/$ITERATION $DEST_FARCE/$ITERATION.filelist 15 input vars: $1 directory where files from current iteration are stored 16 $2 name of the file list to be created 17 externals: -- 18 modifies: -- 19 returns: -- 20 on error: 21 on success: 22 inline_doc 68 23 69 70 # process the argument, if there is one71 # normally, we exclude files in /tools and /cross-tools72 EXCLUDE=true73 74 case "$1" in75 76 --whole-build)77 # do NOT exclude cross-tools and tools78 EXCLUDE=79 shift80 ;;81 --*)82 error "Bad option $1"83 ;;84 85 esac86 87 88 if [ $# -lt 1 ]; then89 error "no argument"90 elif [ $1 = "--version" ]; then91 echo "$0 version $VERSION"92 exit93 elif [ $# -gt 2 ]; then94 error "more than two arguments"95 elif ! [ -d $1 ]; then96 error "not a directory"97 fi98 24 if [ $# -eq 2 ]; then 99 100 101 echo "output $2 already exists"102 103 25 OUTFILE=$2 26 if [ -e $2 ]; then 27 echo -e "\nOutput $2 already exists\n" 28 exit 29 fi 104 30 else 105 NOW=`date +%Y%m%d%H%M` 106 OUTFILE=~/filelist-${NOW} 31 echo -e "\nMissing argument\n" 32 exit 2 107 33 fi 108 34 109 35 if [ "$1" == "/" ]; then 110 36 LOC=$1 111 37 else 112 113 114 38 # ensure the path or mountpoint ends with a slash 39 # because of the seds after the 'find' 40 LOC=`echo $1 | sed 's%[^/]$%&/%'` 115 41 fi 116 42 117 echo " will create file list in $OUTFILE"43 echo "Will create file list in $OUTFILE" 118 44 if [ -f $OUTFILE ]; then 119 120 45 echo "refusing to overwrite $OUTFILE" 46 exit 1 121 47 fi 122 48 … … 124 50 >$OUTFILE 125 51 if [ $? -ne 0 ]; then 126 127 52 echo "error, cannot write to $OUTFILE" 53 exit 1 128 54 fi 129 55 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. 145 if [ -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 150 else 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 156 fi 56 find $LOC -xdev -xtype f | sed "s%^${LOC}%/%" | sort >$OUTFILE 157 57 158 58 exit 159 160 161
Note:
See TracChangeset
for help on using the changeset viewer.