Skip to content

Commit 39e4876

Browse files
author
Yinan Qin
committed
Initial commit
0 parents  commit 39e4876

9 files changed

+280
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
iso
2+
cd
3+
rootfs

1.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
grub.cfg
2+
set default="0" set timeout=10 menuentry "QuarkOS GUI" { linux /casper/vmlinuz boot=casper quiet splash initrd /casper/initrd.img } menuentry "QuarkOS in safe mode" { linux /casper/vmlinuz boot=casper xforcevesa quiet splash initrd /casper/initrd.img } menuentry "QuarkOS CLI" { linux /casper/vmlinuz boot=casper textonly quiet splash initrd /casper/initrd.img } menuentry "QuarkOS GUI persistent mode" { linux /casper/vmlinuz boot=casper persistent quiet splash initrd /casper/initrd.img } menuentry "QuarkOS GUI from RAM" { linux /casper/vmlinuz boot=casper toram quiet splash initrd /casper/initrd.img } menuentry "Check Disk for Defects" { linux /casper/vmlinuz boot=casper integrity-check quiet splash initrd /casper/initrd.img } menuentry "Memory Test" { linux16 /boot/memtest86+.bin } menuentry "Boot from the first hard disk" { set root=(hd0) chainloader +1 }

end.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#! /bin/bash
2+
PWD=`pwd`
3+
CD="cd"
4+
export WORK=`pwd`
5+
export CD="$PWD/$CD"
6+
export FORMAT=squashfs
7+
export FS_DIR=casper
8+
9+
sudo umount ${WORK}/rootfs/proc
10+
11+
sudo umount ${WORK}/rootfs/sys
12+
13+
sudo umount ${WORK}/rootfs/dev

grub.cfg

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
set default="0"
2+
set timeout=10
3+
4+
menuentry "QuarkOS GUI" {
5+
linux /casper/vmlinuz boot=casper quiet splash
6+
initrd /casper/initrd.img
7+
}
8+
9+
10+
menuentry "QuarkOS in safe mode" {
11+
linux /casper/vmlinuz boot=casper xforcevesa quiet splash
12+
initrd /casper/initrd.img
13+
}
14+
15+
16+
menuentry "QuarkOS CLI" {
17+
linux /casper/vmlinuz boot=casper textonly quiet splash
18+
initrd /casper/initrd.img
19+
}
20+
21+
22+
menuentry "QuarkOS GUI persistent mode" {
23+
linux /casper/vmlinuz boot=casper persistent quiet splash
24+
initrd /casper/initrd.img
25+
}
26+
27+
28+
menuentry "QuarkOS GUI from RAM" {
29+
linux /casper/vmlinuz boot=casper toram quiet splash
30+
initrd /casper/initrd.img
31+
}
32+
33+
menuentry "Check Disk for Defects" {
34+
linux /casper/vmlinuz boot=casper integrity-check quiet splash
35+
initrd /casper/initrd.img
36+
}
37+
38+
39+
menuentry "Memory Test" {
40+
linux16 /boot/memtest86+.bin
41+
}
42+
43+
44+
menuentry "Boot from the first hard disk" {
45+
set root=(hd0)
46+
chainloader +1
47+
}

main.sh

+189
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
#!/bin/bash
2+
PWD=`pwd`
3+
CD="cd"
4+
export WORK=`pwd`
5+
export CD="$PWD/$CD"
6+
export FORMAT=squashfs
7+
export FS_DIR=casper
8+
9+
echo "Welcome to QuarkOS build script!"
10+
echo "This system is based on Debian and PiscesDE. So please use Debain Host to run this script!"
11+
echo "WARNING! Please use bash to execute this script! e.g. sudo bash main.sh"
12+
13+
echo "Now we are going to create working environment, continue?"
14+
15+
read -r -p "Continue? [Y/n] " input
16+
17+
case $input in
18+
[yY][eE][sS]|[yY])
19+
echo "------"
20+
;;
21+
*)
22+
echo "Quitting."
23+
exit 1
24+
;;
25+
esac
26+
27+
# Making dirs
28+
sudo mkdir -pv ${CD}/{${FS_DIR},boot/grub} ${WORK}/rootfs
29+
30+
# Install dependencies
31+
32+
echo "The next step will install necessary dependencies for building."
33+
read -r -p "Continue? [Y/n] " input
34+
case $input in
35+
[yY][eE][sS]|[yY])
36+
echo "------"
37+
;;
38+
*)
39+
echo "Quitting."
40+
exit 1
41+
;;
42+
esac
43+
44+
echo 'Installing dependencies:'
45+
apt install xorriso squashfs-tools -y
46+
echo 'Dependencies installed.'
47+
echo '------'
48+
49+
# Creating base system
50+
echo "We are going to create base system. Press enter to continue or Ctrl+C to exit."
51+
read
52+
53+
debootstrap --arch=amd64 bullseye ${WORK}/rootfs http://repo.huaweicloud.com/debian
54+
55+
# Change sources.
56+
57+
rm -fv ${WORK}/rootfs/etc/apt/sources.list
58+
59+
echo "deb http://repo.huaweicloud.com/debian/ bullseye main non-free contrib" >> ${WORK}/rootfs/etc/apt/sources.list
60+
echo "deb http://repo.huaweicloud.com/debian/ bullseye-updates main non-free contrib" >> ${WORK}/rootfs/etc/apt/sources.list
61+
echo "deb http://repo.huaweicloud.com/debian/ bullseye-backports main non-free contrib" >> ${WORK}/rootfs/etc/apt/sources.list
62+
echo "deb-src http://repo.huaweicloud.com/debian/ bullseye main non-free contrib" >> ${WORK}/rootfs/etc/apt/sources.list
63+
echo "deb-src http://repo.huaweicloud.com/debian/ bullseye-updates main non-free contrib" >> ${WORK}/rootfs/etc/apt/sources.list
64+
echo "deb-src http://repo.huaweicloud.com/debian/ bullseye-backports main non-free contrib" >> ${WORK}/rootfs/etc/apt/sources.list
65+
echo "deb http://repo.huaweicloud.com/debian-security/ bullseye-security main non-free contrib" >> ${WORK}/rootfs/etc/apt/sources.list
66+
echo "deb-src http://repo.huaweicloud.com/debian-security/ bullseye-security main non-free contrib" >> ${WORK}/rootfs/etc/apt/sources.list
67+
68+
# Preparing new os
69+
echo "--------------------"
70+
echo "Now we are going to prepare for chroot."
71+
echo "In this step, some special devices will be mounted. So do not be panic. :)"
72+
echo "Press enter to continue."
73+
read
74+
75+
for i in /etc/resolv.conf /etc/hosts /etc/hostname; do sudo cp -pv $i ${WORK}/rootfs/etc/; done
76+
mount --bind /dev ${WORK}/rootfs/dev
77+
mount -t proc proc ${WORK}/rootfs/proc
78+
mount -t sysfs sysfs ${WORK}/rootfs/sys
79+
80+
# Running apt update in new os
81+
echo 'Now running apt update, press enter to continue.'
82+
read
83+
84+
chroot ${WORK}/rootfs /bin/bash -c "apt update"
85+
86+
# Install some essential packages.
87+
echo "Now install some packages. Wait for 5 seconds."
88+
sleep 5
89+
90+
chroot ${WORK}/rootfs /bin/bash -c "apt install linux-image-5.18.0-0.bpo.1-amd64 linux-headers-5.18.0-0.bpo.1-amd64 xorg sddm kwin-x11"
91+
92+
# Building desktop environment.
93+
echo "Now we will build the desktop!"
94+
echo "But it is not working, skipped. haha. Press enter to continue."
95+
read
96+
97+
# Install Packages Essential for live CD
98+
echo "Install Packages Essential for live CD. Press enter to continue."
99+
read
100+
101+
chroot ${WORK}/rootfs /bin/bash -c "apt install casper"
102+
103+
# Update initramfs in the new os
104+
echo "Update initramfs in the new OS. Press enter to continue."
105+
read
106+
107+
cp -rv ./update-initramfs.sh ${WORK}/rootfs/tmp/update-initramfs.sh
108+
109+
chroot ${WORK}/rootfs /tmp/update-initramfs.sh
110+
111+
rm -rv ${WORK}/rootfs/tmp/update-initramfs.sh
112+
113+
# Clean apt cache
114+
echo "Clean apt cache. Wait 5 seconds."
115+
sleep 5
116+
117+
chroot ${WORK}/rootfs /bin/bash -c "apt-get clean"
118+
119+
# Clean some dirs and files
120+
echo "Clean some dirs and files. Wait 5 seconds."
121+
sleep 5
122+
123+
chroot ${WORK}/rootfs /bin/bash -c "rm -fv /etc/resolv.conf"
124+
chroot ${WORK}/rootfs /bin/bash -c "rm -fv /etc/hostname"
125+
126+
# Clean all the extra log files
127+
echo "Clean all the extra log files. Wait 5 seconds."
128+
sleep 5
129+
130+
chroot ${WORK}/rootfs /bin/bash -c "find /var/log -regex '.*?[0-9].*?' -exec rm -v {} \;"
131+
chroot ${WORK}/rootfs /bin/bash -c "find /var/log -type f | while read file;do cat /dev/null | tee $file ;done"
132+
133+
# Copy the kernel, the updated initrd and memtest prepared in the chroot
134+
echo "--------------------"
135+
echo "Now we are going to make livecd."
136+
echo "Following steps are going to prepare the cd tree. Press enter to continue."
137+
read
138+
139+
export kversion=`cd ${WORK}/rootfs/boot && ls -1 vmlinuz-* | tail -1 | sed 's@vmlinuz-@@'`
140+
sudo cp -vp ${WORK}/rootfs/boot/vmlinuz-${kversion} ${CD}/${FS_DIR}/vmlinuz
141+
sudo cp -vp ${WORK}/rootfs/boot/initrd.img-${kversion} ${CD}/${FS_DIR}/initrd.img
142+
sudo cp -vp ${WORK}/rootfs/boot/memtest86+.bin ${CD}/boot
143+
144+
# Unmount bind mounted dirs
145+
echo "Unmount bind mounted dirs. Wait 2 seconds."
146+
sleep 2
147+
148+
sudo umount ${WORK}/rootfs/proc
149+
150+
sudo umount ${WORK}/rootfs/sys
151+
152+
sudo umount ${WORK}/rootfs/dev
153+
154+
# Convert the directory tree into a squashfs
155+
echo "Convert the directory tree into a squashfs. This will take some time to complete. Press enter to continue."
156+
read
157+
158+
mksquashfs ${WORK}/rootfs ${CD}/${FS_DIR}/filesystem.${FORMAT} -noappend
159+
160+
echo "Make filesystem.size"
161+
sleep 1
162+
echo -n $(du -s --block-size=1 ${WORK}/rootfs | tail -1 | awk '{print $1}') | tee ${CD}/${FS_DIR}/filesystem.size
163+
164+
echo "Calculate MD5"
165+
sleep 1
166+
167+
find ${CD} -type f -print0 | xargs -0 md5sum | sed "s@${CD}@.@" | grep -v md5sum.txt | tee -a ${CD}/md5sum.txt
168+
169+
# Make Grub the bootloader of the CD
170+
echo "-------------------------"
171+
echo "Make Grub the bootloader of the CD. This will make this livecd bootable. Press enter to continue."
172+
read
173+
174+
cp -cv grub.cfg ${CD}/boot/grub/grub.cfg
175+
sleep 2
176+
177+
# Build the CD/DVD
178+
echo "Now Build the CD/DVD. Press enter to continue."
179+
read
180+
181+
mkdir -pv ${WORK}/iso
182+
grub-mkrescue -o ${WORK}/iso/live-cd.iso ${CD}
183+
184+
185+
echo "------------------------------"
186+
echo "Finished! The iso file is: "
187+
echo ${WORK}/iso/live-cd.iso
188+
189+
exit

packages-bookworm.txt

+1
Large diffs are not rendered by default.

packages-org.txt

+1
Large diffs are not rendered by default.

prepare.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#! /bin/bash
2+
PWD=`pwd`
3+
CD="cd"
4+
export WORK=`pwd`
5+
export CD="$PWD/$CD"
6+
export FORMAT=squashfs
7+
export FS_DIR=casper
8+
9+
for i in /etc/resolv.conf /etc/hosts /etc/hostname; do sudo cp -pv $i ${WORK}/rootfs/etc/; done
10+
11+
12+
sudo mount --bind /dev ${WORK}/rootfs/dev
13+
14+
sudo mount -t proc proc ${WORK}/rootfs/proc
15+
16+
sudo mount -t sysfs sysfs ${WORK}/rootfs/sys
17+
18+
sudo chroot ${WORK}/rootfs /bin/bash

update-initramfs.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
export kversion=`cd /boot && ls -1 vmlinuz-* | tail -1 | sed 's@vmlinuz-@@'`
4+
depmod -a $kversion
5+
update-initramfs -u -k $kversion
6+
exit

0 commit comments

Comments
 (0)