Skip to content

Simplify the backend of update-station to match pkg new behavior#61

Closed
ericbsd wants to merge 2 commits intomasterfrom
29-update-october-26-2023-loops-itself
Closed

Simplify the backend of update-station to match pkg new behavior#61
ericbsd wants to merge 2 commits intomasterfrom
29-update-october-26-2023-loops-itself

Conversation

@ericbsd
Copy link
Member

@ericbsd ericbsd commented Feb 2, 2025

Now that pkg has a better support for upgrading packages with base. I have cleanup the code that was forcing reinstall, replace pkg-static by pkg. this should take care of the loop issue.

Also took time to clean some deprecated GTK code.

Summary by Sourcery

Update the backend to use pkg instead of pkg-static for package management. This simplifies the upgrade process and resolves a loop issue. Also, remove some deprecated GTK code.

Bug Fixes:

  • Fix a loop issue during upgrades

Enhancements:

  • Switch from pkg-static to pkg for package management

Now that pkg has a better support for upgrading packages with base. I have cleanup the code that was forcing reinstall, replace pkg-static by pkg. this should take care of the loop issue.

Also took time to clean some deprecated GTK code.
@ericbsd ericbsd self-assigned this Feb 2, 2025
@ericbsd ericbsd requested review from a team as code owners February 2, 2025 00:09
@ericbsd ericbsd linked an issue Feb 2, 2025 that may be closed by this pull request
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 2, 2025

Reviewer's Guide by Sourcery

This pull request simplifies the backend of the update-station to align with the new behavior of pkg, which now handles upgrades with base more effectively. This change removes the need to force re-installation of packages and replaces pkg-static with pkg. Additionally, some deprecated GTK code was cleaned up.

Sequence diagram for simplified package update process

sequenceDiagram
    participant User
    participant UpdateStation
    participant pkg

    User->>UpdateStation: Check for updates
    UpdateStation->>pkg: update local pkg database
    pkg-->>UpdateStation: database updated
    UpdateStation->>pkg: pkg upgrade -n
    pkg-->>UpdateStation: list of packages to update
    UpdateStation->>User: Show update dialog
    User->>UpdateStation: Confirm update
    UpdateStation->>pkg: pkg upgrade -Fy
    pkg-->>UpdateStation: packages downloaded
    UpdateStation->>pkg: pkg upgrade -y
    pkg-->>UpdateStation: packages installed
    UpdateStation->>User: Update complete
Loading

Class diagram showing changes to Data class

classDiagram
    class Data {
        +str current_abi
        +bool do_not_upgrade
        +str home
        -bool kernel_upgrade
        +bool major_upgrade
        +str new_abi
        +dict packages_dictionary
        +bool second_update
        +bool stop_pkg_refreshing
        +object system_tray
        -int total_packages
        +bool update_started
        +str username
        +bool system_upgrade
    }
    note for Data "Removed: kernel_upgrade, total_packages
Added: system_upgrade"
Loading

Class diagram showing changes to package upgrade data structure

classDiagram
    class PackageUpgradeData {
        +bool system_upgrade
        +list remove
        +int number_to_remove
        +list upgrade
        +int number_to_upgrade
        +list install
        +int number_to_install
        +list reinstall
        +int number_to_reinstall
        +int total_of_packages
    }
    note for PackageUpgradeData "Added count fields and
total_of_packages for better
tracking of package operations"
Loading

File-Level Changes

Change Details Files
Removed the function to get packages to reinstall.
  • Removed the get_packages_to_reinstall function.
  • Removed the reading of the pkg_to_reinstall file.
update_station/backend.py
Modified the check for update function.
  • Removed the call to kernel_version_change function.
  • Added a call to update_local_pkg_database function.
  • Removed the check for REINSTALLED and REMOVED in the pkg upgrade output.
update_station/backend.py
Modified the function to get the pkg upgrade data.
  • Removed the option parameter.
  • Removed the logic to add the f option to the pkg upgrade command.
  • Added logic to set Data.system_upgrade to True if kernel-generic is in the pkg upgrade output.
  • Added the number of packages to remove, upgrade, install and reinstall to the dictionary.
  • Added the total number of packages to the dictionary.
update_station/backend.py
Modified the function to check if the kernel version has changed.
  • Renamed the kernel_version_change function to update_local_pkg_database.
  • Removed the logic to check if the kernel version has changed.
  • The function now only updates the local pkg database.
update_station/backend.py
Removed the functions to lock and unlock packages.
  • Removed the lock_pkg function.
  • Removed the unlock_all_pkg function.
  • Removed the unlock_pkg function.
update_station/backend.py
Removed the functions related to the pkg base upgrade.
  • Removed the find_if_os_generic_exists function.
  • Removed the set_package_base_config_file function.
  • Removed the remove_os_generic function.
  • Removed the install_ghostbsd_pkgbase function.
  • Removed the fetch_ghostbsd_pkgbase function.
  • Removed the restore_vital_files function.
  • Removed the remove_package_config function.
update_station/backend.py
Modified the frontend to use Gtk.Box instead of Gtk.VBox and Gtk.HBox.
  • Replaced Gtk.VBox with Gtk.Box with orientation=Gtk.Orientation.VERTICAL.
  • Replaced Gtk.HBox with Gtk.Box with orientation=Gtk.Orientation.HORIZONTAL.
update_station/frontend.py
Modified the store function to use the new dictionary keys.
  • The store function now uses the number_to_remove, number_to_upgrade, number_to_install and number_to_reinstall keys from the Data.packages_dictionary.
  • Removed the r_num, u_num, i_num and ri_num variables.
  • Removed the Data.total_packages variable.
update_station/frontend.py
Modified the install update window to use the new dictionary keys.
  • The read_output function now uses the total_of_packages key from the Data.packages_dictionary to calculate the progress bar fraction.
  • The read_output function now uses pkg upgrade instead of pkg-static upgrade.
  • Removed the logic to reinstall packages depending on the kernel.
update_station/frontend.py
Modified the data class.
  • Renamed kernel_upgrade to system_upgrade.
  • Removed the total_packages variable.
update_station/data.py
Modified the setup file.
  • Removed the pkg_to_reinstall file from the data files.
setup.py
Modified the notification message.
  • The notification message now uses Data.system_upgrade instead of Data.kernel_upgrade.
update_station/notification.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ericbsd - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ericbsd ericbsd marked this pull request as draft February 2, 2025 00:13
@ericbsd ericbsd closed this Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

update October 26 2023 loops itself

1 participant