-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaddchroot
More file actions
executable file
·151 lines (143 loc) · 3.6 KB
/
Copy pathaddchroot
File metadata and controls
executable file
·151 lines (143 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash -p
[ $# -ge 2 ] || { echo "$0 requires at least 2 args" 1>&2;exit 1; }
#set -x
CHROOT=$1
SLK_VERSION=$(cat /etc/slackware-version|cut -d' ' -f2)
[ $SLK_VERSION = 14.2 ] && SOLIBS=glibc-solibs || SOLIBS=aaa_glibc-solibs
[ -n "$MKCHROOT_IGNORE_LN_ERRORS" ] && LNE='2>/dev/null' || LNE=
unset T # Temp file list
U=/dev/null # Temp install script
i=$(uname -m)
case $i in
x86_64)
ARCH="$i|x86"
;;
i686)
ARCH="$i|i586|i486|x86"
;;
i586)
ARCH="$i|i486|x86"
;;
i486)
ARCH="$i|x86"
;;
*)
ARCH="$i"
;;
esac
while [ $# -gt 1 ]
do
shift
PKG=$1
P=$(ls /var/log/packages/$PKG* | head -n1 |
grep -E "$PKG-[rv]{0,1}[0-9][^-]*-([^-]*-){0,1}($ARCH|noarch)")
[ -f "$P" ] || { echo "$PKG finds only $P" >&2; exit 1; }
# Get (formerly) doinst.sh name
S=$(echo $P | sed 's+/packages/+/scripts/+')
# The only reason to install man pages is to keep doinst.sh happy.
# So don't install them if doinst.sh is unavailable
[ -r $S ] && j= || j='|man'
[ -z "$VERBOSE_ADDCHROOT" ] || echo "Adding $PKG" >&2
# Check for specials
if [ \
$PKG = glibc \
-o $PKG = $SOLIBS \
-o $PKG = bash \
-o $PKG = devs \
-o $PKG = etc \
-o $PKG = network-scripts \
-o $PKG = sysvinit \
]
then
R=$S
S=/dev/null
T=$(tempfile -s .mkchroot)
if [ "$PKG" = bash ]
then
# Install bash manually and only use the main script to do locale stuff
mkdir -p $CHROOT/bin
(cd $CHROOT/bin
eval ln -f /bin/bash $LNE \|\| cp -a /bin/bash .
ln -sf bash sh)
echo "FILE LIST" >$T
echo >>$T
cat $P|grep -E ^usr/share >>$T
echo usr/bin/bash >>$T # symlink
fi
if [ $PKG = glibc -o $PKG = $SOLIBS ]
then
# Remove incoming/ prefix in file list
cat $P | sed -e 's+/incoming/+/+' >$T
fi
if [ "$PKG" = devs ]
then
# Only install those entries that exist in /dev, and do it here
# (because /dev is always mounted, so hard linking fails)
cat $P | grep -E ^dev/ |
while read i
do
if [ -e /$i ]
then
if [ -d /$i ]
then
mkdir -p $CHROOT/$i
else
cp -a /$i $CHROOT/$i
fi
fi
done
rm $T
unset T
continue
fi
if [ "$PKG" = etc -o "$PKG" = network-scripts ]
then
# Don't want to run doinst.sh
cat $P > $T
fi
if [ "$PKG" = sysvinit ]
then
# Only want to make the symlinks in doinst.sh
cat $P > $T
U=$(tempfile -s .mkchroot)
cat $R|grep -E '^[(]' > $U
fi
P=$T
fi
tail -n +$(($(grep -n "^FILE LIST" $P | cut -f1 -d:) + 2)) $P |
grep -E -v "^(install|usr/(doc|info$j))" | sed -e 's/[.]new$//' |
while read i
do
if [ -d /$i -a ! -L /$i ]
then
mkdir -p $CHROOT/$i
else
eval ln -f \"/$i\" \"$CHROOT/$i\" $LNE \|\| cp -a \"/$i\" \"$CHROOT/$i\"
fi
done
# Apply doinst.sh if possible
if [ -s $S ]
then
mkdir -p $CHROOT/install
cat $S | grep -E -v -e '^[[:space:]]*config [^()]' -e usr/doc |
sed -e s/[.]new// >$CHROOT/install/doinst.sh
[ $SLK_VERSION = 14.2 ] ||
{
# util-linux ends up with an empty if (thanks to PAM)
if [ $PKG = util-linux ]
then
sed -i '/^for configfile in/,/^$/{D}' $CHROOT/install/doinst.sh
sed -i '/^if \[ -r etc/,/^fi$/{D}' $CHROOT/install/doinst.sh
fi
}
(cd $CHROOT;sh install/doinst.sh)
rm -r $CHROOT/install
elif [ -s $U ]
then
(cd $CHROOT;sh $U)
rm $U
U=/dev/null
fi
# Remove temporary file if one created
[ -z "$T" ] || { rm -f $T; unset T; }
done