Skip to content

Commit

Permalink
2.2.15
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Jul 22, 2024
1 parent 3ece144 commit 14ec2b0
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 19 deletions.
176 changes: 173 additions & 3 deletions .github/workflows/build-rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,163 @@ jobs:
path: /tmp/linupdate-test-build-${{ env.VERSION }}.noarch.rpm
retention-days: 1

# Try to install packages on CentOS 7
install-centos7:
name: Install on CentOS 7
needs:
build-rpm
runs-on: ubuntu-latest
container:
image: centos:7
options: --user root
env:
# Force to use node16 (for actions/checkout@v3)
ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: node16
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get linupdate version
run: echo "VERSION=$(cat ${GITHUB_WORKSPACE}/version)" >> $GITHUB_ENV

- name: Install CentOS7 archive repositories
run: |
rm /etc/yum.repos.d/* -f
echo "[os]
name=os repo
baseurl=https://vault.centos.org/7.9.2009/os/x86_64/
enabled=1
gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-7
gpgcheck=1" > /etc/yum.repos.d/os.repo
echo "[extras]
name=extras repo
baseurl=https://vault.centos.org/7.9.2009/extras/x86_64/
enabled=1
gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-7
gpgcheck=1" > /etc/yum.repos.d/extras.repo
echo "[updates]
name=updates repo
baseurl=https://vault.centos.org/7.9.2009/updates/x86_64/
enabled=1
gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-7
gpgcheck=1" > /etc/yum.repos.d/updates.repo
echo "[epel]
name=epel repo
baseurl=https://dl.fedoraproject.org/pub/epel/7/x86_64/
enabled=1
gpgkey=https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
gpgcheck=1" > /etc/yum.repos.d/epel.repo
yum clean all
# Download builded deb package artifact
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: linupdate-test-build-${{ env.VERSION }}.noarch.rpm

- name: Install package
run: yum --nogpgcheck localinstall -y ./linupdate-test-build-${{ env.VERSION }}.noarch.rpm

- name: Test some params
run: |
/opt/linupdate/linupdate --help
/opt/linupdate/linupdate --version
/opt/linupdate/linupdate --check-updates
/opt/linupdate/linupdate --profile container
/opt/linupdate/linupdate --env test
/opt/linupdate/linupdate --mod-enable reposerver
/opt/linupdate/linupdate --mod-configure reposerver --url https://packages.bespin.ovh --fail-level 3
/opt/linupdate/linupdate --mod-configure reposerver --api-key ${{ secrets.REPOSITORY_TOKEN }} --register
/opt/linupdate/linupdate --mod-configure reposerver --send-full-status
/opt/linupdate/linupdate --mod-configure reposerver --unregister
# Try to install packages on RockyLinux 8
install-rockylinux8:
name: Install on RockyLinux 8
needs:
build-rpm
runs-on: ubuntu-latest
container:
image: rockylinux/rockylinux:8
options: --user root
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get linupdate version
run: echo "VERSION=$(cat ${GITHUB_WORKSPACE}/version)" >> $GITHUB_ENV

- name: Install EPEL repository
run: dnf install epel-release glibc-langpack-en -y

# Download builded deb package artifact
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: linupdate-test-build-${{ env.VERSION }}.noarch.rpm

- name: Install package
run: yum --nogpgcheck localinstall -y ./linupdate-test-build-${{ env.VERSION }}.noarch.rpm

- name: Test some params
run: |
/opt/linupdate/linupdate --help
/opt/linupdate/linupdate --version
/opt/linupdate/linupdate --check-updates
/opt/linupdate/linupdate --profile container
/opt/linupdate/linupdate --env test
/opt/linupdate/linupdate --mod-enable reposerver
/opt/linupdate/linupdate --mod-configure reposerver --url https://packages.bespin.ovh --fail-level 3
/opt/linupdate/linupdate --mod-configure reposerver --api-key ${{ secrets.REPOSITORY_TOKEN }} --register
/opt/linupdate/linupdate --mod-configure reposerver --send-full-status
/opt/linupdate/linupdate --mod-configure reposerver --unregister
# Try to install packages on RockyLinux 9
install-rockylinux9:
name: Install on RockyLinux 9
needs:
build-rpm
runs-on: ubuntu-latest
container:
image: rockylinux/rockylinux:9
options: --user root
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get linupdate version
run: echo "VERSION=$(cat ${GITHUB_WORKSPACE}/version)" >> $GITHUB_ENV

- name: Install EPEL repository
run: dnf install epel-release glibc-langpack-en -y

# Download builded deb package artifact
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: linupdate-test-build-${{ env.VERSION }}.noarch.rpm

- name: Install package
run: yum --nogpgcheck localinstall -y ./linupdate-test-build-${{ env.VERSION }}.noarch.rpm

- name: Test some params
run: |
/opt/linupdate/linupdate --help
/opt/linupdate/linupdate --version
/opt/linupdate/linupdate --check-updates
/opt/linupdate/linupdate --profile container
/opt/linupdate/linupdate --env test
/opt/linupdate/linupdate --mod-enable reposerver
/opt/linupdate/linupdate --mod-configure reposerver --url https://packages.bespin.ovh --fail-level 3
/opt/linupdate/linupdate --mod-configure reposerver --api-key ${{ secrets.REPOSITORY_TOKEN }} --register
/opt/linupdate/linupdate --mod-configure reposerver --send-full-status
/opt/linupdate/linupdate --mod-configure reposerver --unregister
# Try to install packages on latest Fedora
install-fedora:
Expand All @@ -118,14 +275,27 @@ jobs:
- name: Get linupdate version
run: echo "VERSION=$(cat ${GITHUB_WORKSPACE}/version)" >> $GITHUB_ENV

- name: Install dependencies packages
run: dnf install glibc-langpack-en -y

# Download builded deb package artifact
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: linupdate-test-build-${{ env.VERSION }}.noarch.rpm

- name: Install package
run: dnf --nogpgcheck localinstall -y ./linupdate-test-build-${{ env.VERSION }}.noarch.rpm

- name: Test some params
run: |
dnf update -y
dnf clean all
dnf --nogpgcheck localinstall -y ./linupdate-test-build-${{ env.VERSION }}.noarch.rpm
/opt/linupdate/linupdate --help
/opt/linupdate/linupdate --version
/opt/linupdate/linupdate --check-updates
/opt/linupdate/linupdate --profile container
/opt/linupdate/linupdate --env test
/opt/linupdate/linupdate --mod-enable reposerver
/opt/linupdate/linupdate --mod-configure reposerver --url https://packages.bespin.ovh --fail-level 3
/opt/linupdate/linupdate --mod-configure reposerver --api-key ${{ secrets.REPOSITORY_TOKEN }} --register
/opt/linupdate/linupdate --mod-configure reposerver --send-full-status
/opt/linupdate/linupdate --mod-configure reposerver --unregister
36 changes: 23 additions & 13 deletions mods-available/reposerver.mod
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function mod_help
echo -e " --get-profile-repos → Get repos sources configuration from reposerver."
echo -e " --send-general-status → Send host global informations to reposerver (OS, version, kernel..)"
echo -e " --send-full-history → Send host packages events history to reposerver (installation, update, uninstallation...)"
echo -e " --send-packages-status → Send host packages informations (installed, available...) to resposerver"
echo -e " --send-packages-status → Send host packages informations (installed, available) to reposerver"
echo -e " --send-full-status → Execute the tree previous parameters"
echo -e ""
echo -e " Agent:"
Expand Down Expand Up @@ -602,7 +602,6 @@ function getModConf

# Configuration serveur (section [REPOSERVER])
REPOSERVER_URL="$(grep "^URL=" $MOD_CONF | cut -d'=' -f2 | sed 's/"//g')"
REPOSERVER_PACKAGE_TYPE="$(grep "^PACKAGE_TYPE=" $MOD_CONF | cut -d'=' -f2 | sed 's/"//g')"

# Récupération du FAILLEVEL pour ce module
FAILLEVEL=$(grep "^FAILLEVEL=" "$MOD_CONF" | cut -d'=' -f2 | sed 's/"//g')
Expand Down Expand Up @@ -657,7 +656,6 @@ function getServerConf

REPOSERVER_IP=$(_jq '.Ip')
REPOSERVER_URL=$(_jq '.Url')
REPOSERVER_PACKAGE_TYPE=$(_jq '.Package_type')
done

# Retrieve the server IP address from the server URL
Expand Down Expand Up @@ -695,7 +693,7 @@ function getServerConf
echo "[REPOSERVER]" >> "$TMP_FILE_REPOSERVER"
echo "URL=\"$REPOSERVER_URL\"" >> "$TMP_FILE_REPOSERVER"
echo "IP=\"$REPOSERVER_IP\"" >> "$TMP_FILE_REPOSERVER"
echo "PACKAGE_TYPE=\"$REPOSERVER_PACKAGE_TYPE\"" >> "$TMP_FILE_REPOSERVER"
echo "PACKAGE_TYPE=\"\"" >> "$TMP_FILE_REPOSERVER"
echo "" >> "$TMP_FILE_REPOSERVER"

# On reconstruit le fichier de configuration
Expand All @@ -720,11 +718,7 @@ function getServerConf
# Fonction exécutée pre-mise à jour
function preCheck
{
# Vérification que le serveur Repomanager gère le même type de paquet que cet hôte
if ! echo "$REPOSERVER_PACKAGE_TYPE" | grep -q "$PKG_TYPE";then
echo -e " [${YELLOW} ERROR ${RESET}] reposerver do not handle the same package type as this host. Reposerver: $REPOSERVER_PACKAGE_TYPE / Host: $PKG_TYPE"
return 2
fi
return
}

# Get profile general configuration from reposerver
Expand Down Expand Up @@ -1220,7 +1214,11 @@ function send_installed_packages_status
# Construction de la liste des paquets
# Cas Redhat
if [ "$OS_FAMILY" == "Redhat" ];then
repoquery -a --installed --qf="%{name} %{epoch}:%{version}-%{release}.%{arch}" > "$INSTALLED_PACKAGES_TMP"
if [ -f "/usr/bin/dnf" ];then
dnf repoquery -q -a --installed --qf="%{name} %{epoch}:%{version}-%{release}.%{arch}" > "$INSTALLED_PACKAGES_TMP"
else
repoquery -a --installed --qf="%{name} %{epoch}:%{version}-%{release}.%{arch}" > "$INSTALLED_PACKAGES_TMP"
fi
fi
# Cas Debian
if [ "$OS_FAMILY" == "Debian" ];then
Expand Down Expand Up @@ -1290,7 +1288,11 @@ function send_available_packages_status
# Cas Redhat
if [ "$OS_FAMILY" == "Redhat" ];then
# Récupération des paquets disponibles pour mise à jour
repoquery -q -a --qf="%{name} %{epoch}:%{version}-%{release}.%{arch}" --pkgnarrow=updates > "$AVAILABLE_PACKAGES_TMP"
if [ -f "/usr/bin/dnf" ];then
dnf repoquery -q --upgrades --latest-limit 1 -a --qf="%{name} %{epoch}:%{version}-%{release}.%{arch}" --upgrades > "$AVAILABLE_PACKAGES_TMP"
else
repoquery -a --qf="%{name} %{epoch}:%{version}-%{release}.%{arch}" --pkgnarrow=updates > "$AVAILABLE_PACKAGES_TMP"
fi
fi
# Cas Debian
if [ "$OS_FAMILY" == "Debian" ];then
Expand Down Expand Up @@ -1389,10 +1391,18 @@ function genFullHistory

# Récupération de tous les ID d'évènements dans la base de données de yum
if [ "$HISTORY_START" == "newest" ];then
YUM_HISTORY_IDS=$(yum history list all | tail -n +4 | awk '{print $1}' | grep -v "history")
if [ -f "/usr/bin/dnf" ];then
YUM_HISTORY_IDS=$(dnf history list | tail -n +4 | awk '{print $1}' | grep -v "history")
else
YUM_HISTORY_IDS=$(yum history list all | tail -n +4 | awk '{print $1}' | grep -v "history")
fi
fi
if [ "$HISTORY_START" == "oldest" ];then
YUM_HISTORY_IDS=$(yum history list all | tail -n +4 | awk '{print $1}' | grep -v "history" | tac)
if [ -f "/usr/bin/dnf" ];then
YUM_HISTORY_IDS=$(dnf history list | tail -n +4 | awk '{print $1}' | grep -v "history" | tac)
else
YUM_HISTORY_IDS=$(yum history list all | tail -n +4 | awk '{print $1}' | grep -v "history" | tac)
fi
fi

# Pour chaque évènement on peut récupérer la date et l'heure de début et la date et l'heure de fin
Expand Down
6 changes: 4 additions & 2 deletions src/02_check-packages-before-update
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ function checkPackagesBeforeUpdate
apt-get clean && apt-get -qq --allow-releaseinfo-change update
fi

echo -e "\n Generating packages list..."

# Temporary file to work with
CHECK_UPDATE_TMP="/tmp/linupdate_check-update.tmp"

# List packages available for update
if [ "$OS_FAMILY" == "Redhat" ];then
if [ -f "/usr/bin/dnf" ];then
repoquery -q -a --qf="%{name} %{version}-%{release}.%{arch} %{repoid}" --upgrades >> "$CHECK_UPDATE_TMP"
dnf repoquery -q --upgrades --latest-limit 1 -a --qf="%{name} %{version}-%{release}.%{arch} %{repoid}" --upgrades >> "$CHECK_UPDATE_TMP"
else
repoquery -q -a --qf="%{name} %{version}-%{release}.%{arch} %{repoid}" --pkgnarrow=updates > "$CHECK_UPDATE_TMP"
repoquery -a --qf="%{name} %{version}-%{release}.%{arch} %{repoid}" --pkgnarrow=updates > "$CHECK_UPDATE_TMP"
fi
fi
if [ "$OS_FAMILY" == "Debian" ];then
Expand Down
36 changes: 36 additions & 0 deletions src/200_yum-history-parser
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,25 @@ function yumHistoryParser

if echo "$LINE" | egrep -q "^ +Install ";then
PACKAGE_NAME=$(echo "$LINE" | awk '{print $2}' | sed 's/-[0-9].*//g')

# If package name starts with '@', ignore it as it's a group
if echo "$PACKAGE_NAME" | grep -q "^@";then
continue
fi

PACKAGE_VERSION=$(echo "$LINE" | awk '{print $2}' | sed "s/$PACKAGE_NAME//g" | sed 's/^-//g')
REPO=$(echo "$LINE" | awk '{print $3}')
PACKAGES_INSTALLED_JSON+="{\"name\":\"$PACKAGE_NAME\",\"version\":\"$PACKAGE_VERSION\",\"repo\":\"$REPO\"},"
fi

if echo "$LINE" | egrep -q "^ +Dep-Install ";then
PACKAGE_NAME=$(echo "$LINE" | awk '{print $2}' | sed 's/-[0-9].*//g')

# If package name starts with '@', ignore it as it's a group
if echo "$PACKAGE_NAME" | grep -q "^@";then
continue
fi

PACKAGE_VERSION=$(echo "$LINE" | awk '{print $2}' | sed "s/$PACKAGE_NAME//g" | sed 's/^-//g')
REPO=$(echo "$LINE" | awk '{print $3}')
DEPENDENCIES_INSTALLED_JSON+="{\"name\":\"$PACKAGE_NAME\",\"version\":\"$PACKAGE_VERSION\",\"repo\":\"$REPO\"},"
Expand All @@ -66,6 +78,12 @@ function yumHistoryParser
# Sinon on ignore cette ligne
if grep -A1 "^${LINE}" "$TMP_EVENT_FILE" | grep -v "$LINE" | awk '{print $2}' | grep -q "^[0-9]";then
PACKAGE_NAME=$(echo "$LINE" | awk '{print $2}' | sed 's/-[0-9].*//g')

# If package name starts with '@', ignore it as it's a group
if echo "$PACKAGE_NAME" | grep -q "^@";then
continue
fi

PACKAGE_VERSION=$(grep -A1 "^${LINE}" "$TMP_EVENT_FILE" | grep -v "$LINE" | awk '{print $2}')
REPO=$(grep -A1 "^${LINE}" "$TMP_EVENT_FILE" | grep -v "$LINE" | awk '{print $3}')
PACKAGES_UPGRADED_JSON+="{\"name\":\"$PACKAGE_NAME\",\"version\":\"$PACKAGE_VERSION\",\"repo\":\"$REPO\"},"
Expand All @@ -74,18 +92,36 @@ function yumHistoryParser

if echo "$LINE" | egrep -q "^ +Erase ";then
PACKAGE_NAME=$(echo "$LINE" | awk '{print $2}' | sed 's/-[0-9].*//g')

# If package name starts with '@', ignore it as it's a group
if echo "$PACKAGE_NAME" | grep -q "^@";then
continue
fi

PACKAGE_VERSION=$(echo "$LINE" | awk '{print $2}' | sed "s/$PACKAGE_NAME//g" | sed 's/^-//g')
PACKAGES_REMOVED_JSON+="{\"name\":\"$PACKAGE_NAME\",\"version\":\"$PACKAGE_VERSION\"},"
fi

if echo "$LINE" | egrep -q "^ +Downgrade ";then
PACKAGE_NAME=$(echo "$LINE" | awk '{print $2}' | sed 's/-[0-9].*//g')

# If package name starts with '@', ignore it as it's a group
if echo "$PACKAGE_NAME" | grep -q "^@";then
continue
fi

PACKAGE_VERSION=$(echo "$LINE" | awk '{print $2}' | sed "s/$PACKAGE_NAME//g" | sed 's/^-//g')
PACKAGES_DOWNGRADED_JSON+="{\"name\":\"$PACKAGE_NAME\",\"version\":\"$PACKAGE_VERSION\"},"
fi

if echo "$LINE" | egrep -q "^ +Reinstall ";then
PACKAGE_NAME=$(echo "$LINE" | awk '{print $2}' | sed 's/-[0-9].*//g')

# If package name starts with '@', ignore it as it's a group
if echo "$PACKAGE_NAME" | grep -q "^@";then
continue
fi

PACKAGE_VERSION=$(echo "$LINE" | awk '{print $2}' | sed "s/$PACKAGE_NAME//g" | sed 's/^-//g')
REPO=$(echo "$LINE" | awk '{print $3}')
PACKAGES_REINSTALLED_JSON+="{\"name\":\"$PACKAGE_NAME\",\"version\":\"$PACKAGE_VERSION\",\"repo\":\"$REPO\"},"
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.14
2.2.15

0 comments on commit 14ec2b0

Please sign in to comment.