forked from reinterpretcat/lfs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
90 lines (77 loc) · 3.19 KB
/
Dockerfile
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
FROM ubuntu:21.10
# image info
LABEL description="Host OS Image for Building LFS System \n this image contains the work until the end of chapter 4 from LFS 10.1 book"
LABEL version="LFS-10.1"
LABEL maintainer="ayeminoosc@gmail.com"
ENV PATH=/tools/bin:/bin:/usr/bin:/sbin:/usr/sbin
ENV MAKEFLAGS="-j 1"
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ="America/New_York"
ARG LFS_SOURCES="http://www.linuxfromscratch.org"
# LFS mount point
ENV LFS=/mnt/lfs
# install required packages
RUN apt-get update && apt-get install -y \
bash \
binutils \
bison \
bzip2 \
coreutils \
diffutils \
findutils \
gawk \
gcc \
g++ \
glibc-source \
grep \
gzip \
m4 \
make \
patch \
perl \
python3 \
sed \
tar \
texinfo \
xz-utils \
genisoimage \
wget \
&& apt-get -q -y autoremove
# set bash as default shell
WORKDIR /bin
RUN rm sh && ln -s bash sh
# create sources directory as writable and sticky
RUN mkdir -pv $LFS/sources \
&& chmod -v a+wt $LFS/sources
#download sources and check md5sums
COPY "scripts/download-sources.sh" "$LFS/sources/"
RUN chmod +x $LFS/sources/download-sources.sh
RUN $LFS/sources/download-sources.sh
COPY "scripts/version-check.sh" "$LFS/sources/"
RUN chmod +x $LFS/sources/version-check.sh
RUN $LFS/sources/version-check.sh
#4.2 creating a limited direcotry layout in LFS filesystem
RUN mkdir -pv $LFS/{bin,etc,lib,sbin,usr,var}sudo
RUN case $(uname -m) in \
x86_64) mkdir -pv $LFS/lib64 ;; \
esac
# In order to separate this cross-compiler from the other programs, it will be installed in a special directory.
RUN mkdir -pv $LFS/tools
#4.3 Adding the LFS User
# create lfs user with 'lfs' password
RUN groupadd lfs \
&& useradd -s /bin/bash -g lfs -m -k /dev/null lfs \
&& echo "lfs:lfs" | chpasswd
RUN adduser lfs sudo
# Grant lfs full access to all directories under $LFS by making lfs the directory owner:
RUN chown -v lfs $LFS/{usr,lib,var,etc,bin,sbin,tools}
RUN case $(uname -m) in \
x86_64) chown -v lfs $LFS/lib64 ;; \
esac
RUN mv /bin/*.tar.* $LFS/sources/ && mv /bin/*.patch $LFS/sources/
#4.4 Setting Up the Environment
#Copy bash_profile and .bashrc to home directory of the container
COPY [ "config/.bash_profile", "config/.bashrc", "/home/lfs/" ]
USER lfs
#Finally, to have the environment fully prepared for building the temporary tools, source the just-created user profile:
RUN source ~/.bash_profile