Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

ubports-qa upgrades only the packages related to the PR/MR repo #30

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions debian/install
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
ubports-qa /usr/bin
pkginstall /usr/bin
pkgcheck /usr/bin
pkgremove /usr/bin
pkgupdate /usr/bin
ubports-qa_completion /etc/bash_completion.d
16 changes: 16 additions & 0 deletions pkgcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
branch="$1"
arch=$(dpkg --print-architecture)

case "${branch}" in
"xenial"*) repo="repo.ubports.com";;
*) repo="repo2.ubports.com";;
esac

while read pkg
do
status=$(apt-cache policy $pkg|awk '/Installed/{print $2}')
if [[ -n "${status}" && "$status" != "(none)" ]]; then
echo -n "${pkg} "
fi
done < <(awk '/Package/{print $2}' /var/lib/apt/lists/${repo}_dists_${branch//_/%5f}_main_binary-${arch}_Packages|uniq)
4 changes: 4 additions & 0 deletions pkginstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
branch="$1"
pkgs=$(pkgcheck "$branch")
apt-get install $pkgs
5 changes: 5 additions & 0 deletions pkgremove
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
branch="$1"
pkgs=$(pkgcheck "${branch}")
apt-get update
apt-get install $pkgs
Copy link
Member

Choose a reason for hiding this comment

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

This should be remove, I guess?

Copy link
Author

@Fuseteam Fuseteam Mar 8, 2022

Choose a reason for hiding this comment

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

no actually, we're not really removing packages, we're downgrading packages. originally we were running apt full-upgrade here too
pkginstall will not and should not install something that isn't installed already

i have updated de logs to reflect this

10 changes: 10 additions & 0 deletions pkgupdate
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
while read list
do
list=$(basename "${list}")
if [[ "${list}" != "ubports.list" && "${list}" != "ubports-android9.list" ]]; then
list="${list/ubports-/}"
pkgs=$(pkgcheck "${list/.list/}")" "${pkgs}
fi
done < <(ls /etc/apt/sources.list.d/*)
apt-get install ${pkgs}
29 changes: 20 additions & 9 deletions ubports-qa
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,26 @@ def apt_update():
LOG.error("Failed to run 'apt update'. See the output above for details.")


def apt_upgrade():
LOG.debug("Running 'apt full-upgrade'.")
def apt_remove(repository):
LOG.debug("Downgrading packages")
try:
subprocess.run(["apt", "full-upgrade"], check=True)
subprocess.run(["apt", "autoremove"], check=True)
subprocess.run(["pkgremove", repository], check=True)
except subprocess.CalledProcessError:
LOG.error("Failed to run 'apt full-upgrade'. See the output above for details.")
LOG.error("Failed to downgrade packages. See the output above for details.")

def apt_install(repository_name):
LOG.debug("Upgrading packages")
try:
subprocess.run(["pkginstall", repository_name], check=True)
except subprocess.CalledProcessError:
LOG.error("Failed to upgrade Packages. See the output above for details.")

def apt_upgrade_all():
LOG.debug("Upgrading all qa package")
try:
subprocess.run(["pkgupdate"], check=True)
except subprocess.CalledProcessError:
LOG.error("Failed to install Package. See the output above for details.")

def get_list_file(branch):
list_file = "/etc/apt/sources.list.d/ubports-{}.list".format(branch)
Expand Down Expand Up @@ -220,7 +232,7 @@ def install_command(args):
add_list(repository_name)
add_pref(repository_name)
apt_update()
apt_upgrade()
apt_install(repository_name)

LOG.info(
"You can remove this repository by running 'sudo ubports-qa remove {}'".format(
Expand All @@ -238,8 +250,7 @@ def remove_command(args):
with WritableRootFS():
remove_list(repository)
remove_pref(repository)
apt_update()
apt_upgrade()
apt_remove(repository)


def list_command(args):
Expand All @@ -251,7 +262,7 @@ def update_command(args):
"""Update all packages using apt"""
with WritableRootFS():
apt_update()
apt_upgrade()
apt_upgrade_all()


parser = argparse.ArgumentParser(
Expand Down