Skip to content

feat: Add script to generate minimal clp-core Debian package.#718

Open
jackluo923 wants to merge 5 commits into
y-scope:mainfrom
jackluo923:debian-package
Open

feat: Add script to generate minimal clp-core Debian package.#718
jackluo923 wants to merge 5 commits into
y-scope:mainfrom
jackluo923:debian-package

Conversation

@jackluo923

@jackluo923 jackluo923 commented Feb 12, 2025

Copy link
Copy Markdown
Member

Description

This PR adds a python script to automatically generate a minimal clp-core Debian package. The available options are:

$ python3 create-debian-package.py --help
usage: create-debian-package.py [-h] -b BUILD_DIR -v VERSION [-r REVISION] [-o OUTPUT_DIR]

Create a minimal CLP core Debian package

options:
  -h, --help            show this help message and exit
  -b BUILD_DIR, --build-dir BUILD_DIR
                        The CLP core CMake build directory
  -v VERSION, --version VERSION
                        The Debian package upstream version
  -r REVISION, --revision REVISION
                        The Debian package revision
  -o OUTPUT_DIR, --output-dir OUTPUT_DIR
                        The debian package output dir

Simple description and usage is also added to components/core/tools/scripts/utils/README.md

Validation

3 commands are executed on an Ubuntu machine to build the Debian package, check the content of the package and install the package. The logs of the command line executions are shown below:

$  python3 create-debian-package.py --version 0.0 --revision 1 --build-dir ../../../build

=========================================================================

Copying clp-core binary `clg` to usr/local/bin
Copying clp-core binary `clo` to usr/local/bin
Copying clp-core binary `clp` to usr/local/bin
Copying clp-core binary `clp-s` to usr/local/bin
Copying clp-core binary `glt` to usr/local/bin
Copying clp-core binary `indexer` to usr/local/bin
Copying clp-core binary `make-dictionaries-readable` to usr/local/bin

=========================================================================

dpkg-deb: building package 'clp-core' in '/home/jack/projects/jackluo923/clp/components/core/tools/scripts/utils/clp-core_0.0-1_amd64.deb'.

Package created: /home/jack/projects/jackluo923/clp/components/core/tools/scripts/utils/clp-core_0.0-1_amd64.deb

Install with: sudo dpkg -i /home/jack/projects/jackluo923/clp/components/core/tools/scripts/utils/clp-core_0.0-1_amd64.deb

$ dpkg -c clp-core_0.0-1_amd64.deb
drwxr-xr-x jack/jack         0 2025-02-13 05:31 ./
drwxr-xr-x jack/jack         0 2025-02-13 05:31 ./usr/
drwxr-xr-x jack/jack         0 2025-02-13 05:31 ./usr/local/
drwxr-xr-x jack/jack         0 2025-02-13 05:31 ./usr/local/bin/
-rwxr-xr-x jack/jack   4480440 2025-02-13 05:31 ./usr/local/bin/clg
-rwxr-xr-x jack/jack   6907752 2025-02-13 05:31 ./usr/local/bin/clo
-rwxr-xr-x jack/jack  10247608 2025-02-13 05:31 ./usr/local/bin/clp
-rwxr-xr-x jack/jack   8337536 2025-02-13 05:31 ./usr/local/bin/clp-s
-rwxr-xr-x jack/jack   9890200 2025-02-13 05:31 ./usr/local/bin/glt
-rwxr-xr-x jack/jack   3136320 2025-02-13 05:31 ./usr/local/bin/indexer
-rwxr-xr-x jack/jack   1399096 2025-02-13 05:31 ./usr/local/bin/make-dictionaries-readable

$ sudo dpkg -i /home/jack/projects/jackluo923/clp/components/core/tools/scripts/utils/clp-core_0.0-1_amd64.deb
(Reading database ... 80606 files and directories currently installed.)
Preparing to unpack .../utils/clp-core_0.0-1_amd64.deb ...
Unpacking clp-core (0.0-1) over (0.0-1) ...
Setting up clp-core (0.0-1) ...

Summary by CodeRabbit

  • New Features
    • Introduced a utility script that simplifies creating a minimal Debian package for the CLP core, allowing users to specify parameters like version and build directory.
  • Documentation
    • Enhanced documentation with a detailed description and sample usage to guide users through the new package creation process.

@coderabbitai

coderabbitai Bot commented Feb 12, 2025

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@jackluo923 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 51 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 2af97d1 and c8a473f.

📒 Files selected for processing (1)
  • components/core/tools/scripts/utils/create-debian-package.py (1 hunks)

Walkthrough

The pull request adds a new utility script, create-debian-package.py, designed to generate minimal Debian packages for the CLP core. The script, which is documented in the updated README file, uses the argparse module to manage command-line arguments, detects the system architecture, cleans any pre-existing package directory, and builds the necessary directory structure and metadata before creating the package via dpkg-deb. The README now provides a brief description and sample command usage for this new script.

Changes

File(s) Change Summary
components/core/tools/scripts/utils/README.md Updated documentation to include the new create-debian-package.py utility, providing its purpose and a sample command demonstrating its usage.
components/core/tools/scripts/utils/create-debian-package.py New script that creates Debian packages for the CLP core by parsing command-line arguments, determining system architecture, creating the necessary directory structure, and building the package.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as Command Line Interface
    participant Script as create-debian-package.py
    participant Sys as System (dpkg, file system)

    CLI->>Script: Execute script with arguments (build dir, version, revision, output)
    Script->>Script: Parse command-line arguments with argparse
    Script->>Sys: Execute dpkg command to detect architecture
    Sys-->>Script: Return architecture or error
    Script->>Script: Clean existing package directory and prepare new structure
    Script->>Script: Generate control file with metadata (name, maintainer, version, architecture, dependencies)
    Script->>Sys: Copy binaries and set permissions
    Script->>Sys: Run dpkg-deb to build the Debian package
    Sys-->>Script: Return package build result
    Script->>CLI: Output package location and installation instructions
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
components/core/tools/scripts/utils/create-debian-package.py (1)

39-44: Move configuration to constants.

Consider moving the hard-coded values to module-level constants for better maintainability.

+# Package configuration constants
+PACKAGE_NAME = "clp-core"
+PACKAGE_MAINTAINER = "YScope <admin@yscope.com>"
+PACKAGE_DESCRIPTION = "A minimal CLP core Debian package"
+PACKAGE_DEPENDENCIES = ["libmariadb-dev", "libssl-dev"]
+
 def create_debian_package(args):
     """
     Create a Debian package for CLP core.
     """
     # Package configuration
-    package_name = "clp-core"
-    maintainer = "YScope <admin@yscope.com>"
-    description = "A minimal CLP core Debian package"
+    package_name = PACKAGE_NAME
+    maintainer = PACKAGE_MAINTAINER
+    description = PACKAGE_DESCRIPTION
     full_version = f"{args.version}-{args.revision}"
-    package_dependencies = ["libmariadb-dev", "libssl-dev"]
+    package_dependencies = PACKAGE_DEPENDENCIES
components/core/tools/scripts/utils/README.md (1)

12-14: Fix grammar in the documentation.

Add the missing article "the" before "CLP core package".

 * `create-debian-package.py` can be used to generate a minimal Debian package
-  containing CLP core package. Sample command:
+  containing the CLP core package. Sample command:
🧰 Tools
🪛 LanguageTool

[style] ~12-~12: To form a complete sentence, be sure to include a subject.
Context: ...ty issues. * create-debian-package.py can be used to generate a minimal Debian pa...

(MISSING_IT_THERE)


[uncategorized] ~13-~13: You might be missing the article “the” here.
Context: ...e a minimal Debian package containing CLP core package. Sample command: `python...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 26b45ff and a731212.

📒 Files selected for processing (2)
  • components/core/tools/scripts/utils/README.md (1 hunks)
  • components/core/tools/scripts/utils/create-debian-package.py (1 hunks)
🧰 Additional context used
🪛 LanguageTool
components/core/tools/scripts/utils/README.md

[style] ~12-~12: To form a complete sentence, be sure to include a subject.
Context: ...ty issues. * create-debian-package.py can be used to generate a minimal Debian pa...

(MISSING_IT_THERE)


[uncategorized] ~13-~13: You might be missing the article “the” here.
Context: ...e a minimal Debian package containing CLP core package. Sample command: `python...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: lint-check (ubuntu-latest)
  • GitHub Check: lint-check (macos-latest)
  • GitHub Check: build (macos-latest)
🔇 Additional comments (1)
components/core/tools/scripts/utils/create-debian-package.py (1)

9-29: LGTM! Well-structured function with proper error handling.

The function is well-documented, has proper error handling, and follows Python best practices.

Comment thread components/core/tools/scripts/utils/create-debian-package.py Outdated
Comment thread components/core/tools/scripts/utils/create-debian-package.py
Comment thread components/core/tools/scripts/utils/create-debian-package.py
Comment thread components/core/tools/scripts/utils/create-debian-package.py
jackluo923 and others added 4 commits February 13, 2025 05:48
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants