diff options
-rw-r--r-- | .SRCINFO | 37 | ||||
-rw-r--r-- | PKGBUILD | 53 | ||||
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | croco-hooks.sh | 97 | ||||
-rw-r--r-- | foreign.hook | 11 | ||||
-rw-r--r-- | grub-fix-initrd-generation | 160 | ||||
-rw-r--r-- | grub-fix-initrd-generation.hook | 14 | ||||
-rw-r--r-- | issue.hook | 10 | ||||
-rw-r--r-- | just-reboot.hook | 19 | ||||
-rw-r--r-- | lsb-release.hook | 10 | ||||
-rw-r--r-- | mkinitcpio-grub-update.hook | 21 | ||||
-rw-r--r-- | nsswitch.hook | 10 | ||||
-rw-r--r-- | orphans.hook | 12 | ||||
-rw-r--r-- | os-release.hook | 10 | ||||
-rw-r--r-- | pacnew-check.hook | 12 |
15 files changed, 479 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..6e75fea4186c --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,37 @@ +pkgbase = croco-hooks + pkgdesc = additions and enhancements to croco. + pkgver = 0.0.1 + pkgrel = 30 + install = croco-hooks.sh + arch = any + license = GPL + depends = pacman + depends = pacman-contrib + depends = chaotic-mirrorlist + depends = nss-mdns + depends = rebuild-detector + source = just-reboot.hook + source = mkinitcpio-grub-update.hook + source = lsb-release.hook + source = os-release.hook + source = orphans.hook + source = pacnew-check.hook + source = foreign.hook + source = issue.hook + source = nsswitch.hook + source = grub-fix-initrd-generation.hook + source = grub-fix-initrd-generation + md5sums = d1c93d328cd5f3a0791390a66d62ca55 + md5sums = d48b7bf271c8cb8a37f4c13777aae09e + md5sums = d94e41ee0b47a1a864abe23468773b6d + md5sums = 857cd16880445e022a911463e1b4b76d + md5sums = f7aef70544b2f4ce5423de2c77a57232 + md5sums = e5274c70d324eb139960f3a6e8e99a19 + md5sums = e0f95c27949d32c8e05bc2d5b07605a6 + md5sums = b554d500e01b768fe2f07f97ea91930b + md5sums = 3d67e3587221018eacc5d04a0eb464eb + md5sums = cc5954d4d78e8289bc1990b0aaaf3157 + md5sums = 865891564d21ac40db26f22a56bf68df + +pkgname = croco-hooks + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..a5fc79e3ef5b --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,53 @@ +# Maintainer: GiacoLenzo2109 <GiacoLenzo2109@gmail.com> +# Contributor: Librewish <librewish@garudalinux.in> + +pkgname=croco-hooks +pkgdesc="additions and enhancements to croco." +pkgver=0.0.1 +pkgrel=30 +arch=('any') +license=('GPL') +depends=('pacman' 'pacman-contrib' 'chaotic-mirrorlist' 'nss-mdns' 'rebuild-detector') +install=croco-hooks.sh +source=(just-reboot.hook +mkinitcpio-grub-update.hook +lsb-release.hook +os-release.hook +orphans.hook +pacnew-check.hook +foreign.hook +issue.hook +nsswitch.hook +grub-fix-initrd-generation.hook +grub-fix-initrd-generation +) +md5sums=('d1c93d328cd5f3a0791390a66d62ca55' + 'd48b7bf271c8cb8a37f4c13777aae09e' + 'd94e41ee0b47a1a864abe23468773b6d' + '857cd16880445e022a911463e1b4b76d' + 'f7aef70544b2f4ce5423de2c77a57232' + 'e5274c70d324eb139960f3a6e8e99a19' + 'e0f95c27949d32c8e05bc2d5b07605a6' + 'b554d500e01b768fe2f07f97ea91930b' + '3d67e3587221018eacc5d04a0eb464eb' + 'cc5954d4d78e8289bc1990b0aaaf3157' + '865891564d21ac40db26f22a56bf68df') + +package() { + cd $srcdir + + install -d $pkgdir/etc/pacman.d/hooks + install -Dm644 just-reboot.hook $pkgdir/etc/pacman.d/hooks/just-reboot.hook + install -Dm644 mkinitcpio-grub-update.hook $pkgdir/etc/pacman.d/hooks/mkinitcpio-grub-update.hook + install -Dm644 lsb-release.hook $pkgdir/etc/pacman.d/hooks/lsb-release.hook + install -Dm644 os-release.hook $pkgdir/etc/pacman.d/hooks/os-release.hook + install -Dm644 orphans.hook $pkgdir/etc/pacman.d/hooks/orphans.hook + install -Dm644 pacnew-check.hook $pkgdir/etc/pacman.d/hooks/pacnew-check.hook + install -Dm644 foreign.hook $pkgdir/etc/pacman.d/hooks/foreign.hook + install -Dm644 issue.hook $pkgdir/etc/pacman.d/hooks/issue.hook + install -Dm644 nsswitch.hook $pkgdir/etc/pacman.d/hooks/nsswitch.hook + install -Dm644 grub-fix-initrd-generation.hook $pkgdir/etc/pacman.d/hooks/grub-fix-initrd-generation.hook + + install -d $pkgdir/usr/bin + install -Dm755 grub-fix-initrd-generation $pkgdir/usr/bin/grub-fix-initrd-generation +} diff --git a/README.md b/README.md new file mode 100644 index 000000000000..cd8ceb1a210d --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# croco-hooks + +PKGBUILD for croco-hooks diff --git a/croco-hooks.sh b/croco-hooks.sh new file mode 100644 index 000000000000..38a1eeb8887d --- /dev/null +++ b/croco-hooks.sh @@ -0,0 +1,97 @@ +# Run croco hooks related commands. + +Lsb_release() { + sed -i /etc/lsb-release \ + -e 's,DISTRIB_ID=.*,DISTRIB_ID=Croco,' \ + -e 's,DISTRIB_RELEASE=.*,DISTRIB_RELEASE=Soaring,' \ + -e 's,DISTRIB_DESCRIPTION=.*,DISTRIB_DESCRIPTION=\"Croco OS\",' + +} + +Os_release() { + sed -i /usr/lib/os-release \ + -e 's,NAME=.*,NAME=\"Croco OS\",' \ + -e 's,PRETTY_NAME=.*,PRETTY_NAME=\"Croco OS\",' \ + -e 's,ID=.*,ID=croco,' \ + -e 's,ID_LIKE=.*,ID_LIKE=arch,' \ + -e 's,BUILD_ID=.*,BUILD_ID=rolling,' \ + -e 's,HOME_URL=.*,HOME_URL=\"https://crocolinux.org/\",' \ + -e 's,DOCUMENTATION_URL=.*,DOCUMENTATION_URL=\"https://wiki.crocolinux.org/\",' \ + -e 's,SUPPORT_URL=.*,SUPPORT_URL=\"https://forum.crocolinux.org/\",' \ + -e 's,BUG_REPORT_URL=.*,BUG_REPORT_URL=\"https://gitlab.com/groups/croco-os/\",' \ + -e 's,LOGO=.*,LOGO=crocolinux,' +} + +Issues() { + sed -i 's|Arch|Croco|g' /etc/issue /usr/share/factory/etc/issue +} + +Fix_nsswitch() { + sed -i 's|systemd||g' /etc/nsswitch.conf && sed -i 's|hosts:.*|hosts: files mymachines myhostname mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns wins|g' /etc/nsswitch.conf +} + +Fix_pacman() { + sed -i 's|Server = http://lonewolf-builder.duckdns.org/$repo/x86_64|Include = /etc/pacman.d/chaotic-mirrorlist|g' /etc/pacman.conf + sed -i 's|Server = http://chaotic.bangl.de/$repo/x86_64||g' /etc/pacman.conf + sed -i 's|Server = https://repo.kitsuna.net/x86_64||g' /etc/pacman.conf + sed -i 's|Server = http://lonewolf-ipfs.pedrohlc.com/$repo/x86_64||g' /etc/pacman.conf + sed -i 's|Server = https://chaotic.tn.dedyn.io/x86_64||g' /etc/pacman.conf +} + +Grub-btrfs() { + sed -i /etc/default/grub-btrfs/config \ + -e 's,.*GRUB_BTRFS_SUBMENUNAME=.*,GRUB_BTRFS_SUBMENUNAME=\"Croco OS snapshots\",' + sed -i /usr/lib/systemd/system/grub-btrfs.path \ + -e 's,.*PathModified=.*,PathModified=/run/timeshift/backup/timeshift-btrfs/snapshots,' +} +Pamac-fix() { +zcat /usr/share/app-info/xmls/community.xml.gz | sed 's|<em>||g;s|<\/em>||g;' | gzip > "new.xml.gz" + cp new.xml.gz /usr/share/app-info/xmls/community.xml.gz + appstreamcli refresh-cache --force +} + +os-prober_fix() { +/usr/bin/grub-fix-initrd-generation +} + +nohang_fix() { + sed -i 's|zram_checking_enabled = False|zram_checking_enabled = True|g' /etc/nohang/nohang-desktop.conf +} + +timeshift_fix() { +sed -i 's|"btrfs_mode" : "false",|"btrfs_mode" : "true",|g' /etc/timeshift/default.json +} + + +limits_fix() { +sed -i /etc/systemd/system.conf \ + -e 's,.*DefaultLimitNOFILE=.*,DefaultLimitNOFILE=1048576,' \ + -e 's,.*DefaultTimeoutStopSec=.*,DefaultTimeoutStopSec=30s,' + +sed -i /etc/systemd/user.conf \ + -e 's,.*DefaultLimitNOFILE=.*,DefaultLimitNOFILE=1048576,' \ + -e 's,.*DefaultTimeoutStopSec=.*,DefaultTimeoutStopSec=30s,' +} + +btrfs_commit_fix() { +sed -i 's|,commit=120||g' /etc/fstab +} + +post_install() { +post_upgrade +} + +post_upgrade() { +Lsb_release +Os_release +Issues +Fix_nsswitch +Fix_pacman +Grub-btrfs +Pamac-fix +os-prober_fix +nohang_fix +timeshift_fix +limits_fix +btrfs_commit_fix +} diff --git a/foreign.hook b/foreign.hook new file mode 100644 index 000000000000..8d9112ca6392 --- /dev/null +++ b/foreign.hook @@ -0,0 +1,11 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Operation = Remove +Type = Package +Target = * + +[Action] +Description = Foreign/AUR package notification +When = PostTransaction +Exec = /usr/bin/bash -c "/usr/bin/pacman -Qm || /usr/bin/echo '=> No foreign/AUR packages found.'" diff --git a/grub-fix-initrd-generation b/grub-fix-initrd-generation new file mode 100644 index 000000000000..db9e7e27b176 --- /dev/null +++ b/grub-fix-initrd-generation @@ -0,0 +1,160 @@ +#!/bin/bash +# +# A workaround for grub-mkconfig's initrd line generation problem on some distros. +# This modifies two files, see their names (in "local file=...") in the functions below. +# +# NOTE: to restore old behavior, simply reinstall packages 'grub' and 'os-prober'. + +_log2() { + echo "$@" >&2 +} + +_logfile() { + echo "$@" >> $log +} + +_log() { + _log2 "$@" + _logfile "$@" +} + +_die() { + _log "Error: $@" + rm -f $lock + exit 1 +} + +_check_file_existence() { + local file="$1" + local pkg="$2" + if [ ! -r "$file" ] ; then + case "$pkg" in + grub) + _die "file '$file' from package '$pkg' does not exist." \ + "Note: if you have used grub-customizer, you may need to reinstall grub, but be careful!" + ;; + os-prober) + _die "file '$file' from package '$pkg' does not exist." + ;; + esac + fi +} + +_backup() { + local file="$1" + local pkg="$2" + _check_file_existence "$file" "$pkg" + rm -f $file.bak || _die "$file.bak: delete failed." + cp -a $file $file.bak || _die "$file: backup failed." + chmod -x $file.bak || _die "$file.bak: chmod failed." +} + +_show_result() { + local file="$1" + local diffs="$(diff $file $file.bak)" + + if [ "$diffs" != "" ] ; then + changed=yes + _logfile "$prompt: Changes for $file:" + _logfile "$diffs" + _logfile "$prompt: Backup to $file.bak." + _log2 "$prompt: $file changed. See file $log." + else + _logfile "$prompt: $file not changed." + fi +} + +_grub_mod1() { + local file=/etc/grub.d/30_os-prober # from package 'grub' + _backup $file grub + sed -i $file \ + -e "s|\(echo \${LINUX} \| cut -d ':' -f 5\)\`|\1 \| tr '^' ' '\`|" + _show_result $file +} + +_grub_mod2() { + local file=/etc/grub.d/10_linux # from package 'grub' + _backup $file grub + sed -i $file \ + -e "s|s, with OS |s, on |" \ + -e 's|"Loading OS |"Loading kernel |' \ + -e 's|^ OS="${GRUB_DISTRIBUTOR} OS"$| OS="${GRUB_DISTRIBUTOR}"|' + _show_result $file +} + +_grub_mod3() { + # Make sure GRUB_DISTRIBUTOR is taken from /etc/lsb-release:DISTRIB_ID. + + local lsb=/etc/lsb-release + test -r $lsb || { + _log "$warning: package lsb-release is not installed." + return + } + local name="$(grep "^DISTRIB_ID=" $lsb | cut -d '=' -f 2 | tr -d '"' | tr -d "'")" + test -n "$name" || { + _log "$warning: $lsb does not contain a value for DISTRIB_ID." + return + } + local file=/etc/default/grub # from package 'grub' + + _backup $file grub + if [ -n "$(grep "^GRUB_DISTRIBUTOR=" $file)" ] ; then + sed -i $file -e "s|^GRUB_DISTRIBUTOR=.*|GRUB_DISTRIBUTOR=\"$name\"|" + else + echo "GRUB_DISTRIBUTOR=\"$name\"" >> $file + fi + _show_result $file +} + +_grub_mods() { + _grub_mod1 # this is related to _os_prober_mod ! + _grub_mod2 + _grub_mod3 +} + +_os_prober_mod() { + if [ -x /usr/bin/os-prober ] ; then + local file=/usr/lib/linux-boot-probes/mounted/40grub2 # from package 'os-prober' + _backup $file os-prober + sed -i $file \ + -e 's|initrd="\$(echo "\$2"|shift; initrd="\$(echo "\$\@"|' \ + -e 's|initrd="/boot\$initrd"|initrd=($initrd); initrd=\${initrd[@]/#//boot}|' + _show_result $file + fi +} + +Main() { + local in_pkg=grub-tools + local progname=grub-fix-initrd-generation + local lock=/var/log/$progname.lck + local log=/var/log/$progname.log + local prompt="===> INFO" + local warning="===> WARNING" + local changed=no + + if [ -r $lock ] ; then + _log2 "$progname is already running!" + return + fi + if [ $EUID -ne 0 ] ; then + _log2 "Elevated privileges required!" + return 1 + fi + touch $lock + + rm -f $log + + _log2 "$prompt: $in_pkg / $progname:" + _grub_mods + _os_prober_mod + + rm -f $lock + + if [ "$changed" = "yes" ] ; then + /usr/bin/grub-mkconfig -o /boot/grub/grub.cfg + else + _log2 "No changes." + fi +} + +Main "$@" diff --git a/grub-fix-initrd-generation.hook b/grub-fix-initrd-generation.hook new file mode 100644 index 000000000000..8ca6bf0fe115 --- /dev/null +++ b/grub-fix-initrd-generation.hook @@ -0,0 +1,14 @@ +[Trigger] +Operation = Upgrade +Operation = Install +Operation = Remove +Type = Package +Target = grub +Target = os-prober + +[Action] +Description = Fix 'grub' and 'os-prober' after upgrading either of them. +When = PostTransaction +Depends = grub +Depends = os-prober +Exec = /usr/bin/grub-fix-initrd-generation diff --git a/issue.hook b/issue.hook new file mode 100644 index 000000000000..4129354e094d --- /dev/null +++ b/issue.hook @@ -0,0 +1,10 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Type = Package +Target = filesystem + +[Action] +Description = Add Croco specifc config. +When = PostTransaction +Exec = /bin/sh -c "sed -i 's|Arch|Croco|g' /etc/issue /usr/share/factory/etc/issue" diff --git a/just-reboot.hook b/just-reboot.hook new file mode 100644 index 000000000000..ff4b8c40c4f8 --- /dev/null +++ b/just-reboot.hook @@ -0,0 +1,19 @@ +#/etc/pacman.d/hooks/just-reboot.hook + +#2018.07.17 +# +#--if vital pkgs are changed, +#--then suggests to reboot + +[Trigger] +Operation = Upgrade +Operation = Install +Operation = Remove +Type = Package +Target = linux* +Target = systemd* + +[Action] +Description = Checking for kernel changes... +When = PostTransaction +Exec = /usr/bin/notify-send "Vital OS packages are changed.\nReboot is recommended." diff --git a/lsb-release.hook b/lsb-release.hook new file mode 100644 index 000000000000..f98fd9d63428 --- /dev/null +++ b/lsb-release.hook @@ -0,0 +1,10 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Type = Package +Target = lsb-release + +[Action] +Description = Add Croco OS specifc config. +When = PostTransaction +Exec = /bin/sh -c "sed -i -e 's,DISTRIB_ID=.*,DISTRIB_ID=Croco,' -e 's,DISTRIB_RELEASE=.*,DISTRIB_RELEASE=14.12,' -e 's,DISTRIB_DESCRIPTION=.*,DISTRIB_DESCRIPTION=\"Croco OS\",' /etc/lsb-release" diff --git a/mkinitcpio-grub-update.hook b/mkinitcpio-grub-update.hook new file mode 100644 index 000000000000..0f76c21f59c4 --- /dev/null +++ b/mkinitcpio-grub-update.hook @@ -0,0 +1,21 @@ +[Trigger] +Operation = Install +Operation = Remove +Operation = Upgrade +Type = Package +Target = linux* +Target = linux-lts +Target = linux-zen +Target = linux-hardened +Target = amd-ucode +Target = intel-ucode +Target = usr/lib/modules/*/vmlinuz +Target = boot/vmlinuz* +Target = *dkms* +Target = nvidia-dkms + +[Action] +Description = mkinitcpio and grub update after transaction. +When = PostTransaction +Depends = grub +Exec = /bin/sh -c "mkinitcpio -P && /usr/bin/grub-mkconfig -o /boot/grub/grub.cfg" diff --git a/nsswitch.hook b/nsswitch.hook new file mode 100644 index 000000000000..aa4c6df2e079 --- /dev/null +++ b/nsswitch.hook @@ -0,0 +1,10 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Type = Package +Target = filesystem + +[Action] +Description = Add Croco specifc config. +When = PostTransaction +Exec = /bin/sh -c "sed -i 's|systemd||g' /etc/nsswitch.conf && sed -i 's|hosts:.*|hosts: files mymachines myhostname mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns wins|g' /etc/nsswitch.conf" diff --git a/orphans.hook b/orphans.hook new file mode 100644 index 000000000000..45f2d2b2bf7e --- /dev/null +++ b/orphans.hook @@ -0,0 +1,12 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Operation = Remove +Type = Package +Target = * + +[Action] +Description = Orphaned package notification +When = PostTransaction +Exec = /usr/bin/bash -c "/usr/bin/pacman -Qtd || /usr/bin/echo '=> No orphans found.'" +#/etc/pacman.d/hooks/orphans.hook diff --git a/os-release.hook b/os-release.hook new file mode 100644 index 000000000000..36c2bdb8aace --- /dev/null +++ b/os-release.hook @@ -0,0 +1,10 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Type = Package +Target = filesystem + +[Action] +Description = Add Croco specifc config. +When = PostTransaction +Exec = /bin/sh -c "sed -i -e 's,NAME=.*,NAME=\"Croco OS\",' -e 's,PRETTY_NAME=.*,PRETTY_NAME=\"Croco OS\",' -e 's,ID=.*,ID=croco,' -e 's,ID_LIKE=.*,ID_LIKE=arch,' -e 's,BUILD_ID=.*,BUILD_ID=rolling,' -e 's,HOME_URL=.*,HOME_URL=\"https://crocoos.org/\",' -e 's,DOCUMENTATION_URL=.*,DOCUMENTATION_URL=\"https://wiki.crocoos.org/\",' -e 's,SUPPORT_URL=.*,SUPPORT_URL=\"https://forum.crocoos.org/\",' -e 's,BUG_REPORT_URL=.*,BUG_REPORT_URL=\"https://gitlab.com/groups/OS/\",' -e 's,LOGO=.*,LOGO=croco,' /usr/lib/os-release" diff --git a/pacnew-check.hook b/pacnew-check.hook new file mode 100644 index 000000000000..7704a85f487b --- /dev/null +++ b/pacnew-check.hook @@ -0,0 +1,12 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Operation = Remove +Type = Package +Target = * + +[Action] +Description = Checking for .pacnew and .pacsave files... +When = PostTransaction +Exec = /usr/bin/bash -c 'pacfiles=$(pacdiff -o); if [[ -n "$pacfiles" ]]; then echo -e "\e[1m.pac* files found:\e[0m\n$pacfiles\n\e[1mPlease check and merge\e[0m"; fi' +#/etc/pacman.d/hooks/pacnew-check.hook |