Skip to content

Commit

Permalink
src: patch-hub: Use new patch-hub implementation
Browse files Browse the repository at this point in the history
[What]

Make `kw patch-hub` use the new `patch-hub` implementation, which is
being developed as a standalone sub-project of the KWorfkflow
organization [1]. The `patch-hub` executable is installed by running
`curl` to an endpoint to the latest release.

Also, add instructions to users on installing the new `patch-hub`
executable when running `setup.sh --install` fails to install the latest
release or when invoking `kw patch-hub` without having the executable
accessible in the system `PATH`.

Finally, make adaptations to the manpage.

[Why]

With the growth of the `patch-hub` implementation inside the `kworkflow`
project, it became increasingly apparent that it basically reached its
ceiling. More notably, these were the main issues we were facing:

  1. Even though we dedicated much time to parallelizing the fetching of
     the latest patchsets from target mailing lists, the performance was
     (being generous) unacceptable half of the time. This stemmed from
     the interpreted nature of `Bash`, which was aggravated by the
     gigantic number of context changes by the heavy use of `sed`,
     `grep`, and other building blocks for processing.
  2. `Dialog` is an excellent tool to bootstrap a TUI, but, on the other
     hand, its simplicity and "black-box essence" made it absurdly hard
     (practically impossible) to implement some of the not-so-complex
     TUI elements we needed.
  3. Difficulty in testing the TUI components, lowering the feature
     robustness and making it unreliable.

Although we felt that it reached its ceiling, we were nowhere close to
the functionalities and overall look and feel we aimed for. So,
I decided to completely redo the feature as a dedicated sub-project
using Rust. The new `patch-hub` is promising, as its current release
easily surpasses the old one in all the points mentioned above and
doesn't show signs that it will be so complex that we will hit another
ceiling in the future. Besides, it already progressed farther in terms
of functionalities with the action to reply a patchset with the
`Reviewed-by` tag.

[1]: https://github.com/kworkflow/patch-hub

Signed-off-by: David Tadokoro <[email protected]>
  • Loading branch information
davidbtadokoro committed Sep 6, 2024
1 parent 434a216 commit c1db32d
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 110 deletions.
2 changes: 1 addition & 1 deletion documentation/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
('man/features/kw-ssh', 'kw-ssh', 'ssh access', [author], 1),
('man/features/kw-vm', 'kw-vm', 'commands to work with QEMU VMs', [author], 1),
('man/features/kw-self-update', 'kw-self-update', 'kw self-update mechanism', ['David Tadokoro, Everaldo Junior'], 1),
('man/features/kw-patch-hub', 'kw-patch-hub', 'UI with lore.kernel.org archives', ['David Tadokoro, Rodrigo Siqueira'], 1),
('man/features/kw-patch-hub', 'kw-patch-hub', 'Terminal UI to interact with patches from lore.kernel.org', ['David Tadokoro, Rodrigo Siqueira'], 1),
('man/features/kw-bd', 'kw-bd', 'build and then deploy the kernel', ['Briza Mel de Sousa, Lorenzo Salvador'], 1),
]

Expand Down
35 changes: 20 additions & 15 deletions documentation/man/features/kw-patch-hub.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
===============================================
kw-patch-hub - UI with lore.kernel.org archives
===============================================
========================================================================
kw-patch-hub - Terminal UI to interact with patches from lore.kernel.org
========================================================================

.. _patch-hub-doc:

Expand All @@ -10,22 +10,27 @@ SYNOPSIS
DESCRIPTION
===========
The `kw patch-hub` feature provides an interface with the public mailing lists
archived on `https://lore.kernel.org`, focusing on patch series. The feature can
be used to just consult patch series from a given list, but, as it integrates
with other kw features, it simplifies the process of reviewing patch series,
like:
The `kw patch-hub` feature provides a TUI (*Terminal User Interface*) that
streamlines the interaction of Linux developers with patches archived on
lore.kernel.org. The feature can be used to just consult patchsets from a
target list, but, as it integrates with other kw features, it simplifies the
process of reviewing patchset, like:

- Applying a patch series to a git tree
- Building the series version of the kernel
- Deploying the series version of the kernel
- Replying with `Reviewed-by/Tested-by`
- Applying a patchset to a git tree
- Building the patchset version of the Linux kernel
- Deploying the patchset version of the Linux kernel
- Replying with `Reviewed-by/Tested-by` tags

`kw patch-hub` provides routines to automate and simplify these actions.
`kw patch-hub` is an integrated interface to automate and simplify these
actions.

.. note::
`patch-hub` is a `standalone sub-project
<https://github.com/kworkflow/patch-hub>`_ from the kw organization and it is
under heavy development. We welcome contributions!

EXAMPLES
========
The feature is screen-focused, and to open the UI with the public mailing lists,
just run::
To launch `kw patch-hub` simply run::

kw patch-hub
44 changes: 44 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ declare -r CONFIGS_PATH='configs'

declare -r DOCS_VIRTUAL_ENV='docs_virtual_env'

# patch-hub latest release endpoint
declare -r PATCH_HUB_LATEST_RELEASE='https://github.com/kworkflow/patch-hub/releases/latest/download/patch-hub-x86_64-unknown-linux-gnu.tar.xz'

# This function identifies the missing packages required by the distribution.
#
# @distro: The distribution name (arch, debian, fedora, etc.)
Expand Down Expand Up @@ -431,6 +434,9 @@ function clean_legacy()
# Remove etc files
[[ -d "$etcdir" ]] && mv "$etcdir" "$trash/etc"

# Remove patch-hub binary
[[ -f "${binpath}/patch-hub" ]] && mv "${binpath}/patch-hub" "$trash"

# Completely remove user data
if [[ "$completely_remove" =~ '-d' ]]; then
mv "$datadir" "$trash/userdata"
Expand Down Expand Up @@ -650,10 +656,48 @@ function install_home()
# Show current environment in terminal
setup_bashrc_to_show_current_kw_env

install_patch_hub
if [[ "$?" != 0 ]]; then
warning ''
warning '-> Could not install the latest release of `patch-hub`.'
warning ' To use the `kw patch-hub` feature, you will need to install the `patch-hub` executable.'
warning ' Either try re-running this script or following the instructions below.'
warning ' Install instructions: https://github.com/kworkflow/patch-hub?tab=readme-ov-file#package-how-to-install.'
fi

warning ''
warning '-> For a better experience with kw, please, open a new terminal.'
}

function install_patch_hub()
{
local tmp_dir
local ret

say ''
say 'Installing `patch-hub`...'

tmp_dir="$(mktemp --directory)"

curl --silent --location --output "${tmp_dir}/patch-hub.tar.xz" "$PATCH_HUB_LATEST_RELEASE"
ret="$?"
if [[ "$?" != 0 ]]; then
return "$ret"
fi

tar xf "${tmp_dir}/patch-hub.tar.xz" --directory="$tmp_dir" --strip-components=1
ret="$?"
if [[ "$?" != 0 ]]; then
return "$ret"
fi

cp "${tmp_dir}/patch-hub" "${binpath}"
ret="$?"
if [[ "$?" != 0 ]]; then
return "$ret"
fi
}

function full_installation()
{
say 'Starting kw installation...'
Expand Down
2 changes: 1 addition & 1 deletion src/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function kworkflow_help()
' debug - Linux kernel debug utilities' \
' mail - Send patches via email' \
' env - Handle kw envs' \
' patch-hub - Interface to lore kernel' \
' patch-hub - Open Terminal UI to interact with patches from lore.kernel.org' \
' clear-cache - Clear files generated by kw' \
' drm - Set of commands to work with DRM drivers' \
' vm - Basic support for QEMU image' \
Expand Down
60 changes: 14 additions & 46 deletions src/patch_hub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,23 @@ include "${KW_LIB_DIR}/ui/patch_hub/patch_hub_core.sh"

function patch_hub_main()
{
if [[ "$1" =~ -h|--help ]]; then
patch_hub_help "$1"
exit 0
fi

parse_patch_hub_options "$@"
if [[ "$?" -gt 0 ]]; then
complain "${options_values['ERROR']}"
patch_hub_help
return 22 # EINVAL
fi

patch_hub_main_loop
return "$?"
}
local ret

function parse_patch_hub_options()
{
local long_options=''
local short_options=''

options="$(kw_parse "$short_options" "$long_options" "$@")"
if [[ "$?" != 0 ]]; then
options_values['ERROR']="$(kw_parse_get_errors 'kw patch-hub' "$short_options" \
"$long_options" "$@")"
return 22 # EINVAL
if ! command_exists 'patch-hub'; then
complain 'Could not find the `patch-hub` executable.'
warning 'Either run `./setup.sh --install` from the root of a kw repo or follow the instructions below.'
warning 'Install instructions: https://github.com/kworkflow/patch-hub?tab=readme-ov-file#package-how-to-install.'
return 2 # ENOENT
fi

eval "set -- ${options}"
# We must export these env variables to be accessible by `patch-hub`
export KW_DATA_DIR
export KW_CACHE_DIR

while [[ "$#" -gt 0 ]]; do
case "$1" in
--)
shift
;;
*)
shift
;;
esac
done
}

function patch_hub_help()
{
if [[ "$1" == --help ]]; then
include "${KW_LIB_DIR}/help.sh"
kworkflow_man 'patch-hub'
return
patch-hub "$@"
ret="$?"
if [[ "$ret" != 0 ]]; then
complain "patch-hub exited with error code ${ret}"
return "$ret"
fi
printf '%s\n' 'kw patch-hub:' \
' patch-hub - Open UI with lore.kernel.org archives'
}
47 changes: 0 additions & 47 deletions tests/unit/patch_hub_test.sh

This file was deleted.

0 comments on commit c1db32d

Please sign in to comment.