Code Monkey home page Code Monkey logo

modulemd-tools's Introduction

modulemd-tools

Collection of tools for modular (in terms of Fedora Modularity origin) content creators

Tools provided by this package

>>> Detailed README about individual tools usage <<<

repo2module

Author: Stephen Gallagher <[email protected]>

Takes a YUM repository on its input and creates modules.yaml containing YAML module definitions generated for each package.

For more information about repo2module, please see repo2module/README.md

dir2module

Author: Jakub Kadlcik <[email protected]>

Generates a module YAML definition based on essential module information provided via command-line parameters. The packages provided by the module are found in a specified directory or a text file containing their list.

For more information about dir2module, please see dir2module/README.md

createrepo_mod

Author: Jakub Kadlcik <[email protected]>

A small wrapper around createrepo_c and modifyrepo_c to provide an easy tool for generating module repositories.

For more information about createrepo_mod, please see createrepo_mod/README.md

modulemd-add-platform

Author: Petr Pisar <[email protected]>

Add a context configuration for a new platform to a modulemd-packager-v3 document.

For more information about modulemd-add-platform, please see modulemd-add-platform/README.md

modulemd-merge

Author: Gerd v. Egidy <[email protected]>

Merge several modules.yaml files into one.

For more information about modulemd-merge, please see modulemd-merge/README.md

modulemd-generate-macros

Author: Jakub Kadlcik <[email protected]>

Generate module-build-macros SRPM package, which is a central piece for building modules. It should be present in the buildroot before any other module packages are submitted to be built.

For more information about modulemd-generate-macros, please see modulemd-generate-macros/README.md

modulemd_tools (python library)

Author: Jakub Kadlcik <[email protected]>

Provides convenient functions for working with modulemd YAML definitions. It is a place for sharing code among other tools within this project. It is also meant to be used as a dependency for other tools, such as build-systems. It is not ready to be used by other tools yet, be cautious. modulemd_tools/README.md

bld2repo

Author: Martin Curlej <[email protected]>

Simple tool for dowloading build required RPMs of a modular build from koji.

For more information about bld2repo, please see bld2repo/README.md

Installation instructions

The modulemd-tools package is available in the official Fedora repositories, and RHEL 8.5 and higher. As such, it can be easily installed with:

dnf install modulemd-tools

There is also a Copr repository providing up-to-date stable builds for EPEL8. It is recommended to use this repository for installing modulemd-tools on RHEL 8.4 and lower.

dnf copr enable frostyx/modulemd-tools-epel
dnf install modulemd-tools

If you prefer to install the latest stable package from this repository, use

git clone https://github.com/rpm-software-management/modulemd-tools.git
cd modulemd-tools
sudo dnf builddep modulemd-tools.spec
tito build --rpm --install

Alternatively, if you want to build and install a package from the latest commit, use

tito build --rpm --test --install

Use cases

Creating a module repository from a regular repository

Let's assume that we have a regular (meaning non-modular) repository.

$ ls
hello-2.8-1.fc32.x86_64.rpm  repodata

We might want to convert this repository to a modular repository, i.e. creating a module providing current packages and then making the module available through the repository. It is a two-step process. First, generate a modulemd YAML providing all repository packages.

$ repo2module . \
    --module-name foo \
    --module-stream devel \
    --module-version 123 \
    --module-context f32

This command generates a modules.yaml file, you might want to open it in a text editor and review its contents.

$ ls
hello-2.8-1.fc32.x86_64.rpm  modules.yaml  repodata

Once the modules.yaml fits your expectations (it shouldn't require any changes for the tooling to work, you might want to fill in just some information for its users), re-create the repository to provide the module. For that, use createrepo_mod, or createrepo_c in the 0.16.1 version and above. They both accept the same parameters.

$ createrepo_mod .

Optionally, check that the module metadata is available within the repository.

$ ls repodata/ |grep modules
c92f0efc3db47c5c8875665699781d001d9a78afdb49fab301b19d84968932f8-modules.yaml.gz

Creating a module repository from a set of RPM packages

Let's start with just a normal directory containing one or many RPM files.

$ ls
hello-2.8-1.fc32.x86_64.rpm

We might want to create a module providing those packages and then make the module available through a repository. It is a two-step process. First, generate a modulemd YAML providing all packages in the directory.

$ dir2module foo:devel:123:f32:x86_64 -m "My example module" --dir .

You will most likely encounter the following error.

WARNING: RPM does not have `modularitylabel` header set: ./hello-2.8-1.fc32.x86_64.rpm
Error: All packages need to contain the `modularitylabel` header.
To suppress this constraint, use `--force` parameter

That's because module RPM packages should contain a modularitylabel header, please see the Modules โ€“ Fake it till you make it blogpost from @sgallagher.

For the sake of simplicity, we won't deal with that and use --force parameter to suppress the warning and generate the module YAML despite that.

$ ls
foo:devel:123:f32:x86_64.modulemd.yaml  hello-2.8-1.fc32.x86_64.rpm

You might want to review and edit the generated YAML file. Once it fits your expectations (it shouldn't require any changes for the tooling to work, you might want to fill in just some information for its users), create a Yum repository from this directory. For that, use createrepo_mod, or createrepo_c in the 0.16.1 version and above. They both accept the same parameters.

$ createrepo_mod .

Optionally, check that the module metadata is available within the repository.

$ ls repodata/ |grep modules
14ff485b98924c8e97bba9b0c9e369283f15f3e30ffaf637186eb5e3f13fc178-modules.yaml.gz

Installing module from a local repository

Let's assume that you have successfully created a modular repository as described in the previous chapters and it is located at /tmp/myrepo. First, we need to let Dnf know that exists. For that, create a /etc/yum.repos.d/myrepo.repo file with following content.

[myrepo]
name=My local foo module
baseurl=file:///tmp/myrepo
gpgcheck=0
enabled=1

That is enough for the client to be able to work with the module. Check that Dnf can find it.

$ dnf module info foo:devel
Name             : foo
Stream           : devel [d][a]
Version          : 123
Context          : f32
...

You should be able to install the module.

$ sudo dnf module install foo:devel

In this example case, the foo:devel module provides hello package. Let's test that it was successfully installed.

$ hello
Hello, world!

Merging two modulemd YAML files into one

Sometimes you might need to merge two modulemd YAML files. Such a task is done e.g. internally in createrepo_mod and createrepo_c (0.16.1 and newer) when dumping modules.yaml file based on input modulemd YAML files.

In the following example we have two input files - foo:devel:123:f32:x86_64.modulemd.yaml and bar:stable:234:f32:x86_64.modulemd.yaml and merging them into modules.yaml.

$ modulemd-merge -i \
    foo:devel:123:f32:x86_64.modulemd.yaml \
    bar:stable:234:f32:x86_64.modulemd.yaml \
    modules.yaml

We can quickly make sure the final YAML file contains both modules.

$ grep name modules.yaml -A2
  name: bar
  stream: stable
  version: 234
--
  name: foo
  stream: devel
  version: 123

Building a module for the next distribution version

Modulemd YAML files in modulemd-packager format needs to list each supported platform stream. When porting a module to the next distribution version it is necessary to add a new context configuration matching the new platform. modulemd-add-platform tool helps with it.

For instance, porting a module.yaml from Fedora 35 to Fedora 36 can be achieved with:

$ modulemd-add-platform --old f35 --new f36 module.yaml

modulemd-tools's People

Contributors

frostyx avatar g-v-egidy avatar kdudka avatar mcurlej avatar mkulik-rh avatar ppisar avatar sgallagher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modulemd-tools's Issues

use command of repo2module to make modules.yaml,but met error

[root@test-change module]# /root/.local/bin/repo2module -s stable . modules.yaml
Traceback (most recent call last):
File "/root/.local/bin/repo2module", line 11, in
load_entry_point('repo2module==0.1', 'console_scripts', 'repo2module')()
File "/root/.local/lib/python3.6/site-packages/repo2module-0.1-py3.6.egg/repo2module/cli.py", line 122, in cli
File "/root/.local/lib/python3.6/site-packages/repo2module-0.1-py3.6.egg/repo2module/cli.py", line 65, in get_source_packages
TypeError: 'NoneType' object is not subscriptable

bld2repo and a corresponding mock config?

Could we somewhat cooperate on creating an appropriate mock configuration
for the created local repository? This is just a rough idea/brainstorm,
"this" can be implemented in Mock directly, or anywhere else.

Currently, I tried to call bld2repo (with Red hat internal Koji server)
and then edited an existing (EL8) mock configuration and I'm getting
various errors (not being able to reproduce the build eventually).

Currently I'm getting:

...
No available modular metadata for modular package 'xmvn-subst-....module+....', it cannot be installed on the system
No available modular metadata for modular package 'xz-java-...module+.....', it cannot be installed on the system
Error: No available modular metadata for modular package
``

I had to patch dir2module.py to get it to complete

Here's the patch:

diff --git a/dir2module/dir2module/dir2module.py b/dir2module/dir2module/dir2module.py
index 6643a83..e639bba 100755
--- a/dir2module/dir2module/dir2module.py
+++ b/dir2module/dir2module/dir2module.py
@@ -113,8 +113,8 @@ class Module(ModuleBase):
         for pkglicense in self.licenses:
             mod_stream.add_content_license(pkglicense)
 
-        for nevra in self.package_nevras:
-            mod_stream.add_rpm_artifact(nevra)
+#        for nevra in self.package_nevras:
+#            mod_stream.add_rpm_artifact(nevra)
 
         dependencies = Modulemd.Dependencies()
         for depname, depstream in self.requires.items():

Apparently nevras is an empty list, so add_rpm_artifact dies.

I'm hacking yes, but if the list is null, I don't need the code right?

Can you provide a proper fix?

need installation instructions

Hi
I'm trying to use this repo and not sure what should be the way to utilise it in RHEL 8
I've tried yum install modulemd_tools but get Error: Unable to find a match: modulemd_tools

Should I build it from source or is there a way to pull it like any other package?

modulemd_add_platform tool issues with variables

/cc @ppisar
Based on #53 re-factoring of the whole modulemd-tools package, I discovered some issues with modulemd_add_platform tool, see:

modulemd_tools/modulemd_add_platform/modulemd_add_platform.py:77:17: F821 undefined name 'hexvalue'
modulemd_tools/modulemd_add_platform/modulemd_add_platform.py:211:24: F821 undefined name 'indent_configurations'
modulemd_tools/modulemd_add_platform/modulemd_add_platform.py:211:48: F821 undefined name 'indent_context'
modulemd_tools/modulemd_add_platform/modulemd_add_platform.py:214:43: F821 undefined name 'indent_configurations'
modulemd_tools/modulemd_add_platform/modulemd_add_platform.py:215:37: F821 undefined name 'indent_context'
modulemd_tools/modulemd_add_platform/modulemd_add_platform.py:220:25: F841 local variable 'this_context_is_old_platform' is assigned to but never used
modulemd_tools/modulemd_add_platform/modulemd_add_platform.py:238:25: F821 undefined name 'indent_configurations'
modulemd_tools/modulemd_add_platform/modulemd_add_platform.py:243:17: F841 local variable 'indent_context' is assigned to but never used
modulemd_tools/modulemd_add_platform/modulemd_add_platform.py:258:13: F841 local variable 'indent_configurations' is assigned to but never used
modulemd_tools/modulemd_add_platform/modulemd_add_platform.py:445:86: F821 undefined name 'e'
modulemd_tools/modulemd_add_platform/modulemd_add_platform.py:463:21: F524 '...'.format(...) is missing argument(s) for placeholder(s): 1

[RFE] Provide a tool to get module-build-macros SRPM out of modulemd YAML

Because the module-build-macros SRPM is the central piece for building module package, it would be useful to have a simple tool, which would provide the module-build-macros SRPM out of modulemd YAML. Having the SRPM at hand, it would allow me to build modular packages by hand in Mock.

Basically, is should be some simple command line tool, which calls the KojiModuleBuilder.get_disttag_srpm

May be I should contact the fedpkg developers, because calling fedpkg srpm in directory with module YAML file could be interesting variant.

Originally requested here, but I figured this might be better place.

CI error

Invalid workflow file: .github/workflows/rpm.yml#L12
The workflow is not valid. .github/workflows/rpm.yml (Line: 12, Col: 11): Input test_type is required, but not provided while calling.

modulemd-generate-macros: consider whether the YAML file is in git repository

The modulemd-generate-macros script expects, that some mandatory attributes that are described as AUTOMATIC, are filled in the modulemd YAML file (such as name, stream, version, context, and arch). Otherwise, it fails, please see

https://github.com/rpm-software-management/modulemd-tools/tree/master/modulemd-generate-macros#wrong-modulemd-yaml-file

We can add a feature checking whether the passed modulemd YAML file is a part of a GIT repository and if yes, generating those values (well, at least some of them).

Unable to resolve argument foo:devel: broken groups or modules

I have a question about install docker-ce in offline case:

there are two vms, one is online, another is not. I try to download the rpm of docker-ce in the online one and install it on the offline vm.

but met the following error:

[root@localhost repo]#  dnf module install foo:devel
Last metadata expiration check: 0:01:53 ago on Sun 23 Oct 2022 11:30:35 PM EDT.
Unable to resolve argument foo:devel
No match for package docker-ce
Unable to resolve argument foo:devel
No match for package docker-ce-cli
Error: Problems in request:
broken groups or modules: foo:devel, foo:devel

Step to reproduce

on the online one:

  1. add docker-ce repo
sudo yum install -y yum-utils
sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
  1. download rpm
yum makecache
yum install --downloadonly --installroot=/var/rpm/repo-installroot \
	--releasever=8 --downloaddir=/var/rpm/repo docker-ce docker-ce-cli containerd.io docker-compose-plugin
  1. create repo
createrepo --database /var/rpm/repo

add module feature to rpm downloaded, following the instruction Creating a module repository from a set of RPM packages in README.md :

[root@localhost repo]# cd /var/rpm/repo
[root@localhost repo]# dir2module foo:devel:123:f32:x86_64 -m "My example module" --force --dir .
ERROR: RPM does not have `modularitylabel` header set: ./libxkbcommon-0.9.1-1.el8.x86_64.rpm
ERROR: RPM does not have `modularitylabel` header set: ./xkeyboard-config-2.28-1.el8.noarch.rpm
ERROR: RPM does not have `modularitylabel` header set: ./acl-2.2.53-1.el8.1.x86_64.rpm
// a lot of same kind of error, omit for brevity
Created foo:devel:123:f32:x86_64.modulemd.yaml
Created foo:devel:123:f32:x86_64.modulemd-defaults.yaml


[root@localhost repo]# createrepo_mod .
Directory walk started
Directory walk done - 197 packages
Temporary output repo path: ./.repodata/
Preparing sqlite DBs
Pool started (with 5 workers)
Pool finished

[root@localhost repo]# ls repodata/ |grep modules
ce7589fb16229ae9f5c31f2ba47ce60748c4d098e94dd13efd964b3c6f5748c6-modules.yaml.gz

copy the yum repo to /etc/yum.repos.d/ dir:

[root@localhost repo]# cat /etc/yum.repos.d/docker-offline.repo
[docker-offline]
name=My local foo module
baseurl=file:///var/rpm/repo
gpgcheck=0
enabled=1

and check module info:

[root@localhost repo]# dnf module info foo:devel
My local foo module                                                                                          52 MB/s | 277 kB     00:00
Name             : foo
Stream           : devel [d][a]
Version          : 123
Context          : f32
Architecture     :
Profiles         : common [d]
Default profiles : common
Repo             : docker-offline
Summary          : My example module
Description      : This module has been generated using dir2module tool
Requires         :
Artifacts        : acl-0:2.2.53-1.el8.1.x86_64
                 : audit-libs-0:3.0.7-2.el8.2.x86_64
                 : basesystem-0:11-5.el8.noarch
                 : bash-0:4.4.20-4.el8_6.x86_64
                 // a lot of list, no error at the end
[root@localhost repo]# ls |grep modulemd
foo:devel:123:f32:x86_64.modulemd-defaults.yaml
foo:devel:123:f32:x86_64.modulemd.yaml
[root@localhost repo]# pwd
/var/rpm/repo
  1. install the docker on the offline vm (I disconnect the internet at this point of time)

the error I can't figure out:

[root@localhost repo]#  dnf module install foo:devel
Last metadata expiration check: 0:01:22 ago on Sun 23 Oct 2022 11:30:35 PM EDT.
Unable to resolve argument foo:devel
No match for package docker-ce
Unable to resolve argument foo:devel
No match for package docker-ce-cli
Error: Problems in request:
broken groups or modules: foo:devel, foo:devel

bld2repo should download subpackages needed for build

python2-six-1.11.0-6.module+el8.4.0+9287+299307c7 needs python2-libs-2.7.18-2.module+el8.4.0+9193+f3daf6ef.x86_64.rpm for build but the following command does not download it:

$ bld2repo --build-id 1444241 \
    --koji-host "https://brewhub.engineering.redhat.com/brewhub" \
    --koji-storage-host "http://download.devel.redhat.com/brewroot"

... which prevents the package from being successfully built in mock:

$ mock -r rhel-8-x86_64 --quiet --installdeps" "/tmp/csmockiodxf3_u/python2-six-1.11.0-6.module+el8.4.0+9287+299307c7.src.rpm" "--addrepo" "file:///tmp/csmockiodxf3_u/local-build-repo"
Error: 
 Problem: package python2-tkinter-2.7.18-2.module+el8.4.0+9193+f3daf6ef.x86_64 requires python2 = 2.7.18-2.module+el8.4.0+9193+f3daf6ef, but none of the providers can be installed
  - conflicting requests
  - nothing provides python2-libs(x86-64) = 2.7.18-2.module+el8.4.0+9193+f3daf6ef needed by python2-2.7.18-2.module+el8.4.0+9193+f3daf6ef.x86_64
(try to add '--skip-broken' to skip uninstallable packages

I/O intensive walk by createrepo_mod

The code eats in order of magnitude more IO than the optimized createrepo_c run on large repositories.

In copr, we run:
/usr/bin/createrepo_mod /var/lib/copr/public_html/results/iucar/cran/fedora-31-x86_64 --database --ignore-lock --local-sqlite --cachedir /tmp/ --workers 8 --recycle-pkglist --update --skip-stat --pkglist /var/lib/copr/public_html/results/iucar/cran/fedora-31-x86_64/.copr-createrepo-pkglist

RFE - determine build batches from modulemd

I imagine that every build system that supports building modules needs to have some piece of code determining what module RPMs can be built simultaneously and which need to wait and be built after some prerequisites. At this moment it is (AFAIK) trivially determined by buildorder.

The problem is, that build systems still need to parse the modulemd (i.e. directly depend on python3-libmodulemd) and implement this basic functionality by themselves. Therefore I think, that modulemd-tools is the right place to put such code.

I am suggesting to create a script called modulemd-builds or more explicitly modulemd-build-batches that will parse a modulemd YAML file and return output in this format.

[
  [
    {
      "name": "jss",
      "repository": "http://foo.bar/jss.git",
      "ref": "master"
    }
  ],
  [
    {
      "name": "tomcatjss",
      "repository": "http://foo.bar/tomcat.git",
      "ref": "master"
    },
    {
      "name": "ldapjdk",
      "repository": "http://foo.bar/ldapjdk.git",
      "ref": "master"
    }
  ],
  [
    {
      "name": "pki-core",
      "repository": "http://foo.bar/pki-core.git",
      "ref": "master"
    },
    {
      "name": "dogtag-pki",
      "repository": "http://foo.bar/dogtag-pki.git",
      "ref": "master"
    }
  ]
]

So, the format it JSON having a list of batches where each batch is represented by a list of packages. The batches need to be built after each other if and only if all the builds from the previous batch succeeded. Packages within a batch can be submitted in random order or in parallel. Each package is represented by a dictionary of all the parameters required for building it.

Do you think it is worth it having such script? Do you like the output format?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.