Skip to content

YaST Tips and Tricks

Ladislav Slezák edited this page Feb 2, 2022 · 13 revisions

Tips and Tricks

Here are some Tips and Tricks related to YaST. Currently this is just a place for dumping your ideas and knowledge. We should sort, move, ... etc later when we have enough data.

Building Packages

Use RAM disk for package building

To build packages faster you can build them in RAM. The speed up is bigger with rotational disks, on the other hand with SSD you can save quite a lot of writing (less wear off):

# use bigger size if needed
sudo mount -t tmpfs tmpfs -o size=1G,mode=0777 /var/tmp/build-root/
osc build
sudo umount /var/tmp/build-root/

1GB is enough for vast majority of YaST packages but in some cases you might need to use a bigger RAM disk.

Build an YaST Package Chain from Sources

If you change several YaST packages at once and you need to build the RPMs with the new packages use -k (keep) and -p (prefer) osc options for each package:

rake osc:build["-k /tmp/new_packages -p /tmp/new_packages"]

You need to build the packages in the correct build dependency.

Using a Different Build Target

YAST_SUBMIT=sle12sp1 rake osc:build

See the targets.yml for the complete list of the supported targets.

Build a DUD (Driver Update Disk)

mkdud --create dud.cpio.gz --dist sle12 my_updated_package.rpm

To include a new control.xml put it into inst-sys directory and then use

mkdud --create dud.cpio.gz --dist sle12 my_updated_package.rpm inst-sys

Expand RPM Macros in a Spec File

Expanding the RPM %macros in a specfile:

rpmspec --parse *.spec

Code

Conflicting Class Names

Unfortunately there are some YaST class names which conflict with the native Ruby classes. If you need to use the Ruby classes you usually need to fully qualify the name with a double colon, e.g. ::String.

Be careful when referring to these classes:

  • String
  • FileUtils
  • ???

YaST at Installation

YaST at Run Time

YaST Installation Theme

Using the YaST installation theme in a running system:

Y2STYLE=installation.qss yast2 repositories

Registration

See more at Registration Wiki

Migration

AutoYaST

Package Management

Virtualization

VirtualBox Remote Display

  • Install the VirtualBox Extension Pack
  • Enable remote access in the VM setup (Display➔Remote Display➔Enable Server)
  • Make sure krdc package is installed
  • Connect to the VM using command krdc rdp://localhost:3389

Emulating a Serial Console in VirtualBox

  • Install the socat utility (zypper in socat) in the host system
  • Create a new virtual machine in VirtualBox, configure it for installing the requested product (i.e. add the selected ISO image as a virtual CD drive)
  • In "Settings" -> "Serial Ports" set "Enable Serial Port", "Port Number": COM1, "Port Mode": "Host Pipe" Select "Create Pipe" checkbox, enter path to the created pipe file in "Port/File Path" (e.g. /home/user/com1)
  • Boot the machine
  • In the host run command socat unix-connect:/home/user/com1 stdio,raw,echo=0,icanon=0 in a terminal (replace /home/user by the path set in the serial port config)
  • In the VM boot prompt add console=ttyS0,115200 option (or you can enter that using the text menu in the serial console)
  • Start the installation
  • You should see the boot process and then textmode YaST installer in the serial console terminal. Install the system as usually, there is nothing specific to serial console installation (besides it is in textmode).

Testing

Simple Web Server

If you need to quickly run a web server to serve a testing AutoYaST profile or installation repository at http://localhost:8000/

ruby -run -ehttpd . -p8000

To use HTTPS (https://localhost:8000/) run

# generate a random SSL certificate at every start
ruby -r webrick/https -e 'WEBrick::HTTPServer.new(Port: 8000, DocumentRoot: ".", SSLEnable: true, SSLCertName: [["CN", "localhost", OpenSSL::ASN1::PRINTABLESTRING]]).start'
# use a custom certificate and key
ruby -r webrick/https -e 'WEBrick::HTTPServer.new(Port: 8000, DocumentRoot: ".", SSLEnable: true, SSLCertificate: OpenSSL::X509::Certificate.new(File.read("cert.pem")), SSLPrivateKey: OpenSSL::PKey::RSA.new(File.read("key.pem"))).start'

RPM Repository

Miscellaneous

Timestamping STDOUT

Print time stamp for each STDOUT line to see how long does it take to print some line from program start or since printing the previous line.

Install the moreutils package(zypper in moreutils).

# time from start
<command> | ts -s %.s
# time for each line
<command> | ts -i %.s
# if the <command> uses STDOUT buffering you might disable
# that with some command line option or you might try the `unbuffer` tool
unbuffer <command> | ts -s %.s

Example to find long running unit tests:

rake test:unit | ts -i %.s

Debugging SSL Problems

Screen Recording

See these blog posts:

Attaching a Screenshot at GitHub

You can attach images and screenshots to GitHub README and Wiki. The problem is where to store the images. You can store them directly in the Git repository, but the problem is that these images will be included in every clone and the Git repository size can grow up pretty quickly.

The solution is to attach the assets into a GitHub issue and link them from elsewhere. See this article for the details.

Useful Links

Quick Docker Crash Course

Terminology

  • image - root filesystem with some additional attributes (e.g. the default environment variables), changes done by a container are local
  • container - running instance using a Docker image, each instance has its own writable overlay so they cannot change the original image or affect the other containers using the same image
  • volume - special directory in the container tree which is mapped to a host directory (outside the Docker image), can be used for persistent data or for sharing data between several containers

See more in the Docker Glossary.

Links

Installation

  • Install Docker: sudo zypper in docker
  • Start the Docker service sudo systemctl start docker
  • Start it at boot sudo systemctl enable docker
  • Add yourselves into the docker user groups otherwise you will need to run all commands below as the root user: sudo usermod -a -G docker `whoami`

Basic Docker Commands

  • docker build -t <tag> . build an image from Dockerfile, the last argument is a directory with Dockerfile. The build steps are cached, repeated builds use the previous results if possible.
  • docker images prints the locally available images (built or downloaded)
  • docker pull downlod an image from a server
  • docker run -it --rm <image> <command> start a new container (-i interactive, -t use a TTY, --rm remove the container after exiting, see the Docker Run reference)
  • docker ps prints containers (-a also stopped)

Examples

  • docker run -it -p 8080:80 nginx download and run the nginx container (to check open http://localhost:8080)
  • docker run -it -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123 mysql start an MySQL server, connect with mysql -h 127.0.0.1 -u root -p shutdown using the mysqladmin -h 127.0.0.1 -u root -p shutdown command

Tips & Tricks

  • CTRL-p CTRL-q detach from terminal (in TTY mode)
  • docker attach <container> attach back
  • docker top <container>
  • docker stats <container>
  • docker commit save result of a stopped container, make the changes permanent

Cleanup

  • docker rm <container> remove a container
  • docker rmi <image> remove an image
  • docker images -q --filter "dangling=true" | xargs docker rmi remove unused images

Big Cleanup

Be careful when running these:

  • docker rm `docker ps -a -q` removes all containers
  • docker rm `docker ps -f "status=exited" -q` removes all exited containers
  • docker rmi `docker images -q` removes all images