diff --git a/README.md b/README.md index fb2d7b8..bb774d3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # melawy-branding -Logo, logo in KDE Infocenter (About), liveuser avatar +Logo, logo in KDE Infocenter (About), liveuser avatar, lsb-release, os-release ### Donate [Tinkoff](https://www.tinkoff.ru/rm/fadeeva.valeriya96/9bLRi79066) diff --git a/usr/bin/melawy-hooks-runner b/usr/bin/melawy-hooks-runner new file mode 100755 index 0000000..a426eb4 --- /dev/null +++ b/usr/bin/melawy-hooks-runner @@ -0,0 +1,74 @@ +#!/bin/bash + +# Run melawy hooks related commands. + +Lsb_release() { + local file=/etc/lsb-release + + if [ -z "$(grep "^DISTRIB_CODENAME=" $file)" ] ; then + # add missing DISTRIB_CODENAME= + echo "DISTRIB_CODENAME=${quote}rolling${quote}" >> $file + fi + sed -i $file \ + -e "s|^DISTRIB_ID=.*|DISTRIB_ID=${quote}MelawyLinux${quote}|" \ + -e "s|^DISTRIB_CODENAME=.*|DISTRIB_CODENAME=${quote}rolling${quote}|" \ + -e "s|^DISTRIB_DESCRIPTION=.*|DISTRIB_DESCRIPTION=${quote}Melawy Linux${quote}|" \ + -e "s|^DISTRIB_RELEASE=\"\(.*\)\"|DISTRIB_RELEASE=${quote}\1${quote}|" +} + +Os_release() { + local file=/usr/lib/os-release + local melawyfile=/etc/melawy-linux-release + + # Get URLs from the EndeavourOS web site! + local home=https://melawy.ru/ + local doc=https://melawy.ru/ + local support=https://melawy.ru/ + local bugs=https://melawy.ru/ + local privacy=https://melawy.ru/ + + sed -i $file \ + -e "s|^NAME=.*|NAME=${quote}Melawy Linux${quote}|" \ + -e "s|^PRETTY_NAME=.*|PRETTY_NAME=${quote}Melawy Linux${quote}|" \ + -e "s|^HOME_URL=.*|HOME_URL=${quote}$home${quote}|" \ + -e "s|^DOCUMENTATION_URL=.*|DOCUMENTATION_URL=${quote}$doc${quote}|" \ + -e "s|^SUPPORT_URL=.*|SUPPORT_URL=${quote}$support${quote}|" \ + -e "s|^BUG_REPORT_URL=.*|BUG_REPORT_URL=${quote}$bugs${quote}|" \ + -e "s|^LOGO=.*|LOGO=${quote}MelawyLinux${quote}|" \ + -e "s|^ID=.*|ID=${quote}MelawyLinux${quote}|" \ + -e "s|^ID_LIKE=.*|ID_LIKE=${quote}arch${quote}|" \ + -e "s|^PRIVACY_POLICY_URL=.*|PRIVACY_POLICY_URL=${quote}$privacy${quote}|" \ + -e "s|^ANSI_COLOR=\"\(.*\)\"|ANSI_COLOR=${quote}\1${quote}|" + + if [ -z "$(grep "^ID_LIKE=" $file)" ] && [ -n "$(grep "^ID=" $file)" ] ; then + # add missing ID_LIKE= + sed -i $file -e "/^ID=/a \ID_LIKE=${quote}arch${quote}" + fi + if [ -r $melawyfile ] ; then + # fix BUILD_ID for Melawy Linux + local buildid="$(grep "^VERSION=" $melawyfile | awk '{print $1}' | cut -d '=' -f 2)" + sed -i $file -e "s|^BUILD_ID=.*|BUILD_ID=${quote}$buildid${quote}|" + fi +} + +Issues() { + sed -i 's|Arch|Melawy Linux|g' /etc/issue /usr/share/factory/etc/issue +} + +Main() +{ + local hookname="$1" + local quote="'" + quote='\"' + + case "$hookname" in + os-release) Os_release ;; + lsb-release) Lsb_release ;; + "") Os_release + Lsb_release + Issues + ;; + esac +} + +Main "$@" diff --git a/usr/share/libalpm/hooks/melawy-hooks.hook b/usr/share/libalpm/hooks/melawy-hooks.hook new file mode 100644 index 0000000..bf3a08e --- /dev/null +++ b/usr/share/libalpm/hooks/melawy-hooks.hook @@ -0,0 +1,10 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Type = Package +Target = melawy-hooks + +[Action] +Description = Update Melawy Linux specific hooks. +When = PostTransaction +Exec = /usr/bin/melawy-hooks-runner diff --git a/usr/share/libalpm/hooks/melawy-lsb-release.hook b/usr/share/libalpm/hooks/melawy-lsb-release.hook new file mode 100644 index 0000000..4cd7a24 --- /dev/null +++ b/usr/share/libalpm/hooks/melawy-lsb-release.hook @@ -0,0 +1,10 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Type = Package +Target = lsb-release + +[Action] +Description = Add Melawy Linux specific config. +When = PostTransaction +Exec = /usr/bin/melawy-hooks-runner lsb-release diff --git a/usr/share/libalpm/hooks/melawy-os-release.hook b/usr/share/libalpm/hooks/melawy-os-release.hook new file mode 100644 index 0000000..b373167 --- /dev/null +++ b/usr/share/libalpm/hooks/melawy-os-release.hook @@ -0,0 +1,10 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Type = Package +Target = filesystem + +[Action] +Description = Add Melawy Linux specific config. +When = PostTransaction +Exec = /usr/bin/melawy-hooks-runner os-release