diff --git a/setup.py b/setup.py
index 8363590..1af6a6f 100644
--- a/setup.py
+++ b/setup.py
@@ -14,7 +14,7 @@
# ,,python setup.py build_i18n -m''
# silence pyflakes, __VERSION__ is properly assigned below...
-__VERSION__ = '1.2'
+__VERSION__ = '1.3'
# for line in open('gbinstall', 'r').readlines():
# if (line.startswith('__VERSION__')):
diff --git a/software-station b/software-station
index 2a83ec6..f6288f5 100755
--- a/software-station
+++ b/software-station
@@ -37,7 +37,6 @@ import pwd
import os
from time import sleep
-
from software_station_pkg import (
search_packages,
available_package_origin,
@@ -50,7 +49,8 @@ from software_station_pkg import (
fetch_packages,
network_stat,
repo_online,
- sync_with_repository
+ sync_with_repository,
+ start_update_station
)
from software_station_xpm import xpmPackageCategory
@@ -306,6 +306,7 @@ class TableWindow(Gtk.Window):
self.pkg_statistic.set_text('Syncing statistic')
self.pkg_statistic.set_use_markup(True)
self.network = network_stat()
+ self.need_upgrade = False
if self.network == 'UP':
self.online = repo_online()
else:
@@ -314,7 +315,8 @@ class TableWindow(Gtk.Window):
if self.online is True:
msg = 'syncing with the repository'
GLib.idle_add(self.update_progress, self.progress, 0.1, msg)
- sync_with_repository()
+ if sync_with_repository() == 'UPGRADE':
+ self.need_upgrade = True
sleep(1)
msg = 'syncing available packages'
GLib.idle_add(self.update_progress, self.progress, 0.2, msg)
@@ -345,6 +347,8 @@ class TableWindow(Gtk.Window):
GLib.idle_add(self.unlock_ui)
if self.online is False:
GLib.idle_add(self.confirm_offline)
+ elif self.need_upgrade is True:
+ GLib.idle_add(self.confirm_upgrade)
def hide_window(self, button, window):
window.hide()
@@ -353,6 +357,7 @@ class TableWindow(Gtk.Window):
window = Gtk.Window()
window.set_title("Software Station")
window.connect("delete-event", Gtk.main_quit)
+ window.set_keep_above(True)
window.set_size_request(200, 80)
box1 = Gtk.VBox(homogeneous=False, spacing=0)
window.add(box1)
@@ -382,6 +387,53 @@ class TableWindow(Gtk.Window):
hBox.pack_end(close_button, False, False, 5)
window.show_all()
+ def start_upgrade(self, button):
+ start_update_station()
+ Gtk.main_quit()
+
+ def confirm_upgrade(self):
+ window = Gtk.Window()
+ window.set_title("Upgrade Needed")
+ window.connect("delete-event", Gtk.main_quit)
+ window.set_keep_above(True)
+ window.set_size_request(200, 80)
+ vBox = Gtk.VBox(homogeneous=False, spacing=0)
+ window.add(vBox)
+ vBox.show()
+ hBox = Gtk.HBox(homogeneous=False, spacing=0)
+ hBox.show()
+ vBox.pack_start(hBox, False, False, 10)
+ title = "Warning this system need to be upgraded!"
+ title_label = Gtk.Label(label=title)
+ title_label.set_use_markup(True)
+ title_label.set_justify(Gtk.Justification.CENTER)
+ hBox.pack_start(title_label, True, True, 10)
+ hBox = Gtk.HBox(homogeneous=False, spacing=0)
+ hBox.show()
+ vBox.pack_start(hBox, False, False, 5)
+ msg = "Installing software without upgrading could harm this installation.\n" \
+ "Would you like to upgrade now?"
+ msg_label = Gtk.Label(label=msg)
+ hBox.pack_start(msg_label, True, True, 20)
+ hBox = Gtk.HBox(homogeneous=False, spacing=0)
+ hBox.show()
+ vBox.pack_end(hBox, False, False, 5)
+ offline_button = Gtk.Button()
+ offline_button.set_label("Yes")
+ apply_img = Gtk.Image()
+ apply_img.set_from_icon_name('gtk-yes', 1)
+ offline_button.set_image(apply_img)
+ offline_button.connect("clicked", self.start_upgrade)
+ hBox.pack_end(offline_button, False, False, 5)
+ close_button = Gtk.Button()
+ close_button.set_label("No")
+ apply_img = Gtk.Image()
+ apply_img.set_from_icon_name('gtk-no', 1)
+ close_button.set_image(apply_img)
+ close_button.connect("clicked", self.hide_window, window)
+ hBox.pack_end(close_button, False, False, 5)
+ window.show_all()
+
def unlock_ui(self):
self.origin_treeview.set_sensitive(True)
self.pkgtreeview.set_sensitive(True)
diff --git a/software_station_pkg.py b/software_station_pkg.py
index e62dc06..9ae51ad 100644
--- a/software_station_pkg.py
+++ b/software_station_pkg.py
@@ -33,9 +33,26 @@ def repo_online():
def sync_with_repository():
- cmd = "pkg update -f"
- pkg_out = run(cmd, shell=True)
- return True if pkg_out.returncode == 0 else False
+ cmd = "yes | pkg update -f"
+ pkg_out = run(
+ cmd,
+ shell=True,
+ stdout=PIPE,
+ universal_newlines=True,
+ encoding='utf-8'
+ )
+ if pkg_out.returncode == 0:
+ if 'Newer FreeBSD version' in pkg_out.stdout:
+ return 'UPGRADE'
+ return 'SYNCED'
+ else:
+ return 'FAILLED'
+
+
+def start_update_station():
+ cmd = "update-station check-now"
+ update_station = Popen(cmd, shell=True)
+ return True if update_station.returncode == 0 else False
def available_package_origin():