3 # Copyright (C) 2009 Red Hat Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 # Decide which files will stay in the supermin appliance and which
20 # files will be pulled out of the host at runtime.
22 # Read the README file!
24 # The basic idea is that we create two output files, one containing
25 # the files that will stay, and the other listing the files that
26 # will be pulled from the host (ie. not go into the appliance now).
28 # The list of files that stay ('supermin.incfiles') is just a straight
29 # list of files and directories.
31 # The list of files that come from the host ('*.supermin.hostfiles')
32 # can include wildcards, to allow libraries to be upgraded on the
39 cd @top_builddir@/initramfs
41 incfiles=../appliance/supermin.incfiles
42 hostfiles=../appliance/initramfs.@REPO@.@host_cpu@.supermin.hostfiles
47 # Note currently the initramfs contains ~2500 files, and none have
48 # "funny characters" in the names. So this is reasonable just to
49 # simplify the script.
50 for path in $(find -not -name fakeroot.log); do
51 dir=$(dirname "$path")
52 file=$(basename "$path")
54 # For quoting problems with the bash =~ operator, see bash FAQ
55 # question E14 here http://tiswww.case.edu/php/chet/bash/FAQ and
56 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=487387#25
59 # All we're going to keep are the special files /init, the daemon,
60 # configuration files (/etc), devices and modifiable stuff (/var).
61 if [ "$path" = "./init" -o "$file" = "guestfsd" ]; then
64 elif [[ "$path" =~ ^\./etc || "$path" =~ ^\./dev || "$path" =~ ^\./var ]]
68 # Kernel modules are always copied in from the host, including all
69 # the dependency files.
70 elif [[ "$path" =~ ^\./lib/modules/ ]]; then
73 # On mock/Koji, exclude bogus /builddir directory which for some
74 # reason contains some yum temporary files (RHBZ#566512).
75 elif [[ "$path" =~ ^\./builddir ]]; then
78 elif [ -d "$path" ]; then
79 # Always write directory names to both output files.
83 # Some libraries need fixed version numbers replaced by wildcards.
85 elif [[ "$file" =~ ^ld-[.0-9]+\.so$ ]]; then
86 echo "$dir/ld-*.so" >&6
88 # Special case for libbfd
89 elif [[ "$file" =~ ^libbfd-.*\.so$ ]]; then
90 echo "$dir/libbfd-*.so" >&6
92 # Special case for libgcc_s-<gccversion>-<date>.so.N
93 elif [[ "$file" =~ ^libgcc_s-.*\.so\.([0-9]+)$ ]]; then
94 echo "$dir/libgcc_s-*.so.${BASH_REMATCH[1]}" >&6
97 elif [[ "$file" =~ ^lib(.*)-[-.0-9]+\.so$ ]]; then
98 echo "$dir/lib${BASH_REMATCH[1]}-*.so" >&6
100 # libfoo-1.2.3.so.1.2.3 (but NOT '*.so.N')
101 elif [[ "$file" =~ ^lib(.*)-[-.0-9]+\.so\.([0-9]+)\. ]]; then
102 echo "$dir/lib${BASH_REMATCH[1]}-*.so.${BASH_REMATCH[2]}.*" >&6
104 # libfoo.so.1.2.3 (but NOT '*.so.N')
105 elif [[ "$file" =~ ^lib(.*)\.so\.([0-9]+)\. ]]; then
106 echo "$dir/lib${BASH_REMATCH[1]}.so.${BASH_REMATCH[2]}.*" >&6
109 # Anything else comes from the host directly.