diff --git a/.github/workflows/generate_manpage.yml b/.github/workflows/generate_manpage.yml index 66e8e27a3c..62a8798bd2 100644 --- a/.github/workflows/generate_manpage.yml +++ b/.github/workflows/generate_manpage.yml @@ -1,33 +1,103 @@ -name: Generate Manpages +name: Update Manpages on: + push: + branches: + - main pull_request: branches: - main jobs: - generate-manpages: + update-manpages: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: 3.10.13 - - - name: Install dependencies - run: | - pip install argparse-manpage six pexpect - - - name: Install python3-rpm and python3-dnf package with apt-get - run: | - sudo apt-get update - sudo apt-get install -y python3-rpm python3-dnf - - - name: Generate Manpages - run: | - chmod +x scripts/manpage_generation.sh - bash scripts/manpage_generation.sh + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.10' + + - name: Add Universe Repository + run: | + sudo add-apt-repository universe + sudo apt-get update + + - name: Install dependencies + run: | + sudo apt-get install -y python3-pip rpm libnspr4-dev libnss3-dev libpopt-dev libarchive-dev libdb-dev \ + autoconf automake bison flex gettext libtool pkg-config + pip install --upgrade pip + pip install pexpect argparse-manpage six + + - name: Create /etc/convert2rhel.ini + run: | + sudo mkdir -p /etc + sudo bash -c 'cat < /etc/convert2rhel.ini + [main] + subscription_manager = placeholder_value + host_metering = placeholder_value + inhibitor_overrides = placeholder_value + EOF' + + - name: Download and install RPM + run: | + wget http://ftp.rpm.org/releases/rpm-4.14.x/rpm-4.14.2.tar.bz2 + tar -xjf rpm-4.14.2.tar.bz2 + cd rpm-4.14.2 + export PKG_CONFIG_PATH=/opt/hostedtoolcache/Python/3.10.15/x64/lib/pkgconfig + export PYTHON_CFLAGS="-I/opt/hostedtoolcache/Python/3.10.15/x64/include/python3.10" + export PYTHON_LIBS="-L/opt/hostedtoolcache/Python/3.10.15/x64/lib -lpython3.10" + ./configure --disable-nls --enable-python --without-lua + make + sudo make install + cd python + python3 setup.py install + sudo ldconfig + + - name: Verify Python Path + run: | + python -c "import sys; print(sys.path)" + python -c "import pexpect; print('pexpect module is available.')" + python -c "import rpm; print('rpm module is available.')" + + - name: Debug CLI Attribute + run: | + python -c "import convert2rhel.cli as cli; print(dir(cli)); print(cli.CLI)" || exit 1 + + - name: Generate manpages + run: | + set -e + + # Directory to store the generated manpages + MANPAGE_DIR='man' + + # Ensure the manpage directory exists + mkdir -p "$MANPAGE_DIR" + + echo 'Generating manpages' + + # Add debug statements + python -c 'import convert2rhel.cli as cli; print(dir(cli)); print(cli.CLI)' || exit 1 + + # Generate a file with convert2rhel synopsis for argparse-manpage + python -c 'from convert2rhel.cli import CLI; print("[synopsis]\n."+CLI.usage())' > "$MANPAGE_DIR/synopsis" + + # Extract the current version from the spec file + CURRENT_VER=$(grep -oP '^Version:\s+\K\S+' packaging/convert2rhel.spec) + echo 'Current version: $CURRENT_VER' + + # Generate the manpage using argparse-manpage + PYTHONPATH=. argparse-manpage --pyfile man/__init__.py --function get_parser --manual-title='General Commands Manual' --description='Automates the conversion of Red Hat Enterprise Linux derivative distributions to Red Hat Enterprise Linux.' --project-name 'convert2rhel $CURRENT_VER' --prog='convert2rhel' --include man/distribution --include man/synopsis > "$MANPAGE_DIR/convert2rhel.8" + + # Check for differences in the generated manpage + if ! git diff --quiet HEAD -- "$MANPAGE_DIR/convert2rhel.8"; then + echo 'Manpages are outdated. Please update them.' + exit 1 + else + echo 'Manpages are up-to-date.' + exit 0 + fi diff --git a/Containerfiles/manpage_check.Containerfile b/Containerfiles/manpage_check.Containerfile new file mode 100644 index 0000000000..a37f59f641 --- /dev/null +++ b/Containerfiles/manpage_check.Containerfile @@ -0,0 +1,34 @@ +# Use the latest Fedora image as the base +FROM quay.io/fedora/fedora:latest + +# Install system dependencies +RUN dnf install -y \ + python3 \ + python3-pip \ + python3-devel \ + rpm-devel \ + python3-rpm \ + git \ + && dnf clean all + +# Install Python packages +RUN pip3 install --upgrade pip +RUN pip3 install pexpect argparse-manpage six + +# Set the working directory +WORKDIR /app + +# Copy the project files into the container +COPY . /app + +# Copy the convert2rhel.ini configuration file into the container +COPY config/convert2rhel.ini /etc/convert2rhel/convert2rhel.ini + +# Copy manpage_generation.sh from the scripts directory into the container +COPY scripts/manpage_generation.sh /app/ + +# Ensure the script is executable +RUN chmod +x /app/manpage_generation.sh + +# Set up entrypoint to run manpage_generation.sh +ENTRYPOINT ["/app/manpage_generation.sh"] diff --git a/convert2rhel/cli.py b/convert2rhel/cli.py index 3ae5251b86..959317b7f4 100644 --- a/convert2rhel/cli.py +++ b/convert2rhel/cli.py @@ -23,8 +23,9 @@ import sys from convert2rhel import __version__, utils -from convert2rhel.toolopts import tool_opts +from convert2rhel.toolopts.__init__ import tool_opts from convert2rhel.toolopts.config import CliConfig, FileConfig +from convert2rhel.utils.rpm import PRE_RPM_VA_LOG_FILENAME, POST_RPM_VA_LOG_FILENAME loggerinst = logging.getLogger(__name__) @@ -134,7 +135,7 @@ def _register_options(self): " to show you what rpm files have been affected by the conversion." " Cannot be used with analyze subcommand." " The incomplete_rollback option needs to be set to true in the /etc/convert2rhel.ini config file to" - " use this argument.".format(utils.rpm.PRE_RPM_VA_LOG_FILENAME, utils.rpm.POST_RPM_VA_LOG_FILENAME), + " use this argument.".format(PRE_RPM_VA_LOG_FILENAME, POST_RPM_VA_LOG_FILENAME), ) self._shared_options_parser.add_argument( "--eus", diff --git a/convert2rhel/toolopts/config.py b/convert2rhel/toolopts/config.py index 8c6cac6635..7d75bd9c65 100644 --- a/convert2rhel/toolopts/config.py +++ b/convert2rhel/toolopts/config.py @@ -133,6 +133,7 @@ def options_from_config_files(self): # (meaning that the user entered something through the `-c` option), we # will use only that, as it has a higher priority over the rest paths = [os.path.expanduser(path) for path in self._config_files if os.path.exists(os.path.expanduser(path))] + print(paths) if not paths: raise FileNotFoundError("No such file or directory: {}".format(", ".join(paths))) diff --git a/convert2rhel/utils/__init__.py b/convert2rhel/utils/__init__.py index 6d23a3fef0..1fd61c4f6c 100644 --- a/convert2rhel/utils/__init__.py +++ b/convert2rhel/utils/__init__.py @@ -40,7 +40,7 @@ from convert2rhel import exceptions, i18n from convert2rhel.logger import root_logger -from convert2rhel.toolopts import tool_opts +from convert2rhel.toolopts.__init__ import tool_opts logger = root_logger.getChild(__name__) diff --git a/man/convert2rhel.8 b/man/convert2rhel.8 index f98421e2df..f170d4f889 100644 --- a/man/convert2rhel.8 +++ b/man/convert2rhel.8 @@ -1,11 +1,11 @@ -.TH CONVERT2RHEL "1" "2024\-03\-04" "convert2rhel 1.7.1" "General Commands Manual" +.TH CONVERT2RHEL "1" "2024\-11\-24" "convert2rhel 2.1.0" "General Commands Manual" .SH NAME convert2rhel \- Automates the conversion of Red Hat Enterprise Linux derivative distributions to Red Hat Enterprise Linux. .SH SYNOPSIS . convert2rhel [--version] [-h] convert2rhel [-u username] [-p password | -c conf_file_path] [--pool pool_id | -a] [--disablerepo repoid] [--enablerepo repoid] [--serverurl url] [--no-rpm-va] [--els] [--eus] [--debug] [--restart] [-y] - convert2rhel [--no-rhsm] [--disablerepo repoid] [--enablerepo repoid] [--no-rpm-va] [--els] [--eus] [--debug] [--restart] [-y] + convert2rhel [--no-rhsm] [--disablerepo repoid] [--enablerepo repoid] [--no-rpm-va] [--els ] [--eus] [--debug] [--restart] [-y] convert2rhel [-k activation_key | -c conf_file_path] [-o organization] [--pool pool_id | -a] [--disablerepo repoid] [--enablerepo repoid] [--serverurl url] [--no-rpm-va] [--els] [--eus] [--debug] [--restart] [-y] .SH DESCRIPTION The Convert2RHEL utility automates converting Red Hat Enterprise Linux derivative distributions to Red Hat Enterprise Linux. The whole conversion procedure is performed on the running RHEL derivative OS installation and a restart is needed at the end of the conversion to boot into the RHEL kernel. The utility replaces the original OS packages with the RHEL ones. Available are conversions of CentOS Linux 7/8, Oracle Linux 7/8, Scientific Linux 7, Alma Linux 8, and Rocky Linux 8 to the respective major version of RHEL. @@ -32,9 +32,9 @@ Convert the system. If no subcommand is given, 'convert' is used as a default. .SH COMMAND \fI\,'convert2rhel analyze'\/\fR usage: convert2rhel [\-\-version] [\-h] - convert2rhel analyze [\-u username] [\-p password | \-c conf_file_path] [\-\-pool pool_id | \-a] [\-\-disablerepo repoid] [\-\-enablerepo repoid] [\-\-serverurl url] [\-\-no\-rpm\-va] [\-\-els] [\-\-eus] [\-\-debug] [\-\-restart] [\-y] - convert2rhel analyze [\-\-no\-rhsm] [\-\-disablerepo repoid] [\-\-enablerepo repoid] [\-\-no\-rpm\-va] [\-\-els] [\-\-eus] [\-\-debug] [\-\-restart] [\-y] - convert2rhel analyze [\-k activation_key | \-c conf_file_path] [\-o organization] [\-\-pool pool_id | \-a] [\-\-disablerepo repoid] [\-\-enablerepo repoid] [\-\-serverurl url] [\-\-no\-rpm\-va] [\-\-els] [\-\-eus] [\-\-debug] [\-\-restart] [\-y] + convert2rhel analyze [\-u username] [\-p password | \-c conf_file_path] [\-\-pool pool_id | \-a] [\-\-disablerepo repoid] [\-\-enablerepo repoid] [\-\-serverurl url] [\-\-no\-rpm\-va] [\-\-eus] [\-\-els] [\-\-debug] [\-\-restart] [\-y] + convert2rhel analyze [\-\-no\-rhsm] [\-\-disablerepo repoid] [\-\-enablerepo repoid] [\-\-no\-rpm\-va] [\-\-eus] [\-\-els] [\-\-debug] [\-\-restart] [\-y] + convert2rhel analyze [\-k activation_key | \-c conf_file_path] [\-o organization] [\-\-pool pool_id | \-a] [\-\-disablerepo repoid] [\-\-enablerepo repoid] [\-\-serverurl url] [\-\-no\-rpm\-va] [\-\-eus] [\-\-els] [\-\-debug] [\-\-restart] [\-y] .SH OPTIONS \fI\,'convert2rhel analyze'\/\fR .TP @@ -53,19 +53,17 @@ before and after the conversion with the output stored in log files rpm_va.log and rpm_va_after_conversion.log. At the end of the conversion, these logs are compared to show you what rpm files have been affected by the conversion. Cannot be used with analyze subcommand. The environment variable -CONVERT2RHEL_INCOMPLETE_ROLLBACK needs to be set to 1 to use this -argument. +CONVERT2RHEL_INCOMPLETE_ROLLBACK needs to be set to 1 to use this argument. .TP -\fB\-\-els\fR -Utilize Extended Lifecycle Support (els) repositories. Necessary for RHEL 7 -servers to land on a system patched with the latest security errata. +\fB\-\-eus\fR +Explicitly recognize the system as eus, utilizing eus repos. This option is +meant for el8.8+ systems. .TP -\fB\-\-eus\fR -Automatically recognize the system as eus, utilizing eus repos. 8.6 systems do -not require this option as they are recognized as eus automatically. This -option is meant for 8.8+ systems. +\fB\-\-els\fR +Explicitly recognize the system as els, utilizing els repos. This option is +meant for el7 systems. .TP \fB\-\-enablerepo\fR \fI\,repoidglob\/\fR @@ -105,13 +103,7 @@ recommend using the \-\-config\-file option instead to prevent leaking the password through a list of running processes. .TP -\fB\-f\fR \fI\,PASSWORD_FROM_FILE\/\fR, \fB\-\-password\-from\-file\fR \fI\,PASSWORD_FROM_FILE\/\fR -File containing password for the subscription\-manager in the plain text form. -It's an alternative to the \-\-password option. Deprecated, use \-\-config\-file -instead. - -.TP -\fB\-k\fR \fI\,ACTIVATIONKEY\/\fR, \fB\-\-activationkey\fR \fI\,ACTIVATIONKEY\/\fR +\fB\-k\fR \fI\,ACTIVATION_KEY\/\fR, \fB\-\-activationkey\fR \fI\,ACTIVATION_KEY\/\fR Activation key used for the system registration by the subscription\-manager. It requires to have the \-\-org option specified. We recommend using the \-\-config\-file option instead to prevent leaking the activation key through a @@ -154,18 +146,9 @@ Management service (subscription.rhsm.redhat.com). It is not to be used to specify a Satellite server. For that, read the product documentation at https://access.redhat.com/. -.TP -\fB\-\-keep\-rhsm\fR -Deprecated. This option has no effect. Convert2rhel will now use whatever -subscription\-manager packages are present on the system. - .SH ALTERNATIVE INSTALLATION OPTIONS \fI\,'convert2rhel analyze'\/\fR The following options are required if you do not intend on using subscription\-manager. -.TP -\fB\-\-disable\-submgr\fR -Replaced by \-\-no\-rhsm. Both options have the same effect. - .TP \fB\-\-no\-rhsm\fR Do not use the subscription\-manager, use custom repositories instead. See @@ -176,9 +159,9 @@ requires to have the \-\-enablerepo specified. .SH COMMAND \fI\,'convert2rhel convert'\/\fR usage: convert2rhel [\-\-version] [\-h] - convert2rhel convert [\-u username] [\-p password | \-c conf_file_path] [\-\-pool pool_id | \-a] [\-\-disablerepo repoid] [\-\-enablerepo repoid] [\-\-serverurl url] [\-\-no\-rpm\-va] [\-\-els] [\-\-eus] [\-\-debug] [\-\-restart] [\-y] - convert2rhel convert [\-\-no\-rhsm] [\-\-disablerepo repoid] [\-\-enablerepo repoid] [\-\-no\-rpm\-va] [\-\-els] [\-\-eus] [\-\-debug] [\-\-restart] [\-y] - convert2rhel convert [\-k activation_key | \-c conf_file_path] [\-o organization] [\-\-pool pool_id | \-a] [\-\-disablerepo repoid] [\-\-enablerepo repoid] [\-\-serverurl url] [\-\-no\-rpm\-va] [\-\-els] [\-\-eus] [\-\-debug] [\-\-restart] [\-y] + convert2rhel convert [\-u username] [\-p password | \-c conf_file_path] [\-\-pool pool_id | \-a] [\-\-disablerepo repoid] [\-\-enablerepo repoid] [\-\-serverurl url] [\-\-no\-rpm\-va] [\-\-eus] [\-\-els] [\-\-debug] [\-\-restart] [\-y] + convert2rhel convert [\-\-no\-rhsm] [\-\-disablerepo repoid] [\-\-enablerepo repoid] [\-\-no\-rpm\-va] [\-\-eus] [\-\-els] [\-\-debug] [\-\-restart] [\-y] + convert2rhel convert [\-k activation_key | \-c conf_file_path] [\-o organization] [\-\-pool pool_id | \-a] [\-\-disablerepo repoid] [\-\-enablerepo repoid] [\-\-serverurl url] [\-\-no\-rpm\-va] [\-\-eus] [\-\-els] [\-\-debug] [\-\-restart] [\-y] .SH OPTIONS \fI\,'convert2rhel convert'\/\fR .TP @@ -197,19 +180,17 @@ before and after the conversion with the output stored in log files rpm_va.log and rpm_va_after_conversion.log. At the end of the conversion, these logs are compared to show you what rpm files have been affected by the conversion. Cannot be used with analyze subcommand. The environment variable -CONVERT2RHEL_INCOMPLETE_ROLLBACK needs to be set to 1 to use this -argument. +CONVERT2RHEL_INCOMPLETE_ROLLBACK needs to be set to 1 to use this argument. .TP -\fB\-\-els\fR -Utilize Extended Lifecycle Support (els) repositories. Necessary for RHEL 7 -servers to land on a system patched with the latest security errata. +\fB\-\-eus\fR +Explicitly recognize the system as eus, utilizing eus repos. This option is +meant for el8.8+ systems. .TP -\fB\-\-eus\fR -Automatically recognize the system as eus, utilizing eus repos. 8.6 systems do -not require this option as they are recognized as eus automatically. This -option is meant for 8.8+ systems. +\fB\-\-els\fR +Explicitly recognize the system as els, utilizing els repos. This option is +meant for el7 systems. .TP \fB\-\-enablerepo\fR \fI\,repoidglob\/\fR @@ -249,13 +230,7 @@ recommend using the \-\-config\-file option instead to prevent leaking the password through a list of running processes. .TP -\fB\-f\fR \fI\,PASSWORD_FROM_FILE\/\fR, \fB\-\-password\-from\-file\fR \fI\,PASSWORD_FROM_FILE\/\fR -File containing password for the subscription\-manager in the plain text form. -It's an alternative to the \-\-password option. Deprecated, use \-\-config\-file -instead. - -.TP -\fB\-k\fR \fI\,ACTIVATIONKEY\/\fR, \fB\-\-activationkey\fR \fI\,ACTIVATIONKEY\/\fR +\fB\-k\fR \fI\,ACTIVATION_KEY\/\fR, \fB\-\-activationkey\fR \fI\,ACTIVATION_KEY\/\fR Activation key used for the system registration by the subscription\-manager. It requires to have the \-\-org option specified. We recommend using the \-\-config\-file option instead to prevent leaking the activation key through a @@ -298,18 +273,9 @@ Management service (subscription.rhsm.redhat.com). It is not to be used to specify a Satellite server. For that, read the product documentation at https://access.redhat.com/. -.TP -\fB\-\-keep\-rhsm\fR -Deprecated. This option has no effect. Convert2rhel will now use whatever -subscription\-manager packages are present on the system. - .SH ALTERNATIVE INSTALLATION OPTIONS \fI\,'convert2rhel convert'\/\fR The following options are required if you do not intend on using subscription\-manager. -.TP -\fB\-\-disable\-submgr\fR -Replaced by \-\-no\-rhsm. Both options have the same effect. - .TP \fB\-\-no\-rhsm\fR Do not use the subscription\-manager, use custom repositories instead. See diff --git a/scripts/manpage_generation.sh b/scripts/manpage_generation.sh index ff3677c75e..8b1b5766fd 100755 --- a/scripts/manpage_generation.sh +++ b/scripts/manpage_generation.sh @@ -3,17 +3,26 @@ # Directory to store the generated manpages MANPAGE_DIR="man" -echo Generating manpages +# Ensure the manpage directory exists +mkdir -p "$MANPAGE_DIR" -VER=$(grep -oP '^Version:\s+\K\S+' packaging/convert2rhel.spec) +echo "Generating manpages" -echo Generating for version $VER # Generate a file with convert2rhel synopsis for argparse-manpage -/usr/bin/python -c 'from convert2rhel import toolopts; print("[synopsis]\n."+toolopts.CLI.usage())' > man/synopsis +python -c 'from convert2rhel import toolopts; print("[synopsis]\n."+toolopts.CLI.usage())' > "$MANPAGE_DIR/synopsis" -/usr/bin/python -m pip install argparse-manpage six pexpect +# Extract the current version from the spec file +CURRENT_VER=$(grep -oP '^Version:\s+\K\S+' packaging/convert2rhel.spec) +echo "Current version: $CURRENT_VER" # Generate the manpage using argparse-manpage -PYTHONPATH=. /usr/bin/python /home/runner/.local/bin/argparse-manpage --pyfile man/__init__.py --function get_parser --manual-title="General Commands Manual" --description="Automates the conversion of Red Hat Enterprise Linux derivative distributions to Red Hat Enterprise Linux." --project-name "convert2rhel $VER" --prog="convert2rhel" --include man/distribution --include man/synopsis > "$MANPAGE_DIR/convert2rhel.8" +PYTHONPATH=. argparse-manpage --pyfile man/__init__.py --function get_parser --manual-title="General Commands Manual" --description="Automates the conversion of Red Hat Enterprise Linux derivative distributions to Red Hat Enterprise Linux." --project-name "convert2rhel $CURRENT_VER" --prog="convert2rhel" --include man/distribution --include man/synopsis > "$MANPAGE_DIR/convert2rhel.8" -git status +# Check for differences in the generated manpage +if ! git diff --quiet HEAD -- "$MANPAGE_DIR/convert2rhel.8"; then + echo "Manpages are outdated. Please update them." + exit 1 +else + echo "Manpages are up-to-date." + exit 0 +fi