Initial workflow for building packages

This commit is contained in:
Martin Valba 2022-09-17 23:10:26 +03:00
commit d71a296c63
17 changed files with 170 additions and 0 deletions

126
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,126 @@
name: Package build
on:
push:
branches:
- master
paths:
- 'x86_64/**'
pull_request:
paths:
- 'x86_64/**'
workflow_dispatch:
inputs:
packages:
description: "A space-separated names of packages selected for rebuilding"
required: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Clone repository
uses: actions/checkout@v3
with:
fetch-depth: 1000
- name: Clean up workflow env
run: |
# Free up space ( for this workflow )
#sudo apt purge -yq $(dpkg -l | grep '^ii' | awk '{ print $2 }' | grep -P '(cabal-|dotnet-|ghc-|libmono|php)') \
#liblldb-6.0 libllvm6.0:amd64 mono-runtime-common monodoc-manual powershell ruby
#sudo apt autoremove -yq
#sudo rm -rf /opt/hostedtoolcache /usr/local /usr/share/dotnet /usr/share/swift
# Move some stuff
cd /home/runner/work/drunk_pkg/
mkdir -p DRUNK/pkgbuild
cp -rf /home/runner/work/drunk_pkg/drunk_pkg/* DRUNK/pkgbuild
mv -f DRUNK drunk_pkg
- name: prepare build env
run: |
# Basics
export HEAD_COMMIT=$(jq --raw-output .commits[-1].id "$GITHUB_EVENT_PATH")
# Clone and install required deps
mkdir -p /home/runner/work/drunk_pkg/drunk_pkg/DRUNK/
cd /home/runner/work/drunk_pkg/drunk_pkg/DRUNK
git clone https://git.it-kuny.ch/drunk/setup.git setup --depth=10
mkdir -p setup/tmp
# Checkout the changed commitid
cd pkgbuild && git reset --hard ${HEAD_COMMIT}
cd /home/runner/work/drunk_pkg/drunk_pkg/DRUNK
ln -sf setup/drunk.sh drunk
mkdir -p setup/tmp
# Now prepare drunk build env
# As were running in ubuntu env then we need to bypass normal checks of script
touch setup/checks/is_checked
- name: Setup docker
run: |
cd /home/runner/work/drunk_pkg/drunk_pkg/DRUNK
export P_ROOT=$(pwd)
# Pull drunk docker image and make new container of it
sudo docker pull hilledkinged/drunk:latest
docker container create \
--name work01 \
--volume $P_ROOT:/home/developer/DRUNK \
--tty \
--privileged \
--device=/dev/loop-control:/dev/loop-control \
--device=/dev/loop0:/dev/loop0 \
hilledkinged/drunk /bin/bash
sleep 1
sudo docker start work01 >/dev/null
sleep 1
sudo docker exec --tty -e PATH=/bin:/sbin:/usr/bin:/usr/sbin work01 /bin/bash -c "rm -rf /var/lib/bottle/sync/*"
sudo docker exec --tty -e PATH=/bin:/sbin:/usr/bin:/usr/sbin work01 /bin/bash -c "useradd developer -m -g wheel"
sudo docker exec --tty -e PATH=/bin:/sbin:/usr/bin:/usr/sbin work01 /bin/bash -c "bash -c /home/developer/DRUNK/setup/docker/developer.sh"
sudo docker exec --tty -e PATH=/bin:/sbin:/usr/bin:/usr/sbin work01 /bin/bash -c "cp -f /home/developer/DRUNK/setup/docker/bottle.conf /etc/bottle.conf"
sudo docker exec --tty -e PATH=/bin:/sbin:/usr/bin:/usr/sbin work01 /bin/bash -c "bottle -Syu --needed --noconfirm --disable-download-timeout"
sudo docker exec --tty -e PATH=/bin:/sbin:/usr/bin:/usr/sbin work01 /bin/bash -c "bash -c /home/developer/DRUNK/setup/docker/developer.sh"
sudo docker exec --tty -e PATH=/bin:/sbin:/usr/bin:/usr/sbin work01 /bin/bash -c "bottle --needed --noconfirm --disable-download-timeout -Sy sudo autoconf automake grep nano mpfr mpc base-devel m4 git linux"
sudo docker exec --tty -e PATH=/bin:/sbin:/usr/bin:/usr/sbin work01 /bin/bash -c "bash -c /home/developer/DRUNK/setup/docker/fix_sudo.sh"
sudo docker exec --tty -e PATH=/bin:/sbin:/usr/bin:/usr/sbin work01 /bin/bash -c "bash -c /home/developer/DRUNK/setup/docker/locale.sh"
- name: PKG Build
run: |
# Perms fix
iamnow=$(whoami)
echo $iamnow
sudo chmod -R 777 /home/runner/work/drunk_pkg/drunk_pkg/DRUNK
sudo chmod +x /home/runner/work/drunk_pkg/drunk_pkg/DRUNK/drunk
sudo chmod +x /home/runner/work/drunk_pkg/drunk_pkg/DRUNK/setup/drunk.sh
# Create pkg list to compile
cd /home/runner/work/drunk_pkg/drunk_pkg/DRUNK/pkgbuild
./changed.sh > ../pkglist
# Build the packages in docker env
cd /home/runner/work/drunk_pkg/drunk_pkg/DRUNK
# Print pkg's
echo " "
echo "[List of pkgs to build]: " && cat pkglist
echo " "
./drunk -d -b $(cat pkglist)
# Now lets move the packages to certain path
mkdir -p /home/runner/work/drunk_pkg/drunk_pkg/DRUNK/pkgs
mv pkgbuild/pkgs/*/*pkg.tar.gz /home/runner/work/drunk_pkg/drunk_pkg/DRUNK/pkgs
- name: "Upload the pkg's"
uses: actions/upload-artifact@v3
with:
path: /home/runner/work/drunk_pkg/drunk_pkg/DRUNK/pkgs/*pkg.tar.gz

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# drunk_pkg
Place where brewery is done

28
changed.sh Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
#
# Autohor: darkmaster | https://github.com/grm34
#
get_pkg_list() {
# Usage: get_pkg_list "$@"
# Returns: pkg_list (array)
pkg_list=()
local entry pkg
for entry in "$@"; do
IFS=$'\n' read -d "" -ra pkg <<< "${entry//\//$'\n'}"
if [[ ${pkg[-1]} == "PKGBUILD" ]] && [[ ${#pkg[@]} -gt 3 ]]; then
pkg_list+=("${pkg[-2]}")
fi
done
}
# Run
git diff-tree --name-only --no-commit-id -r HEAD > temp
mapfile -t output < "temp"; rm -f temp
get_pkg_list "${output[@]}"
# Test
echo "${pkg_list[@]}"

1
pkgs/core/.gitkeepme Normal file
View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

1
pkgs/extra/.gitkeepme Normal file
View File

@ -0,0 +1 @@

1
pkgs/extra32/.gitkeepme Normal file
View File

@ -0,0 +1 @@

1
pkgs/games/.gitkeepme Normal file
View File

@ -0,0 +1 @@

1
pkgs/gnome/.gitkeepme Normal file
View File

@ -0,0 +1 @@

1
pkgs/kde/.gitkeepme Normal file
View File

@ -0,0 +1 @@

1
pkgs/layers/.gitkeepme Normal file
View File

@ -0,0 +1 @@

1
pkgs/pentest/.gitkeepme Normal file
View File

@ -0,0 +1 @@

1
pkgs/perl/.gitkeepme Normal file
View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

1
pkgs/python/.gitkeepme Normal file
View File

@ -0,0 +1 @@

1
pkgs/server/.gitkeepme Normal file
View File

@ -0,0 +1 @@

1
pkgs/xfce/.gitkeepme Normal file
View File

@ -0,0 +1 @@