Skip to content

Commit 3f63b68

Browse files
author
Zadjad Rezai
committed
Merge branch 'add-AUR-updates'
2 parents 01ae16e + 4d1520c commit 3f63b68

File tree

3 files changed

+89
-78
lines changed

3 files changed

+89
-78
lines changed

.github/workflows/test-update.yml

+31-17
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,49 @@
22

33
name: Test LinuxUpdate
44

5-
# Controls when the action will run.
5+
# Controls when the action will run.
66
on:
7-
# Triggers the workflow on push or pull request events but only for the master branch
87
push:
9-
branches: [ master ]
8+
branches: [master]
109
pull_request:
11-
branches: [ master ]
10+
branches: [master]
1211

13-
# Allows you to run this workflow manually from the Actions tab
14-
workflow_dispatch:
15-
16-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1712
jobs:
18-
# This workflow contains a single job called "build"
19-
build:
20-
# The type of runner that the job will run on
13+
ubuntu_check:
2114
runs-on: ubuntu-latest
2215

23-
# Steps represent a sequence of tasks that will be executed as part of the job
2416
steps:
25-
2617
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2718
- uses: actions/checkout@v2
2819

29-
# Runs a single command using the runners shell
20+
- name: Install prerequisites
21+
run: |
22+
sudo apt update
23+
sudo apt install bash sudo
24+
3025
- name: Run ./LinuxUpdate.sh
3126
run: ./LinuxUpdate.sh
3227

33-
# Runs a set of commands using the runners shell
34-
- name: Done
28+
arch_check:
29+
runs-on: ubuntu-latest
30+
container:
31+
image: archlinux:latest
32+
33+
steps:
34+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
35+
- uses: actions/checkout@v2
36+
37+
# https://github.com/qutebrowser/qutebrowser/commit/478e4de7bd1f26bebdcdc166d5369b2b5142c3e2
38+
- name: Workaround glibc issue
39+
run: |
40+
patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst && \
41+
curl -LO "https://repo.archlinuxcn.org/x86_64/$patched_glibc" && \
42+
bsdtar -C / -xvf "$patched_glibc"
43+
44+
- name: Install prerequisites
3545
run: |
36-
echo Everything worked fine. :)
46+
pacman -Syyu --noconfirm
47+
pacman -S sudo reflector --noconfirm
48+
49+
- name: Run ./LinuxUpdate.sh
50+
run: ./LinuxUpdate.sh

LinuxUpdate.sh

+36-59
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -o pipefail
4+
35
RESET='\033[00m'
46
RED='\033[01;31m'
57
GREEN='\033[01;32m'
@@ -13,44 +15,31 @@ UNDERLINE='\033[4m'
1315
BASE_DISTRO=$(cat /etc/*release | grep -oP 'ID_LIKE=\K\w+')
1416
REAL_DISTRO=$(cat /etc/*release | grep -oP '^ID=\K\w+')
1517

16-
if [ "$BASE_DISTRO" = "" ]; then
18+
if [[ -z "$BASE_DISTRO" ]]; then
1719
BASE_DISTRO=$REAL_DISTRO
1820
fi
1921

2022
function update_arch_based_mirror_lists() {
21-
if [ "$REAL_DISTRO" != "arch" ]; then
22-
sudo pacman-mirrors --interactive --default
23-
else
24-
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
25-
echo "/etc/pacman.d/mirrorlist -> /etc/pacman.d/mirrorlist.backup"
26-
sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist.backup
27-
rankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist
28-
fi
23+
reflector --verbose -l 5 --sort rate --save /etc/pacman.d/mirrorlist
2924
}
3025

3126
function install_yay() {
3227
yay -Syu;
3328
if [ "$?" != 0 ]; then
34-
read -p $'\033[1m\033[01;32m::\033[00m\033[1m Install yay? (y/n) \033[00m' -n 1 -r
35-
case $REPLY in
36-
y|Y)
37-
echo -e "\n Installing yay - version 10.1.0"
38-
mkdir /tmp/yay && cd /tmp/yay
39-
curl -LJO https://github.com/Jguer/yay/releases/download/v10.1.0/yay_10.1.0_x86_64.tar.gz
40-
tar xfz yay_10.1.0_x86_64.tar.gz
41-
sudo mv yay_10.1.0_x86_64/yay /usr/local/bin/yay
42-
rm -r -f yay*
43-
yay -Syu;;
44-
n|N)
45-
echo "Okay.";;
46-
*)
47-
echo "Invalid";;
48-
esac
29+
echo -e "\033[1m\033[01;32m::\033[00m\033[1m Installing latest version of yay \033[00m"
30+
mkdir /tmp/yay && cd /tmp/yay
31+
ARCH=$(uname -m)
32+
URL=$(curl -s https://api.github.com/repos/Jguer/yay/releases/latest | grep "browser_download_url.*${ARCH}.*tar.gz" | cut -d '"' -f 4 )
33+
curl -LJ $URL -o yay.tar.gz
34+
tar xfz yay.tar.gz
35+
sudo mv yay*/yay /usr/local/bin/yay
36+
rm -r -f yay*
37+
yay -Syu
4938
fi
5039
}
5140

5241
clear
53-
echo -e "${BOLD}Hi, $(whoami), I'm updating ${CYAN}${REAL_DISTRO} ${RESET}${BOLD}for you."
42+
echo -e "${BOLD}Hi, $(whoami), I'm updating ${CYAN}${REAL_DISTRO}${BOLD} ${RESET}for you."
5443
echo -e "${RESET}Please give me sudo-rights."
5544
echo
5645

@@ -61,50 +50,38 @@ if [ "$BASE_DISTRO" = "arch" ]; then
6150

6251
echo -e "${BOLD}Populating the keyring and refreshing it.. ${RESET}"
6352
echo
64-
sudo pacman-key --populate archlinux "$REAL_DISTRO"
53+
54+
populate_keys="sudo pacman-key --populate archlinux"
55+
56+
echo $BASE_DISTRO
57+
echo $REAL_DISTRO
58+
59+
if [[ $REAL_DISTRO != "arch" ]]; then
60+
eval "$populate_keys $REAL_DISTRO"
61+
else
62+
eval $populate_keys
63+
fi
64+
6565
sudo pacman-key --refresh-keys
6666

6767
echo
68-
read -p $'\033[1m\033[01;32m::\033[00m\033[1m Do you want to update the mirrorlist? (y/n) \033[00m' -n 1 -r
68+
echo "Updating the mirrorlist (uses 'reflector').."
6969
echo
70-
case $REPLY in
71-
y|Y)
72-
echo "Updating the mirrorlist.."
73-
echo
74-
update_arch_based_mirror_lists;;
75-
n|N)
76-
echo "Okay, not updating mirrorlist.";;
77-
* ) echo "Invalid";;
78-
esac
79-
80-
sudo pacman -Syu
81-
read -p $'\033[1m\033[01;32m::\033[00m\033[1m Do you want to update AUR packages (yay needed)? (y/n) \033[00m' -n 1 -r
82-
echo
83-
case $REPLY in
84-
y|Y)
85-
install_yay;;
86-
n|N)
87-
echo "Okay, not updating via AUR packages (via yay).";;
88-
* ) echo "Invalid";;
89-
esac
70+
update_arch_based_mirror_lists;
9071
echo
9172

92-
read -p $'\033[1m\033[01;32m::\033[00m\033[1m Do you want to clear pacmans cache? (y/n) \033[00m' -n 1 -r
73+
sudo pacman -Syu --noconfirm
74+
75+
echo -e "\033[1m\033[01;32m::\033[00m\033[1m Updating AUR packages (yay will be installed, if not already there) \033[00m"
76+
install_yay;
77+
9378
echo
94-
case $REPLY in
95-
y|Y)
96-
echo -e "${RED}Removing ${NONE}old stuff from your cache.."
97-
echo
98-
sudo pacman -Sc;;
99-
n|N)
100-
echo "Okay, not clearing pacmans cache.";;
101-
* ) echo "Invalid";;
102-
esac
79+
echo -e "${RED}Removing ${NONE}old stuff from your cache.."
10380
echo
10481

10582
elif [ "$BASE_DISTRO" = "debian" ]; then
106-
sudo apt-get update
107-
sudo apt-get full-upgrade
83+
sudo apt update
84+
sudo apt -y full-upgrade
10885
else
10986
echo -e "Sorry, I don't know how to update ${BASE_DISTRO}, yet."
11087
exit 1

README.md

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# LinuxUpdate
22

3+
[![LinuxUpdate on Ubuntu & Arch](https://github.com/Xcalizorz/LinuxUpdate/actions/workflows/test-update.yml/badge.svg)](https://github.com/Xcalizorz/LinuxUpdate/actions/workflows/test-update.yml)
4+
35
This is a small bash script that can update all Arch and Debian Distros, create a new mirrorlist and delete old stuff (only arch).
4-
I didn't like typing all the code in everytime, so I created a small bash script -
6+
I didn't like typing all the code in everytime, so I created a small bash script -
57
maybe you're like me and I can help you with this :)
68
\
79
The plan is to create an easy command-line tool for (almost) all Linux Distros.
@@ -22,6 +24,24 @@ Since I just started looking at bash, it might take a little bit to upload scrip
2224

2325
## Usage
2426

27+
### Prerequisites
28+
29+
#### Arch based
30+
31+
Install the following packages, to make this script work:
32+
33+
```bash
34+
pacman -S sudo reflector
35+
```
36+
37+
#### Debian based
38+
39+
Install the following packages, to make this script work:
40+
41+
```bash
42+
apt install bash sudo
43+
```
44+
2545
### Use the cli
2646

2747
```bash
@@ -50,4 +70,4 @@ Now you have a shortcut and can start the update via double-click.
5070

5171
### Removing old stuff
5272

53-
![Removing old stuff](img/removingStuff.png)
73+
![Removing old stuff](img/removingStuff.png)

0 commit comments

Comments
 (0)