Skip to content

Commit

Permalink
Improve Docker build, initial server variant
Browse files Browse the repository at this point in the history
  • Loading branch information
Seshpenguin committed Feb 14, 2024
1 parent eecf93b commit fd362f1
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
@@ -0,0 +1,5 @@
{
"files.watcherExclude": {
"**/build": true
}
}
12 changes: 6 additions & 6 deletions scripts/build_x64_docker.sh
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
set -e
echo "Running ProLinux 2 Build using the ProLinux SDK Container"
if [ ! -f package.json ]; then
echo "This script must be run from the root of the project"
exit 1
fi



#docker run -it prolinux-sdk:latest bash
# run ./scripts/build_x64.sh in the container and mount cwd to /home/user/prolinux-2

docker run -it -v $(pwd):/home/user/prolinux-2 prolinux-sdk:latest bash -c "cd /home/user/prolinux-2 && ./scripts/build_x64.sh"
docker run -it --rm --privileged=true -v $(pwd):/home/user/prolinux-2 sineware/prolinux-sdk:latest bash -c "cd /home/user/prolinux-2 && ./scripts/unmount.sh && ./scripts/build_x64.sh"
30 changes: 28 additions & 2 deletions sdk/Dockerfile
@@ -1,7 +1,7 @@
FROM archlinux:latest
#ADD ./staging/prolinux-root-mobile-dev.tar /

RUN pacman -Syyu --noconfirm && \
RUN pacman-key --init && pacman-key --populate archlinux && pacman -Syy --noconfirm archlinux-keyring && pacman -Syyu --noconfirm && \
pacman -S --noconfirm \
base-devel \
git \
Expand All @@ -20,6 +20,7 @@ RUN pacman -Syyu --noconfirm && \
npm \
aarch64-linux-gnu-gcc \
distcc \
rsync \
&& \
pacman -Scc --noconfirm

Expand All @@ -32,9 +33,34 @@ RUN echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
USER user
WORKDIR /home/user

# Install x86_64-linux-musl-native to /opt
RUN wget http://musl.cc/x86_64-linux-musl-native.tgz && \
sudo tar -xvf x86_64-linux-musl-native.tgz -C /opt && \
rm x86_64-linux-musl-native.tgz


# Install https://aur.archlinux.org/packages/abootimg
RUN git clone https://aur.archlinux.org/abootimg.git && \
cd abootimg && \
makepkg -si --noconfirm && \
cd .. && \
rm -rf abootimg
rm -rf abootimg

# From git

# Follow this section if your Linux distribution doesn't have pmbootstrap packaged, or its version of pmbootstrap is too old, or you would like to change the code. Run the following to clone and install pmbootstrap from git.

# $ git clone --depth=1 https://gitlab.com/postmarketOS/pmbootstrap.git
# $ mkdir -p ~/.local/bin
# $ ln -s "$PWD/pmbootstrap/pmbootstrap.py" ~/.local/bin/pmbootstrap
# $ pmbootstrap --version
# 2.1.0

# If this returns something like pmbootstrap: command not found instead of a version number, ensure that ~/.local/bin is in your PATH. For example by adding the following to your ~/.profile (zsh: ~/.zprofile) followed by source ~/.profile to update your environment

# PATH="$HOME/.local/bin:$PATH"

RUN git clone --depth=1 https://gitlab.com/postmarketOS/pmbootstrap.git && \
mkdir -p ~/.local/bin && \
ln -s "$PWD/pmbootstrap/pmbootstrap.py" ~/.local/bin/pmbootstrap && \
pmbootstrap --version
8 changes: 7 additions & 1 deletion sdk/build-sdk.sh
@@ -1,7 +1,13 @@
#!/usr/bin/env bash
set -e
echo "Building ProLinux SDK"

if [ ! -f Dockerfile ]; then
echo "This script must be run from the sdk directory"
exit 1
fi

mkdir -pv staging
#cp -v ../output/prolinux-root-mobile-dev.tar staging/
docker build --ulimit "nofile=1024:1048576" -t sineware/prolinux-sdk .
docker build --ulimit "nofile=1024:1048576" -t sineware/prolinux-sdk:latest .
echo "Done!"
20 changes: 13 additions & 7 deletions src/index.ts
Expand Up @@ -14,7 +14,7 @@ import { buildEmbeddedDev } from './os-variants/embedded/embedded-dev';
import { buildMobileStable } from './os-variants/mobile/mobile-stable';
import { buildMobileCommon } from './os-variants/mobile/mobile-common';
import { buildMobileHaliumDev } from './os-variants/mobile-halium/mobile-halium-dev';

import { buildServerDev } from './os-variants/server/server-dev';
// # Copyright (C) 2023 Seshan Ravikumar
// #
// # This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -102,6 +102,10 @@ async function main() {
exec(`sudo mkdir -pv ${BUILD_DIR}/pacman-cache`);
exec(`sudo mount --bind ${BUILD_DIR}/pacman-cache ${ROOTFS_DIR}/var/cache/pacman/pkg`);

// merge FILES_DIR/layout into rootfs
console.log("Merging files from " + FILES_DIR + "/layout into " + ROOTFS_DIR);
exec(`sudo rsync -a ${FILES_DIR}/layout/ ${ROOTFS_DIR}/`);

exec(`sudo arch-chroot ${ROOTFS_DIR} /bin/bash -x <<'EOF'
set -e
chown root:root /
Expand Down Expand Up @@ -132,6 +136,11 @@ async function main() {
# fixes plasma-mobile app list
pacman -S --noconfirm --needed xorg
# server related packages
pacman -S --noconfirm --needed podman podman-docker podman-dnsname netavark buildah
echo "Setting up user"
${arch === "x64" ? 'useradd -m -G wheel user' : ''}
${arch === "arm64" ? 'usermod -l user alarm' : ''}
Expand Down Expand Up @@ -159,10 +168,6 @@ EOFSU
sleep 2
EOF`);

// merge FILES_DIR/layout into rootfs
console.log("Merging files from " + FILES_DIR + "/layout into " + ROOTFS_DIR);
exec(`sudo rsync -a ${FILES_DIR}/layout/ ${ROOTFS_DIR}/`);

/* Install NODEJS_PACKAGE */
console.log("Installing NodeJS");
exec(`sudo mkdir -pv ${ROOTFS_DIR}/opt/nodejs`);
Expand Down Expand Up @@ -221,7 +226,7 @@ EOF`);
await buildEmbeddedDev();
/* ------------- ProLinux Server ------------- */
} else if(PROLINUX_VARIANT === "server" && PROLINUX_CHANNEL === "dev") {

await buildServerDev();
} else {
throw new Error("Unknown ProLinux variant/channel");
}
Expand All @@ -238,6 +243,7 @@ EOF`);
systemctl enable prolinux-setup
systemctl enable prolinuxd
systemctl enable getty@tty0
systemctl enable podman
mkdir -pv /opt/build-info
echo "${buildnum},${builduuid},prolinux,${PROLINUX_VARIANT},${PROLINUX_CHANNEL},$(date),prolinux-root-${PROLINUX_VARIANT}-${PROLINUX_CHANNEL}.squish,${arch}" >> /opt/build-info/prolinux-info.txt
Expand Down Expand Up @@ -288,8 +294,8 @@ EOF`);
console.log("Cleaning up rootfs before final squash...");
exec(`
sudo arch-chroot ${ROOTFS_DIR} /bin/bash -x <<'EOF'
set -e
sudo pacman -R --noconfirm qt6-doc qt6-examples
echo "Cleaned up packages."
EOF
sudo rm -rf ${ROOTFS_DIR}/usr/share/doc/*
sudo rm -rf ${ROOTFS_DIR}/opt/kde/build/
Expand Down
9 changes: 9 additions & 0 deletions src/os-variants/server/server-dev.ts
@@ -0,0 +1,9 @@
import exec from "../../helpers/exec";
import { BUILD_DIR, ROOTFS_DIR, OUTPUT_DIR, FILES_DIR, arch, TARGET_DEVICE, PROLINUX_CHANNEL, PROLINUX_VARIANT } from '../../helpers/consts';

export async function buildServerDev() {
console.log("Building ProLinux Server (Dev)");
exec(`sudo arch-chroot ${ROOTFS_DIR} /bin/bash -x <<'EOF'
echo "Installing packages for server-dev profile";
EOF`);
}

0 comments on commit fd362f1

Please sign in to comment.