weishanshan1084
6 months ago
17 changed files with 1159 additions and 0 deletions
@ -0,0 +1,41 @@ |
|||
# /etc/inittab |
|||
# |
|||
# Copyright (C) 2001 Erik Andersen <andersen@codepoet.org> |
|||
# |
|||
# Note: BusyBox init doesn't support runlevels. The runlevels field is |
|||
# completely ignored by BusyBox init. If you want runlevels, use |
|||
# sysvinit. |
|||
# |
|||
# Format for each entry: <id>:<runlevels>:<action>:<process> |
|||
# |
|||
# id == tty to run on, or empty for /dev/console |
|||
# runlevels == ignored |
|||
# action == one of sysinit, respawn, askfirst, wait, and once |
|||
# process == program to run |
|||
|
|||
# Startup the system |
|||
::sysinit:/bin/mount -o remount,rw / |
|||
::sysinit:/bin/mkdir -p /dev/pts /dev/shm |
|||
::sysinit:/bin/mount -a |
|||
::sysinit:/sbin/swapon -a |
|||
null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd |
|||
null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin |
|||
null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout |
|||
null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr |
|||
::sysinit:/bin/hostname -F /etc/hostname |
|||
# now run any rc scripts |
|||
::sysinit:/etc/init.d/rcS |
|||
|
|||
# Put a getty on the serial port |
|||
#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL |
|||
ttyAMA0::respawn:/sbin/getty -L ttyAMA0 115200 vt100 |
|||
ttyAMA1::respawn:/sbin/getty -L ttyAMA1 115200 vt100 |
|||
tty1::respawn:/sbin/getty 38400 tty1 |
|||
|
|||
# Stuff to do for the 3-finger salute |
|||
#::ctrlaltdel:/sbin/reboot |
|||
|
|||
# Stuff to do before rebooting |
|||
::shutdown:/etc/init.d/rcK |
|||
::shutdown:/sbin/swapoff -a |
|||
::shutdown:/bin/umount -a -r |
@ -0,0 +1,163 @@ |
|||
#!/bin/sh |
|||
# Copyright (C) 2011 O.S. Systems Software LTDA. |
|||
# Licensed on MIT |
|||
# |
|||
# Provides the API to be used by the initramfs modules |
|||
# |
|||
# Modules need to provide the following functions: |
|||
# |
|||
# <module>_enabled : check if the module ought to run (return 1 to skip) |
|||
# <module>_run : do what is need |
|||
# |
|||
# Boot parameters are available on environment in the as: |
|||
# |
|||
# 'foo=value' as 'bootparam_foo=value' |
|||
# 'foo' as 'bootparam_foo=true' |
|||
# 'foo.bar[=value] as 'foo_bar=[value|true]' |
|||
|
|||
# Register a function to be called before running a module |
|||
# The hook is called as: |
|||
# <function> pre <module> |
|||
add_module_pre_hook() { |
|||
MODULE_PRE_HOOKS="$MODULE_PRE_HOOKS $1" |
|||
} |
|||
|
|||
# Register a function to be called after running a module |
|||
# The hook is called as: |
|||
# <function> post <module> |
|||
add_module_post_hook() { |
|||
MODULE_POST_HOOKS="$MODULE_POST_HOOKS $1" |
|||
} |
|||
|
|||
# Load kernel module |
|||
load_kernel_module() { |
|||
if modprobe $1 >/dev/null 2>&1; then |
|||
info "Loaded module $1" |
|||
else |
|||
debug "Failed to load module $1" |
|||
fi |
|||
} |
|||
|
|||
# Prints information |
|||
msg() { |
|||
echo "$@" >/dev/console |
|||
} |
|||
|
|||
# Prints information if verbose bootparam is used |
|||
info() { |
|||
[ -n "$bootparam_verbose" ] && echo "$@" >/dev/console |
|||
} |
|||
|
|||
# Prints information if debug bootparam is used |
|||
debug() { |
|||
[ -n "$bootparam_debug" ] && echo "DEBUG: $@" >/dev/console |
|||
} |
|||
|
|||
# Prints a message and start a endless loop |
|||
fatal() { |
|||
echo $1 >/dev/console |
|||
echo >/dev/console |
|||
|
|||
if [ -n "$bootparam_init_fatal_sh" ]; then |
|||
sh |
|||
else |
|||
while [ "true" ]; do |
|||
sleep 3600 |
|||
done |
|||
fi |
|||
} |
|||
|
|||
# Variables shared amoung modules |
|||
ROOTFS_DIR="/rootfs" # where to do the switch root |
|||
MODULE_PRE_HOOKS="" # functions to call before running each module |
|||
MODULE_POST_HOOKS="" # functions to call after running each module |
|||
MODULES_DIR=/init.d # place to look for modules |
|||
EFI_DIR=/sys/firmware/efi # place to store device firmware information |
|||
|
|||
# make mount stop complaining about missing /etc/fstab |
|||
touch /etc/fstab |
|||
|
|||
# initialize /proc, /sys, /run/lock and /var/lock |
|||
mkdir -p /proc /sys /run/lock /var/lock |
|||
mount -t proc proc /proc |
|||
mount -t sysfs sysfs /sys |
|||
|
|||
if [ -d $EFI_DIR ];then |
|||
mount -t efivarfs none /sys/firmware/efi/efivars |
|||
fi |
|||
|
|||
# populate bootparam environment |
|||
for p in `cat /proc/cmdline`; do |
|||
if [ -n "$quoted" ]; then |
|||
value="$value $p" |
|||
if [ "`echo $p | sed -e 's/\"$//'`" != "$p" ]; then |
|||
eval "bootparam_${quoted}=${value}" |
|||
unset quoted |
|||
fi |
|||
continue |
|||
fi |
|||
|
|||
opt=`echo $p | cut -d'=' -f1` |
|||
opt=`echo $opt | sed -e 'y/.-/__/'` |
|||
if [ "`echo $p | cut -d'=' -f1`" = "$p" ]; then |
|||
eval "bootparam_${opt}=true" |
|||
else |
|||
value="`echo $p | cut -d'=' -f2-`" |
|||
if [ "`echo $value | sed -e 's/^\"//'`" != "$value" ]; then |
|||
quoted=${opt} |
|||
continue |
|||
fi |
|||
eval "bootparam_${opt}=\"${value}\"" |
|||
fi |
|||
done |
|||
|
|||
# use /dev with devtmpfs |
|||
if grep -q devtmpfs /proc/filesystems; then |
|||
mkdir -p /dev |
|||
mount -t devtmpfs devtmpfs /dev |
|||
else |
|||
if [ ! -d /dev ]; then |
|||
fatal "ERROR: /dev doesn't exist and kernel doesn't has devtmpfs enabled." |
|||
fi |
|||
fi |
|||
|
|||
mkdir $ROOTFS_DIR |
|||
|
|||
# Load and run modules |
|||
for m in $MODULES_DIR/*; do |
|||
# Skip backup files |
|||
if [ "`echo $m | sed -e 's/\~$//'`" != "$m" ]; then |
|||
continue |
|||
fi |
|||
|
|||
module=`basename $m | cut -d'-' -f 2` |
|||
debug "Loading module $module" |
|||
|
|||
# pre hooks |
|||
for h in $MODULE_PRE_HOOKS; do |
|||
debug "Calling module hook (pre): $h" |
|||
eval "$h pre $module" |
|||
debug "Finished module hook (pre): $h" |
|||
done |
|||
|
|||
# process module |
|||
. $m |
|||
|
|||
if ! eval "${module}_enabled"; then |
|||
debug "Skipping module $module" |
|||
continue |
|||
fi |
|||
|
|||
debug "Running ${module}_run" |
|||
eval "${module}_run" |
|||
|
|||
# post hooks |
|||
for h in $MODULE_POST_HOOKS; do |
|||
debug "Calling module hook (post): $h" |
|||
eval "$h post $module" |
|||
debug "Finished module hook (post): $h" |
|||
done |
|||
done |
|||
|
|||
# Catch all |
|||
fatal "ERROR: Initramfs failed to initialize the system." |
@ -0,0 +1,50 @@ |
|||
#!/bin/sh |
|||
# Copyright (C) 2011, 2012 O.S. Systems Software LTDA. |
|||
# Licensed on MIT |
|||
|
|||
udev_shutdown_hook_handler() { |
|||
status=$1 |
|||
module=$2 |
|||
if [ "$status" = "pre" ] && [ "$module" = "finish" ]; then |
|||
udevadm settle |
|||
killall `basename $_UDEV_DAEMON` 2>/dev/null |
|||
fi |
|||
} |
|||
|
|||
udev_daemon() { |
|||
OPTIONS="/sbin/udev/udevd /sbin/udevd /lib/udev/udevd /lib/systemd/systemd-udevd" |
|||
|
|||
for o in $OPTIONS; do |
|||
if [ -x "$o" ]; then |
|||
echo $o |
|||
return 0 |
|||
fi |
|||
done |
|||
|
|||
return 1 |
|||
} |
|||
|
|||
_UDEV_DAEMON=`udev_daemon` |
|||
|
|||
udev_enabled() { |
|||
if [ -z "$_UDEV_DAEMON" ]; then |
|||
msg "WARNING: Cannot find the udev daemon; daemon will not be started in initramfs." |
|||
return 1 |
|||
fi |
|||
|
|||
return 0 |
|||
} |
|||
|
|||
udev_run() { |
|||
add_module_pre_hook "udev_shutdown_hook_handler" |
|||
|
|||
mkdir -p /run |
|||
mkdir -p /var/run |
|||
|
|||
# Workaround if console=null, systemd-udevd needs valid stdin, stdout and stderr to work |
|||
sh -c "exec 4< /dev/console" || { exec 0> /dev/null; exec 1> /dev/null; exec 2> /dev/null; } |
|||
|
|||
$_UDEV_DAEMON --daemon |
|||
udevadm trigger --action=add |
|||
udevadm settle |
|||
} |
@ -0,0 +1,66 @@ |
|||
#!/bin/sh |
|||
# Copyright (C) 2011 O.S. Systems Software LTDA. |
|||
# Licensed on MIT |
|||
|
|||
rootfs_enabled() { |
|||
return 0 |
|||
} |
|||
|
|||
rootfs_run() { |
|||
if [ -z "$ROOTFS_DIR" ]; then |
|||
return |
|||
fi |
|||
C=0 |
|||
delay=${bootparam_rootdelay:-1} |
|||
timeout=${bootparam_roottimeout:-5} |
|||
while ! mountpoint -q $ROOTFS_DIR; do |
|||
if [ $(( $C * $delay )) -gt $timeout ]; then |
|||
fatal "root '$bootparam_root' doesn't exist or does not contain a /dev." |
|||
fi |
|||
|
|||
if [ -n "$bootparam_root" ]; then |
|||
debug "No e2fs compatible filesystem has been mounted, mounting $bootparam_root..." |
|||
|
|||
if [ "`echo ${bootparam_root} | cut -c1-5`" = "UUID=" ]; then |
|||
root_uuid=`echo $bootparam_root | cut -c6-` |
|||
bootparam_root="/dev/disk/by-uuid/$root_uuid" |
|||
elif [ "`echo ${bootparam_root} | cut -c1-9`" = "PARTUUID=" ]; then |
|||
root_partuuid=`echo $bootparam_root | cut -c10-` |
|||
bootparam_root="/dev/disk/by-partuuid/$root_partuuid" |
|||
elif [ "`echo ${bootparam_root} | cut -c1-10`" = "PARTLABEL=" ]; then |
|||
root_partlabel=`echo $bootparam_root | cut -c11-` |
|||
bootparam_root="/dev/disk/by-partlabel/$root_partlabel" |
|||
elif [ "`echo ${bootparam_root} | cut -c1-6`" = "LABEL=" ]; then |
|||
root_label=`echo $bootparam_root | cut -c7-` |
|||
bootparam_root="/dev/disk/by-label/$root_label" |
|||
fi |
|||
|
|||
if [ -e "$bootparam_root" ]; then |
|||
flags="" |
|||
if [ -n "$bootparam_ro" ] && ! echo "$bootparam_rootflags" | grep -w -q "ro"; then |
|||
if [ -n "$bootparam_rootflags" ]; then |
|||
bootparam_rootflags="$bootparam_rootflags," |
|||
fi |
|||
bootparam_rootflags="${bootparam_rootflags}ro" |
|||
fi |
|||
if [ -n "$bootparam_rootflags" ]; then |
|||
flags="$flags -o$bootparam_rootflags" |
|||
fi |
|||
if [ -n "$bootparam_rootfstype" ]; then |
|||
flags="$flags -t$bootparam_rootfstype" |
|||
fi |
|||
mount $flags $bootparam_root $ROOTFS_DIR |
|||
if mountpoint -q $ROOTFS_DIR; then |
|||
break |
|||
else |
|||
# It is unlikely to change, but keep trying anyway. |
|||
# Perhaps we pick a different device next time. |
|||
umount $ROOTFS_DIR |
|||
fi |
|||
fi |
|||
fi |
|||
debug "Sleeping for $delay second(s) to wait root to settle..." |
|||
sleep $delay |
|||
C=$(( $C + 1 )) |
|||
done |
|||
} |
@ -0,0 +1,28 @@ |
|||
#!/bin/sh |
|||
# Copyright (C) 2011 O.S. Systems Software LTDA. |
|||
# Licensed on MIT |
|||
|
|||
finish_enabled() { |
|||
return 0 |
|||
} |
|||
|
|||
finish_run() { |
|||
if [ -n "$ROOTFS_DIR" ]; then |
|||
if [ ! -d $ROOTFS_DIR/dev ]; then |
|||
fatal "ERROR: There's no '/dev' on rootfs." |
|||
fi |
|||
|
|||
info "Switching root to '$ROOTFS_DIR'..." |
|||
|
|||
debug "Moving /dev, /proc and /sys onto rootfs..." |
|||
|
|||
mount --move /dev $ROOTFS_DIR/dev |
|||
#mount --move /proc $ROOTFS_DIR/proc |
|||
mount --move /sys $ROOTFS_DIR/sys |
|||
|
|||
cd $ROOTFS_DIR |
|||
exec switch_root -c /dev/console $ROOTFS_DIR ${bootparam_init:-/sbin/init} |
|||
else |
|||
debug "No rootfs has been set" |
|||
fi |
|||
} |
Binary file not shown.
@ -0,0 +1,116 @@ |
|||
#!/bin/bash |
|||
|
|||
DISTROTYPE=$3 |
|||
DISTROSCALE=$5 |
|||
tarch=$1 |
|||
|
|||
do_distrorfs_second_stage() { |
|||
[ -f /etc/buildinfo -a ! -f /proc/uptime ] && return |
|||
packages_list=/usr/aptpkg/$4 |
|||
. $packages_list |
|||
|
|||
echo "1." $1 |
|||
echo "2." $2 |
|||
echo "3." $3 |
|||
echo "4." $4 |
|||
echo "5." $5 |
|||
echo "6." $6 |
|||
if [ ! -d /home/user ]; then |
|||
useradd -m -d /home/user -s /bin/bash user |
|||
gpasswd -a user sudo |
|||
echo -e 'root\nroot\n' | passwd root |
|||
echo -e 'user\nuser\n' | passwd user |
|||
usermod -aG sudo user |
|||
chown -R user:user /home/user |
|||
fi |
|||
if [ -d /etc/shadow ]; then |
|||
cd /etc |
|||
chmod u=rw,g=r,o=r shadow |
|||
fi |
|||
# set default hostname |
|||
echo localhost > /etc/hostname |
|||
|
|||
# set apt sources list to install additional packages |
|||
asl=/etc/apt/sources.list |
|||
rm -f $asl |
|||
cat <<-EOF > $asl |
|||
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free |
|||
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free |
|||
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free |
|||
deb http://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free |
|||
EOF |
|||
chmod +777 /tmp |
|||
apt update |
|||
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C \ |
|||
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" update || exit 1 |
|||
|
|||
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C \ |
|||
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade || exit 1 |
|||
echo upgraded |
|||
|
|||
export LC_ALL=C LANGUAGE=C LANG=C |
|||
|
|||
echo installing base packages: $pkglist |
|||
for pkg in $additional_base_packages_list; do |
|||
echo Installing $pkg ... |
|||
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install $pkg || exit 1 |
|||
done |
|||
|
|||
dpkg -l | grep linux-headers | cut -d ' ' -f3 | xargs dpkg --purge |
|||
dpkg -l | grep linux-kbuild | cut -d ' ' -f3 | xargs dpkg --purge |
|||
|
|||
echo installed additional packages. |
|||
if [ $6 = desktop ]; then |
|||
for pkg in task-xfce-desktop ukui-greeter; do |
|||
DEBIAN_FRONTEND=noninteractive apt -y install $pkg || true |
|||
done |
|||
usermod -a -G video,render,audio user |
|||
|
|||
ln -sf /lib/systemd/system/lightdm.service /etc/systemd/system/display-manager.service |
|||
sed -i "s/gdm3/lightdm/" /etc/X11/default-display-manager |
|||
echo '[SeatDefaults]' >> /etc/lightdm/lightdm.conf |
|||
echo 'greeter-session=ukui-greeter' >> /etc/lightdm/lightdm.conf |
|||
echo 'user-session=xfce' >> /etc/lightdm/lightdm.conf |
|||
|
|||
fi |
|||
|
|||
# clean cached packages |
|||
apt-get clean |
|||
|
|||
|
|||
if [ $1 = arm64 ]; then |
|||
sysarch=aarch64-linux-gnu |
|||
elif [ $1 = armhf ]; then |
|||
sysarch=arm-linux-gnueabihf |
|||
fi |
|||
|
|||
|
|||
[ -f /usr/bin/sudo -a ! -u /usr/bin/sudo ] && chmod +s /usr/bin/sudo |
|||
[ -d /var/cache/man ] && chown -R man:root /var/cache/man |
|||
[ -d /var/lib/sddm ] && chown -R sddm:sddm /var/lib/sddm |
|||
|
|||
# some shared libraries locate in /lib/aarch64-linux-gnu(or /lib/arm-linux-gnueabihf) and /usr/local/lib |
|||
echo export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/$sysarch:/lib/$sysarch >> /etc/profile |
|||
|
|||
tmpusr=`ls -t /home | cut -d' ' -f1 | head -1` |
|||
[ -d /home/$tmpusr -a "$tmpusr" != "user" ] && rm -rf /home/$tmpusr |
|||
|
|||
test -c /dev/pts/0 && umount /dev/pts |
|||
test -f /proc/uptime && umount /proc |
|||
|
|||
echo APT Packages List: > /etc/packages.list |
|||
echo -e "Package\t Version\t Download-Size\t APT-Sources" >> /etc/packages.list |
|||
apt list --installed | cut -d/ -f1 | xargs apt show | \ |
|||
grep -E '^Package:|^APT-Sources:|^Version:|^Download-Size:' > packagelist |
|||
lnum=`wc -l packagelist |cut -d' ' -f1` |
|||
for((i=1; i<$lnum;)); do |
|||
t=$[ $i + 3 ] |
|||
sed -n "${i},${t}p" packagelist | grep -E 'Package:|APT-Sources:|Version:|Download-Size:' | \ |
|||
tr "\n" " " | cut -d' ' -f2,4,6,7,9,10 >> /etc/packages.list |
|||
i=$[ $i + 4 ] |
|||
done |
|||
rm -f packagelist |
|||
} |
|||
|
|||
do_distrorfs_second_stage $1 $2 $3 $4 $5 $6 |
|||
# end second stage installing |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,124 @@ |
|||
#!/usr/bin/env bash |
|||
|
|||
deploy_kernel_headers_510 () { |
|||
topdir=$(pwd) |
|||
pdir=$1 |
|||
version=$2 |
|||
srctree=$pdir/lib/modules/$version/source |
|||
objtree=$pdir/lib/modules/$version/build |
|||
cd $objtree |
|||
mkdir debian |
|||
|
|||
( |
|||
cd $srctree |
|||
find . arch/arm64 -maxdepth 1 -name Makefile\* |
|||
find include scripts -type f -o -type l |
|||
find arch/arm64 -name Kbuild.platforms -o -name Platform |
|||
find $(find arch/arm64 -name include -o -name scripts -type d) -type f |
|||
) > debian/hdrsrcfiles |
|||
|
|||
{ |
|||
if grep -q "^CONFIG_STACK_VALIDATION=y" include/config/auto.conf; then |
|||
echo tools/objtool/objtool |
|||
fi |
|||
|
|||
find arch/arm64/include Module.symvers include scripts -type f |
|||
|
|||
if grep -q "^CONFIG_GCC_PLUGINS=y" include/config/auto.conf; then |
|||
find scripts/gcc-plugins -name \*.so |
|||
fi |
|||
} > debian/hdrobjfiles |
|||
|
|||
destdir=$pdir/usr/src/linux-headers-$version |
|||
mkdir -p $destdir |
|||
tar -c -f - -C $srctree -T debian/hdrsrcfiles | tar -xf - -C $destdir |
|||
tar -c -f - -T debian/hdrobjfiles | tar -xf - -C $destdir |
|||
rm -rf debian |
|||
|
|||
# copy .config manually to be where it's expected to be |
|||
cp .config $destdir/.config |
|||
# used to build dma |
|||
cp drivers/dma/dmaengine.h $1/usr/include |
|||
cp drivers/dma/virt-dma.h $1/usr/include |
|||
find $destdir -name "*.o" -type f -exec rm -rf {} \; |
|||
cd $topdir |
|||
cp -r board/phytium/common/linux-5.10/scripts $destdir |
|||
|
|||
rm -rf $srctree |
|||
rm -rf $objtree |
|||
ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build |
|||
} |
|||
|
|||
deploy_kernel_headers_419 () { |
|||
topdir=$(pwd) |
|||
pdir=$1 |
|||
version=$2 |
|||
srctree=$pdir/lib/modules/$version/source |
|||
objtree=$pdir/lib/modules/$version/build |
|||
cd $objtree |
|||
mkdir debian |
|||
|
|||
(cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles" |
|||
(cd $srctree; find arch/*/include include scripts -type f -o -type l) >> "$objtree/debian/hdrsrcfiles" |
|||
(cd $srctree; find arch/arm64 -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles" |
|||
(cd $srctree; find $(find arch/arm64 -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles" |
|||
if grep -q '^CONFIG_STACK_VALIDATION=y' .config ; then |
|||
(cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles" |
|||
fi |
|||
(cd $objtree; find arch/arm64/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" |
|||
if grep -q '^CONFIG_GCC_PLUGINS=y' .config ; then |
|||
(cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles" |
|||
fi |
|||
destdir=$pdir/usr/src/linux-headers-$version |
|||
mkdir -p "$destdir" |
|||
(cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -) |
|||
(cd $objtree; tar -c -f - -T -) < "$objtree/debian/hdrobjfiles" | (cd $destdir; tar -xf -) |
|||
(cd $objtree; cp .config $destdir/.config) # copy .config manually to be where it's expected to be |
|||
(cd $srctree; cp --parents tools/include/tools/be_byteshift.h $destdir) |
|||
(cd $srctree; cp --parents tools/include/tools/le_byteshift.h $destdir) |
|||
(cd $srctree; cp drivers/dma/dmaengine.h $1/usr/include) # used to build dma |
|||
(cd $srctree; cp drivers/dma/virt-dma.h $1/usr/include) |
|||
find $destdir -name "*.o" -type f -exec rm -rf {} \; |
|||
cd $topdir |
|||
cp -r board/phytium/common/linux-4.19/scripts $destdir |
|||
rm -rf "$objtree/debian" |
|||
|
|||
rm -rf $srctree |
|||
rm -rf $objtree |
|||
ln -sf "/usr/src/linux-headers-$version" "$pdir/lib/modules/$version/build" |
|||
} |
|||
|
|||
main() |
|||
{ |
|||
# $1 - the current rootfs directory, skeleton-custom or target |
|||
|
|||
if [ ! -d $1/lib/modules ]; then |
|||
make linux-rebuild ${O:+O=$O} |
|||
fi |
|||
|
|||
KERNELVERSION=`ls $1/lib/modules` |
|||
if grep -Eq "^BR2_ROOTFS_LINUX_HEADERS=y$" ${BR2_CONFIG} && [ -L $1/lib/modules/${KERNELVERSION}/source ]; then |
|||
if [[ ${KERNELVERSION} = 5.10* || ${KERNELVERSION} = 5.15* ]];then |
|||
deploy_kernel_headers_510 $1 ${KERNELVERSION} |
|||
elif [[ ${KERNELVERSION} = 4.19* ]];then |
|||
deploy_kernel_headers_419 $1 ${KERNELVERSION} |
|||
else |
|||
echo "error: linux kernel version is not 4.19, 5.10, or 5.15." |
|||
fi |
|||
fi |
|||
|
|||
if grep -Eq "^BR2_ROOTFS_CHOWN=y$" ${BR2_CONFIG}; then |
|||
sudo chroot ${1} systemctl enable systemd-rootfs-chown.service |
|||
fi |
|||
|
|||
if grep -Eq "^BR2_PACKAGE_PHYTIUM_OPTEE=y$" ${BR2_CONFIG}; then |
|||
# add tee-supplicant systemd service |
|||
cp -dpf package/phytium-optee/phytium-tee-supplicant.service $1/lib/systemd/system/phytium-tee-supplicant.service |
|||
# default set start tee-supplicant |
|||
ln -sf /lib/systemd/system/phytium-tee-supplicant.service $1/etc/systemd/system/sysinit.target.wants/phytium-tee-supplicant.service |
|||
fi |
|||
|
|||
exit $? |
|||
} |
|||
|
|||
main $@ |
@ -0,0 +1,207 @@ |
|||
#!/usr/bin/env bash |
|||
|
|||
distro=bullseye |
|||
|
|||
trap recover_from_ctrl_c INT |
|||
|
|||
recover_from_ctrl_c() |
|||
{ |
|||
do_recover_from_error "Interrupt caught ... exiting" |
|||
exit 1 |
|||
} |
|||
|
|||
do_recover_from_error() |
|||
{ |
|||
sudo chroot $RFSDIR /bin/umount /proc > /dev/null 2>&1; |
|||
sudo chroot $RFSDIR /bin/umount /sys > /dev/null 2>&1; |
|||
USER=$(id -u); GROUPS=${GROUPS}; \ |
|||
sudo chroot $RFSDIR /bin/chown -R ${USER}:${GROUPS} / > /dev/null 2>&1; |
|||
echo -e "\n************" |
|||
echo $1 |
|||
echo -e " Please running the below commands before re-compiling:" |
|||
echo -e " rm -rf $RFSDIR" |
|||
echo -e " make skeleton-custom-dirclean" |
|||
echo -e " Or\n make skeleton-custom-dirclean O=<output dir>" |
|||
} |
|||
|
|||
do_distrorfs_first_stage() { |
|||
# $1: platform architecture, arm64 |
|||
# $2: rootfs directory, output/build/skeleton-custom |
|||
# $3: board/phytium/common/ubuntu-additional_packages_list |
|||
# $4: bullseye |
|||
# $5: debian |
|||
# $6: plat name |
|||
# $7: desktop or base |
|||
|
|||
DISTROTYPE=$5 |
|||
[ -z "$RFSDIR" ] && RFSDIR=$2 |
|||
[ -z $RFSDIR ] && echo No RootFS exist! && return |
|||
[ -f $RFSDIR/etc/.firststagedone ] && echo $RFSDIR firststage exist! && return |
|||
[ -f /etc/.firststagedone -a ! -f /proc/uptime ] && return |
|||
|
|||
if [ $1 = arm64 ]; then |
|||
tgtarch=aarch64 |
|||
elif [ $1 = armhf ]; then |
|||
tgtarch=arm |
|||
fi |
|||
|
|||
qemu-${tgtarch}-static -version > /dev/null 2>&1 |
|||
if [ "x$?" != "x0" ]; then |
|||
echo qemu-${tgtarch}-static not found |
|||
exit 1 |
|||
fi |
|||
|
|||
debootstrap --version > /dev/null 2>&1 |
|||
if [ "x$?" != "x0" ]; then |
|||
echo debootstrap not found |
|||
exit 1 |
|||
fi |
|||
|
|||
sudo chown 0:0 $RFSDIR |
|||
sudo mkdir -p $2/usr/local/bin |
|||
sudo cp -f board/phytium/common/debian-package-installer $RFSDIR/usr/local/bin/ |
|||
packages_list=board/phytium/common/$3 |
|||
[ ! -f $packages_list ] && echo $packages_list not found! && exit 1 |
|||
|
|||
echo additional packages list: $packages_list |
|||
if [ ! -d $RFSDIR/usr/aptpkg ]; then |
|||
sudo mkdir -p $RFSDIR/usr/aptpkg |
|||
sudo cp -f $packages_list $RFSDIR/usr/aptpkg |
|||
fi |
|||
|
|||
sudo mkdir -p $RFSDIR/etc |
|||
sudo cp -f /etc/resolv.conf $RFSDIR/etc/resolv.conf |
|||
|
|||
if [ ! -d $RFSDIR/debootstrap ]; then |
|||
echo "testdeboot" |
|||
export LANG=en_US.UTF-8 |
|||
sudo debootstrap --keyring=board/phytium/common/debian-archive-bullseye-stable.gpg --arch=$1 --foreign bullseye $RFSDIR https://mirrors.tuna.tsinghua.edu.cn/debian/ |
|||
|
|||
[ $1 != amd64 -a ! -f $RFSDIR/usr/bin/qemu-${tgtarch}-static ] && sudo cp $(which qemu-${tgtarch}-static) $RFSDIR/usr/bin |
|||
echo "installing for second-stage ..." |
|||
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C \ |
|||
sudo chroot $RFSDIR /debootstrap/debootstrap --variant=minbase --second-stage |
|||
if [ "x$?" != "x0" ]; then |
|||
do_recover_from_error "debootstrap failed in second-stage" |
|||
exit 1 |
|||
fi |
|||
|
|||
echo "configure ... " |
|||
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C \ |
|||
sudo chroot $RFSDIR dpkg --configure -a |
|||
fi |
|||
|
|||
sudo chroot $RFSDIR debian-package-installer $1 $distro $5 $3 $6 $7 |
|||
if [ "x$?" != "x0" ]; then |
|||
do_recover_from_error "debian-package-installer failed" |
|||
exit 1 |
|||
fi |
|||
|
|||
# sudo chroot $RFSDIR systemctl enable systemd-rootfs-resize |
|||
file_s=$(sudo find $RFSDIR -perm -4000) |
|||
sudo chown -R $USER:$GROUPS $RFSDIR |
|||
for f in $file_s; do |
|||
sudo chmod u+s $f |
|||
done |
|||
sudo chmod u+s $RFSDIR/sbin/unix_chkpwd |
|||
|
|||
if [ $distro = bullseye ]; then |
|||
echo debian,11 | tee $RFSDIR/etc/.firststagedone 1>/dev/null |
|||
elif [ $distro = bionic ]; then |
|||
echo Ubuntu,18.04.5 | tee $RFSDIR/etc/.firststagedone 1>/dev/null |
|||
fi |
|||
setup_distribution_info $5 $2 $1 |
|||
|
|||
#rm $RFSDIR/etc/apt/apt.conf |
|||
sudo rm $RFSDIR/dev/* -rf |
|||
} |
|||
|
|||
setup_distribution_info () { |
|||
DISTROTYPE=$1 |
|||
RFSDIR=$2 |
|||
tarch=$3 |
|||
distroname=`head -1 $RFSDIR/etc/.firststagedone | cut -d, -f1` |
|||
distroversion=`head -1 $RFSDIR/etc/.firststagedone | cut -d, -f2` |
|||
releaseversion="$distroname (based on $DISTROTYPE-$distroversion-base) ${tarch}" |
|||
releasestamp="Build: `date +'%Y-%m-%d %H:%M:%S'`" |
|||
echo $releaseversion > $RFSDIR/etc/buildinfo |
|||
sed -i "1 a\\$releasestamp" $RFSDIR/etc/buildinfo |
|||
if grep U-Boot $RFSDIR/etc/.firststagedone 1>$RFSDIR/dev/null 2>&1; then |
|||
tail -1 $RFSDIR/etc/.firststagedone >> $RFSDIR/etc/buildinfo |
|||
fi |
|||
|
|||
if [ $DISTROTYPE = ubuntu ]; then |
|||
echo $distroname $1-$distroversion > $RFSDIR/etc/issue |
|||
echo $distroname $1-$distroversion > $RFSDIR/etc/issue.net |
|||
|
|||
tgtfile=$RFSDIR/etc/lsb-release |
|||
echo DISTRIB_ID=Phytium > $tgtfile |
|||
echo DISTRIB_RELEASE=$distroversion >> $tgtfile |
|||
echo DISTRIB_CODENAME=$distro >> $tgtfile |
|||
echo DISTRIB_DESCRIPTION=\"$distroname $1-$distroversion\" >> $tgtfile |
|||
|
|||
tgtfile=$RFSDIR/etc/update-motd.d/00-header |
|||
echo '#!/bin/sh' > $tgtfile |
|||
echo '[ -r /etc/lsb-release ] && . /etc/lsb-release' >> $tgtfile |
|||
echo 'printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"' >> $tgtfile |
|||
|
|||
tgtfile=$RFSDIR/etc/update-motd.d/10-help-text |
|||
echo '#!/bin/sh' > $tgtfile |
|||
echo 'printf "\n"' >> $tgtfile |
|||
echo 'printf " * Support: https://www.phytium.com.cn\n"' >> $tgtfile |
|||
|
|||
tgtfile=$RFSDIR/usr/lib/os-release |
|||
echo NAME=\"$distroname\" > $tgtfile |
|||
echo VERSION=${DISTROTYPE}-$distroversion >> $tgtfile |
|||
echo ID=debian >> $tgtfile |
|||
echo VERSION_ID=$distroversion >> $tgtfile |
|||
echo PRETTY_NAME=\"Ubuntu Built with Buildroot, based on Ubuntu $distroversion LTS\" >> $tgtfile |
|||
echo VERSION_CODENAME=$distro >> $tgtfile |
|||
|
|||
rm -f $RFSDIR/etc/default/motd-news |
|||
rm -f $RFSDIR/etc/update-motd.d/50-motd-news |
|||
fi |
|||
} |
|||
|
|||
plat_name() |
|||
{ |
|||
echo "phytium" |
|||
} |
|||
|
|||
arch_type() |
|||
{ |
|||
if grep -Eq "^BR2_aarch64=y$" ${BR2_CONFIG}; then |
|||
echo "arm64" |
|||
elif grep -Eq "^BR2_arm=y$" ${BR2_CONFIG}; then |
|||
echo "armhf" |
|||
fi |
|||
} |
|||
|
|||
full_rtf() |
|||
{ |
|||
if grep -Eq "^BR2_PACKAGE_ROOTFS_DESKTOP=y$" ${BR2_CONFIG}; then |
|||
echo "desktop" |
|||
else |
|||
echo "base" |
|||
fi |
|||
} |
|||
|
|||
main() |
|||
{ |
|||
# $1 - the current rootfs directory, skeleton-custom or target |
|||
rm -rf $1/* |
|||
|
|||
# run first stage do_distrorfs_first_stage arm64 ${1} ubuntu-additional_packages_list bullseye debian |
|||
do_distrorfs_first_stage $(arch_type) ${1} ubuntu-additional_packages_list bullseye debian $(plat_name) $(full_rtf) |
|||
|
|||
# change the hostname to "platforms-Ubuntu" |
|||
echo $(plat_name)-debian > ${1}/etc/hostname |
|||
|
|||
if ! grep -q "$(plat_name)-debian" ${1}/etc/hosts; then |
|||
echo 127.0.0.1 $(plat_name)-debian | sudo tee -a ${1}/etc/hosts 1>/dev/null |
|||
fi |
|||
|
|||
exit $? |
|||
} |
|||
|
|||
main $@ |
@ -0,0 +1,217 @@ |
|||
#!/usr/bin/env bash |
|||
|
|||
trap recover_from_ctrl_c INT |
|||
|
|||
recover_from_ctrl_c() |
|||
{ |
|||
do_recover_from_error "Interrupt caught ... exiting" |
|||
exit 1 |
|||
} |
|||
|
|||
do_recover_from_error() |
|||
{ |
|||
sudo chroot $RFSDIR /bin/umount /proc > /dev/null 2>&1; |
|||
sudo chroot $RFSDIR /bin/umount /sys > /dev/null 2>&1; |
|||
USER=$(id -u); GROUPS=${GROUPS}; \ |
|||
sudo chroot $RFSDIR /bin/chown -R ${USER}:${GROUPS} / > /dev/null 2>&1; |
|||
echo -e "\n************" |
|||
echo $1 |
|||
echo -e " Please running the below commands before re-compiling:" |
|||
echo -e " rm -rf $RFSDIR" |
|||
echo -e " make skeleton-custom-dirclean" |
|||
echo -e " Or\n make skeleton-custom-dirclean O=<output dir>" |
|||
} |
|||
|
|||
do_distrorfs_first_stage() { |
|||
# $1: platform architecture, arm64 |
|||
# $2: rootfs directory, output/build/skeleton-custom |
|||
# $3: board/phytium/common/ubuntu-additional_packages_list |
|||
# $4: focal |
|||
# $5: ubuntu |
|||
# $6: plat name |
|||
# $7: desktop or base |
|||
|
|||
DISTROTYPE=$5 |
|||
[ -z "$RFSDIR" ] && RFSDIR=$2 |
|||
[ -z $RFSDIR ] && echo No RootFS exist! && return |
|||
[ -f $RFSDIR/etc/.firststagedone ] && echo $RFSDIR firststage exist! && return |
|||
[ -f /etc/.firststagedone -a ! -f /proc/uptime ] && return |
|||
|
|||
if [ $1 = arm64 ]; then |
|||
tgtarch=aarch64 |
|||
elif [ $1 = armhf ]; then |
|||
tgtarch=arm |
|||
fi |
|||
|
|||
qemu-${tgtarch}-static -version > /dev/null 2>&1 |
|||
if [ "x$?" != "x0" ]; then |
|||
echo qemu-${tgtarch}-static not found |
|||
exit 1 |
|||
fi |
|||
|
|||
debootstrap --version > /dev/null 2>&1 |
|||
if [ "x$?" != "x0" ]; then |
|||
echo debootstrap not found |
|||
exit 1 |
|||
fi |
|||
|
|||
sudo chown 0:0 $RFSDIR |
|||
sudo mkdir -p $2/usr/local/bin |
|||
sudo cp -f board/phytium/common/ubuntu-package-installer $RFSDIR/usr/local/bin/ |
|||
packages_list=board/phytium/common/$3 |
|||
[ ! -f $packages_list ] && echo $packages_list not found! && exit 1 |
|||
|
|||
echo additional packages list: $packages_list |
|||
if [ ! -d $RFSDIR/usr/aptpkg ]; then |
|||
sudo mkdir -p $RFSDIR/usr/aptpkg |
|||
sudo cp -f $packages_list $RFSDIR/usr/aptpkg |
|||
fi |
|||
|
|||
sudo mkdir -p $RFSDIR/etc |
|||
sudo cp -f /etc/resolv.conf $RFSDIR/etc/resolv.conf |
|||
|
|||
if [ ! -d $RFSDIR/debootstrap ]; then |
|||
echo "testdeboot" |
|||
export LANG=en_US.UTF-8 |
|||
sudo debootstrap --arch=$1 --foreign $4 $RFSDIR https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports |
|||
|
|||
[ $1 != amd64 -a ! -f $RFSDIR/usr/bin/qemu-${tgtarch}-static ] && sudo cp $(which qemu-${tgtarch}-static) $RFSDIR/usr/bin |
|||
echo "installing for second-stage ..." |
|||
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C \ |
|||
sudo chroot $RFSDIR /debootstrap/debootstrap --second-stage |
|||
if [ "x$?" != "x0" ]; then |
|||
do_recover_from_error "debootstrap failed in second-stage" |
|||
exit 1 |
|||
fi |
|||
|
|||
echo "configure ... " |
|||
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C \ |
|||
sudo chroot $RFSDIR dpkg --configure -a |
|||
fi |
|||
|
|||
sudo chroot $RFSDIR ubuntu-package-installer $1 $4 $5 $3 $6 $7 |
|||
if [ "x$?" != "x0" ]; then |
|||
do_recover_from_error "ubuntu-package-installer failed" |
|||
exit 1 |
|||
fi |
|||
|
|||
# sudo chroot $RFSDIR systemctl enable systemd-rootfs-resize |
|||
file_s=$(sudo find $RFSDIR -perm -4000) |
|||
sudo chown -R $USER:$GROUPS $RFSDIR |
|||
for f in $file_s; do |
|||
sudo chmod u+s $f |
|||
done |
|||
sudo chmod u+s $RFSDIR/sbin/unix_chkpwd |
|||
|
|||
if dpkg-query -l snapd | grep ii 1>/dev/null; then |
|||
chmod +rw -R $RFSDIR/var/lib/snapd/ |
|||
fi |
|||
|
|||
if [ $4 = focal ]; then |
|||
echo Ubuntu,20.04 | tee $RFSDIR/etc/.firststagedone 1>/dev/null |
|||
elif [ $4 = jammy ]; then |
|||
echo Ubuntu,22.04 | tee $RFSDIR/etc/.firststagedone 1>/dev/null |
|||
fi |
|||
setup_distribution_info $5 $2 $1 $4 |
|||
|
|||
#rm $RFSDIR/etc/apt/apt.conf |
|||
rm $RFSDIR/dev/* -rf |
|||
} |
|||
|
|||
setup_distribution_info () { |
|||
DISTROTYPE=$1 |
|||
RFSDIR=$2 |
|||
tarch=$3 |
|||
distro=$4 |
|||
distroname=`head -1 $RFSDIR/etc/.firststagedone | cut -d, -f1` |
|||
distroversion=`head -1 $RFSDIR/etc/.firststagedone | cut -d, -f2` |
|||
releaseversion="$distroname (based on $DISTROTYPE-$distroversion-base) ${tarch}" |
|||
releasestamp="Build: `date +'%Y-%m-%d %H:%M:%S'`" |
|||
echo $releaseversion > $RFSDIR/etc/buildinfo |
|||
sed -i "1 a\\$releasestamp" $RFSDIR/etc/buildinfo |
|||
if grep U-Boot $RFSDIR/etc/.firststagedone 1>$RFSDIR/dev/null 2>&1; then |
|||
tail -1 $RFSDIR/etc/.firststagedone >> $RFSDIR/etc/buildinfo |
|||
fi |
|||
|
|||
if [ $DISTROTYPE = ubuntu ]; then |
|||
echo $distroname $1-$distroversion > $RFSDIR/etc/issue |
|||
echo $distroname $1-$distroversion > $RFSDIR/etc/issue.net |
|||
|
|||
tgtfile=$RFSDIR/etc/lsb-release |
|||
echo DISTRIB_ID=Phytium > $tgtfile |
|||
echo DISTRIB_RELEASE=$distroversion >> $tgtfile |
|||
echo DISTRIB_CODENAME=$distro >> $tgtfile |
|||
echo DISTRIB_DESCRIPTION=\"$distroname $1-$distroversion\" >> $tgtfile |
|||
|
|||
tgtfile=$RFSDIR/etc/update-motd.d/00-header |
|||
echo '#!/bin/sh' > $tgtfile |
|||
echo '[ -r /etc/lsb-release ] && . /etc/lsb-release' >> $tgtfile |
|||
echo 'printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"' >> $tgtfile |
|||
|
|||
tgtfile=$RFSDIR/etc/update-motd.d/10-help-text |
|||
echo '#!/bin/sh' > $tgtfile |
|||
echo 'printf "\n"' >> $tgtfile |
|||
echo 'printf " * Support: https://www.phytium.com.cn\n"' >> $tgtfile |
|||
|
|||
tgtfile=$RFSDIR/usr/lib/os-release |
|||
echo NAME=\"$distroname\" > $tgtfile |
|||
echo VERSION=${DISTROTYPE}-$distroversion >> $tgtfile |
|||
echo ID=ubuntu >> $tgtfile |
|||
echo VERSION_ID=$distroversion >> $tgtfile |
|||
echo PRETTY_NAME=\"Ubuntu Built with Buildroot, based on Ubuntu $distroversion LTS\" >> $tgtfile |
|||
echo VERSION_CODENAME=$distro >> $tgtfile |
|||
|
|||
rm -f $RFSDIR/etc/default/motd-news |
|||
rm -f $RFSDIR/etc/update-motd.d/50-motd-news |
|||
fi |
|||
} |
|||
|
|||
plat_name() |
|||
{ |
|||
echo "phytium" |
|||
} |
|||
|
|||
arch_type() |
|||
{ |
|||
if grep -Eq "^BR2_aarch64=y$" ${BR2_CONFIG}; then |
|||
echo "arm64" |
|||
elif grep -Eq "^BR2_arm=y$" ${BR2_CONFIG}; then |
|||
echo "armhf" |
|||
fi |
|||
} |
|||
|
|||
full_rtf() |
|||
{ |
|||
if grep -Eq "^BR2_PACKAGE_ROOTFS_DESKTOP=y$" ${BR2_CONFIG}; then |
|||
echo "desktop" |
|||
else |
|||
echo "base" |
|||
fi |
|||
} |
|||
|
|||
ubuntu_distro() |
|||
{ |
|||
if grep -Eq "^BR2_ROOTFS_SKELETON_UBUNTU_FOCAL=y$" ${BR2_CONFIG}; then |
|||
echo "focal" |
|||
else |
|||
echo "jammy" |
|||
fi |
|||
} |
|||
|
|||
main() |
|||
{ |
|||
# $1 - the current rootfs directory, skeleton-custom or target |
|||
rm -rf $1/* |
|||
|
|||
# run first stage do_distrorfs_first_stage arm64 ${1} ubuntu-additional_packages_list focal ubuntu |
|||
do_distrorfs_first_stage $(arch_type) ${1} ubuntu-additional_packages_list $(ubuntu_distro) ubuntu $(plat_name) $(full_rtf) |
|||
|
|||
# change the hostname to "platforms-Ubuntu" |
|||
echo $(plat_name)-Ubuntu > ${1}/etc/hostname |
|||
|
|||
sed -i "s/float(n\[0\])/float(n[0].split()[0])/" ${1}/usr/share/pyshared/lsb_release.py |
|||
|
|||
exit $? |
|||
} |
|||
|
|||
main $@ |
@ -0,0 +1,11 @@ |
|||
# additional packages list for SDK main userland gathered from main repo |
|||
additional_full_packages_list=" " |
|||
|
|||
additional_desktop_packages_list="network-manager-gnome" |
|||
|
|||
# for Lite userland gathered from main repo |
|||
additional_base_packages_list="net-tools iputils-ping gcc g++ vim make autoconf automake libtool pkg-config bison bc flex libssl-dev openssh-server python-is-python3 \ |
|||
libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools \ |
|||
gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-pulseaudio \ |
|||
dkms initramfs-tools debhelper libgles-dev libexpat1-dev libglvnd-dev ffmpeg \ |
|||
network-manager wpasupplicant wireless-tools parted locales" |
@ -0,0 +1,136 @@ |
|||
#!/bin/bash |
|||
|
|||
DISTROTYPE=$3 |
|||
DISTROSCALE=$5 |
|||
tarch=$1 |
|||
|
|||
do_distrorfs_second_stage() { |
|||
[ -f /etc/buildinfo -a ! -f /proc/uptime ] && return |
|||
packages_list=/usr/aptpkg/$4 |
|||
. $packages_list |
|||
|
|||
echo "1." $1 |
|||
echo "2." $2 |
|||
echo "3." $3 |
|||
echo "4." $4 |
|||
echo "5." $5 |
|||
echo "6." $6 |
|||
if [ ! -d /home/user ]; then |
|||
useradd -m -d /home/user -s /bin/bash user |
|||
gpasswd -a user sudo |
|||
echo -e 'root\nroot\n' | passwd root |
|||
echo -e 'user\nuser\n' | passwd user |
|||
usermod -aG sudo user |
|||
chown -R user:user /home/user |
|||
fi |
|||
if [ -d /etc/shadow ]; then |
|||
cd /etc |
|||
chmod u=rw,g=r,o=r shadow |
|||
fi |
|||
# set default hostname |
|||
echo localhost > /etc/hostname |
|||
|
|||
test -f /proc/uptime || mount -t proc proc /proc |
|||
|
|||
# set apt sources list to install additional packages |
|||
asl=/etc/apt/sources.list |
|||
rm -f $asl |
|||
cat <<-EOF > $asl |
|||
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ $2 main restricted universe multiverse |
|||
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ $2-updates main restricted universe multiverse |
|||
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ $2-backports main restricted universe multiverse |
|||
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ $2-security main restricted universe multiverse |
|||
EOF |
|||
chmod +777 /tmp |
|||
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C \ |
|||
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" update || exit 1 |
|||
|
|||
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C \ |
|||
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade || exit 1 |
|||
echo upgraded |
|||
|
|||
export LC_ALL=C LANGUAGE=C LANG=C |
|||
|
|||
echo installing base packages: $pkglist |
|||
for pkg in $additional_base_packages_list; do |
|||
echo Installing $pkg ... |
|||
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install $pkg || exit 1 |
|||
done |
|||
|
|||
dpkg -l | grep linux-headers | cut -d ' ' -f3 | xargs dpkg --purge |
|||
|
|||
test -f /dev/pts/ptmx || mount -t devpts devpts /dev/pts |
|||
|
|||
echo installed additional packages. |
|||
if [ $6 = desktop ]; then |
|||
for pkg in xfce4 ukui-greeter; do |
|||
DEBIAN_FRONTEND=noninteractive apt -y install $pkg || true |
|||
done |
|||
if [ $2 = jammy ]; then |
|||
sed -i 's/debian-x-terminal-emulator/gnome-terminal/g' /etc/xdg/xfce4/helpers.rc || true |
|||
DEBIAN_FRONTEND=noninteractive apt -y install software-properties-common || true |
|||
DEBIAN_FRONTEND=noninteractive add-apt-repository -y ppa:mozillateam/ppa || true |
|||
sed -i 's/ppa.launchpadcontent.net/launchpad.proxy.ustclug.org/g' /etc/apt/sources.list.d/mozillateam-*.list && \ |
|||
DEBIAN_FRONTEND=noninteractive apt -y update || true |
|||
cat <<-EOF > /etc/apt/preferences.d/mozillateamppa |
|||
Package: firefox |
|||
Pin: release o=LP-PPA-mozillateam |
|||
Pin-Priority: 501 |
|||
EOF |
|||
fi |
|||
DEBIAN_FRONTEND=noninteractive apt -y install firefox || true |
|||
|
|||
usermod -a -G video,render,audio user |
|||
|
|||
ln -sf /lib/systemd/system/lightdm.service /etc/systemd/system/display-manager.service |
|||
sed -i "s/gdm3/lightdm/" /etc/X11/default-display-manager |
|||
echo '[SeatDefaults]' >> /etc/lightdm/lightdm.conf |
|||
echo 'greeter-session=ukui-greeter' >> /etc/lightdm/lightdm.conf |
|||
echo 'user-session=xfce' >> /etc/lightdm/lightdm.conf |
|||
|
|||
echo installing desktop packages: $pkglist |
|||
for pkg in $additional_desktop_packages_list; do |
|||
echo Installing $pkg ... |
|||
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install $pkg || exit 1 |
|||
done |
|||
fi |
|||
# clean cached packages |
|||
apt-get clean |
|||
|
|||
|
|||
if [ $1 = arm64 ]; then |
|||
sysarch=aarch64-linux-gnu |
|||
elif [ $1 = armhf ]; then |
|||
sysarch=arm-linux-gnueabihf |
|||
fi |
|||
|
|||
|
|||
[ -f /usr/bin/sudo -a ! -u /usr/bin/sudo ] && chmod +s /usr/bin/sudo |
|||
[ -d /var/cache/man ] && chown -R man:root /var/cache/man |
|||
[ -d /var/lib/sddm ] && chown -R sddm:sddm /var/lib/sddm |
|||
|
|||
# some shared libraries locate in /lib/aarch64-linux-gnu(or /lib/arm-linux-gnueabihf) and /usr/local/lib |
|||
echo export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/$sysarch:/lib/$sysarch >> /etc/profile |
|||
|
|||
tmpusr=`ls -t /home | cut -d' ' -f1 | head -1` |
|||
[ -d /home/$tmpusr -a "$tmpusr" != "user" ] && rm -rf /home/$tmpusr |
|||
|
|||
test -c /dev/pts/ptmx && umount /dev/pts |
|||
test -f /proc/uptime && umount /proc |
|||
|
|||
echo APT Packages List: > /etc/packages.list |
|||
echo -e "Package\t Version\t Download-Size\t APT-Sources" >> /etc/packages.list |
|||
apt list --installed | cut -d/ -f1 | xargs apt show | \ |
|||
grep -E '^Package:|^APT-Sources:|^Version:|^Download-Size:' > packagelist |
|||
lnum=`wc -l packagelist |cut -d' ' -f1` |
|||
for((i=1; i<$lnum;)); do |
|||
t=$[ $i + 3 ] |
|||
sed -n "${i},${t}p" packagelist | grep -E 'Package:|APT-Sources:|Version:|Download-Size:' | \ |
|||
tr "\n" " " | cut -d' ' -f2,4,6,7,9,10 >> /etc/packages.list |
|||
i=$[ $i + 4 ] |
|||
done |
|||
rm -f packagelist |
|||
} |
|||
|
|||
do_distrorfs_second_stage $1 $2 $3 $4 $5 $6 |
|||
# end second stage installing |
Loading…
Reference in new issue