2020-09-28 00:49:26 +09:00
|
|
|
#!/bin/bash
|
2021-03-21 19:03:29 +09:00
|
|
|
set -uex -o pipefail
|
2020-09-28 00:49:26 +09:00
|
|
|
|
2021-03-22 20:08:42 +09:00
|
|
|
if [ ! -v TIMEZONE ]; then
|
|
|
|
TIMEZONE=Asia/Tokyo
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -v CI ]; then
|
|
|
|
CI=false
|
|
|
|
fi
|
2020-09-28 00:49:26 +09:00
|
|
|
|
|
|
|
/debootstrap/debootstrap --second-stage
|
|
|
|
|
2021-02-20 04:29:49 +09:00
|
|
|
if [ "${CI}" == "true" ]; then
|
|
|
|
REPO=deb.debian.org
|
|
|
|
REPO_SECURITY=deb.debian.org
|
|
|
|
else
|
|
|
|
REPO=localhost:65432
|
|
|
|
REPO_SECURITY=localhost:65433
|
|
|
|
fi
|
|
|
|
|
2020-09-28 00:49:26 +09:00
|
|
|
cat <<EOF > /etc/apt/sources.list
|
2021-08-26 21:57:59 +09:00
|
|
|
deb http://${REPO}/debian bullseye main contrib non-free
|
|
|
|
deb-src http://${REPO}/debian bullseye main contrib non-free
|
|
|
|
deb http://${REPO}/debian bullseye-updates main contrib non-free
|
|
|
|
deb-src http://${REPO}/debian bullseye-updates main contrib non-free
|
2021-12-07 20:35:28 +09:00
|
|
|
deb http://${REPO_SECURITY}/debian-security bullseye-security/updates main contrib non-free
|
|
|
|
deb-src http://${REPO_SECURITY}/debian-security bullseye-security/updates main contrib non-free
|
2020-09-28 00:49:26 +09:00
|
|
|
EOF
|
|
|
|
|
|
|
|
cat <<EOF > /etc/apt/apt.conf.d/90-norecommend
|
|
|
|
APT::Install-Recommends "0";
|
|
|
|
APT::Install-Suggests "0";
|
|
|
|
EOF
|
|
|
|
|
2022-08-07 13:48:43 +09:00
|
|
|
# locales: locale has to be set before going any further
|
2020-09-28 00:49:26 +09:00
|
|
|
apt update -y
|
2022-02-27 22:49:35 +09:00
|
|
|
DEBIAN_FRONTEND=noninteractive \
|
|
|
|
apt install -y locales
|
2020-09-28 00:49:26 +09:00
|
|
|
|
|
|
|
echo "$TIMEZONE" > /etc/timezone && \
|
|
|
|
dpkg-reconfigure -f noninteractive tzdata && \
|
2021-03-22 20:08:42 +09:00
|
|
|
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
|
2020-09-28 00:49:26 +09:00
|
|
|
echo 'LANG="en_US.UTF-8"' > /etc/default/locale && \
|
|
|
|
dpkg-reconfigure -f noninteractive locales && \
|
|
|
|
update-locale LANG=en_US.UTF-8
|
|
|
|
|
2021-12-07 21:07:56 +09:00
|
|
|
LANG=en_US.UTF-8
|
|
|
|
|
2021-04-05 04:47:13 +09:00
|
|
|
rm /etc/localtime
|
|
|
|
ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
|
|
|
|
|
2020-09-28 00:49:26 +09:00
|
|
|
echo "brain" > /etc/hostname
|
2022-08-07 13:48:43 +09:00
|
|
|
|
|
|
|
# Install packagecloud repository
|
|
|
|
# Reference: https://packagecloud.io/brainhackers/brainux/install
|
|
|
|
|
2022-11-13 11:48:38 +09:00
|
|
|
# curl, ca-certificates: downloads the GPG key from packagecloud
|
2022-08-07 13:48:43 +09:00
|
|
|
# gnupg, debian-archive-keyring: packagecloud verification dependency
|
|
|
|
DEBIAN_FRONTEND=noninteractive \
|
2022-11-13 11:48:38 +09:00
|
|
|
apt install -y curl ca-certificates gnupg debian-archive-keyring
|
2022-08-07 13:48:43 +09:00
|
|
|
|
|
|
|
# apt-transport-https can be installed after debian-archive-keyring being installed
|
|
|
|
DEBIAN_FRONTEND=noninteractive \
|
|
|
|
apt install -y apt-transport-https
|
|
|
|
|
|
|
|
# Install GPG key and packagecloud repository config
|
|
|
|
mkdir -p /etc/apt/keyrings
|
|
|
|
curl -fsSL "https://packagecloud.io/brainhackers/brainux/gpgkey" \
|
|
|
|
| gpg --dearmor > /etc/apt/keyrings/brainhackers_brainux-archive-keyring.gpg
|
|
|
|
|
|
|
|
cat <<EOF > /etc/apt/sources.list.d/packagecloud.list
|
|
|
|
deb [signed-by=/etc/apt/keyrings/brainhackers_brainux-archive-keyring.gpg] https://packagecloud.io/brainhackers/brainux/any/ any main
|
|
|
|
deb-src [signed-by=/etc/apt/keyrings/brainhackers_brainux-archive-keyring.gpg] https://packagecloud.io/brainhackers/brainux/any/ any main
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Fetch packagecloud repository
|
|
|
|
apt update -y
|
|
|
|
|
2020-09-28 00:49:26 +09:00
|
|
|
DEBIAN_FRONTEND=noninteractive \
|
|
|
|
apt install -y dialog sudo \
|
|
|
|
libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev \
|
2021-03-22 20:12:24 +09:00
|
|
|
xserver-xorg xserver-xorg-video-fbdev xserver-xorg-dev xserver-xorg-input-evdev xinput-calibrator xorg-dev x11-apps xinit \
|
2021-12-07 21:08:10 +09:00
|
|
|
jwm \
|
2020-09-28 00:49:26 +09:00
|
|
|
weston xwayland \
|
|
|
|
bash tmux vim htop \
|
2021-03-22 20:12:24 +09:00
|
|
|
midori pcmanfm lxterminal xterm gnome-terminal fbterm uim-fep uim-anthy fonts-noto-cjk \
|
2022-11-23 23:14:38 +09:00
|
|
|
dbus udev alsa-utils usbutils iw fake-hwclock systemd-timesyncd\
|
2021-03-22 20:12:24 +09:00
|
|
|
build-essential flex bison pkg-config autotools-dev libtool autoconf automake device-tree-compiler \
|
2020-10-27 19:27:27 +09:00
|
|
|
python3 python3-dev python3-setuptools python3-wheel python3-pip python3-smbus \
|
2022-08-07 13:48:43 +09:00
|
|
|
resolvconf net-tools ssh openssh-client avahi-daemon wget git \
|
2022-08-07 12:48:59 +09:00
|
|
|
network-manager zip neofetch sl python3-numpy ipython3 netsurf-gtk fcitx-anthy
|
2021-04-05 04:41:41 +09:00
|
|
|
|
2022-08-07 13:48:43 +09:00
|
|
|
# Packages from packagecloud
|
|
|
|
DEBIAN_FRONTEND=noninteractive \
|
|
|
|
apt install -y --install-recommends brain-config
|
|
|
|
|
2021-04-05 03:13:24 +09:00
|
|
|
systemctl enable fake-hwclock
|
|
|
|
|
2021-03-22 20:13:07 +09:00
|
|
|
# Ly
|
2022-02-27 22:49:35 +09:00
|
|
|
DEBIAN_FRONTEND=noninteractive \
|
|
|
|
apt install -y libpam0g-dev libxcb-xkb-dev
|
2021-03-22 20:13:07 +09:00
|
|
|
cd /
|
2023-01-10 19:14:43 +09:00
|
|
|
git clone --recurse-submodules -b master-24f017e https://github.com/brain-hackers/ly.git
|
2021-03-22 20:13:07 +09:00
|
|
|
cd ly
|
|
|
|
make
|
|
|
|
make install
|
2022-11-13 21:35:03 +09:00
|
|
|
make installsystemd
|
2021-03-22 20:13:07 +09:00
|
|
|
cd /
|
|
|
|
rm -r ly
|
|
|
|
systemctl enable ly
|
|
|
|
|
2021-03-22 20:14:04 +09:00
|
|
|
# Create editable xorg.conf.d
|
|
|
|
install -m 0777 -d /etc/X11/xorg.conf.d
|
|
|
|
|
2021-02-23 23:39:40 +09:00
|
|
|
# Fix Midori launch failure
|
|
|
|
sudo update-mime-database /usr/share/mime
|
|
|
|
|
2021-03-22 20:10:33 +09:00
|
|
|
# Setup users
|
|
|
|
adduser --gecos "" --disabled-password --home /home/user user
|
|
|
|
echo user:brain | chpasswd
|
|
|
|
echo "user ALL=(ALL:ALL) ALL" > /etc/sudoers.d/user
|
|
|
|
echo -e "127.0.1.1\tbrain" >> /etc/hosts
|
|
|
|
|
|
|
|
echo root:root | chpasswd
|
|
|
|
|
2021-03-22 20:13:07 +09:00
|
|
|
# Fix Xorg permission for non-root users
|
|
|
|
# https://unix.stackexchange.com/questions/315169/how-can-i-run-usr-bin-xorg-without-sudo
|
|
|
|
chown root:input /usr/lib/xorg/Xorg
|
|
|
|
chmod g+s /usr/lib/xorg/Xorg
|
|
|
|
usermod -a -G video user
|
|
|
|
|
2021-03-22 20:10:33 +09:00
|
|
|
# Allow root login via UART
|
|
|
|
cat <<EOF >> /etc/securetty
|
|
|
|
ttymxc0
|
2021-03-06 20:19:11 +09:00
|
|
|
ttyLP0
|
2021-03-22 20:10:33 +09:00
|
|
|
EOF
|
|
|
|
|
2023-03-21 18:01:11 +09:00
|
|
|
# Enable /boot mount
|
|
|
|
systemctl enable boot.mount
|
|
|
|
|
2023-03-27 19:37:52 +09:00
|
|
|
# Enable RNDIS gadget
|
|
|
|
systemctl enable rndis_gadget
|
|
|
|
|
2020-10-27 19:52:59 +09:00
|
|
|
# Get wild
|
|
|
|
cat <<EOF > /etc/apt/sources.list
|
2021-08-26 21:57:59 +09:00
|
|
|
deb http://deb.debian.org/debian bullseye main contrib non-free
|
|
|
|
deb-src http://deb.debian.org/debian bullseye main contrib non-free
|
|
|
|
deb http://deb.debian.org/debian bullseye-updates main contrib non-free
|
|
|
|
deb-src http://deb.debian.org/debian bullseye-updates main contrib non-free
|
2021-12-07 20:35:28 +09:00
|
|
|
deb http://deb.debian.org/debian-security bullseye-security/updates main contrib non-free
|
|
|
|
deb-src http://deb.debian.org/debian-security bullseye-security/updates main contrib non-free
|
2020-10-27 19:52:59 +09:00
|
|
|
EOF
|
|
|
|
|