Hello,
recently I fixed a small bug in cockpit [1]. The fix is rather trivial but it
was
quite difficult to test it and verify that it really fixes the problem.
ALP Prerequisites
=================
1. Install ALP from
https://download.opensuse.org/repositories/SUSE:/ALP/images/,
see the previous mails about the installation and configuration
2. Install cockpit with "transactional-update pkg install cockpit",
then reboot the system
(the backend packages are already preinstalled in the ALP image, this will
install the web frontend)
3. Start the cockpit service: "systemctl enable --now cockpit.socket"
Now you will have the standard cockpit installed and ready to run, you might
test it by connecting to https://localhost:9090
Development
===========
Note: I needed to patch a cockpit plugin which is basically a JS code + HTML +
CSS.
If you would need to patch the cockpit core (the C code) it would be more
difficult, see the suggestion in the end.
I did the development directly on my workstation (Leap 15.4), the ALP instance
was
running in a VM.
Development Prerequisites
-------------------------
For patching a cockpit plugin you should not need much libraries installed, but
the
the Makefile (generated by autotools) requires the libraries also for the C
part.
On my workstation I had to additionally install these packages:
zypper install json-glib-devel krb5-devel sassc nodejs16
You might actually need some more libraries or tools (autotools), I use my
workstation as a development machine and it already contains a lot of libraries.
Check that nodejs and npm default versions are 16, esp. if you have multiple
versions
installed. Originally I probably did something wrong and got some strange
failures...
Then you can checkout the sources from GitHub
git clone [email protected]:cockpit-project/cockpit.git
and checkout the version used in ALP
cd cockpit
git checkout -b 276
Check https://build.opensuse.org/package/show/SUSE:ALP/cockpit, it might change
in
the future.
To build the sources use:
# this installs the npm packages using "npm install"
./autogen.sh
# autogen.sh runs configure but it will very likely fail, by default it needs
# some additional libraries, if you want to patch just a plugin then run
./configure --disable-doc --disable-ssh --disable-pcp --disable-polkit
make
Now the compiled plugins are available in ./dist/ subdirectory. Now we need to
transfer these changed file to the ALP system.
There are several possibilities to do this. You can run an "scp" command after
each
edit/build or you can use some network file system.
I tested that with sshfs. The disadvantage is that the sshfs packages are not
available for ALP, as a workaround I installed the "sshfs" and "fuse3" packages
from
Tumbleweed. That works currently because ALP is based on TW, but that will
probably
not work later when ALP is branched from TW. The clean solution would be to
provide a
container for that...
To mount a directory over sshfs run
sshfs <user>@<machine>:<path_to_git_checkout> /mnt
Now we need cockpit to load the new files. Fortunately it can load the plugins
from
the user's $HOME:
mkdir ~/.local/share/cockpit
link the shared directory from the development machine
ln -s /mnt/dist/networkmanager/ ~/.local/share/cockpit/networkmanager
(You could link the whole /dist/ to override all plugins, but that could
possibly
have some side effects, I'd rather just override the updated plugin to be safe.)
Then you can just reload the cockpit page in the web browser and that's it, you
do
not need to relogin or restart the cockpit service.
Testing with the "main" branch
==============================
Then I wanted to test my change also with the "main" branch to be sure it can be
properly submitted to upstream.
It turned out that they changed the way how the node modules are loaded. They
do not
run "npm install" anymore, but rather use Git submodules for that, the whole
"node_modules" directory is a Git submodule.
The problem is that the submodules are not checked out by default. If you want
to
use the "main" branch then do the initial checkout with
git clone --recurse-submodules [email protected]:cockpit-project/cockpit.git
or if you already have a clone without submodules then you can download them
with
git submodule update --init
Be careful when switching the branches! When you later switch to an older
version you
might need to delete the "node_modules" directory and run ./autogen.sh to
install
them via npm otherwise you will end up with different modules and probably get
some
nasty errors!
Patching the Core Cockpit
=========================
If you need to patch the C part then you could just run "make" and copy the
built
binary to the ALP VM.
The problem is that /usr is read-only in ALP. But you can create a writable
overlay
using overlayfs:
mkdir /tmp/upperdir
mkdir /tmp/workdir
mount -t overlay overlay -o
lowerdir=/usr,upperdir=/tmp/upperdir/,workdir=/tmp/workdir/ /usr
Then the /usr will become writable, see more details in
https://www.kernel.org/doc/Documentation/filesystems/overlayfs.txt
Now you can easily rewrite or edit the files there
cp /mnt/cockpit-tls /usr/libexec/cockpit-tls
To take effect you need to restart the cockpit service
systemctl restart cockpit
HTH
Ladislav
[1] https://github.com/cockpit-project/cockpit/pull/17776
--
Ladislav Slezák
YaST Developer
SUSE LINUX, s.r.o.
Corso IIa
Křižíkova 148/34
18600 Praha 8