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
|
install_dependencies() {
apt-get install -y $DEPS
}
fetch_source() {
:
}
build() {
BUILDDIR=${TOOL_DIR}/${TOOL}/build
mkdir -p ${BUILDDIR}
FILELIST="list_binaries_and_files"
[ -e ${FILELIST} ] && rm ${FILELIST}
for BIN in ${REQUIRED_BINARIES}
do
BIN_LOCATION=$(which ${BIN})
if [ ! -z ${BIN_LOCATION} -a -e ${BIN_LOCATION} ];
then
pdebug "Processing $BIN at $BIN_LOCATION ..."
echo ${BIN_LOCATION} >> "${FILELIST}"
[ -L "${BIN_LOCATION}" ] \
&& pdebug "${BIN_LOCATION} is a symbolic link, copying $(readlink -f "${BIN_LOCATION}")" \
&& echo $(readlink -f "${BIN_LOCATION}") >> "${FILELIST}"
else
perror "${BIN} not found on the system! Please install it."
fi
done
for LIB in ${REQUIRED_LIBRARIES}
do
for LIB_LOCATION in $(locate ${LIB} | grep ^/lib/)
do
echo ${LIB_LOCATION} >> "${FILELIST}"
done
done
for FILE in ${REQUIRED_DIRECTORIES}
do
[ ! -d ${FILE} ] && perror "Missing required directory $FILE"
echo ${FILE} >> "${FILELIST}"
done
for FILE in ${REQUIRED_FILES}
do
[ ! -f ${FILE} ] && perror "Missing required file $FILE"
echo ${FILE} >> "${FILELIST}"
done
local NUMFILES=$(cat "${FILELIST}" | wc -l)
if [ "x$NUMFILES" != "x" -a "x$NUMFILES" != "x0" ]; then
pinfo "File list generated at ${BUILDDIR}/${FILELIST} ($NUMFILES entries)"
tar -cp $(cat "${FILELIST}") | tar -xp -C "${BUILDDIR}"
local RET=$?
[ $RET -ne 0 ] && perror "tar-copy from '$FILELIST' to '$BUILDDIR' failed."
fi
}
post_copy() {
# make basic directory structure
mkdir -p "${INIT_DIR}"/{bin,dev,proc,lib,etc,mnt,sys,var/run,var/lock,var/log,run/lock,run/shm,openslx/mnt}
# copy devices from running system
cp -a /dev/{console,kmsg,mem,null,shm,tty,tty0,tty1,tty9,fb0,urandom,zero} \
"${INIT_DIR}"/dev
# set /etc/environment to include /openslx/bin and /openslx/sbin
echo "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/openslx/sbin:/openslx/bin\"" \
> "${INIT_DIR}/etc/environment"
# copy static files
cp -r "${TOOL_DIR}/${TOOL}/data/*" "${INIT_DIR}"
# better: dirname $(ldd $SHELL|grep libc | awk -F " " '{print $3}')
# copy pam modules, TODO: better way to find arch-dependant interfix...
tarcopy "$(dirname $(locate pam_unix.so | grep ^/lib/))" "${INIT_DIR}"
# quick fix for /etc/fstab
echo "# no configuration" >> "${INIT_DIR}/etc/fstab"
# link /etc/mtab, needed for systemd
[ ! -e ${INIT_DIR}/etc/mtab ] && ln -s /proc/self/mounts ${INIT_DIR}/etc/mtab
# passwd, group, shadow
init_users_and_groups
# quick fix for missing group in /etc/group
add_group "lock"
# setup root accoun
USER=root PASSWORD='!r00t' add_user
[ ! -d ${INIT_DIR}/root ] && mkdir ${INIT_DIR}/root
echo "minilinux-$(hostname)" > "${INIT_DIR}/etc/hostname"
# copy kernel modules
#[ ! -d ${INIT_DIR}/lib/modules/$(uname -r) ] && mkdir -p ${INIT_DIR}/lib/modules/$(uname -r)
#cp -r /lib/modules/$(uname -r) ${INIT_DIR}/lib/modules/$(uname -r)
#quick fix xterm symlink
[ -e /usr/lib/libXaw7.so.7.0.0 ] && \
ln -s "/usr/lib/libXaw7.so.7.0.0" "${INIT_DIR}/usr/lib/libXaw7.so.7"
}
|