华为openeuler创新实践课程教程

第一部分:安装openeuler系统并进行硬件配置(使用vmware的尽量按照这个来)

华为课程git链接
第一步

第二步

第三步:选取openeuler20.09版本操作系统镜像

第四步

第五步:给自己的虚拟机起个名字,再找个好位置放起来

第六步

第七步

点击关闭

点击完成

第八步:打开刚刚创建的虚拟机

等待

选择英文

点击这个

点击Done

设置root用户

不要lock root account

设置完成后直接开始安装

安装完成后reboot,然后关机

第九步:添加硬盘以及网卡

硬件配置到此结束

第二部分:运行脚本

由于官方的脚本运行起来过于困难,因此我又重新整理了一份

首先进行环境的配置,这里使用ssh命令,主机连接虚拟机:ssh root@192.168.xxx.xxx,这里的ip地址换成虚拟机ip地址

连接成功后直接将这部分代码复制粘贴

yum group install -y "Development Tools"
yum install -y bc
yum install -y openssl-devel

yum install -y texinfo # for makeinfo

yum install -y vim
yum install -y nano

mkdir ~/openEuler
cd ~/openEuler
git clone https://gitee.com/openeuler-practice-courses/lfs-course
cd lfs-course/
ls

ls ~/openEuler/lfs-course/lfs-7.7-systemd/scripts/sample/patch/cfns-4.9.2.patch


cat > ./version-check.sh << "EOF"
#!/bin/bash
# Simple script to list version numbers of critical development tools
export LC_ALL=C
bash --version | head -n1 | cut -d" " -f2-4
MYSH=$(readlink -f /bin/sh)
echo "/bin/sh -> $MYSH"
echo $MYSH | grep -q bash || echo "ERROR: /bin/sh does not point to bash"
unset MYSH
echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-
bison --version | head -n1
if [ -h /usr/bin/yacc ]; then
echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`";
elif [ -x /usr/bin/yacc ]; then
echo yacc is `/usr/bin/yacc -V | head -n1`
else
echo "yacc not found"
fi
bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-
echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2
diff --version | head -n1
find --version | head -n1
gawk --version | head -n1
if [ -h /usr/bin/awk ]; then
echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`";
elif [ -x /usr/bin/awk ]; then
echo awk is `/usr/bin/awk --version | head -n1`
else
echo "awk not found"
fi
gcc --version | head -n1
g++ --version | head -n1
ldd --version | head -n1 | cut -d" " -f2- # glibc version
grep --version | head -n1
gzip --version | head -n1
cat /proc/version
m4 --version | head -n1
make --version | head -n1
patch --version | head -n1
echo Perl `perl -V:version`
sed --version | head -n1
tar --version | head -n1
makeinfo --version | head -n1 # texinfo version
xz --version | head -n1
echo 'int main(){}' > dummy.c && g++ -o dummy dummy.c
if [ -x dummy ]
then echo "g++ compilation OK";
else echo "g++ compilation failed"; fi
rm -f dummy.c dummy
EOF

bash version-check.sh

cat > ./library-check.sh << "EOF"
#!/bin/bash
for lib in lib{gmp,mpfr,mpc}.la; do
echo $lib: $(if find /usr/lib* -name $lib|
grep -q $lib;then :;else echo not;fi) found
done
unset lib
EOF

bash library-check.sh

shutdown -h now

接下来我们重新打开虚拟机,还是使用在主机上使用ssh命令连接虚拟机ssh root@192.168.xxx.xxx

lsblk
fdisk -l /dev/sdb

fdisk /dev/sdb

#依次输入 n  p 回车 回车 回车 w
# Welcome to fdisk (util-linux 2.35.2).
# Changes will remain in memory only, until you decide to write them.
# Be careful before using the write command.

# Device does not contain a recognized partition table.
# Created a new DOS disklabel with disk identifier 0x9d1c2177.

# Command (m for help): n
# Partition type
#    p   primary (0 primary, 0 extended, 4 free)
#    e   extended (container for logical partitions)
# Select (default p):

# Using default response p.
# Partition number (1-4, default 1):
# First sector (2048-62914559, default 2048):
# Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-62914559, default 62914559):

# Created a new partition 1 of type 'Linux' and of size 30 GiB.

# Command (m for help): w
# The partition table has been altered.
# Calling ioctl() to re-read partition table.
# Syncing disks.

按照教程一步一步来,这里如果没有新建硬盘,是会报错的

接下来还是将下面的代码复制进命令行

lsblk
blkid

mkfs -v -t ext4 /dev/sdb1
lsblk
blkid

cp /root/.bash_profile{,.origin}
echo "export LFS=/mnt/lfs" >> /root/.bash_profile
source /root/.bash_profile

echo $LFS

mkdir -pv $LFS

ls $LFS

cp /etc/fstab{,.origin}
echo "/dev/sdb1 /mnt/lfs ext4 defaults 1 1" >> /etc/fstab

reboot

重启后我们重新连接虚拟机:将下面的代码复制进命令行

ls $LFS
mkdir -v $LFS/sources

chmod -v a+wt $LFS/sources

cd $LFS
wget https://zhuanyejianshe.obs.cn-north-4.myhuaweicloud.com/chuangxinshijianke/lfs-packages-7.7-systemd.tar

scp ~/openEuler/lfs-course/lfs-7.7-systemd/scripts/sample/patch/cfns-4.9.2.patch $LFS/

mkdir -pv $LFS/tools

ln -sv $LFS/tools /

groupadd lfs
useradd -s /bin/bash -g lfs -m -k /dev/null lfs

passwd lfs

这里需要设置密码,随后继续复制粘贴

chown -v lfs $LFS/tools

chown -v lfs $LFS/sources

whoami

cp /etc/sudoers{,.origin}
nano +100 /etc/sudoers

#复制root这一行,将root替换为lfs,替换后结果如下:
#  root    ALL=(ALL)       ALL
#  lfs     ALL=(ALL)       ALL
#按Ctrl+o回车保存,Ctrl+x退出

还是按照教程来。这一段是复制后将root替换为lfs,一定要注意

然后我们切换用户:
su - lfs
sudo ls

切换用户后继续复制粘贴:

whoami

cat > ~/.bash_profile << "EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
EOF

cat > ~/.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

source ~/.bash_profile

whoami

echo $LFS

cat /etc/shells

ls -l /bin/sh

echo $SHELL

ls -l /usr/bin/awk
ls -l /usr/bin/yacc
whereis bison
exit

reboot

重启后重新连接,一定要用lfs用户登录,然后继续复制粘贴

# 此处开始第一遍编译,以lfs用户登录
# ssh lfs@192.168.11.130 # instead of your own IP address

cd $LFS
tar xf ./lfs-packages-7.7-systemd.tar -C ./sources
cd $LFS/sources/
tar xjf binutils-2.25.tar.bz2
cd binutils-2.25
mkdir build && cd build

../configure --prefix=/tools --with-sysroot=$LFS --with-lib-path=/tools/lib --target=$LFS_TGT --disable-nls --disable-werror
make
uname -m 
mkdir -v /tools/lib && ln -sv lib /tools/lib64
make install
cd $LFS/sources/
rm -rf binutils-2.25

cd $LFS/sources/
tar xjf gcc-4.9.2.tar.bz2
cd gcc-4.9.2

tar -xf ../mpfr-3.1.2.tar.xz
mv -v mpfr-3.1.2 mpfr
tar -xf ../gmp-6.0.0a.tar.xz
mv -v gmp-6.0.0 gmp
tar -xf ../mpc-1.0.2.tar.gz
mv -v mpc-1.0.2 mpc

cat > ./gcc-lambda.sh << "EOF"
#!/bin/sh

for file in \
    $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
do
    cp -uv $file{,.orig}
    sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
        -e 's@/usr@/tools@g' $file.orig > $file
    echo '
#undef STANDARD_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
    touch $file.orig
done
EOF

sh gcc-lambda.sh

sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure

cd $LFS/sources/gcc-4.9.2

cp $LFS/cfns-4.9.2.patch ./
patch -p1 < cfns-4.9.2.patch

mkdir -v build
cd build/
../configure --target=$LFS_TGT --prefix=/tools --with-sysroot=$LFS --with-newlib --without-headers --with-local-prefix=/tools --with-native-system-header-dir=/tools/include --disable-nls --disable-shared --disable-multilib --disable-decimal-float --disable-threads --disable-libatomic --disable-libgomp --disable-libitm --disable-libquadmath --disable-libsanitizer --disable-libssp --disable-libvtv --disable-libcilkrts --disable-libstdc++-v3 --enable-languages=c,c++

make -j 4
make install

cd $LFS/sources/
rm -rf gcc-4.9.2


cd $LFS/sources/
tar xJf linux-3.19.tar.xz
cd linux-3.19

make mrproper
make INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* /tools/include

cd $LFS/sources/
rm -rf linux-3.19

cd $LFS/sources/
tar xJf glibc-2.21.tar.xz
cd glibc-2.21

cat > ./glibc-lambda.sh << "EOF"
#!/bin/sh

if [ ! -r /usr/include/rpc/types.h ]; then
echo "ture"
fi
EOF
sh glibc-lambda.sh

sudo ls /usr/include/rpc/ 

最后会让你输入密码,按照指示输入刚刚设置的密码即可

继续复制粘贴

sudo mv /usr/include/rpc/netdb.h{,.origin}

sudo cp -v $LFS/sources/glibc-2.21/sunrpc/rpc/*.h /usr/include/rpc/

cp sysdeps/i386/i686/multiarch/mempcpy_chk.S{,.origin}
sed -e '/ia32/s/^/1:/' -e '/SSE2/s/^1://' -i sysdeps/i386/i686/multiarch/mempcpy_chk.S

mkdir build && cd build

../configure --prefix=/tools --host=$LFS_TGT --build=$(../glibc-2.21/scripts/config.guess) --disable-profile --enable-kernel=2.6.32 --with-headers=/tools/include libc_cv_forced_unwind=yes libc_cv_ctors_header=yes libc_cv_c_cleanup=yes

make
make install

echo 'int main(){}' > dummy.c
$LFS_TGT-gcc dummy.c
readelf -l a.out | grep ': /tools'
rm -v dummy.c a.out

cd $LFS/sources/
rm -rf glibc-2.21

cd $LFS/sources/
tar xjf gcc-4.9.2.tar.bz2
cd gcc-4.9.2

mkdir build && cd build

../libstdc++-v3/configure --host=$LFS_TGT --prefix=/tools --disable-multilib --disable-shared --disable-nls --disable-libstdcxx-threads --disable-libstdcxx-pch --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/4.9.2

make -j 4
make install

cd $LFS/sources/
rm -rf gcc-4.9.2

cd $LFS/sources/
tar xjf binutils-2.25.tar.bz2
cd binutils-2.25
mkdir build && cd build

CC=$LFS_TGT-gcc AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib ../configure --prefix=/tools --disable-nls --disable-werror --with-lib-path=/tools/lib --with-sysroot

make
make install

make -C ld clean
make -C ld LIB_PATH=/usr/lib:/lib
cp -v ld/ld-new /tools/bin

cd $LFS/sources/
rm -rf binutils-2.25

cd $LFS/sources/
tar xjf gcc-4.9.2.tar.bz2
cd gcc-4.9.2

cat gcc/limitx.h gcc/glimits.h gcc/limity.h > `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h
cat > ./gcc-lambda.sh << "EOF"
#!/bin/sh

for file in \
    $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
do
    cp -uv $file{,.orig}
    sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
        -e 's@/usr@/tools@g' $file.orig > $file
    echo '
#undef STANDARD_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
    touch $file.orig
done
EOF

sh gcc-lambda.sh

tar -xf ../mpfr-3.1.2.tar.xz
mv -v mpfr-3.1.2 mpfr
tar -xf ../gmp-6.0.0a.tar.xz
mv -v gmp-6.0.0 gmp
tar -xf ../mpc-1.0.2.tar.gz
mv -v mpc-1.0.2 mpc

cd $LFS/sources/gcc-4.9.2

cp $LFS/cfns-4.9.2.patch ./
patch -p1 < cfns-4.9.2.patch

mkdir -v build
cd build/

CC=$LFS_TGT-gcc CXX=$LFS_TGT-g++ AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib ../configure --prefix=/tools --with-local-prefix=/tools --with-native-system-header-dir=/tools/include --enable-languages=c,c++ --disable-libstdcxx-pch --disable-multilib --disable-bootstrap --disable-libgomp

make
make install

ln -sv gcc /tools/bin/cc

echo 'int main(){}' > dummy.c
cc dummy.c 
readelf -l a.out | grep ': /tools'
rm -v dummy.c a.out

cd $LFS/sources/
rm -rf gcc-4.9.2

cd $LFS/sources/
tar xzf tcl8.6.3-src.tar.gz 
cd tcl8.6.3/unix

./configure --prefix=/tools

make

make install

chmod -v u+w /tools/lib/libtcl8.6.so

make install-private-headers

ln -sv tclsh8.6 /tools/bin/tclsh

which tclsh 
cd $LFS/sources/
rm -rf tcl8.6.3

cd $LFS/sources/
tar xzf expect5.45.tar.gz
cd expect5.45

cp -v configure{,.orig}
sed 's:/usr/local/bin:/bin:' configure.orig > configure

./configure --prefix=/tools --with-tcl=/tools/lib --with-tclinclude=/tools/include

make
make SCRIPTS="" install

which expect 
cd $LFS/sources/
rm -rf expect5.45

cd $LFS/sources/
tar xzf dejagnu-1.5.2.tar.gz
cd dejagnu-1.5.2

./configure --prefix=/tools

make install

which runtest 

cd $LFS/sources/
rm -rf dejagnu-1.5.2

cd $LFS/sources/
tar xzf check-0.9.14.tar.gz
cd check-0.9.14

PKG_CONFIG= ./configure --prefix=/tools

make
make install

which checkmk 

cd $LFS/sources/
rm -rf check-0.9.14

cd $LFS/sources/
tar xzf ncurses-5.9.tar.gz
cd ncurses-5.9

./configure --prefix=/tools --with-shared --without-debug --without-ada --enable-widec --enable-overwrite

make
make install

cd $LFS/sources/
rm -rf ncurses-5.9

cd $LFS/sources/
tar xzf bash-4.3.30.tar.gz
cd bash-4.3.30

./configure --prefix=/tools --without-bash-malloc

make
make install

ln -sv bash /tools/bin/sh

cd $LFS/sources/
rm -rf bash-4.3.30

cd $LFS/sources/
tar xzf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6

make
make PREFIX=/tools install

which bzip2 

cd $LFS/sources/
rm -rf bzip2-1.0.6


cd $LFS/sources/
tar xJf coreutils-8.23.tar.xz
cd coreutils-8.23

./configure --prefix=/tools --enable-install-program=hostname

make
make install
cd $LFS/sources/
rm -rf coreutils-8.23

cd $LFS/sources/
tar xJf diffutils-3.3.tar.xz
cd diffutils-3.3

./configure --prefix=/tools

make
make install

which diff

cd $LFS/sources/
rm -rf diffutils-3.3

cd $LFS/sources/
tar xzf file-5.22.tar.gz 
cd file-5.22

./configure --prefix=/tools

make
make install

which file

cd $LFS/sources/
rm -rf file-5.22

cd $LFS/sources/
tar xzf findutils-4.4.2.tar.gz 
cd findutils-4.4.2

./configure --prefix=/tools

make
make install

which find

cd $LFS/sources/
rm -rf findutils-4.4.2

cd $LFS/sources/
tar xJf gawk-4.1.1.tar.xz 
cd gawk-4.1.1

./configure --prefix=/tools

make
make install

which gawk
cd $LFS/sources/
rm -rf gawk-4.1.1

cd $LFS/sources/
tar xJf gettext-0.19.4.tar.xz 
cd gettext-0.19.4

cd gettext-tools/

EMACS="no" ./configure --prefix=/tools --disable-shared

make -C gnulib-lib
make -C intl pluralx.c
make -C src msgfmt
make -C src msgmerge
make -C src xgettext

cp -v src/{msgfmt,msgmerge,xgettext} /tools/bin

cd $LFS/sources/
rm -rf gettext-0.19.4
cd $LFS/sources/
tar xJf grep-2.21.tar.xz 
cd grep-2.21

./configure --prefix=/tools

make
make install

which grep

cd $LFS/sources/
rm -rf grep-2.21

cd $LFS/sources/
tar xJf gzip-1.6.tar.xz 
cd gzip-1.6

./configure --prefix=/tools

make
make install

which gzip

cd $LFS/sources/
rm -rf gzip-1.6

cd $LFS/sources/
tar xJf m4-1.4.17.tar.xz 
cd m4-1.4.17

./configure --prefix=/tools

make
make install

which m4

cd $LFS/sources/
rm -rf m4-1.4.17

cd $LFS/sources/
tar xjf make-4.1.tar.bz2 
cd make-4.1

./configure --prefix=/tools --without-guile

make
make install

which make

cd $LFS/sources/
rm -rf make-4.1

cd $LFS/sources/
tar xJf patch-2.7.4.tar.xz 
cd patch-2.7.4

./configure --prefix=/tools

make
make install

which patch

cd $LFS/sources/
rm -rf patch-2.7.4

cd $LFS/sources/
tar xjf perl-5.20.2.tar.bz2 
cd perl-5.20.2

sh Configure -des -Dprefix=/tools -Dlibs=-lm

make

cp -v perl cpan/podlators/pod2man /tools/bin
mkdir -pv /tools/lib/perl5/5.20.2
cp -Rv lib/* /tools/lib/perl5/5.20.2

which perl

cd $LFS/sources/
rm -rf perl-5.20.2

cd $LFS/sources/
tar xjf sed-4.2.2.tar.bz2 
cd sed-4.2.2

./configure --prefix=/tools

make
make install

which sed
cd $LFS/sources/
rm -rf sed-4.2.2
cd $LFS/sources/
tar xJf tar-1.28.tar.xz 
cd tar-1.28

./configure --prefix=/tools

make
make install

which tar

cd $LFS/sources/
rm -rf tar-1.28

cd $LFS/sources/
tar xJf texinfo-5.2.tar.xz 
cd texinfo-5.2

./configure --prefix=/tools

make
make install

which makeinfo

cd $LFS/sources/
rm -rf texinfo-5.2

cd $LFS/sources/
tar xJf util-linux-2.26.tar.xz 
cd util-linux-2.26

./configure --prefix=/tools --without-python --disable-makeinstall-chown --without-systemdsystemunitdir PKG_CONFIG=""

make -j 4
make install

cd $LFS/sources/
rm -rf util-linux-2.26

cd $LFS/sources/
tar xJf xz-5.2.0.tar.xz 
cd xz-5.2.0

./configure --prefix=/tools

make
make install

cd $LFS/sources/
rm -rf xz-5.2.0

sudo chown -Rv root:root $LFS/tools
##输入密码
exit

这里的sudo可能会让你输入密码,输入后再exit即可

接下来我们使用root重新连接:继续复制粘贴

mkdir -pv $LFS/{dev,proc,sys,run}

mknod -m 600 $LFS/dev/console c 5 1
mknod -m 666 $LFS/dev/null c 1 3
mount -v --bind /dev $LFS/dev

mount -v --bind /dev/pts $LFS/dev/pts -o gid=5,mode=620
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
mount -vt tmpfs tmpfs $LFS/run

cat > ~/mount-and-populate.sh << "EOF"
#!/bin/bash

# 6.2.2. Mounting and Populating /dev
mount -v --bind /dev $LFS/dev
# 6.2.3. Mounting Virtual Kernel File Systems 
mount -v --bind /dev/pts $LFS/dev/pts -o gid=5,mode=620
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
mount -vt tmpfs tmpfs $LFS/run
EOF

cat > dev-shm.sh << "EOF"
#!/bin/bash

if [ -h $LFS/dev/shm ]; then
        mkdir -pv $LFS/$(readlink $LFS/dev/shm)
fi
EOF

sh dev-shm.sh

cat > ~/chroot-lfs.sh << "EOF"
#!/bin/bash

# 6.4. Entering the Chroot Environment
chroot "$LFS" /tools/bin/env -i \
    HOME=/root \
    TERM="$TERM" \
    PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
    /tools/bin/bash --login +h
EOF

sh ~/chroot-lfs.sh

cat > lambda-of-creating-directories.sh << "EOF"
#!/bin/bash

mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib/firmware,mnt,opt}
mkdir -pv /{media/{floppy,cdrom},sbin,srv,var}
install -dv -m 0750 /root
install -dv -m 1777 /tmp /var/tmp
mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src}
mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man}
mkdir -v /usr/{,local/}share/{misc,terminfo,zoneinfo}
mkdir -v /usr/libexec
mkdir -pv /usr/{,local/}share/man/man{1..8}
case $(uname -m) in
x86_64) ln -sv lib /lib64
ln -sv lib /usr/lib64
ln -sv lib /usr/local/lib64 ;;
esac
mkdir -v /var/{log,mail,spool}
ln -sv /run /var/run
ln -sv /run/lock /var/lock
mkdir -pv /var/{opt,cache,lib/{color,misc,locate},local}
EOF

sh lambda-of-creating-directories.sh

ln -sv /tools/bin/{bash,cat,echo,pwd,stty} /bin
ln -sv /tools/bin/perl /usr/bin
ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib
sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la
ln -sv bash /bin/sh

ln -sv /proc/self/mounts /etc/mtab

cat > /etc/passwd << "EOF"
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/dev/null:/bin/false
daemon:x:6:6:Daemon User:/dev/null:/bin/false
messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
systemd-network:x:76:76:systemd Network Management:/:/bin/false
systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
EOF


cat > /etc/group << "EOF"
root:x:0:
bin:x:1:daemon
sys:x:2:
kmem:x:3:
tape:x:4:
tty:x:5:
daemon:x:6:
floppy:x:7:
disk:x:8:
lp:x:9:
dialout:x:10:
audio:x:11:
video:x:12:
utmp:x:13:
usb:x:14:
cdrom:x:15:
adm:x:16:
messagebus:x:18:
systemd-journal:x:23:
input:x:24:
mail:x:34:
systemd-bus-proxy:x:72:
systemd-journal-gateway:x:73:
systemd-journal-remote:x:74:
systemd-journal-upload:x:75:
systemd-network:x:76:
systemd-resolve:x:77:
systemd-timesync:x:78:
nogroup:x:99:
users:x:999:
EOF

exec /tools/bin/bash --login +h

touch /var/log/{btmp,lastlog,wtmp}
chgrp -v utmp /var/log/lastlog
chmod -v 664 /var/log/lastlog
chmod -v 600 /var/log/btmp

cd /sources
tar xJf linux-3.19.tar.xz
cd linux-3.19

make mrproper 
make INSTALL_HDR_PATH=dest headers_install
find dest/include \( -name .install -o -name ..install.cmd \) -delete
cp -rv dest/include/* /usr/include

cd /sources/
rm -rf linux-3.19

cd /sources
tar xJf man-pages-3.79.tar.xz
cd man-pages-3.79

make install

cd /sources/
rm -rf man-pages-3.79

cd /sources
tar xJf glibc-2.21.tar.xz
cd glibc-2.21

patch -Np1 -i ../glibc-2.21-fhs-1.patch

sed -e '/ia32/s/^/1:/' -e '/SSE2/s/^1://' -i sysdeps/i386/i686/multiarch/mempcpy_chk.S

mkdir build
cd build/

../configure --prefix=/usr --disable-profile --enable-kernel=2.6.32 --enable-obsolete-rpc

make

touch /etc/ld.so.conf
make install

cp -v /sources/glibc-2.21/nscd/nscd.conf /etc/nscd.conf
mkdir -pv /var/cache/nscd

install -v -Dm644 ../nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf
install -v -Dm644 ../nscd/nscd.service /lib/systemd/system/nscd.service

make localedata/install-locales

cat > /etc/nsswitch.conf << "EOF"
# Begin /etc/nsswitch.conf
passwd: files
group: files
shadow: files
hosts: files dns myhostname
networks: files
protocols: files
services: files
ethers: files
rpc: files
# End /etc/nsswitch.conf
EOF

cd ..
tar -xf ../tzdata2015a.tar.gz

cat > install-timezone-data.sh << "EOF"
#!/bin/bash

ZONEINFO=/usr/share/zoneinfo
mkdir -pv $ZONEINFO/{posix,right}
for tz in etcetera southamerica northamerica europe africa antarctica asia australasia backward pacificnew systemv; do
zic -L /dev/null -d $ZONEINFO -y "sh yearistype.sh" ${tz}
zic -L /dev/null -d $ZONEINFO/posix -y "sh yearistype.sh" ${tz}
zic -L leapseconds -d $ZONEINFO/right -y "sh yearistype.sh" ${tz}
done
cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO
zic -d $ZONEINFO -p America/New_York
unset ZONEINFO
EOF

sh install-timezone-data.sh

ln -sfv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

cat > /etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf
/usr/local/lib
/opt/lib
EOF

cat >> /etc/ld.so.conf << "EOF"
# Add an include directory
include /etc/ld.so.conf.d/*.conf
EOF

mkdir -pv /etc/ld.so.conf.d

cd /sources/
rm -rf glibc-2.21

mv -v /tools/bin/{ld,ld-old}
mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}
mv -v /tools/bin/{ld-new,ld}
ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld

gcc -dumpspecs | sed -e 's@/tools@@g' -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > `dirname $(gcc --print-libgcc-file-name)`/specs

echo 'int main(){}' > dummy.c
cc dummy.c -v -Wl,--verbose &> dummy.log
readelf -l a.out | grep ': /lib'

grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log
grep -B1 '^ /usr/include' dummy.log
grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'
grep "/lib.*/libc.so.6 " dummy.log
grep found dummy.log

rm -v dummy.c a.out dummy.log
cd /sources
tar xJf zlib-1.2.8.tar.xz
cd zlib-1.2.8

./configure --prefix=/usr
make
make install

mv -v /usr/lib/libz.so.* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libz.so) /usr/lib/libz.so

cd /sources/
rm -rf zlib-1.2.8

cd /sources
tar xzf file-5.22.tar.gz
cd file-5.22

./configure --prefix=/usr
make
make install

cd /sources/
rm -rf file-5.22

cd /sources
tar xjf binutils-2.25.tar.bz2
cd binutils-2.25
expect -c "spawn ls"
  
mkdir build
cd build

../configure --prefix=/usr --enable-shared --disable-werror
make tooldir=/usr
make tooldir=/usr install

cd /sources/
rm -rf binutils-2.25

cd /sources
tar xJf gmp-6.0.0a.tar.xz
cd gmp-6.0.0

./configure --prefix=/usr --enable-cxx --docdir=/usr/share/doc/gmp-6.0.0a
make -j 4
make html

make install
make install-html

cd /sources/
rm -rf gmp-6.0.0

cd /sources
tar xJf mpfr-3.1.2.tar.xz
cd mpfr-3.1.2

patch -Np1 -i ../mpfr-3.1.2-upstream_fixes-3.patch
./configure --prefix=/usr --enable-thread-safe --docdir=/usr/share/doc/mpfr-3.1.2
make -j 4
make html
make install
make install-html

cd /sources/
rm -rf mpfr-3.1.2

cd /sources
tar xzf mpc-1.0.2.tar.gz
cd mpc-1.0.2

./configure --prefix=/usr --docdir=/usr/share/doc/mpc-1.0.2
make -j 4
make html
make install
make install-html

cd /sources/
rm -rf mpc-1.0.2

cd /sources
tar xjf gcc-4.9.2.tar.bz2
cd gcc-4.9.2

cp /cfns-4.9.2.patch ./
patch -p1 < cfns-4.9.2.patch

mkdir build
cd build

SED=sed ../configure --prefix=/usr --enable-languages=c,c++ --disable-multilib --disable-bootstrap --with-system-zlib

make
make install

ln -sv /usr/bin/cpp /lib
ln -sv gcc /usr/bin/cc

install -v -dm755 /usr/lib/bfd-plugins
ln -sfv /usr/libexec/gcc/$(gcc -dumpmachine)/4.9.2/liblto_plugin.so /usr/lib/bfd-plugins/

echo 'int main(){}' > dummy.c
cc dummy.c -v -Wl,--verbose &> dummy.log
readelf -l a.out | grep ': /lib'

grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log
grep -B4 '^ /usr/include' dummy.log
grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'
grep "/lib.*/libc.so.6 " dummy.log
grep found dummy.log

rm -v dummy.c a.out dummy.log # no necessary

mkdir -pv /usr/share/gdb/auto-load/usr/lib
mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib

cd /sources/
rm -rf gcc-4.9.2

cd /sources
tar xzf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6

patch -Np1 -i ../bzip2-1.0.6-install_docs-1.patch

sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile
sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile

make -f Makefile-libbz2_so
make clean
make
make PREFIX=/usr install

cp -v bzip2-shared /bin/bzip2
cp -av libbz2.so* /lib
ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so
rm -v /usr/bin/{bunzip2,bzcat,bzip2}
ln -sv bzip2 /bin/bunzip2
ln -sv bzip2 /bin/bzcat

cd /sources/
rm -rf bzip2-1.0.6

cd /sources
tar xzf pkg-config-0.28.tar.gz
cd pkg-config-0.28

./configure --prefix=/usr --with-internal-glib --disable-host-tool --docdir=/usr/share/doc/pkg-config-0.28

make
make install

cd /sources/
rm -rf pkg-config-0.28

cd /sources
tar xzf ncurses-5.9.tar.gz
cd ncurses-5.9

./configure --prefix=/usr --mandir=/usr/share/man --with-shared --without-debug --enable-pc-files --enable-widec

make
make install

mv -v /usr/lib/libncursesw.so.5* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libncursesw.so) /usr/lib/libncursesw.so

cat > ncurses4app.sh << "EOF"
#!/bin/bash

for lib in ncurses form panel menu ; do
rm -vf /usr/lib/lib${lib}.so
echo "INPUT(-l${lib}w)" > /usr/lib/lib${lib}.so
ln -sfv lib${lib}w.a /usr/lib/lib${lib}.a
ln -sfv ${lib}w.pc /usr/lib/pkgconfig/${lib}.pc
done
ln -sfv libncurses++w.a /usr/lib/libncurses++.a
EOF

sh ncurses4app.sh

rm -vf /usr/lib/libcursesw.so
echo "INPUT(-lncursesw)" > /usr/lib/libcursesw.so
ln -sfv libncurses.so /usr/lib/libcurses.so
ln -sfv libncursesw.a /usr/lib/libcursesw.a
ln -sfv libncurses.a /usr/lib/libcurses.a

mkdir -v /usr/share/doc/ncurses-5.9
cp -v -R doc/* /usr/share/doc/ncurses-5.9

cd /sources/
rm -rf ncurses-5.9

cd /sources
tar xzf attr-2.4.47.src.tar.gz
cd attr-2.4.47

sed -i -e 's|/@pkg_name@|&-@pkg_version@|' include/builddefs.in
sed -i -e "/SUBDIRS/s|man2||" man/Makefile

./configure --prefix=/usr

make

make install install-dev install-lib
chmod -v 755 /usr/lib/libattr.so

mv -v /usr/lib/libattr.so.* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libattr.so) /usr/lib/libattr.so

cd /sources/
rm -rf attr-2.4.47

cd /sources
tar xzf acl-2.2.52.src.tar.gz
cd acl-2.2.52

sed -i -e 's|/@pkg_name@|&-@pkg_version@|' include/builddefs.in
sed -i "s:| sed.*::g" test/{sbits-restore,cp,misc}.test
sed -i -e "/TABS-1;/a if (x > (TABS-1)) x = (TABS-1);" libacl/__acl_to_any_text.c

./configure --prefix=/usr --libexecdir=/usr/lib

make -j 4
make install install-dev install-lib
chmod -v 755 /usr/lib/libacl.so

mv -v /usr/lib/libacl.so.* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libacl.so) /usr/lib/libacl.so

cd /sources/
rm -rf acl-2.2.52

cd /sources
tar xJf libcap-2.24.tar.xz
cd libcap-2.24

make

make RAISE_SETFCAP=no prefix=/usr install
chmod -v 755 /usr/lib/libcap.so

mv -v /usr/lib/libcap.so.* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libcap.so) /usr/lib/libcap.so

cd /sources/
rm -rf libcap-2.24

cd /sources
tar xjf sed-4.2.2.tar.bz2
cd sed-4.2.2

./configure --prefix=/usr --bindir=/bin --htmldir=/usr/share/doc/sed-4.2.2

make
make html
make install
make -C doc install-html

cd /sources/
rm -rf sed-4.2.2

cd /sources
tar xJf shadow-4.2.1.tar.xz
cd shadow-4.2.1

sed -i 's/groups$(EXEEXT) //' src/Makefile.in
find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \;

sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' -e 's@/var/spool/mail@/var/mail@' etc/login.defs

sed -i 's/1000/999/' etc/useradd

./configure --sysconfdir=/etc --with-group-name-max-length=32

make
make install
mv -v /usr/bin/passwd /bin
pwconv
grpconv

sed -i 's/yes/no/' /etc/default/useradd
passwd root

到最后会让你设置root密码,设置即可

复制粘贴

cd /sources/
rm -rf shadow-4.2.1

cd /sources
tar xzf psmisc-22.21.tar.gz
cd psmisc-22.21

./configure --prefix=/usr

make
make install
mv -v /usr/bin/fuser /bin
mv -v /usr/bin/killall /bin

cd /sources/
rm -rf psmisc-22.21

cd /sources
tar xJf procps-ng-3.3.10.tar.xz
cd procps-ng-3.3.10

./configure --prefix=/usr --exec-prefix= --libdir=/usr/lib --docdir=/usr/share/doc/procps-ng-3.3.10 --disable-static --disable-kill

make

make install
mv -v /usr/bin/pidof /bin
mv -v /usr/lib/libprocps.so.* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libprocps.so) /usr/lib/libprocps.so

cd /sources/
rm -rf procps-ng-3.3.10

cd /sources
tar xzf e2fsprogs-1.42.12.tar.gz
cd e2fsprogs-1.42.12

sed -e '/int.*old_desc_blocks/s/int/blk64_t/' -e '/if (old_desc_blocks/s/super->s_first_meta_bg/desc_blocks/' -i lib/ext2fs/closefs.c
mkdir build
cd build

LIBS=-L/tools/lib CFLAGS=-I/tools/include PKG_CONFIG_PATH=/tools/lib/pkgconfig ../configure --prefix=/usr --bindir=/bin --with-root-prefix="" --enable-elf-shlibs --disable-libblkid --disable-libuuid --disable-uuidd --disable-fsck

make

make install
make install-libs

chmod -v u+w /usr/lib/{libcom_err,libe2p,libext2fs,libss}.a

gunzip -v /usr/share/info/libext2fs.info.gz
install-info --dir-file=/usr/share/info/dir /usr/share/info/libext2fs.info

makeinfo -o doc/com_err.info ../lib/et/com_err.texinfo
install -v -m644 doc/com_err.info /usr/share/info
install-info --dir-file=/usr/share/info/dir /usr/share/info/com_err.info

cd /sources/
rm -rf e2fsprogs-1.42.12

cd /sources
tar xJf coreutils-8.23.tar.xz
cd coreutils-8.23

patch -Np1 -i ../coreutils-8.23-i18n-1.patch
touch Makefile.in

FORCE_UNSAFE_CONFIGURE=1 ./configure --prefix=/usr --enable-no-install-program=kill,uptime
make 

make install

mv -v /usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} /bin
mv -v /usr/bin/{false,ln,ls,mkdir,mknod,mv,pwd,rm} /bin
mv -v /usr/bin/{rmdir,stty,sync,true,uname} /bin
mv -v /usr/bin/chroot /usr/sbin
mv -v /usr/share/man/man1/chroot.1 /usr/share/man/man8/chroot.8
sed -i s/\"1\"/\"8\"/1 /usr/share/man/man8/chroot.8

mv -v /usr/bin/{head,sleep,nice,test,[} /bin

cd /sources/
rm -rf coreutils-8.23

cd /sources
tar xjf iana-etc-2.30.tar.bz2
cd iana-etc-2.30

make
make install

cd /sources/
rm -rf iana-etc-2.30

cd /sources
tar xJf m4-1.4.17.tar.xz
cd m4-1.4.17

./configure --prefix=/usr

make
make install

cd /sources/
rm -rf m4-1.4.17
cd /sources
tar xjf flex-2.5.39.tar.bz2
cd flex-2.5.39

sed -i -e '/test-bison/d' tests/Makefile.in
./configure --prefix=/usr --docdir=/usr/share/doc/flex-2.5.39

make
make install

ln -sv flex /usr/bin/lex

cd /sources/
rm -rf flex-2.5.39

cd /sources
tar xJf bison-3.0.4.tar.xz
cd bison-3.0.4

./configure --prefix=/usr --docdir=/usr/share/doc/bison-3.0.4

make
make install

cd /sources/
rm -rf bison-3.0.4

cd /sources
tar xJf grep-2.21.tar.xz
cd grep-2.21

sed -i -e '/tp++/a if (ep <= tp) break;' src/kwset.c

./configure --prefix=/usr --bindir=/bin

make
make install

cd /sources/
rm -rf grep-2.21

cd /sources
tar xzf readline-6.3.tar.gz
cd readline-6.3

patch -Np1 -i ../readline-6.3-upstream_fixes-3.patch

sed -i '/MV.*old/d' Makefile.in
sed -i '/{OLDSUFF}/c:' support/shlib-install
./configure --prefix=/usr --docdir=/usr/share/doc/readline-6.3

make SHLIB_LIBS=-lncurses
make SHLIB_LIBS=-lncurses install

mv -v /usr/lib/lib{readline,history}.so.* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libreadline.so) /usr/lib/libreadline.so
ln -sfv ../../lib/$(readlink /usr/lib/libhistory.so ) /usr/lib/libhistory.so

install -v -m644 doc/*.{ps,pdf,html,dvi} /usr/share/doc/readline-6.3

cd /sources/
rm -rf readline-6.3

cd /sources
tar xzf bash-4.3.30.tar.gz
cd bash-4.3.30

patch -Np1 -i ../bash-4.3.30-upstream_fixes-1.patch

./configure --prefix=/usr --bindir=/bin --docdir=/usr/share/doc/bash-4.3.30 --without-bash-malloc --with-installed-readline

make
make install

exec /bin/bash --login +h


cd /sources/
rm -rf bash-4.3.30

cd /sources
tar xjf bc-1.06.95.tar.bz2
cd bc-1.06.95

patch -Np1 -i ../bc-1.06.95-memory_leak-1.patch

./configure --prefix=/usr --with-readline --mandir=/usr/share/man --infodir=/usr/share/info

make

make install

cd /sources/
rm -rf bc-1.06.95

cd /sources
tar xJf libtool-2.4.6.tar.xz
cd libtool-2.4.6

./configure --prefix=/usr

make
make install

cd /sources/
rm -rf libtool-2.4.6
cd /sources
tar xzf gdbm-1.11.tar.gz
cd gdbm-1.11

./configure --prefix=/usr --enable-libgdbm-compat

make
make install


cd /sources/
rm -rf gdbm-1.11
cd /sources
tar xzf expat-2.1.0.tar.gz
cd expat-2.1.0
./configure --prefix=/usr
make
make install
  
install -v -dm755 /usr/share/doc/expat-2.1.0
install -v -m644 doc/*.{html,png,css} /usr/share/doc/expat-2.1.0

cd /sources/
rm -rf expat-2.1.0

cd /sources
tar xzf inetutils-1.9.2.tar.gz
cd inetutils-1.9.2

echo '#define PATH_PROCNET_DEV "/proc/net/dev"' >> ifconfig/system/linux.h

./configure --prefix=/usr --localstatedir=/var --disable-logger --disable-whois --disable-servers
make
make install

mv -v /usr/bin/{hostname,ping,ping6,traceroute} /bin
mv -v /usr/bin/ifconfig /sbin

cd /sources/
rm -rf inetutils-1.9.2
cd /sources
tar xjf perl-5.20.2.tar.bz2
cd perl-5.20.2
echo "127.0.0.1 localhost $(hostname)" > /etc/hosts
export BUILD_ZLIB=False
export BUILD_BZIP2=0

sh Configure -des -Dprefix=/usr -Dvendorprefix=/usr -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dpager="/usr/bin/less -isR" -Duseshrplib

make
make install
unset BUILD_ZLIB BUILD_BZIP2

cd /sources/
rm -rf perl-5.20.2

cd /sources
tar xzf XML-Parser-2.44.tar.gz
cd XML-Parser-2.44

perl Makefile.PL

make
make install

cd /sources/
rm -rf XML-Parser-2.44

cd /sources
tar xJf autoconf-2.69.tar.xz
cd autoconf-2.69

./configure --prefix=/usr
make
make install

cd /sources/
rm -rf autoconf-2.69

cd /sources
tar xJf automake-1.15.tar.xz
cd automake-1.15
./configure --prefix=/usr --docdir=/usr/share/doc/automake-1.15
make
sed -i "s:./configure:LEXLIB=/usr/lib/libfl.a &:" t/lex-{clean,depend}-cxx.sh

make install

cd /sources/
rm -rf automake-1.15

cd /sources
tar xJf diffutils-3.3.tar.xz
cd diffutils-3.3
sed -i 's:= @mkdir_p@:= /bin/mkdir -p:' po/Makefile.in.in
./configure --prefix=/usr
make
make install

cd /sources/
rm -rf diffutils-3.3

cd /sources
tar xJf gawk-4.1.1.tar.xz
cd gawk-4.1.1

./configure --prefix=/usr

make
make install

mkdir -v /usr/share/doc/gawk-4.1.1
cp -v doc/{awkforai.txt,*.{eps,pdf,jpg}} /usr/share/doc/gawk-4.1.1

cd /sources/
rm -rf gawk-4.1.1

cd /sources
tar xzf findutils-4.4.2.tar.gz
cd findutils-4.4.2

./configure --prefix=/usr --localstatedir=/var/lib/locate

make
make install
cd /sources/
rm -rf findutils-4.4.2

cd /sources
tar xJf gettext-0.19.4.tar.xz
cd gettext-0.19.4

./configure --prefix=/usr --docdir=/usr/share/doc/gettext-0.19.4

make
make install

cd /sources/
rm -rf gettext-0.19.4

cd /sources
tar xzf intltool-0.50.2.tar.gz
cd intltool-0.50.2

./configure --prefix=/usr
make
make install
install -v -Dm644 doc/I18N-HOWTO /usr/share/doc/intltool-0.50.2/I18NHOWTO

cd /sources/
rm -rf intltool-0.50.2

cd /sources
tar xzf gperf-3.0.4.tar.gz
cd gperf-3.0.4

./configure --prefix=/usr --docdir=/usr/share/doc/gperf-3.0.4
make
make install
cd /sources/
rm -rf gperf-3.0.4
cd /sources
tar xzf groff-1.22.3.tar.gz
cd groff-1.22.3
PAGE=letter ./configure --prefix=/usr

make
make install

cd /sources/
rm -rf groff-1.22.3
cd /sources
tar xJf xz-5.2.0.tar.xz
cd xz-5.2.0

./configure --prefix=/usr --docdir=/usr/share/doc/xz-5.2.0
make
make install
mv -v /usr/bin/{lzma,unlzma,lzcat,xz,unxz,xzcat} /bin
mv -v /usr/lib/liblzma.so.* /lib
ln -svf ../../lib/$(readlink /usr/lib/liblzma.so) /usr/lib/liblzma.so
cd /sources/
rm -rf xz-5.2.0

cd /sources
tar xJf grub-2.02~beta2.tar.xz
cd grub-2.02~beta2

./configure --prefix=/usr --sbindir=/sbin --sysconfdir=/etc --disable-grub-emu-usb --disable-efiemu --disable-werror
make
make install
cd /sources/
rm -rf grub-2.02~beta2

cd /sources
tar xzf less-458.tar.gz
cd less-458

./configure --prefix=/usr --sysconfdir=/etc
make
make install
cd /sources/
rm -rf less-458

cd /sources
tar xJf gzip-1.6.tar.xz
cd gzip-1.6

./configure --prefix=/usr --bindir=/bin
make
make install

mv -v /bin/{gzexe,uncompress,zcmp,zdiff,zegrep} /usr/bin
mv -v /bin/{zfgrep,zforce,zgrep,zless,zmore,znew} /usr/bin

cd /sources/
rm -rf gzip-1.6

cd /sources
tar xJf iproute2-3.19.0.tar.xz
cd iproute2-3.19.0

sed -i '/^TARGETS/s@arpd@@g' misc/Makefile
sed -i /ARPD/d Makefile
sed -i 's/arpd.8//' man/man8/Makefile

make
make DOCDIR=/usr/share/doc/iproute2-3.19.0 install

cd /sources/
rm -rf iproute2-3.19.0

cd /sources
tar xzf kbd-2.0.2.tar.gz
cd kbd-2.0.2

patch -Np1 -i ../kbd-2.0.2-backspace-1.patch

sed -i 's/\(RESIZECONS_PROGS=\)yes/\1no/g' configure
sed -i 's/resizecons.8 //' docs/man/man8/Makefile.in

PKG_CONFIG_PATH=/tools/lib/pkgconfig ./configure --prefix=/usr --disable-vlock

make
make install

mkdir -v /usr/share/doc/kbd-2.0.2
cp -R -v docs/doc/* /usr/share/doc/kbd-2.0.2
cd /sources/
rm -rf kbd-2.0.2
cd /sources
tar xJf kmod-19.tar.xz
cd kmod-19

./configure --prefix=/usr --bindir=/bin --sysconfdir=/etc --with-rootlibdir=/lib --with-xz --with-zlib
make
make install

cat > module-init-tools.sh << "EOF"
#!/bin/bash

for target in depmod insmod lsmod modinfo modprobe rmmod; do
ln -sv ../bin/kmod /sbin/$target
done
ln -sv kmod /bin/lsmod
EOF

sh module-init-tools.sh

cd /sources/
rm -rf kmod-19

cd /sources
tar xzf libpipeline-1.4.0.tar.gz
cd libpipeline-1.4.0

PKG_CONFIG_PATH=/tools/lib/pkgconfig ./configure --prefix=/usr

make
make install

cd /sources/
rm -rf libpipeline-1.4.0

cd /sources
tar xjf make-4.1.tar.bz2
cd make-4.1

./configure --prefix=/usr
make
make install

cd /sources/
rm -rf make-4.1

cd /sources
tar xJf patch-2.7.4.tar.xz
cd patch-2.7.4

./configure --prefix=/usr

make
make install
cd /sources/
rm -rf patch-2.7.4
cd /sources
tar xJf systemd-219.tar.xz
cd systemd-219

cat > config.cache << "EOF"
KILL=/bin/kill
HAVE_BLKID=1
BLKID_LIBS="-lblkid"
BLKID_CFLAGS="-I/tools/include/blkid"
HAVE_LIBMOUNT=1
MOUNT_LIBS="-lmount"
MOUNT_CFLAGS="-I/tools/include/libmount"
cc_cv_CFLAGS__flto=no
EOF

sed -i "s:blkid/::" $(grep -rl "blkid/blkid.h")
patch -Np1 -i ../systemd-219-compat-1.patch
sed -i "s:test/udev-test.pl ::g" Makefile.in
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --config-cache --with-rootprefix= --with-rootlibdir=/lib --enable-split-usr --disable-gudev --disable-firstboot --disable-ldconfig --disable-sysusers --without-python --docdir=/usr/share/doc/systemd-219 --with-dbuspolicydir=/etc/dbus-1/system.d --with-dbussessionservicedir=/usr/share/dbus-1/services --with-dbussystemservicedir=/usr/share/dbus-1/system-services

make LIBRARY_PATH=/tools/lib
make LD_LIBRARY_PATH=/tools/lib install
mv -v /usr/lib/libnss_{myhostname,mymachines,resolve}.so.2 /lib
rm -rfv /usr/lib/rpm
cat > sysvinit-compatibility.sh << "EOF"
#!/bin/bash

for tool in runlevel reboot shutdown poweroff halt telinit; do
ln -sfv ../bin/systemctl /sbin/${tool}
done
ln -sfv ../lib/systemd/systemd /sbin/init
EOF

sh sysvinit-compatibility.sh
sed -i "s:0775 root lock:0755 root root:g" /usr/lib/tmpfiles.d/legacy.conf
sed -i "/pam.d/d" /usr/lib/tmpfiles.d/etc.conf
systemd-machine-id-setup
cd /sources/
rm -rf systemd-219
cd /sources
tar xzf dbus-1.8.16.tar.gz
cd dbus-1.8.16

./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --docdir=/usr/share/doc/dbus-1.8.16 --with-console-auth-dir=/run/console

make
make install
mv -v /usr/lib/libdbus-1.so.* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libdbus-1.so) /usr/lib/libdbus-1.so
ln -sfv /etc/machine-id /var/lib/dbus
cd /sources/
rm -rf dbus-1.8.16
cd /sources
tar -xJf util-linux-2.26.tar.xz
cd util-linux-2.26
mkdir -pv /var/lib/hwclock
./configure ADJTIME_PATH=/var/lib/hwclock/adjtime --docdir=/usr/share/doc/util-linux-2.26 --disable-chfn-chsh --disable-login --disable-nologin --disable-su --disable-setpriv --disable-runuser --disable-pylibmount --without-python

make
make install
cd /sources/
rm -rf util-linux-2.26
cd /sources
tar xJf man-db-2.7.1.tar.xz
cd man-db-2.7.1
./configure --prefix=/usr --docdir=/usr/share/doc/man-db-2.7.1 --sysconfdir=/etc --disable-setuid --with-browser=/usr/bin/lynx --with-vgrind=/usr/bin/vgrind --with-grap=/usr/bin/grap

make
make install
sed -i "s:man root:root root:g" /usr/lib/tmpfiles.d/man-db.conf
cd /sources/
rm -rf man-db-2.7.1
cd /sources
tar xJf tar-1.28.tar.xz
cd tar-1.28
FORCE_UNSAFE_CONFIGURE=1 ./configure --prefix=/usr --bindir=/bin
make
make install
make -C doc install-html docdir=/usr/share/doc/tar-1.28
cd /sources/
rm -rf tar-1.28
cd /sources
tar xJf texinfo-5.2.tar.xz
cd texinfo-5.2
./configure --prefix=/usr
make install
make TEXMF=/usr/share/texmf install-tex
cd /sources/
rm -rf texinfo-5.2
cd /sources
tar xjf vim-7.4.tar.bz2
cd vim74/

echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h
./configure --prefix=/usr
make
make install

ln -sv ../vim/vim74/doc /usr/share/doc/vim-7.4

cat > /etc/vimrc << "EOF"
" Begin /etc/vimrc

set nocompatible
set backspace=2
syntax on
if (&term == "iterm") || (&term == "putty")
    set background=dark
endif

" End /etc/vimrc
EOF

exit
reboot

至此,最耗费时间的部分已经结束。

接下来我们继续复制粘贴

sh ~/mount-and-populate.sh

cat > ~/chroot-lfs2.sh << "EOF"
#!/bin/bash

# 6.72. Cleaning Up
chroot "$LFS" /usr/bin/env -i \
    HOME=/root \
    TERM="$TERM" \
    PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin \
    /bin/bash --login

EOF

sh ~/chroot-lfs2.sh

ip link
ifconfig

cat > /etc/systemd/network/10-static-enp0s8.network << "EOF"
[Match]
Name=enp0s8
[Network]
Address=192.168.56.122/24
Gateway=192.168.56.1
DNS=192.168.56.1
EOF


cat > /etc/resolv.conf << "EOF"
# Begin /etc/resolv.conf
nameserver 114.114.114.114

# End /etc/resolv.conf
EOF


echo "andrew" > /etc/hostname

cat > /etc/hosts << "EOF"
# Begin /etc/hosts (network card version)
127.0.0.1 localhost
::1 localhost
192.168.56.122 andrew@manjucc.com
# End /etc/hosts (network card version)
EOF

全部完成后,进度就到了官方sh文件中的第七章结束。强烈建议使用ssh远程连接命令,不容易卡,而且方便。

posted @ 2021-11-10 20:47  Bzrael  阅读(705)  评论(0编辑  收藏  举报