1 Star 0 Fork 2

谢辉/openeuler_docker

forked from hr_oe/openeuler_docker 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
build_rootfs.sh 1.93 KB
一键复制 编辑 原始数据 按行查看 历史
sugarfillet 提交于 2020-01-16 22:38 +08:00 . tail version
#!/bin/bash
arch=`uname -m`
if [[ $arch != 'aarch64' ]];then
echo "Error: rootfs only build on aarch64"
exit 1
fi
do_cut=0
repo_path='/etc/yum.repos.d/localmount.repo'
install_dir='/oeoe'
mount_dir='/tmp/for_mount'
tar_name="openeuler-1.0-2020-01_${do_cut}.tar"
recover_env(){
umount $mount_dir
rm -rf $mount_dir
#rm -rf $install_dir
rm -rf $repo_path
mv /opt/*.repo /etc/yum.repos.d/
}
trap "recover_env" 2
#check yum env
rpm -qa |grep yum &>/dev/null
if [[ $? != 0 ]];then
echo "Error: no yum env"
exit 2
fi
local_arch=`uname -m`
if [[ $local_arch == 'x86_64' ]];then
echo "Hint: x86_64 build is not supported now"
exit
fi
# wget iso
url='http://openeuler-os-image.obs.cn-north-4.myhuaweicloud.com/openEuler-1.0-1205-aarch64-dvd.iso'
wget -N $url
# mount iso
mkdir -p $mount_dir
mount ${url##*/} $mount_dir
# create repo
mv /etc/yum.repos.d/*.repo /opt
cat > $repo_path << EOF
[local]
name=local
baseurl=file://$mount_dir
enabled=1
gpgcheck=0
EOF
# dnf installroot
mkdir $install_dir || rm -rf $install_dir/*
yum install --installroot=$install_dir --setopt=install_weak_deps=False -y dnf vi
# tar create rootfs.tar
pushd $install_dir
if [[ $do_cut == 1 ]];then
chroot . << eof
/usr/bin/rpm -ql glibc-devel perl-Encode-devel perl-devel kernel-devel libxcrypt-devel \
systemtap-sdt-devel gcc autoconf m4 autogen automake \
cpp color-filesystem emacs-filesystem which crontabs \
fontpackages-filesystem abattis-cantarell-fonts \
fontconfig hicolor-icon-theme adwaita-icon-theme | xargs -I {} rm -rf {}
eof
fi
chroot . << eof
rm -rf /usr/share/{man,doc,locale,icons}/*
cat > /root/.bashrc << EOF
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
EOF
eof
tar --exclude=${tar_name} -cf ${tar_name} .
xz ${tar_name}
popd
echo "Hint: your rootfs lives $install_dir/${tar_name}.xz "
echo "Hint: please expose it to the web server, then you can do docker build"
recover_env
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/xiehui0524/openeuler_docker.git
git@gitee.com:xiehui0524/openeuler_docker.git
xiehui0524
openeuler_docker
openeuler_docker
master

搜索帮助