Skip to content

Commit 7f37141

Browse files
authored
Initial release
1 parent 3ee34c9 commit 7f37141

File tree

4 files changed

+186
-0
lines changed

4 files changed

+186
-0
lines changed

INSTALL

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
To install this program you need to be root and issue the following comamands.
2+
3+
mkdir /opt/google-chrome-the-latest
4+
cp google-chrome-the-latest.py /opt/google-chrome-the-latest
5+
cp google-chrome-the-latest-cron.sh /etc/cron.hourly
6+
7+
thats it!
8+
9+
Optionally you may want force the USERNAME variable at the
10+
google-chrome-the-latest-cron.sh file to your username.

README

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Maintaining an updated chrome browser on Slackware is now made
2+
easier with this small program, "google-chrome-the-latest".
3+
It is a simple python script that checks what is the latest
4+
version available and updates it on your Slackware box.
5+
6+
It does this by parsing the web-page at
7+
https://www.whatismybrowser.com/guides/the-latest-version/chrome
8+
and comparing with the chrome version currently installed.
9+
10+
Chrome is downloaded directly from Google and converted to txz
11+
using the standard rpm2txz command.
12+
13+
You can run this script manually or automatically with the
14+
provided cron.hourly script.
15+
This cron script will attempt to identify which user to notify,
16+
otherwise you can force the variable to USERNAME=’your username’
17+
18+
Normally it is asked if you want to install new version, but
19+
providing the argument "silent" will just update with no
20+
human intervention.
21+

google-chrome-the-latest-cron.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#/bin/bash
2+
3+
#**********************************************************************************
4+
#* *
5+
#* Google Chrome The Latest *
6+
#* ------------------------------------------------------------ *
7+
#* *
8+
#**********************************************************************************
9+
# Copyright 2022 Antonio Leal, Porto Salvo, Portugal
10+
# All rights reserved.
11+
#
12+
# Redistribution and use of this script, with or without modification, is
13+
# permitted provided that the following conditions are met:
14+
#
15+
# 1. Redistributions of this script must retain the above copyright
16+
# notice, this list of conditions and the following disclaimer.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
19+
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20+
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
21+
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26+
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
# $Id:$
29+
30+
31+
USERNAME="root"
32+
readarray -d " " -t strarr <<< "`users`"
33+
for (( n=0; n < ${#strarr[*]}; n++))
34+
do
35+
if [ "${strarr[n]}" != "root" ]; then
36+
USERNAME="${strarr[n]}"
37+
break
38+
fi
39+
done
40+
41+
# force your USERNAME here:
42+
# USERNAME="you username'
43+
44+
export XAUTHORITY=/home/$USERNAME/.Xauthority
45+
export DISPLAY=:0
46+
python3 /opt/google-chrome-the-latest/google-chrome-the-latest.py
47+
48+

google-chrome-the-latest.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
#**********************************************************************************
5+
#* *
6+
#* Google Chrome The Latest *
7+
#* ------------------------------------------------------------ *
8+
#* *
9+
#**********************************************************************************
10+
# Copyright 2022 Antonio Leal, Porto Salvo, Portugal
11+
# All rights reserved.
12+
#
13+
# Redistribution and use of this script, with or without modification, is
14+
# permitted provided that the following conditions are met:
15+
#
16+
# 1. Redistributions of this script must retain the above copyright
17+
# notice, this list of conditions and the following disclaimer.
18+
#
19+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
20+
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21+
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
22+
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27+
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
# $Id:$
30+
31+
import os
32+
import time
33+
import sys
34+
import xml.etree.ElementTree as ET
35+
import tkinter as tk
36+
from tkinter import messagebox
37+
38+
DOWNLOAD_LINK = 'https://dl.google.com/linux/direct'
39+
DOWNLOAD_FILE = 'google-chrome-stable_current_x86_64.rpm'
40+
TXZ_FILE = DOWNLOAD_FILE[:-3] + 'txz'
41+
LASTRUN = '/opt/google-chrome-the-latest/lastrun'
42+
43+
# Check if you are root
44+
if os.geteuid() != 0:
45+
print('You must run this script as root.')
46+
exit(0)
47+
48+
# Only run once a day, even though we set cron.hourly
49+
if os.path.exists(LASTRUN):
50+
ti_m = os.path.getmtime(LASTRUN)
51+
ti_n = time.time()
52+
if (ti_n - ti_m) < 86400:
53+
exit(0)
54+
os.system('touch %s' % LASTRUN)
55+
56+
# Check the web for latest Chrome version.
57+
# We are expecting sometning like:
58+
# xmlstr = """
59+
# <tr>
60+
# <td>Chrome on <strong>Linux</strong></td>
61+
# <td>107.0.5304.121</td>
62+
# <td>2022-11-25</td>
63+
# </tr>
64+
# """
65+
xmlstr=os.popen('curl -s https://www.whatismybrowser.com/guides/the-latest-version/chrome | grep -B 1 -A 3 "<td>Chrome on <strong>Linux</strong></td>"').read()
66+
root = ET.fromstring(xmlstr)
67+
latest_version = root[1].text.strip()
68+
69+
# Check the current installed version, if there is one...
70+
try:
71+
current_version = os.popen('google-chrome-stable --version').read().split()[2]
72+
except:
73+
current_version = 'not found'
74+
75+
# And if these versions are different upgrade...
76+
if current_version != latest_version:
77+
dialog = tk.Tk()
78+
dialog.withdraw()
79+
msg = """Hey, there is a new Google Chrome release!
80+
81+
Your version: %s
82+
New version : %s
83+
84+
Do you want to install it?""" % (current_version, latest_version)
85+
silent = False
86+
if len(sys.argv) == 2:
87+
if sys.argv[1].upper() == 'SILENT':
88+
silent = True
89+
if not silent:
90+
yesno = messagebox.askyesno(title='Chrome, the latest', message=msg)
91+
dialog.destroy()
92+
else:
93+
yesno = True
94+
if yesno:
95+
INSTALL_FILE = 'google-chrome-%s-x86_64-1.txz' % latest_version
96+
os.chdir('/tmp')
97+
os.system('rm -rf %s %s %s' % (DOWNLOAD_FILE, TXZ_FILE, INSTALL_FILE))
98+
os.system('/usr/bin/wget %s/%s' % (DOWNLOAD_LINK, DOWNLOAD_FILE))
99+
os.system('/usr/bin/rpm2txz %s' % DOWNLOAD_FILE)
100+
os.system('mv %s %s' % (TXZ_FILE, INSTALL_FILE))
101+
os.system('/sbin/upgradepkg --install-new %s' % INSTALL_FILE)
102+
os.system('rm -rf %s %s %s' % (DOWNLOAD_FILE, TXZ_FILE, INSTALL_FILE))
103+
104+
if not silent:
105+
dialog = tk.Tk()
106+
dialog.withdraw()
107+
messagebox.showinfo("Done","Google Chrome is now at version %s" % latest_version)

0 commit comments

Comments
 (0)