Create rpm for cockpit

NethServer Version: 7.6.1810
Module: Cockpit

I am following tutorial to create a module in cockpit. When i launch make-rpms i obtain this log. Can anyone help me?

make-rpms nethserver-mymodule.spec

prep-sources [INFO] source0 git archive: nethserver-mymodule-0.0.0.tar.gz
INFO: mock.py version 1.4.16 starting (python version = 3.6.8)...
Start: init plugins
INFO: selinux disabled
Finish: init plugins
Start: run
INFO: Start(nethserver-mymodule.spec)  Config(nethserver-7-x86_64)
Start: clean chroot
Finish: clean chroot
Start: chroot init
INFO: calling preinit hooks
INFO: enabled root cache
Start: unpacking root cache
Finish: unpacking root cache
INFO: enabled yum cache
Start: cleaning yum metadata
Finish: cleaning yum metadata
INFO: enabled HW Info plugin
Mock Version: 1.4.16
INFO: Mock Version: 1.4.16
Start: yum update
Failed to set locale, defaulting to C
Finish: yum update
Finish: chroot init
Start: buildsrpm
Start: rpmbuild -bs
Failed to create directory /var/lib/mock/nethserver-7-x86_64/root//sys/fs/selinux: Read-only file system
Failed to create directory /var/lib/mock/nethserver-7-x86_64/root//sys/fs/selinux: Read-only file system
Building target platforms: x86_64
Building for target x86_64
Wrote: /builddir/build/SRPMS/nethserver-mymodule-0.0.0-1.ns7.src.rpm
Finish: rpmbuild -bs
Finish: buildsrpm
INFO: Done(nethserver-mymodule.spec) Config(nethserver-7-x86_64) 2 minutes 1 seconds
INFO: Results and/or logs in: .
INFO: Cleaning up build root ('cleanup_on_success=True')
Start: clean chroot
Finish: clean chroot
Finish: run
INFO: mock.py version 1.4.16 starting (python version = 3.6.8)...
Start: init plugins
INFO: selinux disabled
Finish: init plugins
Start: run
INFO: Start(nethserver-mymodule-0.0.0-1.ns7.src.rpm)  Config(nethserver-7-x86_64)
Start: clean chroot
Finish: clean chroot
Start: chroot init
INFO: calling preinit hooks
INFO: enabled root cache
Start: unpacking root cache
Finish: unpacking root cache
INFO: enabled yum cache
Start: cleaning yum metadata
Finish: cleaning yum metadata
INFO: enabled HW Info plugin
Mock Version: 1.4.16
INFO: Mock Version: 1.4.16
Start: yum update
Failed to set locale, defaulting to C
Finish: yum update
Finish: chroot init
Start: build phase for nethserver-mymodule-0.0.0-1.ns7.src.rpm
Start: build setup for nethserver-mymodule-0.0.0-1.ns7.src.rpm
Failed to create directory /var/lib/mock/nethserver-7-x86_64/root//sys/fs/selinux: Read-only file system
Failed to create directory /var/lib/mock/nethserver-7-x86_64/root//sys/fs/selinux: Read-only file system
Building target platforms: x86_64
Building for target x86_64
Wrote: /builddir/build/SRPMS/nethserver-mymodule-0.0.0-1.ns7.src.rpm
Failed to set locale, defaulting to C
Getting requirements for nethserver-mymodule-0.0.0-1.ns7.src
 --> nethserver-devtools-1.2.1-1.ns7.noarch

=============================================================================================================================================================================================================================================
 Package                                                    Arch                                          Version                                                               Repository                                              Size
=============================================================================================================================================================================================================================================
Installing:
 nethserver-devtools                                        noarch                                        1.2.1-1.ns7                                                           nethserver-base                                         21 k
Installing for dependencies:
 freetype                                                   x86_64                                        2.8-12.el7_6.1                                                        updates                                                380 k
 jbigkit-libs                                               x86_64                                        2.0-11.el7                                                            base                                                    46 k
 libjpeg-turbo                                              x86_64                                        1.2.90-6.el7                                                          base                                                   134 k
 libpng                                                     x86_64                                        2:1.5.13-7.el7_2                                                      base                                                   213 k
 libtiff                                                    x86_64                                        4.0.3-27.el7_3                                                        base                                                   170 k
 libwebp                                                    x86_64                                        0.3.0-7.el7                                                           base                                                   170 k
 python-docutils                                            noarch                                        0.11-0.3.20130715svn7687.el7                                          base                                                   1.5 M
 python-pillow                                              x86_64                                        2.0.0-19.gitd1c6db8.el7                                               base                                                   438 k

Transaction Summary
=============================================================================================================================================================================================================================================
Install  1 Package (+8 Dependent packages)

Total size: 3.1 M
Installed size: 10 M

Installed:
  nethserver-devtools.noarch 0:1.2.1-1.ns7

Dependency Installed:
  freetype.x86_64 0:2.8-12.el7_6.1                       jbigkit-libs.x86_64 0:2.0-11.el7                libjpeg-turbo.x86_64 0:1.2.90-6.el7  libpng.x86_64 2:1.5.13-7.el7_2  libtiff.x86_64 0:4.0.3-27.el7_3  libwebp.x86_64 0:0.3.0-7.el7
  python-docutils.noarch 0:0.11-0.3.20130715svn7687.el7  python-pillow.x86_64 0:2.0.0-19.gitd1c6db8.el7

Finish: build setup for nethserver-mymodule-0.0.0-1.ns7.src.rpm
Start: rpmbuild nethserver-mymodule-0.0.0-1.ns7.src.rpm
Start: Outputting list of installed packages
Finish: Outputting list of installed packages
Failed to create directory /var/lib/mock/nethserver-7-x86_64/root//sys/fs/selinux: Read-only file system
Failed to create directory /var/lib/mock/nethserver-7-x86_64/root//sys/fs/selinux: Read-only file system
Building target platforms: x86_64
Building for target x86_64
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.httTio
+ umask 022
+ cd /builddir/build/BUILD
+ cd /builddir/build/BUILD
+ rm -rf nethserver-mymodule-0.0.0
+ /usr/bin/gzip -dc /builddir/build/SOURCES/nethserver-mymodule-0.0.0.tar.gz
+ /usr/bin/tar -xvvf -
drwxrwxr-x root/root         0 2019-03-19 11:54 nethserver-mymodule-0.0.0/
-rw-rw-r-- root/root     18046 2019-03-19 11:54 nethserver-mymodule-0.0.0/COPYING
-rw-rw-r-- root/root       119 2019-03-19 11:54 nethserver-mymodule-0.0.0/README.md
drwxrwxr-x root/root         0 2019-03-19 11:54 nethserver-mymodule-0.0.0/api/
-rw-rw-r-- root/root         0 2019-03-19 11:54 nethserver-mymodule-0.0.0/api/read
-rw-rw-r-- root/root         0 2019-03-19 11:54 nethserver-mymodule-0.0.0/api/update
-rw-rw-r-- root/root         0 2019-03-19 11:54 nethserver-mymodule-0.0.0/api/validate
-rw-rw-r-- root/root      1215 2019-03-19 11:54 nethserver-mymodule-0.0.0/createlinks
-rw-rw-r-- root/root       832 2019-03-19 11:54 nethserver-mymodule-0.0.0/nethserver-cockpit-empty.json
-rw-rw-r-- root/root      1106 2019-03-19 11:54 nethserver-mymodule-0.0.0/nethserver-cockpit-empty.spec
-rwxrwxr-x root/root       146 2019-03-19 11:54 nethserver-mymodule-0.0.0/prep-sources
drwxrwxr-x root/root         0 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/
drwxrwxr-x root/root         0 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/css/
-rw-rw-r-- root/root         0 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/css/style.css
drwxrwxr-x root/root         0 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/i18n/
-rw-rw-r-- root/root        98 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/i18n/language.json
-rw-rw-r-- root/root      2549 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/index.html
drwxrwxr-x root/root         0 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/js/
-rw-rw-r-- root/root      6254 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/js/app.js
drwxrwxr-x root/root         0 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/js/lib/
-rw-rw-r-- root/root     27206 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/js/lib/sammy.js
-rw-rw-r-- root/root      6134 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/js/lib/sammy.template.js
-rw-rw-r-- root/root      8626 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/logo.png
-rw-rw-r-- root/root        20 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/manifest.json
-rw-rw-r-- root/root        45 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/override.json
drwxrwxr-x root/root         0 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/views/
-rw-rw-r-- root/root        23 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/views/about.html
-rw-rw-r-- root/root        28 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/views/dashboard.html
-rw-rw-r-- root/root        24 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/views/item1.html
-rw-rw-r-- root/root        22 2019-03-19 11:54 nethserver-mymodule-0.0.0/ui/views/logs.html
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd nethserver-mymodule-0.0.0
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.c8kAp4
+ umask 022
+ cd /builddir/build/BUILD
+ cd nethserver-mymodule-0.0.0
+ /usr/bin/make -f /usr/share/nethserver-devtools/docs.mk
make: Nothing to be done for `all'.
+ perl createlinks
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.F0RjEK
+ umask 022
+ cd /builddir/build/BUILD
+ '[' /builddir/build/BUILDROOT/nethserver-mymodule-0.0.0-1.ns7.x86_64 '!=' / ']'
+ rm -rf /builddir/build/BUILDROOT/nethserver-mymodule-0.0.0-1.ns7.x86_64
++ dirname /builddir/build/BUILDROOT/nethserver-mymodule-0.0.0-1.ns7.x86_64
+ mkdir -p /builddir/build/BUILDROOT
+ mkdir /builddir/build/BUILDROOT/nethserver-mymodule-0.0.0-1.ns7.x86_64
+ cd nethserver-mymodule-0.0.0
+ mkdir -p /builddir/build/BUILDROOT/nethserver-mymodule-0.0.0-1.ns7.x86_64/usr/share/cockpit/nethserver-mymodule/
+ mkdir -p /builddir/build/BUILDROOT/nethserver-mymodule-0.0.0-1.ns7.x86_64/usr/share/cockpit/nethserver/applications/
+ mkdir -p /builddir/build/BUILDROOT/nethserver-mymodule-0.0.0-1.ns7.x86_64/usr/libexec/nethserver/api/nethserver-mymodule/
+ tar xvf /builddir/build/SOURCES/nethserver-mymodule.tar.gz -C /builddir/build/BUILDROOT/nethserver-mymodule-0.0.0-1.ns7.x86_64/usr/share/cockpit/nethserver-mymodule/
css/
css/style.css
i18n/
i18n/language.json
index.html
js/
js/app.js
js/lib/
js/lib/sammy.js
js/lib/sammy.template.js
logo.png
manifest.json
override.json
views/
views/about.html
views/dashboard.html
views/item1.html
views/logs.html
+ cp -a nethserver-mymodule.json /builddir/build/BUILDROOT/nethserver-mymodule-0.0.0-1.ns7.x86_64/usr/share/cockpit/nethserver/applications/
cp: cannot stat 'nethserver-mymodule.json': No such file or directory


RPM build errors:
error: Bad exit status from /var/tmp/rpm-tmp.F0RjEK (%install)
    Bad exit status from /var/tmp/rpm-tmp.F0RjEK (%install)
ERROR: Exception(nethserver-mymodule-0.0.0-1.ns7.src.rpm) Config(nethserver-7-x86_64) 2 minutes 11 seconds
INFO: Results and/or logs in: .
INFO: Cleaning up build root ('cleanup_on_failure=True')
Start: clean chroot
Finish: clean chroot
ERROR: Command failed:
 # /usr/bin/systemd-nspawn -q -M 6940fd33f619438d8268102f777996ae -D /var/lib/mock/nethserver-7-x86_64/root -a --capability=cap_ipc_lock --bind=/tmp/mock-resolv.g7462uu7:/etc/resolv.conf --setenv=TERM=vt100 --setenv=SHELL=/bin/bash --setenv=HOME=/builddir --setenv=HOSTNAME=mock --setenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin --setenv=PROMPT_COMMAND=printf "\033]0;<mock-chroot>\007" --setenv=PS1=<mock-chroot> \s-\v\$  --setenv=LANG=C -u mockbuild bash --login -c /usr/bin/rpmbuild -bb --target x86_64 --nodeps /builddir/build/SPECS/nethserver-mymodule.spec
1 Like

No such file or directory: that’s the issue!

Maybe this could do some noise too, does your user is in the mock group?

Hi @davidep and @stephdl. Thank you for your reply.

  • nethserver-mymodule.json is in the nethserver-mymodule directory… I have to put it into another directory?

  • I added root to mock group. I need to use an user different from root?

ensure it has been committed to your local git repo too

you must be an user different from root, member of the mock group.

Never run mock as root.

1 Like

Ok, I will try. Sorry, but it’s the first time I use it :slight_smile:

1 Like

Yes make-rpms loves you commit all your changes before to trigger it

It’s enough to launch ./prep-source and then make-rpms or I need to use some other commands?

AIUI, make-rpms expects to be run in a git repo, and everything you want in the RPM needs to be committed to the repo. This can simply be a local repo; it isn’t like you have to host it on Github.

As Federico says, prep-sources is needed somewhere (i.e. cockpit packages) to gather NPM dependencies before running the build.

exactly a quick and dirty way

git add .
git commit -m 'my first commit'
./prep-source
make-rpms *.spec

once you are satisfied of your work you can set a remote origin and push it to github (nothing here related to rpm bulid)

Keep in mind that cockpit must be restarted after each changes you made in javascript/html/vue js

We will teach you other tricks later

2 Likes

I built the rpm, but when I install it I obtain this error and cockpit doesn’t load… can you help me?

cockpit.ws couldn't read from connection: Peer sent fatal TLS alert: Unknown certificate

In the browser or in the console of the dev tools?

@stephdl In /var/log/messages
Cockpit browser is blank. Console contains javascript errors.

Javascript error in console are probably the clues of your issue

In the meanwhile what did you do, could you recap the command line you have written

This is the error

index.js:7150 Uncaught TypeError: Cannot read property 'label' of null
    at index.js:7150
    at Function.each (jquery.js:185)
    at Object.<anonymous> (index.js:7147)
    at Function.each (jquery.js:185)
    at i.e.load (index.js:7146)
    at x (index.js:6704)
    at d (index.js:6584)
    at Object.e.navigate (index.js:6708)
    at Object._.ready (index.js:7133)
    at r.o (index.js:6564)
index.js:7150 Uncaught TypeError: Cannot read property 'label' of null
    at index.js:7150
    at Function.each (jquery.js:185)
    at Object.<anonymous> (index.js:7147)
    at Function.each (jquery.js:185)
    at i.e.load (index.js:7146)
    at x (index.js:6704)
    at d (index.js:6584)
    at r.<anonymous> (index.js:6737)
    at r.dispatch (jquery.js:2739)
    at r.v.handle (jquery.js:2626)

I used your commands

git add .
git commit -m 'my first commit'
./prep-source
make-rpms *.spec

I’m following this: https://nethserver.github.io/nethserver-cockpit/tutorial/

may I suggest another approach

yum install git npm
git clone git@github.com:stephdl/nethserver-cockpit-empty-VueJS.git
 cd nethserver-cockpit-empty-VueJS 
./prep-sources
make-rpms *.spec
scp *noarch.rpm root@ns7loc11:/root 

on your vm

yum install nethserver-cockpit-empty-VueJS-0.0.0-1.ns7.noarch.rpm nethserver-cockpit -y

This will install your_ amazing_application with vuejs, at worse to learn web development and cockpit you could start with vue, you have hundred thousand lines of code