aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--ansible/update_adjutor.yml12
-rw-r--r--ansible/update_nginx.yml25
-rwxr-xr-xauto-void-packages/auto-build-all-orphans.sh148
-rwxr-xr-xauto-void-packages/commit-push-pr.sh19
-rwxr-xr-xauto-void-packages/update-git-repo.sh12
-rwxr-xr-xauto-void-packages/update-package.sh28
-rwxr-xr-xauto-void-packages/who-needs-update.sh4
-rwxr-xr-xbin/update-everything.sh34
-rwxr-xr-xbin/update-scripts-repo.sh5
10 files changed, 202 insertions, 86 deletions
diff --git a/.gitignore b/.gitignore
index 060ba48..9563182 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
auto-void-packages/*.txt
ansible/hosts
+auto-void-packages/auto-build
diff --git a/ansible/update_adjutor.yml b/ansible/update_adjutor.yml
deleted file mode 100644
index 2724a30..0000000
--- a/ansible/update_adjutor.yml
+++ /dev/null
@@ -1,12 +0,0 @@
----
-- name: Update the server
- hosts: vps
- become: true
- tasks:
-
- - name: Update and upgrade apt packages
- ansible.builtin.apt:
- update_cache: true
- upgrade: true
- autoremove: true
-...
diff --git a/ansible/update_nginx.yml b/ansible/update_nginx.yml
deleted file mode 100644
index 4813e6c..0000000
--- a/ansible/update_nginx.yml
+++ /dev/null
@@ -1,25 +0,0 @@
----
-- name: Update nginx if needed
- hosts: vps
- become: true
- become_user: root
- tasks:
-
- - name: Ensure nginx is at the latest version
- ansible.builtin.package:
- name: nginx
- state: latest
- notify: restart nginx
-
- - name: Ensure nginx is running
- ansible.builtin.service:
- name: nginx
- state: started
- enabled: true
-
- handlers:
- - name: Restart nginx
- ansible.builtin.service:
- name: nginx
- state: restarted
-...
diff --git a/auto-void-packages/auto-build-all-orphans.sh b/auto-void-packages/auto-build-all-orphans.sh
new file mode 100755
index 0000000..8c4c8cf
--- /dev/null
+++ b/auto-void-packages/auto-build-all-orphans.sh
@@ -0,0 +1,148 @@
+#!/usr/bin/env bash
+#
+# Clyhsuriva
+#
+# __ _______ _____
+# \ \ / /_ _| | __ \
+# \ \ /\ / / | | | |__) |
+# \ \/ \/ / | | | ___/
+# \ /\ / _| |_ _| |_
+# \/ \(_) |_____(_)_(_)
+#
+
+###
+
+# All variables must be declared.
+set -o nounset
+# Truncating existing non-empty files must be explicit,
+# so instead of `echo "text" > file` you must use `echo "text" >| file`.
+set -o noclobber
+# Avoids translation of commands messages, numeric and date format, string expansion and sorting.
+export LC_ALL=C
+# This provides a more readable output to follow when tracing with `set -x`.
+export PS4=' (${BASH_SOURCE##*/}::${FUNCNAME[0]:-main}::$LINENO) '
+
+###
+
+### VARIABLES ###
+
+typeset NORMAL=""
+typeset GREEN=""
+typeset BOLD=""
+typeset MAGENTA=""
+
+typeset -i spinner_pid
+
+typeset void_updates_url=""
+typeset void_updates_content=""
+typeset orphan_packages=""
+typeset orphan_packages_sorted=""
+typeset package=""
+
+typeset -A pkgs_to_update=()
+
+typeset -i nb_of_pkgs_to_build=0
+typeset pkgs_to_update_fp="/tmp/pkgs_to_update.txt"
+typeset pkgs_to_exclude=""
+typeset auto_build_archs_path=""
+typeset -i pkg_counter=0
+
+###
+
+### COLOURS ###
+
+NORMAL=$(tput sgr0)
+
+printf_red(){
+RED=$(tput setaf 1)
+ printf "%s%s%s\n" "$RED" "$1" "$NORMAL"
+}
+
+printf_green(){
+GREEN=$(tput setaf 2)
+BOLD=$(tput bold)
+ printf "%s%s%s%s\n" "$GREEN" "$BOLD" "$1" "$NORMAL"
+}
+
+printf_magenta(){
+MAGENTA=$(tput setaf 5)
+ printf "%s[%s]%s" "$MAGENTA" "$1" "$NORMAL"
+}
+
+### FUNCTIONS
+
+function helpy {
+ printf "command: %s [number_of_packages] [pkgs_to_exclude]\n" "$0"
+printf "number_of_packages: Must be an integer, indicates of many packages you want to auto build, defaults to none.\n"
+printf "pkgs_to_exclude: Must be one or a list of packages name separated by commas, e.g., ansible,xonsh,ampache"
+}
+
+function start_spinner {
+ set +m
+ echo -n "$1 "
+ { while : ; do for X in ' • ' ' • ' ' • ' ' • ' ' • ' ' • ' ' • ' ' • ' ' • ' ' • ' ; do echo -en "\b\b\b\b\b\b\b\b$X" ; sleep 0.1 ; done ; done & } 2>/dev/null
+ spinner_pid=$!
+}
+
+function stop_spinner {
+ { kill -9 "$spinner_pid" && wait; } 2>/dev/null
+ set -m
+ echo -en "\033[2K\r"
+}
+
+### MAIN ###
+
+void_updates_url="https://repo-fi.voidlinux.org/void-updates/void-updates.txt"
+void_updates_content=$(curl --silent "$void_updates_url")
+orphan_packages=$(echo "$void_updates_content" | sed -n '/orphan@voidlinux.org/,/@/p' | grep -v '^--' | grep -v '@')
+orphan_packages_sorted=$(echo "$orphan_packages" | awk '{ print $1 }' | sort -u)
+
+nb_of_pkgs_to_build="${1:-0}"
+pkgs_to_exclude=${2:-}
+
+start_spinner "Calculating how many orphan packages there are..."
+for package in $orphan_packages_sorted;
+do
+ # Get the last line of of the corresponding package, hence the lastest version
+ latest_pkg_line=$(echo "$orphan_packages" | grep -e "^$package " | tail -1)
+ latest_version=$(echo "$latest_pkg_line" | awk '{ print $4; }')
+ pkgs_to_update["$package"]="$latest_version"
+done
+stop_spinner
+
+# Infos
+echo -n "Number of orphan packages needing an update : " ; printf_green "${#pkgs_to_update[@]}"
+echo -n "Number of orphan packages you want to build : " ; printf_red "$nb_of_pkgs_to_build"
+echo -n "Packages you want to exclude : " ; printf_red "$pkgs_to_exclude"
+
+# Saving the content of the pkgs_to_update to a file
+[ -f $pkgs_to_update_fp ] && rm $pkgs_to_update_fp
+echo "${!pkgs_to_update[@]}" > $pkgs_to_update_fp
+
+[ $nb_of_pkgs_to_build == 0 ] && exit 1
+
+echo "Executing update-git-repo.sh"
+./update-git-repo.sh || exit 1
+
+for package in "${!pkgs_to_update[@]}"; do
+
+ # If the currently selected package is in the exclude list, continue to the next package
+ if echo "$package" | grep -q -E "^($(echo "$pkgs_to_exclude" | tr ',' '|'))"; then
+ continue
+ fi
+
+ # If we've hit the max number of packages asked by the user, break the loop
+ if [ $pkg_counter -ge $nb_of_pkgs_to_build ]; then
+ break
+ fi
+
+ latest_version="${pkgs_to_update[$package]}"
+ auto_build_archs_path="$HOME/workbench/auto-void-packages/auto-build/archs-${package}-${latest_version}.txt"
+
+ echo ">>>[$package - $latest_version]>>>"
+ ./update-package.sh "$package" "$latest_version" "$auto_build_archs_path"
+ echo "<<<[$package - $latest_version]<<<"
+
+
+ ((pkg_counter++))
+done
diff --git a/auto-void-packages/commit-push-pr.sh b/auto-void-packages/commit-push-pr.sh
index 1352c73..687adc7 100755
--- a/auto-void-packages/commit-push-pr.sh
+++ b/auto-void-packages/commit-push-pr.sh
@@ -3,31 +3,42 @@
helpy(){
-printf "command: %s <package> <version> <tested>\n" "$0"
+printf "command: %s <package> <version> <tested> [path]\n" "$0"
printf "package: package name\n"
printf "version: version update\n"
printf "tested: yes/briefly/no\n"
+printf "path (optional): path of architectures file, defaults to '\$HOME/workbench/auto-void-packages/architectures.txt'\n"
}
+###
[ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] && helpy && exit 1
PKG="$1"
VER="$2"
-TESTED="$3"
+tested="$3"
+archs_fp="${4:-$HOME/workbench/auto-void-packages/architectures.txt}"
+
+# The third variable must be yes, briefly or no
+[[ ! $tested =~ (yes|briefly|no) ]] && helpy && exit 1
+
+###
+
printf "Updating %s to %s.\n" "$PKG" "$VER"
pushd ~/workbench/void-packages || exit 1
+# git stuff
git add "srcpkgs/$PKG" && \
git commit -m "$PKG: update to $VER" && \
git push origin "$PKG-update"
-ARCHS=$(/bin/cat "$HOME/workbench/auto-void-packages/architectures.txt")
+ARCHS=$(/bin/cat "$archs_fp")
+# github stuff
gh pr create \
--title "$PKG: update to $VER" \
--body "#### Testing the changes
-- I tested the changes in this PR: **$TESTED**
+- I tested the changes in this PR: **$tested**
#### Local build testing
- I built this PR locally for my native architecture, x86_64
diff --git a/auto-void-packages/update-git-repo.sh b/auto-void-packages/update-git-repo.sh
index e71701c..9533bc9 100755
--- a/auto-void-packages/update-git-repo.sh
+++ b/auto-void-packages/update-git-repo.sh
@@ -5,19 +5,15 @@ echo_n_notify(){
}
pushd "$HOME/workbench/void-packages" || exit 1
-CHECKOUT="checkout"
-FETCH="fetch"
-MERGE="merge"
-PUSH="push"
git checkout master && \
- echo_n_notify "$CHECKOUT: ok" && \
+ echo_n_notify "checkout: ok" && \
git fetch upstream && \
- echo_n_notify "$FETCH: ok" && \
+ echo_n_notify "fetch: ok" && \
git merge upstream/master && \
- echo_n_notify "$MERGE: ok" && \
+ echo_n_notify "merge: ok" && \
git push && \
- echo_n_notify "$PUSH: ok"
+ echo_n_notify "push: ok"
./xbps-src bootstrap-update
diff --git a/auto-void-packages/update-package.sh b/auto-void-packages/update-package.sh
index 8707626..11345ef 100755
--- a/auto-void-packages/update-package.sh
+++ b/auto-void-packages/update-package.sh
@@ -3,19 +3,24 @@
helpy(){
-printf "command: %s <package> <version>\n" "$0"
+ printf "command: %s <package> <version> [path]\n" "$0"
printf "package: package name\n"
printf "version: version update\n"
+printf "path (optional): path of architectures file, defaults to '\$HOME/workbench/auto-void-packages/architectures.txt'\n"
}
[ -z "$1" ] || [ -z "$2" ] && helpy && exit 1
PKG="$1"
VER="$2"
+archs_fp="${3:-$HOME/workbench/auto-void-packages/architectures.txt}"
+template_path="srcpkgs/$PKG/template"
printf "Updating %s to %s.\n" "$PKG" "$VER"
pushd ~/workbench/void-packages || exit 1
+./xbps-src binary-bootstrap && ./xbps-src clean-repocache
+
git checkout master
git checkout -b "$PKG-update" || ( \
git checkout master &&\
@@ -23,18 +28,23 @@ git checkout -b "$PKG-update" || ( \
git checkout -b "$PKG-update" ) || \
exit 1
-sed -i "s/version=.*/version=$VER/g" "srcpkgs/$PKG/template"
-sed -i "s/revision=.*/revision=1/g" "srcpkgs/$PKG/template"
+sed -i "s/version=.*/version=$VER/g" "$template_path"
+sed -i "s/revision=.*/revision=1/g" "$template_path"
xgensum -f -i "$PKG" ; xgensum -f -i "$PKG" || exit 1
-ARCHS_FILE="$HOME/workbench/auto-void-packages/architectures.txt"
-[ -f "$ARCHS_FILE" ] && rm -v "$ARCHS_FILE"
-./xbps-src -a armv7l pkg "$PKG" && echo " - armv7l" >> "$ARCHS_FILE"
-./xbps-src -a armv6l-musl pkg "$PKG" && echo " - armv6l-musl" >> "$ARCHS_FILE"
-./xbps-src -a aarch64-musl pkg "$PKG" && echo " - aarch64-musl" >> "$ARCHS_FILE"
+xlint "$template_path" || exit 1
+
+[ -f "$archs_fp" ] && rm -v "$archs_fp"
+
+./xbps-src clean "$PKG"
+./xbps-src -a armv7l pkg "$PKG" && echo " - armv7l" >> "$archs_fp"
+./xbps-src -a armv6l-musl pkg "$PKG" && echo " - armv6l-musl" >> "$archs_fp"
+./xbps-src -a aarch64-musl pkg "$PKG" && echo " - aarch64-musl" >> "$archs_fp"
./xbps-src pkg "$PKG" || exit 1
-xi -S --repository="hostdir/binpkgs/$PKG-update" "$PKG" && $PKG --version
+./xbps-src check "$PKG" || exit 1
+
+sudo xbps-install -S --repository="hostdir/binpkgs/$PKG-update" "$PKG" && $PKG --version
popd || exit 1
diff --git a/auto-void-packages/who-needs-update.sh b/auto-void-packages/who-needs-update.sh
index e01af13..e798847 100755
--- a/auto-void-packages/who-needs-update.sh
+++ b/auto-void-packages/who-needs-update.sh
@@ -38,6 +38,10 @@ VOID_UPDATES=$(curl --silent "$VOID_UPDATES_URL")
# v for needing one
while read -r PKG;
do
+ # checks if there's a # at the beginning of the line
+ # if so, skip the current iteration
+ echo "$PKG" | grep -q '^#' && continue
+
printf_magenta "$PKG"
UPDATES=$(echo "$VOID_UPDATES" | grep -e "^$PKG ")
if [ -z "$UPDATES" ];
diff --git a/bin/update-everything.sh b/bin/update-everything.sh
index 5845b71..e69f705 100755
--- a/bin/update-everything.sh
+++ b/bin/update-everything.sh
@@ -9,7 +9,6 @@
# printf_accross_width
# local_update
# remote_update
-# non_free_update
# pip_update
# update_scripts_repo
# update_whatis_db
@@ -53,25 +52,10 @@ remote_update(){
printf_n_notify "remote update"
- ansible-playbook --inventory-file "$HOME/workbench/ansible/hosts" \
- "$HOME/workbench/ansible/update_adjutor.yml"
-
-}
-
-
-# Update non-free xbps packages
-non_free_update(){
-
- printf_n_notify "non-free update"
-
- pushd ~/workbench/auto-void-packages || exit 1
- ./update-git-repo.sh
- cd ../void-packages || exit 1
- ./xbps-src pkg discord && \
- $xi --repository=hostdir/binpkgs/nonfree discord
- ./xbps-src pkg spotify && \
- $xi --repository=hostdir/binpkgs/nonfree spotify
- popd || exit 1
+ export ANSIBLE_CONFIG="$HOME/workbench/homelab-iac/ansible/ansible.cfg"
+ ansible-playbook -v -b \
+ --inventory-file "$HOME/workbench/homelab-iac/ansible/inventory.yaml" \
+ "$HOME/workbench/homelab-iac/ansible/playbooks/update_system.yml"
}
@@ -81,9 +65,11 @@ pip_update(){
printf_n_notify "pip update"
- python3 -m pip list --outdated --format=json | \
+ "$HOME/workbench/pyvenv/bin/pip3" install --upgrade pip
+
+ "$HOME/workbench/pyvenv/bin/pip3" list --outdated --format=json | \
jq -r '.[] | "\(.name)==\(.latest_version)"' | \
- xargs -n1 pip3 install -U
+ xargs -n1 "$HOME/workbench/pyvenv/bin/pip3" install --upgrade
}
@@ -116,9 +102,7 @@ local_update
printf_accross_width "%"
remote_update
printf_accross_width "%"
-non_free_update
-printf_accross_width "%"
-#pip_update # 2023/01/09 : currently not a stable solution to update pip packages
+pip_update
printf_accross_width "%"
update_scripts_repo
printf_accross_width "%"
diff --git a/bin/update-scripts-repo.sh b/bin/update-scripts-repo.sh
index 03a20ee..22e0807 100755
--- a/bin/update-scripts-repo.sh
+++ b/bin/update-scripts-repo.sh
@@ -7,9 +7,8 @@ pushd "$SCRIPTS_REPO_PATH" || exit 1
cp -rv "$HOME/.local/usr/local/bin" .
cp -rv "$HOME/workbench/auto-void-packages" .
-cp -rv "$HOME/workbench/ansible" .
-git status | less && git diff | less
-git add . && git commit && git push -v --progress
+git status | less
+git add --patch . && git commit -v && git push -v --progress
popd || exit 1