From 7f9c9e9fffc56a9ed48021fedc22253ed86530e3 Mon Sep 17 00:00:00 2001 From: smart Date: Thu, 4 Dec 2025 18:12:44 +0800 Subject: [PATCH] first --- .gitignore | 6 ++ add_empty_folders.sh | 14 +++ build-rocky9-livecd.sh | 60 +++++++++++ kickstarts/my.ks | 228 +++++++++++++++++++++++++++++++++++++++++ up+.sh | 68 ++++++++++++ 5 files changed, 376 insertions(+) create mode 100644 .gitignore create mode 100755 add_empty_folders.sh create mode 100644 build-rocky9-livecd.sh create mode 100644 kickstarts/my.ks create mode 100644 up+.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6a53170 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/iso-build/ +/results/ +/tmp/ +/livemedia.log +/program.log +/virt-install.log \ No newline at end of file diff --git a/add_empty_folders.sh b/add_empty_folders.sh new file mode 100755 index 0000000..5059ba2 --- /dev/null +++ b/add_empty_folders.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# 保存为 add_empty_folders.sh + +echo "正在查找并处理空文件夹..." + +# 查找所有空文件夹并创建 .gitkeep +find . -type d -empty | while read dir; do + if [ ! -f "$dir/.gitkeep" ]; then + touch "$dir/.gitkeep" + echo "✅ 已创建: $dir/.gitkeep" + fi +done + +echo "处理完成!" diff --git a/build-rocky9-livecd.sh b/build-rocky9-livecd.sh new file mode 100644 index 0000000..b053dcb --- /dev/null +++ b/build-rocky9-livecd.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# 定义一些变量,方便修改和管理 +BASE_DIR="/home/smart/rocky9-livecd" +RESULTS_DIR="results" +ISO_BUILD_DIR="iso-build" # 新的ISO存放目录 +KS_FILE="kickstarts/my.ks" +ISO_NAME="Rocky-9-Custom-LiveCD-LocalRepo-x86_64.iso" +PROJECT_NAME="Rocky Linux 9 Custom LiveCD (Local Repo)" +RELEASE_VER="9" +VOL_ID="Rocky_9_LiveCD_Local" +BOOT_ISO="/home/smart/Rocky-9.7-x86_64-boot.iso" + +# 切换到工作目录 +cd "${BASE_DIR}" || { echo "错误:无法切换到目录 ${BASE_DIR}"; exit 1; } + +# 清理旧的 results 目录 +echo "清理旧的 ${RESULTS_DIR} 目录..." +rm -rf "${RESULTS_DIR}" + +# 确保 iso-build 目录存在 +echo "检查并创建 ${ISO_BUILD_DIR} 目录..." +mkdir -p "${ISO_BUILD_DIR}" || { echo "错误:无法创建目录 ${ISO_BUILD_DIR}"; exit 1; } + +echo "开始执行 livemedia-creator..." +sudo livemedia-creator \ + --ks "${KS_FILE}" \ + --resultdir "${RESULTS_DIR}" \ + --tmp tmp \ + --make-iso \ + --iso-name "${ISO_NAME}" \ + --project "${PROJECT_NAME}" \ + --releasever "${RELEASE_VER}" \ + --volid "${VOL_ID}" \ + --iso "${BOOT_ISO}" + +# 检查 livemedia-creator 是否成功执行 +if [ $? -eq 0 ]; then + echo "livemedia-creator 执行成功。" + + # 获取当前时间,格式为 年-月-日-时-分 + TIMESTAMP=$(date +"%Y-%m-%d-%H-%M") + NEW_RESULTS_DIR_NAME="${RESULTS_DIR}-${TIMESTAMP}" + + echo "将 ${RESULTS_DIR} 移动并重命名为 ${ISO_BUILD_DIR}/${NEW_RESULTS_DIR_NAME}..." + mv "${RESULTS_DIR}" "${ISO_BUILD_DIR}/${NEW_RESULTS_DIR_NAME}" + + if [ $? -eq 0 ]; then + echo "操作完成。新的结果目录位于:${ISO_BUILD_DIR}/${NEW_RESULTS_DIR_NAME}" + echo "生成的 ISO 文件通常在 ${ISO_BUILD_DIR}/${NEW_RESULTS_DIR_NAME}/images 目录下。" + else + echo "错误:移动或重命名 ${RESULTS_DIR} 失败。" + exit 1 + fi +else + echo "错误:livemedia-creator 执行失败。" + exit 1 +fi + +echo "脚本执行完毕。" diff --git a/kickstarts/my.ks b/kickstarts/my.ks new file mode 100644 index 0000000..52c4c89 --- /dev/null +++ b/kickstarts/my.ks @@ -0,0 +1,228 @@ +# rocky-live-base.ks +# + +lang en_US.UTF-8 +keyboard us +timezone US/Eastern +selinux --enforcing +firewall --enabled --service=mdns +xconfig --startxonboot +zerombr +clearpart --all +part / --size 6144 --fstype ext4 +# services --enabled=NetworkManager,ModemManager --disabled=sshd +services --enabled=NetworkManager --disabled=sshd +network --bootproto=dhcp --device=link --activate +rootpw --lock --iscrypted locked +shutdown + +# # %include fedora-repo.ks +# url --url "http://172.27.175.219/repos/rocky9/BaseOS/x86_64/os/" +# # repo --name="local-rocky9-baseos" --baseurl="http://172.27.175.219/repos/rocky9/BaseOS/x86_64/os/" +# repo --name="local-rocky9-appstream" --baseurl="http://172.27.175.219/repos/rocky9/AppStream/x86_64/os/" +# repo --name="epel" --baseurl="https://download.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm" --install + +# 主要安装源 - 你的本地 BaseOS 仓库 +url --url "https://mirrors.aliyun.com/rockylinux/9.7/BaseOS/x86_64/os/" +# url --url "http://172.27.175.219/repos/rocky9/Custom/x86_64/os/Packages/" +# 你的本地 AppStream 仓库 + +repo --name="appstream" --baseurl="https://mirrors.aliyun.com/rockylinux/9.7/AppStream/x86_64/os/" +repo --name="extras" --baseurl="https://mirrors.aliyun.com/rockylinux/9.7/extras/x86_64/os/" +repo --name="epel" --baseurl="https://mirrors.aliyun.com/epel/9/Everything/x86_64/" +repo --name="my-local-repo" --baseurl="http://172.27.175.219/repos/rocky9/Custom/x86_64/os/Packages/" + +# repo --name="local-rocky9-appstream" --baseurl="http://172.27.175.219/repos/rocky9/AppStream/x86_64/os/" +# repo --name="my-local-repo" --baseurl="http://172.27.175.219/repos/rocky9/Custom/x86_64/os/Packages/" +# 添加公共 EPEL 仓库 (需要互联网连接) +#repo --name="epel" --baseurl="https://download.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm" --install + +# 添加 CRB (CodeReady Builder) 仓库 +# CRB 提供了许多开发工具和库,经常是 EPEL 软件包的依赖。强烈建议启用。 +# 确保你的构建环境可以访问此公共 URL。 +#repo --name="crb" --baseurl="https://download.rockylinux.org/pub/rocky/9/CRB/x86_64/os/" + +# --- 添加 Rocky Linux 官方的 Extras 仓库 --- +# 这个仓库通常包含一些官方支持但不在核心 BaseOS 或 AppStream 中的软件包。 +# 确保你的构建环境可以访问此公共 URL。 +#repo --name="rocky-extras" --baseurl="https://download.rockylinux.org/pub/rocky/9/extras/x86_64/os/" +# --- 添加 Rocky Linux 官方的 Plus 仓库 --- +# Plus 仓库可能包含一些增强功能或特定软件包。 +# 确保你的构建环境可以访问此公共 URL。 +#repo --name="rocky-plus" --baseurl="https://download.rockylinux.org/pub/rocky/9/plus/x86_64/os/" + + + + +%packages +# 基础包 +@core +kernel +memtest86+ +kernel-modules +kernel-modules-extra + +authselect-compat +chrony +cryptsetup +device-mapper-multipath +dosfstools +dracut-network +e2fsprogs +efibootmgr +fcoe-utils +firewalld +glibc-all-langpacks +grub2-efi-x64 +grub2-efi-x64-cdboot +grub2-pc +grub2-tools +grub2-tools-efi +grub2-tools-extra +iscsi-initiator-utils +kdump-anaconda-addon +libblockdev-plugins-all +libreport-plugin-bugzilla +lvm2 +mdadm +realmd +restore +shim-x64 +syslinux-extlinux +teamd +tmux +xfsprogs + + +# live环境包 +anaconda-install-env-deps +anaconda-live +device-mapper-multipath +aajohan-comfortaa-fonts +dracut-live +glibc-all-langpacks +livesys-scripts + + +# xfce 桌面环境,以及应用 +# Thunar +# xfce4-panel +# xfce4-session +# xfce4-settings +# xfce-polkit +# xfce4-appfinder +# xfce4-power-manager +# xfce4-pulseaudio-plugin +# xfce4-screensaver +# xfce4-terminal +# xfce4-about +# xfce4-mount-plugin + + +# xfconf +# xfdesktop +# xfwm4 +# lightdm +# network-manager-applet +# openssh-askpass +# thunar-archive-plugin +# thunar-volman +# tumbler +# # pinentry-gnome3 +# mousepad +# ristretto + + +@Xfce +-gdm +lightdm + +xfce4-about +xfce4-mount-plugin +mousepad +ristretto + + + +# 工具 +wget +vim +nmap + +open-vm-tools +open-vm-tools-desktop + + +%end + + + + + +%post +# Enable livesys services +systemctl enable livesys.service +systemctl enable livesys-late.service +systemctl enable vmtoolsd + +# enable tmpfs for /tmp +systemctl enable tmp.mount + +# make it so that we don't do writing to the overlay for things which +# are just tmpdirs/caches +# note https://bugzilla.redhat.com/show_bug.cgi?id=1135475 +cat >> /etc/fstab << EOF +vartmp /var/tmp tmpfs defaults 0 0 +EOF + +# work around for poor key import UI in PackageKit +rm -f /var/lib/rpm/__db* +echo "Packages within this LiveCD" +rpm -qa --qf '%{size}\t%{name}-%{version}-%{release}.%{arch}\n' |sort -rn +# Note that running rpm recreates the rpm db files which aren't needed or wanted +rm -f /var/lib/rpm/__db* + +# go ahead and pre-make the man -k cache (#455968) +/usr/bin/mandb + +# make sure there aren't core files lying around +rm -f /core* + +# remove random seed, the newly installed instance should make it's own +rm -f /var/lib/systemd/random-seed + +# convince readahead not to collect +# FIXME: for systemd + +echo 'File created by kickstart. See systemd-update-done.service(8).' \ + | tee /etc/.updated >/var/.updated + +# Drop the rescue kernel and initramfs, we don't need them on the live media itself. +# See bug 1317709 +rm -f /boot/*-rescue* + +# Disable network service here, as doing it in the services line +# fails due to RHBZ #1369794 +systemctl disable network + +# Remove machine-id on pre generated images +rm -f /etc/machine-id +touch /etc/machine-id + +%end + +%post +# xfce configuration + +# create /etc/sysconfig/desktop (needed for installation) + +cat > /etc/sysconfig/desktop <