Changeset f4f7d18 for extras/filelist


Ignore:
Timestamp:
04/09/2006 06:07:03 PM (18 years ago)
Author:
Manuel Canales Esparcia <manuel@…>
Branches:
experimental
Children:
de313b3
Parents:
eddf89f5
Message:

filelist clean-up.

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.
    558#
    569
    57 VERSION="002"
     10set -e
    5811
    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:
     22inline_doc
    6823
    69 
    70 # process the argument, if there is one
    71 # normally, we exclude files in /tools and /cross-tools
    72 EXCLUDE=true
    73 
    74 case "$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 
    85 esac
    86 
    87 
    88 if [ $# -lt 1 ]; then
    89         error "no argument"
    90 elif [ $1 = "--version" ]; then
    91         echo "$0 version $VERSION"
    92         exit
    93 elif [ $# -gt 2 ]; then
    94         error "more than two arguments"
    95 elif ! [ -d $1 ]; then
    96         error "not a directory"
    97 fi
    9824if [ $# -eq 2 ]; then
    99         OUTFILE=$2
    100         if [ -e $2 ]; then
    101                 echo "output $2 already exists"
    102                 exit
    103         fi
     25  OUTFILE=$2
     26  if [ -e $2 ]; then
     27    echo -e "\nOutput $2 already exists\n"
     28    exit
     29  fi
    10430else
    105         NOW=`date +%Y%m%d%H%M`
    106         OUTFILE=~/filelist-${NOW}
     31  echo -e "\nMissing argument\n"
     32  exit 2
    10733fi
    10834
    10935if [ "$1" == "/" ]; then
    110         LOC=$1
     36  LOC=$1
    11137else
    112         # ensure the path or mountpoint ends with a slash
    113         # because of the seds after the 'find'
    114         LOC=`echo $1 | sed 's%[^/]$%&/%'`
     38  # ensure the path or mountpoint ends with a slash
     39  # because of the seds after the 'find'
     40  LOC=`echo $1 | sed 's%[^/]$%&/%'`
    11541fi
    11642
    117 echo "will create file list in $OUTFILE"
     43echo "Will create file list in $OUTFILE"
    11844if [ -f $OUTFILE ]; then
    119         echo "refusing to overwrite $OUTFILE"
    120         exit 1
     45  echo "refusing to overwrite $OUTFILE"
     46  exit 1
    12147fi
    12248
     
    12450>$OUTFILE
    12551if [ $? -ne 0 ]; then
    126         echo "error, cannot write to $OUTFILE"
    127         exit 1
     52  echo "error, cannot write to $OUTFILE"
     53  exit 1
    12854fi
    12955
    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
     56find $LOC -xdev -xtype f | sed "s%^${LOC}%/%" | sort >$OUTFILE
    15757
    15858exit
    159 
    160 
    161 
Note: See TracChangeset for help on using the changeset viewer.