Участник:Ulysses

Материал из ALT Linux Wiki

DRAFT

Disclaimer

This wiki article aims to gather basic information in one place. It is for beginner maintainers in Alt. This article does not claim to be complete. Its purpose is to provide the basics. Advanced topics on package building may be covered in other specialized articles. Additionally, experienced maintainers may consider giving lessons to beginners. This article can also be viewed as a reference guide.

Since this is a wiki and not an article on my personal website, other people can edit it.

I do not welcome the following.

  • Text in Russian.
  • Informal language (slang).
  • Alternative viewpoints compared to those described in this article.

I welcome.

  • Adding new examples.
  • Adding links to specialized wiki pages.
  • Correcting errors.

Setting up the build environment

$ ssh-keygen -t ED25519

$ gpg --gen-key

$ gpg --armor --export ulysses@altlinux.org > public.gpg
# apt-get install vim git hasher hasher-priv gear gcc make python patch rpmdevtools rpm-utils rpm-build rpmlint rpm-build-licenses github2spec strace valgrind gdb
$ gpg --list-secret-keys
------------------------------
sec   1024D/835560D9 2023-05-15
uid                  Ulysses Apokin <ulysses@altlinux.org>
$ git config --global user.name 'Ulysses Apokin'

$ git config --global user.email 'ulysses@altlinux.org'

$ git config --global user.signingkey '835560D9'
# hasher-useradd ulysses
# exit
$ pkill -9 -u ulysses
$ mkdir ~/.hasher
$ vim ~/.hasher/config
$ cat ~/.hasher/config

# HASHER-USERADD USERNAME
USER=$USER

# PATH TO WORKDIR
workdir=/tmp/.private/$USER

# TARGET ARCHITECTURE
target=x86_64

# OVERRIDE DEFAULT RPM PACKAGER TAG
packager='Ulysses Apokin <ulysses@altlinux.org>'

# PATH TO CUSTOM APT.CONF FILE
apt_config=$HOME/.hasher/branch.sisyphus-apt.conf

# DO  NOT  RUN  SISYPHUS_CHECK  TESTS
sisyphus_check=--no-check-gpg,--no-check-perms

# SAVE FAKEROOT STATE
save_fakeroot=1

# NO CLEANUP BUILD ENVIRONMENT
lazy_cleanup=1

# EVERY  BUILD  DEPENDENCY  THAT  BELONGS TO THIS LIST WILL BE MOUNTED
known_mountpoints=/dev/pts/,/proc
$ vim ~/.hasher/sisyphus.source.list
$ cat ~/.hasher/sisyphus.source.list
rpm [alt] http://ftp.altlinux.org/pub/distributions ALTLinux/Sisyphus/x86_64 classic
rpm [alt] http://ftp.altlinux.org/pub/distributions ALTLinux/Sisyphus/noarch classic
rpm [alt] http://ftp.altlinux.org/pub/distributions ALTLinux/Sisyphus/x86_64-i586 classic
$ vim ~/.hasher/branch.sisyphus-apt.conf
$ cat ~/.hasher/branch.sisyphus-apt.conf
Dir::Etc::SourceList "/home/ulysses/.hasher/sisyphus.source.list";
Dir::Etc::SourceParts "/var/empty";
$ LANG=C gpg --fingerprint 835560D9 | grep 'fingerprint =' | tr -d ' ' | cut -d= -f2
1B40E49FD40245D0472E4C5FD9528003835560D9
$ vim ~/.rpmmacros
$ cat ~/.rpmmacros

%_topdir	%homedir/RPM

%packager	Ulysses Apokin <ulysses@altlinux.org>
%_gpg_name	1B40E49FD40245D0472E4C5FD9528003835560D9
$ vim ~/.ssh/config
$ cat ~/.ssh/config

Host gitery
	HostName gitery.altlinux.org
	User alt_ulysses
	Port 222
Host gyle
	HostName gyle.altlinux.org
	User alt_ulysses
	Port 222
$ vim ~/.bashrc
$ tail -n 4 ~/.bashrc

alias hasher-build='gear --hasher -- hsh &> LOG'
alias hasher-build-commit='gear --commit --hasher -- hsh &> LOG'
alias hasher-rebuild='gear --hasher -- hsh-rebuild &> LOG'
alias hasher-rebuild-commit='gear --commit --hasher -- hsh-rebuild &> LOG'

Setting up the KVM/QEMU/libvirt hypervisor for package testing

# grep -E 'vmx|svm|0xc0f' /proc/cpuinfo
# find /lib/modules -type f -name *kvm*
# apt-get install qemu
# apt-get install libvirt virt-install dnsmasq dmidecode virt-viewer
# virsh -V
# systemctl enable --now libvirtd.service
# lsmod | grep kvm
# mkdir /QEMU
# mkdir /QEMU/alt-linux-sisyphus
# vim /QEMU/alt-linux-sisyphus/network-alt-linux-sisyphus.xml
# cat /QEMU/alt-linux-sisyphus/network-alt-linux-sisyphus.xml

<network>
	<name>network-alt-linux-sisyphus</name>
	<forward mode='nat'/>
	<bridge name='virbr1' stp='on' delay='0'/>
	<ip address='10.0.1.1' netmask='255.255.255.0'>
		<dhcp>
			<range start='10.0.1.200' end='10.0.1.254'/>
		</dhcp>
	</ip>
</network>
# virsh net-define /QEMU/alt-linux-sisyphus/network-alt-linux-sisyphus.xml
# virsh net-start network-alt-linux-sisyphus
# virsh net-autostart network-alt-linux-sisyphus
# virsh net-list --all
# vim /QEMU/alt-linux-sisyphus/pool-alt-linux-sisyphus.xml
# cat /QEMU/alt-linux-sisyphus/pool-alt-linux-sisyphus.xml

<pool type='dir'>
	<name>pool-alt-linux-sisyphus</name>
	<target>
		<path>/QEMU/pool-alt-linux-sisyphus</path>
	</target>
</pool>
# mkdir /QEMU/pool-alt-linux-sisyphus
# virsh pool-define /QEMU/alt-linux-sisyphus/pool-alt-linux-sisyphus.xml
# virsh pool-start pool-alt-linux-sisyphus
# virsh pool-autostart pool-alt-linux-sisyphus
# virsh pool-list --all
# wget https://nightly.altlinux.org/p11/release/alt-p11-icewm-20241212-x86_64.iso -P /QEMU/alt-linux-sisyphus/
# virt-install \
  --name alt-linux-sisyphus \
  --memory 4096 \
  --vcpus=3 \
  --cpu host \
  --cdrom /QEMU/alt-linux-sisyphus/alt-p11-icewm-20241212-x86_64.iso \
  --disk pool=pool-alt-linux-sisyphus,size=40,bus=virtio,sparse=true,cache=none,io=native \
  --network network=network-alt-linux-sisyphus \
  --virt-type kvm \
  --graphics spice
# virsh autostart alt-linux-sisyphus
# virsh list --all
# virt-viewer alt-linux-sisyphus & disown

Additional actions: shared directory with the host

# mkdir /QEMU/Shared
# chown 0777 /QEMU/Shared
# virsh edit alt-linux-sisyphus

Add the following domain XML elements to share the host directory /QEMU/Shared with the guest

<domain>
  ...
  <memoryBacking>
    <source type='memfd'/>
    <access mode='shared'/>
  </memoryBacking>
  ...
  <devices>
    ...
    <filesystem type='mount' accessmode='passthrough'>
      <driver type='virtiofs' queue='1024'/>
      <source dir='/QEMU/Shared'/>
      <target dir='shared_directory'/>
    </filesystem>
    ...
  </devices>
</domain>
# virsh destroy alt-linux-sisyphus
# virsh start alt-linux-sisyphus

Boot the guest and mount the filesystem

# virt-viewer alt-linux-sisyphus & disown
guest# mount -t virtiofs shared_directory /media

Additional actions: fixing sound on the guest operating system

PulseAudio does not work with root privileges by default. Therefore, when we connect to the guest operating system using SPICE, we have no sound. This is because PulseAudio is not available for the root user. To enable sound, we would need to run PulseAudio as root, which is not ideal. Alternatively, we can allow our user to connect to the guest operating system.

# usermod -aG vmusers ulysses
# chown -R root:vmusers /QEMU
# chmod -R 0775 /QEMU

Now we can connect and hear sound.

$ virt-viewer --connect qemu:///system --wait alt-linux-sisyphus &> /dev/null & disown

ALT Packaging Manual

Order of tags in the SPEC file

  1. Name
  2. Version
  3. Release
  4. Epoch
  5. Empty line
  6. Summary
  7. License
  8. Group
  9. Url
  10. Vcs
  11. Empty line
  12. Source
  13. Patch
  14. Empty line
  15. BuildRequires(pre)
  16. Empty line
  17. BuidRequires
  18. Empty line
  19. Requires
  20. Empty line
  21. BuildArch
  22. Empty line
  23. %description
  24. Empty line
  25. %prep
  26. Empty line
  27. %build
  28. Empty line
  29. %install
  30. Empty line
  31. %check
  32. Empty line
  33. % files
  34. Empty line
  35. % changelog

Maintainer's toolkit ALT

Shared Libs Policy Versioning

  1. Definition
    • A shared library (`.so` file) is intended for use by multiple programs.
    • Explicitly loaded `.so` files (e.g., plugins) are not covered by this policy.
  2. Policy Summary:
    • Avoid placing a new soname in a package with the same name where the old soname was located.
  3. Packaging Libraries:
    • Libraries should be packaged in a way that the package name changes with each ABI break.
    • The package should be named `lib%name%abiversion`, where `%abiversion` is the variable part.
    • Development parts of libraries should be in a separate (only one for each library) package named `lib%name-devel`.
    • Static libraries should be in a separate package named `lib%name-devel-static`.
  4. Choosing the Right %abiversion:
    • Use the soversion if explicitly used by library authors.
    • Otherwise, choose a convenient naming scheme (e.g., sequential numbers).
  5. Legacy Libraries and Backports:
    • Move old libraries to the 'System/Legacy libraries' group when a new version appears.

Changelogs

The following abbreviations are accepted in the changelogs.


  • FTBFS - Failed To Build From Source
  • NMU - Non-Maintainer Update