Skip to content

Commit

Permalink
feature(deb-package):compile_and_deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
ARTHUR CHENU (ext) committed Dec 9, 2024
1 parent 57a33ef commit e762ea8
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 154 deletions.
51 changes: 27 additions & 24 deletions .github/workflows/build_deb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
PKG_NAME: "alumet"
PKG_VERSION: 0.6.1

DEP_PKG: "curl unzip build-essential protobuf-compiler libcap2-bin"
DEP_PKG: "curl unzip build-essential protobuf-compiler"
RUST_REQUIRED: 1.76

jobs:
Expand All @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ "debian:11" ]
os: [ "debian:11", "debian:12", "ubuntu:20.04", "ubuntu:22.04", "ubuntu:24.04", "ubuntu:25.04" ]

container:
image: ${{ matrix.os }}
Expand All @@ -36,9 +36,15 @@ jobs:
with:
fetch-tags: 'true'

- name: Set dynamic environment variables
run: |
echo "OS_NAME=$(grep '^ID=' "/etc/os-release" | cut -d'=' -f2 | tr -d '"')" >> $GITHUB_ENV
echo "OS_VERSION=$(grep '^VERSION_ID=' "/etc/os-release" | cut -d'=' -f2 | tr -d '"')" >> $GITHUB_ENV
- name: Check OS package required dependencies
shell: bash
run: |
clear
apt update
dep_pkg=(${{ env.DEP_PKG }})
Expand All @@ -51,23 +57,10 @@ jobs:
fi
done
- name: Download 'alumet' project sources from Github
shell: bash
run: |
mkdir -p build
cd build/ || exit
curl -L "${{ env.URL_ALUMET }}" -o "${{ env.SRC_FILE }}" || exit
sync
unzip "${{ env.SRC_FILE }}" || exit
sync
rm "${{ env.SRC_FILE }}"
cd ..
- name: Check required rust dependencies to compile 'alumet' project sources
shell: bash
run: |
clear
curl --proto '=https' --tlsv1.2 -sSf "${{ env.URL_RUST }}" | sh -s -- -y || exit
echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
source $HOME/.cargo/env
Expand All @@ -80,9 +73,25 @@ jobs:
echo -e "\e[32mSUCCESS\e[0m : Rust version '$rust_version' is up to date..."
fi
- name: Download 'alumet' project sources from Github
shell: bash
run: |
clear
mkdir -p build
cd build/ || exit
curl -L "${{ env.URL_ALUMET }}" -o "${{ env.SRC_FILE }}" || exit
sync
unzip "${{ env.SRC_FILE }}" || exit
sync
rm "${{ env.SRC_FILE }}"
cd ..
- name: Compilation of 'alumet' project sources
shell: bash
run: |
clear
source $HOME/.cargo/env
mkdir -p build/alumet-main || exit
Expand All @@ -91,20 +100,13 @@ jobs:
sync
cd ../../
- name: Set dynamic environment variables
run: |
echo "OS_NAME=$(grep '^ID=' "/etc/os-release" | cut -d'=' -f2 | tr -d '"')" >> $GITHUB_ENV
echo "OS_VERSION=$(grep '^VERSION_ID=' "/etc/os-release" | cut -d'=' -f2 | tr -d '"')" >> $GITHUB_ENV
- name: Compilation of DEB package for 'alumet' project sources
shell: bash
run: |
clear
source $HOME/.cargo/env
chmod 775 alumet/DEBIAN/preinst alumet/DEBIAN/postinst || exit
[ -z "$OS_NAME" ] && OS_NAME="unknown"
[ -z "$OS_VERSION" ] && OS_VERSION="none"
chmod 775 -R alumet/var/lib/alumet || exit
cp build/alumet-main/target/release/"$BIN" alumet/usr/lib/alumet/ || exit
chmod 775 alumet/usr/lib/alumet/"$BIN" alumet/usr/bin/alumet || exit
Expand All @@ -116,6 +118,7 @@ jobs:
- name: Install alumet DEB package
shell: bash
run: |
clear
dpkg -i build/DEB/"${{ env.PKG_NAME }}"_"${{ env.PKG_VERSION }}"_"${{ env.PKG_ARCH }}"_"${{ env.OS_NAME }}"_"${{ env.OS_VERSION }}".deb || exit
- name: Upload artifact agent
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ on:
jobs:
deb:
uses: ./.github/workflows/build_deb.yaml

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Run the *config.sh* script that downloading **Alumet** project sources on github
extract and compile its content in a final binary according the targeted operating system version and distribution.

```bash
./config.sh
./packager.sh
```

# How to install ?
Expand Down
2 changes: 1 addition & 1 deletion alumet/DEBIAN/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Version: 0.7
Section: utils
Priority: optional
Architecture: amd64
Depends: libc6 (>= 2.2.5), libgcc-s1 (>= 2.35), libcap2-bin
Depends: libc6 (>= 2.2.5), libgcc-s1 (>= 2.35)
Maintainer: Eviden SEED team
Description: A tool for measuring the energy consumption and performance metrics
Customizable and efficient tool for measuring the energy consumption and
Expand Down
19 changes: 4 additions & 15 deletions alumet/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,9 @@

BIN="/usr/lib/alumet/alumet-local-agent"

##
# Check if file exists or not
##
check_file(){
local file="$1"
if ! [ -f "$file" ]; then
echo -e "\e[31mERROR:\e[0m : Abort installation, '$file' not exists."
exit 1
fi
}

check_file "$BIN"
setcap "cap_sys_nice+ep cap_perfmon=ep" "$BIN" || exit
echo -e "$\e[33mWARNING:\e[0m : If some functionalities not working, enter the following command"
echo -e "'sudo sysctl -w kernel.perf_event_paranoid=0'"
echo -e "\e[33mWARNING\e[0m : If some functionalities are not available, install 'procps' and 'libcap2-bin' packages."
echo -e "You can then enter the following commands to set system permissions for running 'alumet' plugins :"
echo -e ">> 'sudo sysctl -w kernel.perf_event_paranoid=0'"
echo -e ">> 'setcap cap_sys_nice+ep cap_perfmon=ep $BIN'"

exit 0
22 changes: 3 additions & 19 deletions alumet/DEBIAN/preinst
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
#!/bin/bash

# Color codes
ERROR="\e[31mERROR:\e[0m"
WARNING="\e[33mWARNING:\e[0m"

LIB=("/lib/x86_64-linux-gnu/libc.so.6"
"/lib/x86_64-linux-gnu/libgcc_s.so.1"
"/lib/x86_64-linux-gnu/libm.so.6");

##
# Check package presence on system
# and set permission to rapl data
##
check_lib(){
local lib_pkg="$1";

for lib_pkg in "${LIB[@]}"; do
if [ ! -f "$lib_pkg" ]; then
echo -e "$ERROR Abort installation, '$lib_pkg' not found...\n"
echo -e "$WARNING Install it...\n"
exit 1
echo -e "\e[31mERROR:\e[0m : Abort installation, '$lib_pkg' not found...\n"
fi
}

check_lib "${LIB[0]}"
check_lib "${LIB[1]}"
check_lib "${LIB[2]}"
done

exit 0
Binary file modified alumet/usr/lib/alumet/alumet-local-agent
Binary file not shown.
Loading

0 comments on commit e762ea8

Please sign in to comment.