forked from nielsterp/LFS-X-KDE-RPM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmk-setup-lfs
executable file
·98 lines (96 loc) · 4.39 KB
/
mk-setup-lfs
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
#!/bin/bash
#################################################
# Title: mk-setup-lfs #
# Date: 2014-06-27 #
# Version: 1.0 #
# Author: [email protected] #
# Options: #
#################################################
# Overview
# install directory /mnt/lfs
# add lfs user
# fetch source packages
# copy build system to /mnt/blfs/usr/src/Octothorpe
# End
#
set -o errexit # exit if error...insurance ;)
set -o nounset # exit if variable not initalized
set +h # disable hashall
PRGNAME=${0##*/} # script name minus the path
source config.inc # configuration parameters
source function.inc # commonn functions
LOGFILE="${PRGNAME}-${LOGFILE}" # set log file name
#LOGFILE=/dev/null # uncomment to disable log file
ARCH=$(uname -m) # host architecture
RPMDIR=${PARENT} # where rpms are stored on the host system
[ ${EUID} -eq 0 ] || die "${PRGNAME}: Need to be root user: FAILURE"
[ -z ${BLFS} ] && die "${PRGNAME}: BLFS: not set"
[ -z ${LFS} ] && die "${PRGNAME}: LFS: not set"
[ -z ${DEVICE} ] && die "${PRGNAME}: DEVICE: not set"
[ -z ${PARENT} ] && die "${PRGNAME}: PARENT: not set"
> ${LOGFILE} # clear/initialize logfile
#
umount /dev/${DEVICE}
[ -d ${LFS} ] && build "Clean directory: ${LFS}" "rm -rf ${LFS} " "${LOGFILE}"
[ -d ${LFS} ] || build "Creating directory: ${LFS}" "install -vdm 755 ${LFS}" "${LOGFILE}"
mount -v -t ${FILESYSTEM} /dev/${DEVICE} $LFS
[ -d ${LFS}/tools ] || build "Creating directory: ${LFS}/tools" "install -vdm 755 ${LFS}/tools" "${LOGFILE}"
[ -h /tools ] || build "Symlink: ${LFS}/tools to /tools" "ln -vs ${LFS}/tools /" "${LOGFILE}"
#
# Create lfs user
#
[ -d /home/lfs ] || {
msg "Adding lfs user to host: "
getent group lfs > /dev/null 2>&1 || build " Creating lfs group" "groupadd lfs" "${LOGFILE}"
getent passwd lfs > /dev/null 2>&1 || build " Creating lfs user" "useradd -c 'LFS user' -g lfs -m -k /dev/null -s /bin/bash lfs" "${LOGFILE}"
build " Adding password to lfs" "passwd -l lfs" "${LOGFILE}"
cat > /home/lfs/.bash_profile <<- "EOF"
exec env -i HOME=/home/lfs TERM=${TERM} PS1='\u:\w\$ ' /bin/bash
EOF
cat > /home/lfs/.bashrc <<- "EOF"
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=$(uname -m)-lfs-linux-gnu
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL LFS_TGT PATH
EOF
build " Changing ownership /home/lfs" "chown -R lfs:lfs /home/lfs" "${LOGFILE}"
}
#
# Fetch source packages
#
msg "Fetching source packages: "
[ -d SOURCES ] || build " Create SOURCES directory" "install -vdm 755 SOURCES"
build "Retrieving lfs packages" "wget -nc -i wget-lfs -P SOURCES" "${LOGFILE}"
build "Retrieving blfs packages" "wget -nc -i wget-blfs -P SOURCES" "${LOGFILE}"
build "Retrieving rpm packages" "wget -nc -i wget-rpm -P SOURCES" "${LOGFILE}"
build "Retrieving xorg packages" "wget -nc -i wget-xorg -P SOURCES" "${LOGFILE}"
build "Retrieving xlibs packages" "wget -nc -i wget-xlibs -P SOURCES" "${LOGFILE}"
build "Retrieving multimedia packages" "wget -nc -i wget-multimedia -P SOURCES" "${LOGFILE}"
build "Retrieving kde packages" "wget -nc -i wget-kde -P SOURCES" "${LOGFILE}"
pushd SOURCES > /dev/null 2>&1;
build "Checking lfs packages" "md5sum -c ../md5sums-lfs" "${LOGFILE}"
build "Checking blfs packages" "md5sum -c ../md5sums-blfs" "${LOGFILE}"
build "Checking rpm packages" "md5sum -c ../md5sums-rpm" "${LOGFILE}"
build "Checking xorg packages" "md5sum -c ../md5sums-xorg" "${LOGFILE}"
build "Checking xlib packages" "md5sum -c ../md5sums-xlibs" "${LOGFILE}"
build "Checking multimedia packages" "md5sum -c ../md5sums-multimedia" "${LOGFILE}"
build "Checking kde packages" "md5sum -c ../md5sums-kde" "${LOGFILE}"
popd > /dev/null 2>&1;
#
# Copy build system to $LFS
#
LIST="BOOK BUILD BUILDROOT LOGS RPMS SOURCES SPECS " # directories
LIST+="README " # docs
LIST+="config config-4.2-32 config-4.2.2-64 locale-gen.conf " # configuration files
LIST+="macros " # rpm macros
LIST+="locale-gen.sh version-check " # lfs scripts
LIST+="config.inc function.inc " # build system includes
LIST+="mk-setup-lfs mk-lfs mk-tools mk-lfs-x mk-lfs-kde goto_chroot outof_chroot template.spec" # build system scripts
msg "Install build system: "
build " Installing directories" "install -vdm 755 ${LFS}/${PARENT}/{BOOK,BUILD,BUILDROOT,LOGS,RPMS,SOURCES,SPECS}" "${LOGFILE}"
build " Copying files" "cp -var ${LIST} ${LFS}/${PARENT}" "${LOGFILE}"
build " Setting ownership to lfs user" "chown -R lfs:lfs ${LFS}/" "${LOGFILE}"
exit 0