The Wakes Book

Wakes GNU/Linux 1.1

Guillaume Kielwasser

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".

Revision History
Revision 0.109 Sept 2008G. Kielwasser
Initial dump
Revision 0.219 Oct 2009G. Kielwasser
Initial write
Revision 0.306 Aug 2010G. Kielwasser
Main contribution
Revision 0.406 Aug 2012G. Kielwasser
Fit installation of gnuwakes 0.2 build number 025
Revision 0.509 Aug 2013G. Kielwasser
Added documentation on how to create the initramfs; Added details on the kernel configuration; Modified installation guide to fir build number 42
Revision 0.627 May 2014G. Kielwasser
Updated to fit Wakes version 0.3
Revision 0.722 June 2014G. Kielwasser
Updated to fit Wakes version 0.4
Revision 0.802 August 2015G. Kielwasser
Updated to fit Wakes version 1.0. This is an alpha revision.
Revision 0.923 September 2015G. Kielwasser
Removed images, fixed manual partition procedure.
Revision 0.1017 Juillet 2016G. Kielwasser
Updated for Wakes version 1.1.
Revision 0.1127 Mai 2018G. Kielwasser
Updated for Wakes version 1.1, build 038.

About this document

Understanding this document assume a certain knowledge of UNIX administration. It can serve as reminder of infrequently used admin commands, but not as novice guidance for beginners.


Table of Contents

I. Developer's Reference Manual
1. Build the programs
2. Build the Linux kernel
3. Initramfs
4. ISO Managment
5. Wakes installer
6. Package manager
II. Installation Guide
7. Download
8. Installation
III. Administrator's Guide
9. Add non priviledged user
10. Grub
11. LVM
12. Console
13. OpenSSH SSH daemon
14. Qemu
15. Java
16. Silc server
17. MySQL
18. Xorg
19. FVWM
20. VirtualBox
21. Tuning
22. Docker
IV. Software Compilaton
23. build
A. GNU Free Documentation License

Part I. Developer's Reference Manual

About this part

Developing a Linux distribution means basically compiling the programs you want in your distro. But not only! Once you have your programs compiled, you must package them (in order to distribute them), and you need an installer (in order to deploy the operating system on a machine). This part document all the steps required to build the Wakes operating system.

Chapter 1. Build the programs

Building programs is made using a independant environment.

1. Independant build environment

The indenpendant environement is basically a folder you can chroot in and compile programs from. The build toolchain is located in an non standard location (/tools in our case), in oder to copy compiled programs in standard locations (/bin, /usr/bin, etc).

1.1. Chroot folder

The Wakes independant build environment (the toolchain) is widely based on the LFS 7.5 temporary system. In addition to it, the following programs were added:

ksh
zlib
iproute2
openssl
openssh
vi
wget
procps
libtar
libarchive
libcurl

1.2. Docker image

The goal is to create a docker image instead of using a basic chroot script to enter the image. Once the toolchain folder is ready, create the docker image:

tar -C /toolchain -c . | docker import - toolchain

Then you can start a container from this image:

docker run -d -p 2222:22 -it toolchain /tools/sbin/sshd -D

and enter the image using ssh:

ssh -p 2222 root@0

2. Adjusted toolchain

todo: compile glibc, wkpkg, make the wakes prep

2.1. Compile wkpkg

wkpkg: wkpkg.o
	gcc -o wkpkg -Wall -g -lm -lrt -ldl wkpkg.o /tools/lib/libtar.a  \
        /tools/lib/libz.a /tools/lib/libarchive.a /tools/lib/libbz2.a    \
        /tools/lib/libcurl.a /tools/lib/libssl.a /tools/lib/libcrypto.a

wkpkg.o: wkpkg.c
	gcc -Wall -g -c wkpkg.c

clean:
	rm wkpkg.o wkpkg

2.2. Wakes preparation

cat <<EOF > /etc/wkpkg.conf

# Default network depot
http://www.gnuwakes.org/depot main

#usb://depot main

#ftp://www.gnuwakes.org/depot main
#cdrom://depot    main

#disk://var/wkpkg/rep main

EOF

cat <<EOF > /etc/wakes_version
1.0
EOF

mkdir /var/wkpkg/{cat,rep,db,mnt,run}
mkdir /var/wkpkg/mnt/{cdrom,usb}

2.3. Adjust the toolchain

# install linux header and glibc
wkpkg -i linux-headers-4.1.1
wkpkg -i glibc

# ld
mv -v /tools/bin/{ld,ld-old}
mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}
mv -v /tools/bin/{ld-new,ld}
ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld

# gcc
gcc -dumpspecs | sed -e 's@/tools@@g'                   \
    -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \
    -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' >      \
    `dirname $(gcc --print-libgcc-file-name)`/specs

2.4. Make the docker image

commit change from the running container to a new one:

# id: from docker ps
docker commit id toolchain-wakes-adjusted

run the adjusted container:

docker run -d -p 2223:22 -it toolchain-wakes-adjusted /tools/sbin/sshd -D

enter the adjusted container:

ssh -p 2223 root@0

Chapter 2. Build the Linux kernel

Linux is a clone of the operating system Unix, written from scratch by Linus Torvalds with assistance from a loosely-knit team of hackers across the Net. It aims towards POSIX and Single UNIX Specification compliance.

1. Configuration

Make sure you have no stale .o files and dependencies lying around:

make mrproper

Run the text based color menus, radiolists & dialogs kernel configuration tools:

make menuconfig

Configure the kernel based on arch/x86/configs/i386_defconfig and the following recommandations.

1.1. Generic configuration

1.1.1. 64-bit kernel

This option lets you build a 64-bit kernel (formerly known as x86_64).

Symbol: 64BIT [=y]
Type  : boolean
Prompt: 64-bit kernel

1.1.2. Local version

Append an extra string to the end of your kernel version. Keep it empty.

Symbol: LOCALVERSION [=]
Type  : string
Prompt: Local version - append to kernel release
  Location:
    -> General setup

1.1.3. Default hostname

Sets the default system hostname before userspace calls sethostname(2).

Symbol: DEFAULT_HOSTNAME [=wakes]
Type  : string
Prompt: Default hostname
  Location:
    -> General setup

1.1.4. swap

Adds support for so called swap devices or swap files in your kernel that are used to provide more virtual memory than the actual RAM present in your computer.

Symbol: SWAP [=y]
Type  : boolean
Prompt: Support for paging of anonymous memory (swap)
  Location:
    -> General setup
  Depends on: MMU [=y] && BLOCK [=y]

1.1.5. Kernel .config

This option enables the complete Linux kernel ".config" file contents to be saved in the kernel. It can be extracted from a running kernel by reading /proc/config.gz or using the script scripts/extract-ikconfig provided with the kernel sources.

Symbol: IKCONFIG [=y]
Prompt: Kernel .config support
  Location:
    -> General setup
Symbol: IKCONFIG_PROC [=y]
Prompt: Enable access to .config through /proc/config.gz
  Location:
    -> General setup
      -> Kernel .config support (IKCONFIG [=y])
  Depends on: IKCONFIG [=y] && PROC_FS [=y]

1.1.6. Initial RAM filesystem and RAM disk

The initial RAM filesystem is a ramfs which is loaded by the boot loader (loadlin or lilo) and that is mounted as root before the normal boot procedure. It is typically used to load modules needed to mount the "real" root file system, etc.

Symbol: BLK_DEV_INITRD [=y]
Type  : boolean
Prompt: Initial RAM filesystem and RAM disk (initramfs/initrd) support
  Location:
    -> General setup
  Depends on: BROKEN [=n] || !FRV

1.1.7. ACPI

Advanced Configuration and Power Interface is an open industry specification that provides a robust functional replacement for several legacy configuration and power management interfaces, including the Plug-and-Play BIOS specification (PnP BIOS), the MultiProcessor Specification (MPS), and the Advanced Power Management (APM) specification.

Symbol: ACPI [=y]
Type  : boolean
Prompt: ACPI (Advanced Configuration and Power Interface) Support
  Location:
    -> Power management and ACPI options
  Depends on: !IA64_HP_SIM && (IA64 || X86 [=y]) && PCI [=y]
  Selects: PNP [=n]

1.1.8. Stack utilization messages

Stack utilization instrumentation: disable to avoid messages like "lvm used greatest stack depth: 5956 bytes left"

Symbol: DEBUG_STACK_USAGE [=n]
Prompt: Stack utilization instrumentation
  Depends on: DEBUG_KERNEL
  Location:
    -> Kernel hacking

1.1.9. SysRq

With SysRq (Alt+PrintScreen) you will be able to flush the buffer cache to disk, reboot the system immediately or dump some status information.

Symbol: MAGIC_SYSRQ [=y]
Type  : boolean
Prompt: Magic SysRq key
  Location:
    -> Kernel hacking
  Depends on: !UML

1.1.10. kexec

kexec is a system call that implements the ability to shutdown your current kernel, and to start another kernel. It is like a reboot but it is independent of the system firmware. And like a reboot you can start any kernel with it, not just Linux.

Symbol: KEXEC [=y]
Type  : boolean
Prompt: kexec system call
  Location:
    -> Processor type and features

1.1.11. kdump

Generate crash dump after being started by kexec.

Symbol: CRASH_DUMP [=y]
Type  : boolean
Prompt: kernel crash dumps
  Location:
    -> Processor type and features
  Depends on: X86_64 [=n] || X86_32 [=y] && HIGHMEM [=y]

1.1.12. SMP

This enables support for systems with more than one CPU.

Symbol: SMP [=y]
Type  : boolean
Prompt: Symmetric multi-processing support
  Location:
    -> Processor type and features

1.1.13. Big SMP

This option is needed for the systems that have more than 8 CPUs.

Symbol: X86_BIGSMP [=y]
Type  : boolean
Prompt: Support for big SMP systems with more than 8 CPUs
  Location:
    -> Processor type and features
  Depends on: X86_32 [=y] && SMP [=y]

1.1.14. Maximum number of CPUs

This allows you to specify the maximum number of CPUs which this kernel will support. The maximum supported value is 512.

Symbol: NR_CPUS [=64]
Type  : integer
Range : [2 512]
Prompt: Maximum number of CPUs
  Location:
    -> Processor type and features

1.2. Control Groups

This option adds support for grouping sets of processes together, for use with process control subsystems such as Cpusets, CFS, memory controls or device isolation.

Symbol: CGROUPS [=y]
Type  : boolean
Prompt: Control Group support
  Location:
    -> General setup
  Depends on: EVENTFD [=y]
  Selected by: SCHED_AUTOGROUP [=n]

1.2.1. Freezer cgroup subsystem

Provides a way to freeze and unfreeze all tasks in a cgroup.

Symbol: CGROUP_FREEZER [=y]
Type  : boolean
Prompt: Freezer cgroup subsystem
  Location:
    -> General setup
      -> Control Group support (CGROUPS [=y])
  Depends on: CGROUPS [=y]

1.2.2. Device controller for cgroups

Provides a cgroup implementing whitelists for devices which a process in the cgroup can mknod or open.

Symbol: CGROUP_DEVICE [=y]
Type  : boolean
Prompt: Device controller for cgroups
  Location:
    -> General setup
      -> Control Group support (CGROUPS [=y])
  Depends on: CGROUPS [=y]

1.2.3. Cpuset support

This option will let you create and manage CPUSETs which allow dynamically partitioning a system into sets of CPUs and Memory Nodes and assigning tasks to run only within those sets. This is primarily useful on large SMP or NUMA systems.

Symbol: CPUSETS [=y]
Type  : boolean
Prompt: Cpuset support
  Location:
    -> General setup
      -> Control Group support (CGROUPS [=y])
  Depends on: CGROUPS [=y]

1.2.4. Simple CPU accounting cgroup subsystem

Provides a simple Resource Controller for monitoring the total CPU consumed by the tasks in a cgroup.

Symbol: CGROUP_CPUACCT [=y]
Type  : boolean
Prompt: Simple CPU accounting cgroup subsystem
  Location:
    -> General setup
      -> Control Group support (CGROUPS [=y])
  Depends on: CGROUPS [=y]

1.2.5. Resource counters

This option enables controller independent resource accounting infrastructure that works with cgroups.

Symbol: RESOURCE_COUNTERS [=y]
Type  : boolean
Prompt: Resource counters
  Location:
    -> General setup
      -> Control Group support (CGROUPS [=y])
  Depends on: CGROUPS [=y]

1.2.6. Enable perf_event per-cpu per-container group (cgroup) monitoring

This option extends the per-cpu mode to restrict monitoring to threads which belong to the cgroup specified and run on the designated cpu.

Symbol: CGROUP_PERF [=y]
Type  : boolean
Prompt: Enable perf_event per-cpu per-container group (cgroup) monitoring
  Location:
    -> General setup
      -> Control Group support (CGROUPS [=y])
  Depends on: PERF_EVENTS [=y] && CGROUPS [=y]

1.2.7. Group CPU scheduler

This feature lets CPU scheduler recognize task groups and control CPU bandwidth allocation to such task groups. It uses cgroups to group tasks.

Symbol: CGROUP_SCHED [=y]
Type  : boolean
Prompt: Group CPU scheduler
  Location:
    -> General setup
      -> Control Group support (CGROUPS [=y])
  Depends on: CGROUPS [=y]

1.2.8. Block IO controller

Generic block IO controller cgroup interface. This is the common cgroup interface which should be used by various IO controlling policies.

Symbol: BLK_CGROUP [=y]
Type  : boolean
Prompt: Block IO controller
  Location:
    -> General setup
      -> Control Group support (CGROUPS [=y])
  Depends on: CGROUPS [=y] && BLOCK [=y]

1.3. Virtualization

1.3.1. KVM host

This allows your Linux host to run other operating systems inside virtual machines (guests). It supports hosting fully virtualized guest machines using hardware virtualization extensions. It also provides support for KVM on Intel processors equipped with the VT extensions and AMD processors equipped with the AMD-V (SVM) extensions.

Symbol: VIRTUALIZATION [=y]
Type  : boolean
Prompt: Virtualization
  Depends on: HAVE_KVM [=y] || X86 [=y]
Symbol: KVM [=m]
Type  : tristate
Prompt: Kernel-based Virtual Machine (KVM) support
  Location:
    -> Virtualization (VIRTUALIZATION [=y])
  Depends on: VIRTUALIZATION[=y] && HAVE_KVM[=y] && HIGH_RES_TIMERS [=y] && NET [=y]
Symbol: KVM_INTEL [=m]
Prompt: KVM for Intel processors support
  Depends on: VIRTUALIZATION && KVM
  Location:
    -> Virtualization (VIRTUALIZATION [=y])
      -> Kernel-based Virtual Machine (KVM) support (KVM [=m])
Symbol: KVM_AMD [=m]
Prompt: KVM for AMD processors support
  Depends on: VIRTUALIZATION && KVM
  Location:
    -> Virtualization (VIRTUALIZATION [=y])
      -> Kernel-based Virtual Machine (KVM) support (KVM [=m])

1.3.2. VM guest

This enables options for running Linux under various hyper-visors. This option enables basic hypervisor detection and platform setup.

Symbol: HYPERVISOR_GUEST [=y]
Type  : boolean
Prompt: Linux guest support
  Location:
    -> Processor type and features
  Selected by: X86_VSMP [=n] && X86_64 [=n] && PCI [=y] && X86_EXTENDED_PLATFORM [=n] && SMP [=y]
1.3.2.1. Paravirtualization

This changes the kernel so it can modify itself when it is run under a hypervisor, potentially improving performance significantly over full virtualization.

Symbol: PARAVIRT [=y]
Type  : boolean
Prompt: Enable paravirtualization code
  Location:
    -> Processor type and features
      -> Linux guest support (HYPERVISOR_GUEST [=y])
  Depends on: HYPERVISOR_GUEST [=y]
  Selected by: X86_VSMP [=n] && X86_64 [=n] && PCI [=y] && X86_EXTENDED_PLATFORM [=n] && SMP [=y]
1.3.2.2. KVM guest support

This option enables various optimizations for running under the KVM hypervisor.

Symbol: KVM_GUEST [=y]
Type  : boolean
Prompt: KVM Guest support (including kvmclock)
  Location:
    -> Processor type and features
      -> Linux guest support (HYPERVISOR_GUEST [=y])
  Depends on: HYPERVISOR_GUEST [=y] && PARAVIRT [=y]
  Selects: PARAVIRT_CLOCK [=y]
1.3.2.3. Lguest guest support

Lguest is a tiny in-kernel hypervisor. Selecting this will allow your kernel to boot under lguest.

Symbol: LGUEST_GUEST [=y]
Type  : boolean
Prompt: Lguest guest support
  Location:
    -> Processor type and features
      -> Linux guest support (HYPERVISOR_GUEST [=y])
  Depends on: HYPERVISOR_GUEST [=y] && X86_32 [=y] && PARAVIRT [=y]
  Selects: TTY [=y] && VIRTUALIZATION [=y] && VIRTIO [=y] && VIRTIO_CONSOLE [=y]
1.3.2.4. Xen guest support

This is the Linux Xen port. Enabling this will allow the kernel to boot in a paravirtualized environment under the Xen hypervisor.

Symbol: XEN [=y]
Type  : boolean
Prompt: Xen guest support
  Location:
    -> Processor type and features
      -> Linux guest support (HYPERVISOR_GUEST [=y])
        -> Enable paravirtualization code (PARAVIRT [=y])
  Depends on: HYPERVISOR_GUEST [=y] && PARAVIRT [=y] && \
              (X86_64 [=n] || X86_32 [=y] && X86_PAE [=y] && \
              !X86_VISWS [=n]) && X86_TSC [=y]
  Selects: PARAVIRT_CLOCK [=y] && XEN_HAVE_PVMMU [=n]

1.3.3. Virt I/O support

1.3.3.1. PCI driver for virtio devices

This drivers provides support for virtio based paravirtual device drivers over PCI. Most QEMU based VMMs should support these devices (like KVM or Xen).

Symbol: VIRTIO_PCI [=y]
Type  : tristate
Prompt: PCI driver for virtio devices
  Location:
    -> Device Drivers
      -> Virtio drivers
  Depends on: PCI [=y]
  Selects: VIRTIO [=y]
1.3.3.2. Virtio balloon driver

This driver supports increasing and decreasing the amount of memory within a KVM guest.

Symbol: VIRTIO_BALLOON [=y]
Type  : tristate
Prompt: Virtio balloon driver
  Location:
    -> Device Drivers
      -> Virtio drivers
  Depends on: VIRTIO [=y]
1.3.3.3. Virtio block driver

This is the virtual block driver for virtio. It can be used with lguest or QEMU based VMMs (like KVM or Xen).

Symbol: VIRTIO_BLK [=y]
Type  : tristate
Prompt: Virtio block driver
  Location:
    -> Device Drivers
      -> Block devices (BLK_DEV [=y])
  Depends on: BLK_DEV [=y] && VIRTIO [=y]
1.3.3.4. Virtio network driver

This is the virtual network driver for virtio. It can be used with lguest or QEMU based VMMs (like KVM or Xen).

Symbol: VIRTIO_NET [=y]
Type  : tristate                                                        
Prompt: Virtio network driver
  Location:
    -> Device Drivers
      -> Network device support (NETDEVICES [=y])
        -> Network core driver support (NET_CORE [=y])
  Depends on: NETDEVICES [=y] && NET_CORE [=y] && VIRTIO [=y]
1.3.3.5. Virtio console

Virtio console for use with lguest and other hypervisors.

Symbol: VIRTIO_CONSOLE [=y]
Type  : tristate
Prompt: Virtio console
  Location:
    -> Device Drivers
      -> Character devices
  Depends on: VIRTIO [=y] && TTY [=y]
  Selects: HVC_DRIVER [=y]
  Selected by: LGUEST_GUEST [=y] && PARAVIRT_GUEST [=y] && X86_32 [=y] && PARAVIRT [=y]
1.3.3.6. Virtio Random Number Generator support

This driver provides kernel-side support for the virtual Random Number Generator hardware.

Symbol: HW_RANDOM_VIRTIO [=y]
Type  : tristate
Prompt: VirtIO Random Number Generator support
  Location:
    -> Device Drivers
      -> Character devices
        -> Hardware Random Number Generator Core support (HW_RANDOM [=y])
  Depends on: HW_RANDOM [=y] && VIRTIO [=y]

1.4. Multiple devices driver support

Support multiple physical spindles through a single logical device. Required for RAID and logical volume management.

Symbol: MD [=y]
Type  : boolean
Prompt: Multiple devices driver support (RAID and LVM)
  Location:
    -> Device Drivers
  Depends on: BLOCK [=y]

1.4.1. RAID support

This driver lets you combine several hard disk partitions into one logical block device. This can be used to simply append one partition to another one or to combine several redundant hard disks into a RAID1/4/5 device so as to provide protection against hard disk failures. This is called "Software RAID" since the combining of the partitions is done by the kernel.

Symbol: BLK_DEV_MD [=y]
Type  : tristate
Prompt: RAID support
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
  Depends on: MD [=y]
  Selected by: DM_RAID [=y] && MD [=y] && BLK_DEV_DM [=y]
1.4.1.1. Linear (append) mode

This mode combines the hard disk partitions by simply appending one to the other.

Symbol: MD_LINEAR [=y]
Type  : tristate
Prompt: Linear (append) mode
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
        -> RAID support (BLK_DEV_MD [=y])
  Depends on: MD && BLK_DEV_MD
1.4.1.2. RAID-0 (striping) mode

This mode combines the hard disk partitions into one logical device in such a fashion as to fill them up evenly, one chunk here and one chunk there. This will increase the throughput rate if the partitions reside on distinct disks.

Symbol: MD_RAID0 [=y]
Type  : tristate
Prompt: RAID-0 (striping) mode
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
        -> RAID support (BLK_DEV_MD [=y])
  Depends on: MD && BLK_DEV_MD
1.4.1.3. RAID-1 (mirroring) mode

A RAID-1 set consists of several disk drives which are exact copies of each other. In the event of a mirror failure, the RAID driver will continue to use the operational mirrors in the set, providing an error free MD (multiple device) to the higher levels of the kernel. In a set with N drives, the available space is the capacity of a single drive, and the set protects against a failure of (N - 1) drives.

Symbol: MD_RAID1 [=y]
Type  : tristate
Prompt: RAID-1 (mirroring) mode
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
        -> RAID support (BLK_DEV_MD [=y])
  Depends on: MD && BLK_DEV_MD
1.4.1.4. RAID-10 (mirrored striping) mode

RAID-10 provides a combination of striping (RAID-0) and mirroring (RAID-1) with easier configuration and more flexible layout. Unlike RAID-0, but like RAID-1, RAID-10 requires all devices to be the same size (or at least, only as much as the smallest device will be used).

Symbol: MD_RAID10 [=y]
Type  : tristate
Prompt: RAID-10 (mirrored striping) mode
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
        -> RAID support (BLK_DEV_MD [=y])
  Depends on: MD && BLK_DEV_MD
1.4.1.5. RAID-4/RAID-5/RAID-6 mode

A RAID-5 set of N drives with a capacity of C MB per drive provides the capacity of C * (N - 1) MB, and protects against a failure of a single drive. For a given sector (row) number, (N - 1) drives contain data sectors, and one drive contains the parity protection. For a RAID-4 set, the parity blocks are present on a single drive, while a RAID-5 set distributes the parity across the drives in one of the available parity distribution methods.

A RAID-6 set of N drives with a capacity of C MB per drive provides the capacity of C * (N - 2) MB, and protects against a failure of any two drives. For a given sector (row) number, (N - 2) drives contain data sectors, and two drives contains two independent redundancy syndromes. Like RAID-5, RAID-6 distributes the syndromes across the drives in one of the available parity distribution methods.

Symbol: MD_RAID456 [=y]
Type  : tristate
Prompt: RAID-4/RAID-5/RAID-6 mode
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
        -> RAID support (BLK_DEV_MD [=y])
  Depends on: MD && BLK_DEV_MD
1.4.1.6. Faulty test module for MD

The "faulty" module allows for a block device that occasionally returns read or write errors. It is useful for testing.

Symbol: MD_FAULTY [=y]
Type  : tristate
Prompt: Faulty test module for MD
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
        -> RAID support (BLK_DEV_MD [=y])
  Depends on: MD [=y] && BLK_DEV_MD [=y]

1.4.2. Block device as cache

Allows a block device to be used as cache for other devices; uses a btree for indexing and the layout is optimized for SSDs.

Symbol: BCACHE [=y]
Type  : tristate
Prompt: Block device as cache
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
  Depends on: MD [=y]

1.4.3. Device Mapper support

Device-mapper is a low level volume manager. It works by allowing people to specify mappings for ranges of logical sectors. Various mapping types are available, in addition people may write their own modules containing custom mappings if they wish.

Symbol: BLK_DEV_DM [=y]
Type  : tristate
Prompt: Device mapper support
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
  Depends on: MD [=y]
1.4.3.1. Crypt target support

This device-mapper target allows you to create a device that transparently encrypts the data on it. You'll need to activate the ciphers you're going to use in the cryptoapi configuration.

Symbol: DM_CRYPT [=y]
Type  : tristate
Prompt: Crypt target support
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
        -> Device mapper support (BLK_DEV_DM [=y])
  Selects: CRYPTO && CRYPTO_CBC
  Depends on: MD && BLK_DEV_DM
1.4.3.2. Snapshot target

Allow volume managers to take writable snapshots of a device.

Symbol: DM_SNAPSHOT [=y]
Type  : tristate
Prompt: Snapshot target
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
        -> Device mapper support (BLK_DEV_DM [=y])
  Depends on: MD && BLK_DEV_DM
1.4.3.3. Thin provisioning target

Provides thin provisioning and snapshots that share a data store.

Symbol: DM_THIN_PROVISIONING [=y]
Type  : tristate
Prompt: Thin provisioning target
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
        -> Device mapper support (BLK_DEV_DM [=y])
  Depends on: MD && BLK_DEV_DM
1.4.3.4. Cache target

dm-cache attempts to improve performance of a block device by moving frequently used data to a smaller, higher performance device. Different 'policy' plugins can be used to change the algorithms used to select which blocks are promoted, demoted, cleaned etc. It supports writeback and writethrough modes.

Symbol: DM_CACHE [=y]
Type  : tristate
Prompt: Cache target (EXPERIMENTAL)
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
        -> Device mapper support (BLK_DEV_DM [=y])
  Depends on: MD && BLK_DEV_DM
1.4.3.5. Mirror target

Allow volume managers to mirror logical volumes, also needed for live data migration tools such as 'pvmove'.

Symbol: DM_MIRROR [=y]
Type  : tristate
Prompt: Mirror target
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
        -> Device mapper support (BLK_DEV_DM [=y])
  Depends on: MD && BLK_DEV_DM
1.4.3.6. RAID 1/4/5/6/10 target

A dm target that supports RAID1, RAID10, RAID4, RAID5 and RAID6 mapping.

Symbol: DM_RAID [=y]
Type  : tristate
Prompt: RAID 1/4/5/6/10 target
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
        -> Device mapper support (BLK_DEV_DM [=y])
  Depends on: MD && BLK_DEV_DM
1.4.3.7. Zero target

A target that discards writes, and returns all zeroes for reads. Useful in some recovery situations.

Symbol: DM_ZERO [=y]
Type  : tristate
Prompt: Zero target
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
  Depends on: MD && BLK_DEV_DM
1.4.3.8. Multipath target

Allow volume managers to support multipath hardware.

Symbol: DM_MULTIPATH [=y]
Type  : tristate
Prompt: Multipath target
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
  Depends on: MD && BLK_DEV_DM && (SCSI_DH || !SCSI_DH)
1.4.3.9. I/O delaying target

A target that delays reads and/or writes and can send them to different devices. Useful for testing.

Symbol: DM_DELAY [=y]
Type  : tristate
Prompt: I/O delaying target
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
  Depends on: MD && BLK_DEV_DM
1.4.3.10. Flakey target

A target that intermittently fails I/O for debugging purposes.

Symbol: DM_FLAKEY [=y]
Type  : tristate
Prompt: Flakey target
  Location:
    -> Device Drivers
      -> Multiple devices driver support (RAID and LVM) (MD [=y])
  Depends on: MD && BLK_DEV_DM

1.5. Network

1.5.1. VLAN Support

Symbol: VLAN_8021Q [=y]
Prompt: 802.1Q VLAN Support
  Depends on: NET
  Location:
    -> Networking support (NET [=y])
      -> Networking options

1.5.2. Bridge Support

Symbol: BRIDGE [=y]
Prompt: 802.1d Ethernet Bridging
  Depends on: NET
  Location:
    -> Networking support (NET [=y])
      -> Networking options
  Selects: LLC && STP

1.5.3. Universal TUN/TAP device driver support

Symbol: TUN [=y]
Prompt: Universal TUN/TAP device driver support
  Depends on: NETDEVICES
  Location:
    -> Device Drivers
      -> Network device support (NETDEVICES [=y])
  Selects: CRC32

1.5.4. Bonding Support

Symbol: BONDING [=y]
Prompt: Bonding driver support
  Depends on: NETDEVICES && INET && (IPV6 || IPV6=n)
  Location:
    -> Device Drivers
      -> Network device support (NETDEVICES [=y])

1.5.5. RealTek RTL-8139 C+ (KVM default NIC)

Symbol: 8139CP [=y]
Prompt: RealTek RTL-8139 C+ PCI Fast Ethernet Adapter support (EXPERIME
  Depends on: NETDEVICES && NET_ETHERNET && NET_PCI && PCI && EXPERIMEN
  Location:
    -> Device Drivers
      -> Network device support (NETDEVICES [=y])
        -> Ethernet (10 or 100Mbit) (NET_ETHERNET [=y])
  Selects: CRC32 && MII

1.5.6. Dummy net driver

Symbol: DUMMY [=m]
Type  : tristate
Prompt: Dummy net driver support
  Location:
    -> Device Drivers
      -> Network device support (NETDEVICES [=y])
        -> Network core driver support (NET_CORE [=y])
  Depends on: NETDEVICES [=y] && NET_CORE [=y]

1.5.7. Virtual Ethernet

This device is a local ethernet tunnel. Devices are created in pairs. When one end receives the packet it appears on its pair and vice versa.

Symbol: VETH [=m]
Type  : tristate
Prompt: Virtual ethernet pair device
  Location:
    -> Device Drivers
      -> Network device support (NETDEVICES [=y])
        -> Network core driver support (NET_CORE [=y])
  Depends on: NETDEVICES [=y] && NET_CORE [=y]

1.5.8. IP-VLAN

This allows one to create virtual devices off of a main interface and packets will be delivered based on the dest L3 (IPv6/IPv4 addr) on packets. All interfaces (including the main interface) share L2 making it transparent to the connected L2 switch.

Ipvlan devices can be added using the "ip" command from the iproute2 package starting with the iproute2-3.19 release:

ip link add link <main-dev> [ NAME ] type ipvlan
Symbol: IPVLAN [=m]
Type  : tristate
Prompt: IP-VLAN support
  Location:
    -> Device Drivers
      -> Network device support (NETDEVICES [=y])
        -> Network core driver support (NET_CORE [=y])
  Depends on: NETDEVICES [=y] && NET_CORE [=y] && INET [=y] && IPV6 [=y]

1.5.9. MAC-VLAN

This allows one to create virtual interfaces that map packets to or from specific MAC addresses to a particular interface.

Macvlan devices can be added using the "ip" command from the iproute2 package starting with the iproute2-2.6.23 release:

ip link add link <real dev> [ address MAC ] [ NAME ] type macvlan
Symbol: MACVLAN [=m]
Type  : tristate
Prompt: MAC-VLAN support
  Location:
    -> Device Drivers
      -> Network device support (NETDEVICES [=y])
        -> Network core driver support (NET_CORE [=y])
  Depends on: NETDEVICES [=y] && NET_CORE [=y]

1.5.10. Virtual eXtensible Local Area Network (VXLAN)

This allows one to create vxlan virtual interfaces that provide Layer 2 Networks over Layer 3 Networks. VXLAN is often used to tunnel virtual network infrastructure in virtualized environments.

Symbol: VXLAN [=m]
Type  : tristate
Prompt: Virtual eXtensible Local Area Network (VXLAN)
  Location:
    -> Device Drivers
      -> Network device support (NETDEVICES [=y])
        -> Network core driver support (NET_CORE [=y])
  Depends on: NETDEVICES [=y] && NET_CORE [=y] && INET [=y]
  Selects: NET_UDP_TUNNEL [=m]

1.6. Filesystems

1.6.1. EXT4

Symbol: EXT4_FS [=y]
Prompt: The Extended 4 (ext4) filesystem
  Depends on: BLOCK
  Location:
    -> File systems
  Selects: JBD2 && CRC16

1.6.2. ReiserFS

Symbol: REISERFS_FS [=y]
Prompt: Reiserfs support
  Depends on: BLOCK
  Location:
    -> File systems
  Selects: CRC32

1.6.3. JFS

Symbol: JFS_FS [=y]
Prompt: JFS filesystem support
  Depends on: BLOCK
  Location:
    -> File systems
  Selects: NLS && CRC32

1.6.4. XFS

Symbol: XFS_FS [=y]
Prompt: XFS filesystem support
  Depends on: BLOCK
  Location:
    -> File systems
  Selects: EXPORTFS

1.6.5. Btrfs

Symbol: BTRFS_FS [=y]
Prompt: Btrfs filesystem support
  Depends on: BLOCK
  Location:
    -> File systems

1.6.6. NTFS

Symbol: NTFS_FS [=y]
Prompt: NTFS file system support
  Depends on: BLOCK
  Location:
    -> File systems
      -> DOS/FAT/NT Filesystems
  Selects: NLS

1.6.7. Inotify

Symbol: INOTIFY_USER [=y]
Prompt: Inotify support for userspace
  Depends on: BLOCK
  Location:
    -> File systems
  Selects: ANON_INODES [=y] && FSNOTIFY [=y]

1.6.8. Overlay filesystem

An overlay filesystem combines two filesystems - an 'upper' filesystem and a 'lower' filesystem. When a name exists in both filesystems, the object in the 'upper' filesystem is visible while the object in the 'lower' filesystem is either hidden or, in the case of directories, merged with the 'upper' object.

Symbol: OVERLAY_FS [=m]
Type  : tristate
Prompt: Overlay filesystem support
  Location:
    -> File systems

1.6.9. FUSE (Filesystem in Userspace)

With FUSE it is possible to implement a fully functional filesystem in a userspace program.

Symbol: FUSE_FS [=m]
Type  : tristate
Prompt: FUSE (Filesystem in Userspace) support
  Location:
    -> File systems

2. Check the configuration

Check the different kernel options and make sure they are set correctly:

#!/bin/ksh

. ./.config

check_param ()
{
  for p in $*
  do
    printf "%-24s  = " "$p"
    eval print -- \$CONFIG_$p
  done
}

paramlist="
# general configuration
LOCALVERSION
DEFAULT_HOSTNAME
SWAP
DEBUG_STACK_USAGE
IKCONFIG
IKCONFIG_PROC
BLK_DEV_INITRD
ACPI
MAGIC_SYSRQ
KEXEC
CRASH_DUMP
SMP
NR_CPUS
SCSI_LOWLEVEL

# cgroups
CGROUPS
MEMCG
MEMCG_SWAP
BLK_CGROUP
CGROUP_PIDS
CGROUP_FREEZER
CGROUP_DEVICE
CGROUP_HUGETLB
CPUSETS
CGROUP_CPUACCT
CGROUP_PERF
CGROUP_SCHED
BLK_CGROUP

# virtualization
VIRTUALIZATION
KVM
KVM_INTEL
KVM_AMD
VHOST_NET
HYPERVISOR_GUEST
PARAVIRT
KVM_GUEST
XEN_PVH
XEN
XEN_NETDEV_FRONTEND
XEN_NETDEV_BACKEND
VMXNET3
VIRTIO_PCI
VIRTIO_BALLOON
VIRTIO_BLK
VIRTIO_INPUT
VIRTIO_NET
VIRTIO_CONSOLE
VIRTIO_MMIO
HW_RANDOM_VIRTIO
SCSI_VIRTIO

# device mapper and md
MD
BLK_DEV_MD
MD_LINEAR
MD_RAID0
MD_RAID1
MD_RAID10
MD_RAID456
MD_MULTIPATH
MD_FAULTY
BCACHE
BLK_DEV_DM
DM_MQ_DEFAULT
DM_CRYPT
DM_SNAPSHOT
DM_THIN_PROVISIONING
DM_CACHE
DM_ERA
DM_MIRROR
DM_RAID
DM_ZERO
DM_MULTIPATH
DM_DELAY
DM_FLAKEY
DM_VERITY
DM_SWITCH
DM_LOG_WRITES

# network
VLAN_8021Q
BRIDGE
TUN
BONDING
8139CP
BRIDGE_VLAN_FILTERING
IPVLAN
MACVLAN
VETH
DUMMY
VXLAN
NET_TEAM

# filesystems
EXT4_FS
REISERFS_FS
JFS_FS
XFS_FS
BTRFS_FS
NTFS_FS
INOTIFY_USER
OVERLAY_FS
FUSE_FS
NFSD
CEPH_FS
CIFS

# netfilter
NETFILTER
BRIDGE_NETFILTER
NETFILTER_XT_MATCH_IPVS
IP_SET
IP_VS
BRIDGE_NF_EBTABLES

# disable
X86_VERBOSE_BOOTUP
"

rawlist=$(print "$paramlist" | grep -Ev '^[ 	]*#|^[ 	]*$')

check_param $rawlist

3. Compilation

Create a compressed kernel image and the kernel modules:

make

4. Installation

If you configured any of the parts of the kernel as modules, install them in /lib/modules/2.6.30.1:

make modules_install

Export the kernel's header files in a form suitable for use by userspace programs:

make headers_install

Kernel version

version=$(<include/config/kernel.release)

Install Linux kernel image:

cp arch/x86_64/boot/bzImage /boot/vmlinuz-$version

System.map is used by module-init tools and some debugging tools to retrieve the actual addresses of symbols in the kernel.

cp System.map /boot/System.map-$version

Save kernel configuration file:

cp .config /boot/config-$version

Recreate the according initramfs:

mkinitramfs $version
mv initrd.img-$version /boot/initrd-$version

Chapter 3. Initramfs

1. Using the initial RAM disk (initrd)

initrd provides the capability to load a RAM disk by the boot loader. This RAM disk can then be mounted as the root file system and programs can be run from it. Afterwards, a new root file system can be mounted from a different device. The previous root (from initrd) is then moved to a directory and can be subsequently unmounted.

2. Compressed cpio images

Recent kernels have support for populating a ramdisk from a compressed cpio archive. On such systems, the creation of a ramdisk image doesn't need to involve special block devices or loopbacks; you merely create a directory on disk with the desired initrd content, cd to that directory, and run (as an example):

find . | cpio --quiet -H newc -o | gzip -9 -n > /boot/imagefile.img

Examining the contents of an existing image file is just as simple:

mkdir /tmp/imagefile
cd /tmp/imagefile
gzip -cd /boot/imagefile.img | cpio -imd --quiet

3. Creating an initramfs

This section describes how to create an initramfs from scratch. We assume we are working in a dedicated directory:

mkdir /tmp/initrd
cd /tmp/initrd

3.1. get binary dependency

for dynamically linked programs:

LD_TRACE_LOADED_OBJECTS=1 /lib/ld-linux.so.2 /sbin/lvm

for statically linked programs:

LANG=C readelf -e /usr/lib/klibc/bin/run-init | grep 'interpreter:'

3.2. directories

mkdir -p bin sbin dev etc etc/udev/rules.d lib lib/udev/rules.d \
  lib/modules/3.10.1 root usr/share

3.3. klibc

We mainly use busybox for our initrd, but instead of using pivot_root and chroot to run the init file on the new root filesystem, we use run-init from the klibc project:

cp /usr/lib/klibc/bin/run-init bin

It needs the klibc interpreter:

cp /lib/klibc-HD4lPOAFFcrZF9wKjmJlHFIQD-4.so lib

3.4. files

for p in /bin/busybox /bin/ksh /bin/disp /usr/bin/loadkeys /bin/bc
do
  cp $p bin
done

for p in /sbin/lvm /sbin/udevd /sbin/udevadm
do
  cp $p sbin
done

3.5. keymaps

rsync -a /usr/share/keymaps usr/share

3.6. libs

for l in libc.so.6 ld-linux.so.2 libdl.so.2 libm.so.6 \
         libdevmapper.so.1.02 libreadline.so.5 librt.so.1 libncurses.so.5 \
         libncursesw.so.5 libpthread.so.0 libnss_files.so.2
do
  cp /lib/$l lib
done

3.7. links

busybox:

cd bin
./busybox --list | while read p; do ln -s busybox $p; done
rm modprobe
cd ../sbin
ln -s ../bin/busybox modprobe
cd ..

lvm:

cd sbin
./lvm help 2>&1 | grep '^  [^ ]' | sed 1,2d | grep -v '^  help ' | \
  awk '{ print $1 }' | while read p; do ln -s lvm $p; done
cd ..

3.8. modules

selective copy:

for m in fs/ext4/ext4.ko lib/crc16.ko fs/jbd2/jbd2.ko \
         fs/mbcache.ko drivers/scsi/sg.ko drivers/scsi/sr_mod.ko \
         drivers/scsi/sd_mod.ko drivers/cdrom/cdrom.ko drivers/ata/ata_piix.ko \
         drivers/ata/libata.ko drivers/scsi/scsi_mod.ko md/dm-mod.ko
do
  cp /lib/modules/3.10.1/kernel/$m lib/modules/3.10.1
done

global copy:

rsync -a /lib/modules/3.10.1 lib/modules

depmod:

cd lib/modules/3.10.1
depmod -b $(pwd)/../../.. 3.10.1
cd ../../..

3.9. udev rules

rsync -a /lib/udev lib

3.10. id and gid

cp /etc/passwd /etc/group /etc/nsswitch.conf etc

3.11. profile

echo export EDITOR=vi > etc/profile

3.12. init

#!/bin/ksh

shell_escape ()
{
  export PATH=/bin:/sbin

  [ -d /dev ]  || mkdir -m 0755 /dev
  [ -d /root ] || mkdir --mode=0700 /root
  [ -d /sys ]  || mkdir /sys
  [ -d /proc ] || mkdir /proc
  [ -d /tmp ]  || mkdir /tmp

  mountpoint -q /sys || mount -t sysfs none /sys -onodev,noexec,nosuid
  mountpoint -q /proc || mount -t proc none /proc -onodev,noexec,nosuid
  [ -d /dev/pts ] || mkdir /dev/pts

  [ -e /dev/console ] || mknod /dev/console c 5 1
  [ -e /dev/null ] || mknod /dev/null c 1 3

  /sbin/udevd --daemon
  udevadm trigger
  udevadm settle

  for mod in dm_mod ext4 iso9660
  do
    modprobe -q $mod
  done
}

print '

                      __          __   _             
                      \ \        / /  | |            
                       \ \  /\  / /_ _| | _____  ___ 
                        \ \/  \/ / _` | |/ / _ \/ __|
                         \  /\  / (_| |   <  __/\__ \
                          \/  \/ \__,_|_|\_\___||___/

                        A GNU/Linux operating system.



'

print '
 ##############################################################################
 #                                                                            #
 #                     Starting initramfs boot scripts                        #
 #                                                                            #
 ##############################################################################
'

export PATH=/bin:/sbin

[ -d /dev ]  || mkdir -m 0755 /dev
[ -d /root ] || mkdir --mode=0700 /root
[ -d /sys ]  || mkdir /sys
[ -d /proc ] || mkdir /proc
[ -d /tmp ]  || mkdir /tmp

disp "Mounting /sys" \
  mount -t sysfs none /sys -onodev,noexec,nosuid
disp "Mounting /proc" \
  mount -t proc none /proc -onodev,noexec,nosuid
mkdir /dev/pts

[ -e /dev/console ] || mknod /dev/console c 5 1
[ -e /dev/null ] || mknod /dev/null c 1 3

disp "Starting udev"
/sbin/udevd --daemon
rc=$?
udevadm trigger
udevadm settle
disp $rc

for mod in dm_mod ext4 iso9660
do
  disp "Loading $mod" modprobe -q $mod
done

for x in $(</proc/cmdline)
do
  case $x in
    lang=*)
      lang=${x#lang=}
      disp "Setting $lang keyboard layout" loadkeys $lang
    ;;
    root=*)
      root=${x#root=}
    ;;
  esac
done

disp "Stopping udevd"
for f in /proc/*/exe
do
  l=$(readlink $f)
  if [ "$l" == /sbin/udevd ]
  then
    pid=$(print $f | cut -d'/' -f3)
    kill $pid
    rc=$?
    break
  fi
done
disp $rc

case $root in
  /dev/*/*)
    vg=$(print $root | cut -d'/' -f3)
    if vgdisplay | grep "VG Name" | awk '{ print $NF }' | grep -qw $vg
    then
      disp "Activate $vg" vgchange -a y $vg
      disp "Mounting $root" mount $root /root
    else
      print ""
      print "error: vg $vg not found, exiting to shell."
      . /etc/profile
      shell_escape
      exec /bin/ksh
    fi
  ;;
esac

if [ -n "$root" ]
then
  disp "Unmounting /sys" umount /sys
  disp "Unmounting /proc" umount /proc
  print ""
  exec run-init /root /sbin/init
else
  print ""
  . /etc/profile
  shell_escape
  exec /bin/ksh
fi
chmod 755 init

3.13. create the compressed image

find . | cpio --quiet -H newc -o | gzip -9 -n > /boot/initrd-3.10.1

3.14. test the new initramfs

qemu -kernel /boot/vmlinuz-3.10.1 -initrd /boot/initrd-3.10.1 \
  -append "root=/dev/rootvg/sys quiet" -hda /dev/sda -snapshot

Chapter 4. ISO Managment

1. ISO Content

ISO file is generated from /wakes/cdrom tree, which contents 2 directories:

# ls -l /wakes/cdrom/
total 4
drwxr-xr-x 1 root root    0 Jul  5 22:53 depot
drwxr-xr-x 1 root root 4096 Aug  5 10:52 isolinux

1.1. isolinux

# ls -l /wakes/cdrom/isolinux
total 15653
-rw-r--r-- 1 root root 6166439 Aug  5 11:07 initrd.gz
-rw-r--r-- 1 root root   13432 Aug  5 11:44 isolinux.bin
-rw-r--r-- 1 root root     311 Jul  8 23:08 isolinux.cfg
-rw-r--r-- 1 root root     237 Oct  5  2009 isolinux.txt
-rw-r--r-- 1 root root 3690848 Aug  9  2009 vmlinuz

/wakes/cdrom/isolinux/isolinux.txt

 __          __   _             
 \ \        / /  | |            
  \ \  /\  / /_ _| | _____  ___ 
   \ \/  \/ / _` | |/ / _ \/ __|
    \  /\  / (_| |   <  __/\__ \
     \/  \/ \__,_|_|\_\___||___/

The Wakes GNU/Linux Operating System

/wakes/cdrom/isolinux/isolinux.cfg

default linux
prompt 0
timeout 0
display isolinux.txt
label linux
kernel vmlinuz
append initrd=initrd.gz boot=install quiet noapic

1.2. depot

# ls -l /wakes/cdrom/depot/0.1/main
total 1
lrwxrwxrwx 1 root root 92 Aug  5 11:33 binaries -> /wakes/rep/0.1/main/binaries
lrwxrwxrwx 1 root root 94 Aug  5 11:33 catalogue -> /wakes/rep/0.1/main/catalogue

2. ISO Creation

wakes=/wakes
-R     Generate  SUSP  and  RR records using the Rock Ridge protocol to
       further describe the files on the ISO-9660 filesystem.  The Rock
       Ridge  protocol  is  needed in order to add POSIX like file meta
       data like permissions, extended time  stamps,  user/group  is'd,
       link  counts,  inode  numbers and symbolic links. The Rock Ridge
       protocol allows to archive hierarchy trees with unlimited depth.
-f     Follow all symbolic links when generating the filesystem.   When
       this  option is not in use, symbolic links will be entered using
       Rock Ridge if enabled, otherwise the file will be ignored. 

2.1. Full ISO creation

mkisofs -R -f -b isolinux/isolinux.bin -c boot.catalog -no-emul-boot \
  -boot-info-table -o $wakes/iso/wakes-full-alpha1-$new_num-$arch.iso \
  $wakes/cdrom

2.2. Slim ISO creation:

mkisofs -R -b isolinux/isolinux.bin -c boot.catalog -no-emul-boot \
  -boot-info-table -o $wakes/iso/wakes-full-alpha1-$new_num-$arch.iso \
  $wakes/cdrom

Chapter 5. Wakes installer

1. Installer call

Initramfs used to host the Wakes installer is a debian one. In the init script we use the keyword boot to pass the install argument:

        boot=*)
                BOOT=${x#boot=}
                ;;

As $BOOT is sourced:

. /scripts/${BOOT}

we created the file scripts/install:

mountroot ()
{
  /wakes/install.sh
}

and we use the moutroot function to start the Wakes installer;

mountroot

2. Install process description

The Wakes installer is divided into 3 phases:

1. wait_disk

2. initial_menu

3. choice_install

The actual installation is made by choice_install.

  • create partition

    fdisk $disk
  • create root volume group

    pvcreate -ff $sys_part
    vgcreate rootvg $sys_part
    lvcreate -l 90%VG rootvg
  • format root partion

    /sbin/mke2fs -j /dev/mapper/rootvg-lvol0
  • mount root partion

    create_dir $rootmnt
    mount /dev/mapper/rootvg-lvol0 $rootmnt
  • create root tree

    create_dir $rootmnt/sys $rootmnt/dev $rootmnt/proc $rootmnt/tmp \
    $rootmnt/var $rootmnt/var/lock $rootmnt/var/run $rootmnt/var/log \
    $rootmnt/etc $rootmnt/root $rootmnt/var/tmp $rootmnt/mnt $rootmnt/boot \
    $rootmnt/var/wkpkg $rootmnt/var/wkpkg/rep $rootmnt/var/wkpkg/db \
    $rootmnt/var/wkpkg/run $rootmnt/var/wkpkg/build \
    $rootmnt/var/wkpkg/mnt/cdrom $rootmnt/var/wkpkg/cat $rootmnt/mnt
  • install packages

    for pkg in $pkg_list
    do
      /bin/wkpkg -d $rootmnt -i $pkg
    done
  • create boot partition

    mke2fs -j $boot_part
    create_dir $rootmnt/boot
    mount $boot_part $rootmnt/boot
    
  • install linux kernel

    /bin/wkpkg -d $rootmnt -i linux
  • install grub

    create_dir $rootmnt/boot/grub
        cp $rootmnt/usr/lib/grub/i386-pc/* $rootmnt/boot/grub
    
        cat <<EOF > $rootmnt/boot/grub/menu.lst
    default         0
    timeout         10
    title           Wakes GNU/Linux, kernel 2.6.30.1
    root            (hd0,0)
    kernel          /vmlinuz root=/dev/mapper/rootvg-lvol0 ro quiet
    initrd          /initrd
    boot
    title           Install Wakes GNU/Linux
    root            (hd0,0)
    kernel          /vmlinuz-install boot=install quiet
    initrd          /initrd-install
    boot
    EOF
  • setup grub

    grub --no-curses --batch <<EOF > /dev/null 2>&1
    root ($gpart)
    setup ($gdisk)
    quit
    EOF
  • install config files

    cp -r /wakes/X11 $rootmnt/etc
  • create passwd

    cat <<EOF > $rootmnt/etc/passwd
    root:\$1\$8/H0/gjl\$L5QE8vjJw5BTt/QAu41gk/:0:0:root:/root:/bin/ksh
    nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
    sshd:x:50:50:sshd PrivSep:/var/lib/sshd:/bin/false
    rsyncd:x:48:48:rsyncd Daemon:/home/rsync:/bin/false
    EOF
  • create group

    cat <<EOF > $rootmnt/etc/group
    root:x:0:
    bin:x:1:
    sys:x:2:
    kmem:x:3:
    tty:x:4:
    tape:x:5:
    daemon:x:6:
    floppy:x:7:
    disk:x:8:
    lp:x:9:
    uucp:x:10:
    audio:x:11:
    video:x:12:
    utmp:x:13:
    usb:x:14:
    cdrom:x:15:
    mail:x:34:
    nogroup:x:99:
    sshd:x:50:
    rsyncd:x:48:
    EOF
  • create inittab

    cat <<EOF > $rootmnt/etc/inittab
    # Begin /etc/inittab
    
    id:3:initdefault:
    
    si::sysinit:/etc/rc.d/init.d/rc sysinit
    
    l0:0:wait:/etc/rc.d/init.d/rc 0
    l1:S1:wait:/etc/rc.d/init.d/rc 1
    l2:2:wait:/etc/rc.d/init.d/rc 2
    l3:3:wait:/etc/rc.d/init.d/rc 3
    l4:4:wait:/etc/rc.d/init.d/rc 4
    l5:5:wait:/etc/rc.d/init.d/rc 5
    l6:6:wait:/etc/rc.d/init.d/rc 6
    
    #ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
    
    su:S016:once:/sbin/sulogin
    
    1:2345:respawn:/sbin/agetty tty1 9600
    2:2345:respawn:/sbin/agetty tty2 9600
    3:2345:respawn:/sbin/agetty tty3 9600
    #4:2345:respawn:/sbin/agetty tty4 9600
    #5:2345:respawn:/sbin/agetty tty5 9600
    #6:2345:respawn:/sbin/agetty tty6 9600
    
    # Run xdm as a separate service
    x:5:respawn:/usr/X11R6/bin/xdm -nodaemon
    
    # End /etc/inittab
    EOF
  • create hosts

    cat <<EOF > $rootmnt/etc/hosts
    127.0.0.1       localhost
    EOF
  • create ld.so.conf

    # Begin /etc/ld.so.conf
    
    /usr/local/lib
    /opt/lib
    
    # End /etc/ld.so.conf
    EOF
  • create resolv.conf

    cat <<EOF > $rootmnt/etc/resolv.conf
    nameserver 89.2.0.1
    nameserver 89.2.0.2
    EOF
  • create network

    cat <<EOF > $rootmnt/etc/sysconfig/network
    HOSTNAME=$hostname
    EOF
  • create clock

    cat <<EOF > $rootmnt/etc/sysconfig/clock
    # Begin /etc/sysconfig/clock
    
    UTC=1
    
    # End /etc/sysconfig/clock
    EOF
  • create profile

    cat <<EOF > $rootmnt/etc/profile
    # Begin /etc/profile
    
    # Default PATH
    export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/i686-pc-linux-gnu/bin
    
    # For ksh -o vi
    export EDITOR=vi
    
    if [ "\`id -u\`" -eq 0 ]
    then
      PS1="\`id -un\`@\`uname -n\` # "
    else
      PS1='$ '
    fi
    
    # End /etc/profile
    EOF
  • create nsswitch.conf

    cat <<EOF > $rootmnt/etc/nsswitch.conf
    # Begin /etc/nsswitch.conf
    
    passwd: files
    group: files
    shadow: files
    
    hosts: files dns
    networks: files
    
    protocols: files
    services: files
    ethers: files
    rpc: files
    
    # End /etc/nsswitch.conf
    EOF
  • create fstab

    cat <<EOF > $rootmnt/etc/fstab
    # Begin /etc/fstab
    
    # file system  mount-point  type   options         dump  fsck
    #                                                        order
    
    xxxxxxxxx      /            ext3   defaults        1     1
    yyyyyyyyy      /boot        ext3   defaults        1     1
    #/dev/zzzz     swap         swap   pri=1           0     0
    proc           /proc        proc   defaults        0     0
    sysfs          /sys         sysfs  defaults        0     0
    devpts         /dev/pts     devpts gid=4,mode=620  0     0
    tmpfs          /dev/shm     tmpfs  defaults        0     0
    
    # End /etc/fstab
    EOF
  • create wkpkg.conf

    cat <<EOF > $rootmnt/etc/wkpkg.conf
    # 
    # cat /etc/wkpkg.conf 
    
    # Default network depot
    http://www.gnuwakes.org/depot main
    
    #usb://depot main
    
    #ftp://www.gnuwakes.org/depot main
    #cdrom://depot    main
    
    #disk://var/wkpkg/rep main
    
    EOF
  • configure fstab

    sed -i "s%xxxxxxxxx %/dev/mapper/rootvg-lvol0 %; s%yyyyyyyyy %$boot_part %" \
        $rootmnt/etc/fstab
  • do some configuration...

      cd $rootmnt/usr/bin && ln -s gcc cc && cd /
      cd $rootmnt && ln -s /usr usr/X11R6
      cd $rootmnt && mkdir usr/share/fonts && \
        ln -s /usr/lib/X11/fonts/OTF usr/share/fonts/OTF && \
        ln -s /usr/lib/X11/fonts/TTF usr/share/fonts/TTF
    
      mkdir -p $rootmnt/usr/lib/X11/xdm
      print "DisplayManager*userPath:        /bin:/usr/bin:/sbin:/usr/sbin" \
        >> $rootmnt/usr/lib/X11/xdm/xdm-config
      print "DisplayManager*systemPath:      /bin:/usr/bin:/sbin:/usr/sbin" \
        >> $rootmnt/usr/lib/X11/xdm/xdm-config
    
      [ -f /usr/bin/i686-pc-linux-gnu-gcc-4.1.2 ] && \
        ln -s /usr/bin/i686-pc-linux-gnu-gcc-4.1.2 /usr/bin/gcc
  • confiigure network

    cd $rootmnt/etc/sysconfig/network-devices
      mkdir ifconfig.eth0
      cat << EOF > ifconfig.eth0/ipv4
    ONBOOT=yes
    SERVICE=ipv4-static
    IP=$ip_address
    GATEWAY=$gateway
    PREFIX=$prefix
    EOF
  • setup Wakes version

    print "0.1" > $rootmnt/etc/wakes_version
  • install root passsword

    print -n "Enter root password: "
      stty -echo
      read passwd
      stty echo
      print ""
      crypted=$(crypt $passwd)
      grep -v '^root:' $rootmnt/etc/passwd > $rootmnt/etc/passwd.tmp
      print "root:$crypted:0:0:root:/root:/bin/ksh" > $rootmnt/etc/passwd
      cat $rootmnt/etc/passwd.tmp >> $rootmnt/etc/passwd
      rm $rootmnt/etc/passwd.tmp
  • umount $rootmnt/boot

    umount $rootmnt/boot
  • create /dev/console

    [ -c $rootmnt/dev/console ] || mknod $rootmnt/dev/console c 5 1 
  • reboot

    reboot

Chapter 6. Package manager

1. Files and directories

Configuration file /etc/wkpkg.conf:

# Default network depot
http://www.gnuwakes.org/depot main

#usb://depot main

#ftp://www.gnuwakes.org/depot main

#cdrom://depot    main

#disk://wakes/rep main

Working directory /var/wkpkg:

# ls -l /var/wkpkg
total 24
drwxr-xr-x   7 root root 4096 Jul 28 23:08 build
drwxr-xr-x   2 root root 4096 Jul 16 02:22 cat
drwxr-xr-x 198 root root 4096 Jul 19 01:32 db
drwxr-xr-x   3 root root 4096 Jul 16 02:22 mnt
drwxr-xr-x   3 root root 4096 Jul 16 02:22 rep
drwxr-xr-x   3 root root 4096 Aug  9 14:40 run

Directory structure:

  • build: where you create new packages

  • cat: where is the index catalog

  • db: database of installed packages

  • mnt: to mount device with repository

  • rep: repo where wkpkg download packages before installing them (for remote sources)

  • run: to edit packages

2. Create a package

create the following structure:

# ls -l
total 24
-rw-r--r-- 1 root root  186 Sep  6  2009 Buildfile
drwxr-xr-x 2 root root 4096 Sep  6  2009 binaries
drwxr-xr-x 2 root root 4096 Sep  6  2009 build
drwxr-xr-x 2 root root 4096 Sep  6  2009 infos
drwxr-xr-x 2 root root 4096 Sep  6  2009 patchs
drwxr-xr-x 2 root root 4096 Sep  6  2009 procedures

binaries is the directory where the compiled programs will stay and build is where the programs will be built with Buildfile:

f_build ()
{
  $SOURCES_DIR/configure --prefix=/usr \
    && make && make DESTDIR=$INSTALL_DIR install
}

f_clean ()
{
  return 0
} 

In patch put the patches. In procedures create the following files:

Configure  Postinstall  Postremove  Preinstall  Preremove

for a future use. Meta datas for the package are in the directory infos:

Architecture  Category  Depends  Description  Maintainer  Version

And put the sources of the program in the directory sources. Then, build the program using build and create the package using:

wkpkg <package_name>

and create the binary package:

wkpkg -b <package_name>

Part II. Installation Guide

Chapter 7. Download

Download the latest Wakes version on www.gnuwakes.org, section "Downloads".

Chapter 8. Installation

1. Boot on the CD


                      __          __   _
                      \ \        / /  | |
                       \ \  /\  / /_ _| | _____  ___
                        \ \/  \/ / _` | |/ / _ \/ __|
                         \  /\  / (_| |   <  __/\__ \
                          \/  \/ \__,_|_|\_\___||___/

                        A GNU/Linux operating system.



       Loading Linux...............................................[ OK ]
       Loading initrd..............................................[ OK ]
       Starting Linux..............................................[ OK ]
       Setting hostname............................................[ OK ]
       Configuring loopback interface..............................[ OK ]
       Starting syslogd............................................[ OK ]
       Looking for udev............................................[ OK ]
       Starting udev...............................................[ OK ]
       Generating dropbear key.....................................[ OK ]

Enter your keyboard layout [us]:

2. Start the installation process

                        *******************************


  Wakes GNU/Linux 1.0 Installation


  [1] - Install Wakes on your hard disk
  [2] - Reboot the system

  [0] - Exit to shell


       Choice:

3. Hard drive selection

Disk(s) attached to the system:

[1] - /dev/sda: 21.4 GB

[0] - Cancel

Enter the disk where to install the system:

4. Partitioning strategy

Select a partitioning strategy

[1] - Automatic partitioning on the entire disk
[2] - Manual partitioning with fdisk
[3] - No partitioning, my disk is already partitioned

[0] - Cancel

Choice:

4.1. Manual partitioning

                  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  Make sure you don't start the first partition at sector 1 otherwise
  grub will fail to install on the disk.
  Also, set the boot flag on the partition and make it of type LVM (8e).

                  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Device contains neither a valid DOS partition table, nor Sun, SGI, OSF or GPT di
sklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that the previous content
won't be recoverable.


The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help):

4.1.1. Create the rootvg partition

Command (m for help): p

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1): 64
Last cylinder or +size or +sizeM or +sizeK (64-2610, default 2610): Using defaul
t value 2610

Command (m for help):

4.1.2. Set the LVM flag

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help):

4.1.3. Set the boot flag

Command (m for help): a
Partition number (1-4): 1

Command (m for help):

4.1.4. Write the partition table on the disk

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table

4.1.5. Select the partition where to create the rootvg

for example, /dev/sda1

Disk(s) attached to the system:


Disk /dev/sda: 21.4 GB, 21474836480 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1   *          64        2610    20458777+ 8e Linux LVM

Enter the partition where do you want to install the system:

4.2. Automatic partitioning

In this mode you are not asked for a partition layout.

5. TimeZone selection

5.1. Continent

TimeZone selection. Please select a continent or ocean.

 1) Africa
 2) Americas
 3) Antarctica
 4) Arctic Ocean
 5) Asia
 6) Atlantic Ocean
 7) Australia
 8) Europe
 9) Indian Ocean
10) Pacific Ocean
#?

5.2. Country

Please select a country.
 1) Aaland Islands       18) Greece               35) Norway
 2) Albania              19) Guernsey             36) Poland
 3) Andorra              20) Hungary              37) Portugal
 4) Austria              21) Ireland              38) Romania
 5) Belarus              22) Isle of Man          39) Russia
 6) Belgium              23) Italy                40) San Marino
 7) Bosnia & Herzegovina 24) Jersey               41) Serbia
 8) Britain (UK)         25) Latvia               42) Slovakia
 9) Bulgaria             26) Liechtenstein        43) Slovenia
10) Croatia              27) Lithuania            44) Spain
11) Czech Republic       28) Luxembourg           45) Sweden
12) Denmark              29) Macedonia            46) Switzerland
13) Estonia              30) Malta                47) Turkey
14) Finland              31) Moldova              48) Ukraine
15) France               32) Monaco               49) Vatican City
16) Germany              33) Montenegro
17) Gibraltar            34) Netherlands
#?

5.3. Confirm time

Europe/Paris will be used.

Local time is now:  Wed Sep 23 07:41:09 CEST 2015.
Universal Time is now:  Wed Sep 23 05:41:09 UTC 2015.

Is the above information OK? [Yn]

6. Choose the software depot

Wakes depot selection

[1] - cdrom
[2] - disk
[3] - network

[0] - Cancel

Choose depot source:

7. Network configuration

Network configuration

[1] - DHCP
[2] - Static IP

[0] - Cancel

Select an IP configuration:

7.1. Manual IP configuration (static)

7.1.1. Network interface

Network configuration

[1] - eth0

[0] - Cancel

Select a network interface:

7.1.2. IP

Enter ip address:

7.1.3. Netmask

Enter network prefix (eg, 24):

7.1.4. Gateway

Enter gateway:

7.1.5. DNS

Enter DNS:

7.2. Automatic network configuration (DHCP)

Network configuration

[1] - eth0

[0] - Cancel

Select a network interface:

8. Select the software categories

Software categories are independent sets of software collections.
Choose one or more categories to install

1 [x] coreos
2 [ ] devel
3 [ ] docker
4 [ ] xorg

0  -  OK

Select a category:

9. Hostname

Enter hostname:

10. root password

Enter root password:
Confirm root password:

11. Confirm

Installation is about to start, last chance to quit. Are you sure ? [Ynq] 

12. Installation

Starting installation
Creating partition table on /dev/sda
Creating rootgvg
Creating /
Creating /boot
Creating /home
Creating /usr
Creating /usr/src
Creating /var
Creating /var/log
Creating /var/wkpkg
Creating /tmp
Creating swap space
Installing acl
Installing attr
Installing bash
Installing bc
Installing binutils
Installing busybox
Installing bzip2
Installing coreutils

13. Reboot

install done, press enter:

Installing openssl
Installing parted
Installing perl
Installing procps-ng
Installing psmisc
Installing readline
Installing rsync
Installing sed
Installing shadow
Installing strace
Installing systemd
Installing tar
Installing texinfo
Installing util-linux
Installing vim
Installing wget
Installing wkpkg
Installing xml-parser
Installing xorriso
Installing xz
Installing zlib
Setting up grub
Configuring the system

  Installation is done, press enter to reboot.

boot on the hard drive:

 __          __   _
 \ \        / /  | |
  \ \  /\  / /_ _| | _____  ___
   \ \/  \/ / _` | |/ / _ \/ __|
    \  /\  / (_| |   <  __/\__ \
     \/  \/ \__,_|_|\_\___||___/

  A GNU/Linux operating system.

      Loading Linux...  [ok]
      Loading initrd... [ok]
      Starting Linux... [ok]
      Starting udev...  [ok]
      Starting root...  [ok]
      Stopping udev...  [ok]
      Booting...

  Welcome to Wakes GNU/Linux 1.1!

devlab01 login:

Part III. Administrator's Guide

Chapter 9. Add non priviledged user

Create user:

useradd --create-home --shell /bin/ksh guki

Set user's password:

# passwd guki
Changing password for guki
Enter the new password (minimum of 5 characters)
Please use a combination of upper and lower case letters and numbers.
New password: 
Re-enter new password: 
passwd: password changed.

Chapter 10. Grub

Starting with grub2 we can boot directly on LVM.

# Begin /boot/grub/grub.cfg

set default=0
set timeout=2
set timeout_style=hidden

echo ' __          __   _
 \ \        / /  | |
  \ \  /\  / /_ _| | _____  ___
   \ \/  \/ / _` | |/ / _ \/ __|
    \  /\  / (_| |   <  __/\__ \
     \/  \/ \__,_|_|\_\___||___/

  A GNU/Linux operating system.
'
echo -n '      Press ESC for boot menu...'

insmod ext2
insmod lvm

set root=(lvm/rootvg-boot)

menuentry "Wakes GNU/Linux 1.1, Linux 4.8.13" {
  echo -n -e '\r                                 '
  echo -n -e '\r      Loading Linux...  '
  linux  /vmlinuz-4.8.13 root=/dev/mapper/rootvg-sys quiet
  echo '[ok]'

  echo -n '      Loading initrd... '
  initrd /initrd-4.8.13
  echo '[ok]'

  echo -n '      Starting Linux... '
}

Add another kernel:

menuentry "Wakes GNU/Linux 1.1, Linux 4.1.3 with iolat patch 0.8" {
  echo -n -e '\r                                 '
  echo -n -e '\r      Loading Linux...  '
  linux   /vmlinuz-4.1.3-iolat-0.8 root=/dev/mapper/rootvg-sys quiet
  echo '[ok]'

  echo -n '      Loading initrd... '
  initrd  /initrd-4.1.3-iolat-0.8
  echo '[ok]'

  echo -n '      Starting Linux... '
}

Chapter 11. LVM

1. Logical volumes

root@devlab01 # lvs
  LV     VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  boot   rootvg -wi-ao---- 128.00m
  docker rootvg -wi-ao----   1.00g
  home   rootvg -wi-ao---- 512.00m
  log    rootvg -wi-ao---- 128.00m
  src    rootvg -wi-ao----   2.00g
  swap   rootvg -wi-ao---- 128.00m
  sys    rootvg -wi-ao---- 512.00m
  tmp    rootvg -wi-ao---- 512.00m
  usr    rootvg -wi-ao----   3.00g
  var    rootvg -wi-ao---- 128.00m
  wkpkg  rootvg -wi-ao---- 512.00m

The docker LV is only present if the docker category was enabled.

2. Increase filesystem size

In order to make some compilations:

lvextend -rL 5G /dev/mapper/rootvg-wkpkg
lvextend -rL 5G /dev/mapper/rootvg-src

Chapter 12. Console

1. Modify keyboard layout on the fly

At the prompt, run the following command to modify the keyboard layout to the French keymap:

loadkeys fr

2. Modify keyboard layout permanently

To make the keyboard layout modification permanent (across reboots) edit the file /etc/vconsole.conf:

echo 'KEYMAP="fr"' > /etc/vconsole.conf

Chapter 13. OpenSSH SSH daemon

Table of Contents

1. Enable X11 forwarding

1. Enable X11 forwarding

Currently not working, need to recompile xserver with security extension enabled

X11 forwarding is disabled by default. To enable it, modify the sshd's configuration file /etc/ssh/sshd_config as the following:

sed -i 's/#X11Forwarding no/X11Forwarding yes/' /etc/ssh/sshd_config

And then reload OpenSSH daemon:

systemctl reload sshd

The current connection may not survive to the daemon's reload...

Chapter 14. Qemu

1. Network settings

First, create a bridge device. Edit the script bridge.sh:

#!/usr/bin/ksh

# Configure a bridge device to use with qemu

# Bridged interface
if=eth0

# Bridge name
bridge=br0

# Bridge network
address=192.168.1.7
netmask=255.255.255.0
gateway=192.168.1.1
broadcast=192.168.1.255

case $1 in
  start)
    print "Configure $bridge bridge..."
    brctl addbr $bridge

    print "Add $if on $bridge..."
    brctl addif $bridge $if

    print "Activating promiscuous mode on $if..."
    ip addr flush dev $if
    ip link set $if promisc on
    ip link set up dev $if

    print "IP address on $bridge..."
    ip addr add $address/$netmask broadcast $broadcast dev $bridge 
    ip link set $bridge up

    print "Set default route..."
    ip route add default via $gateway
  ;;
  stop)
    ip link set $bridge down
    brctl delbr $bridge
    ip addr flush dev $if
    ip link set $if promisc off
    ip link set down dev $if
  ;;
  *)
    print -u2 "usage: $0 start|stop"
    exit 1
  ;;
esac

exit 0
        

Run the script to create the bridge:

./bridge.sh start

Then, edit the script that will add the qemu tap device on the bridge (/etc/qemu-ifup):

#!/usr/bin/ksh

tap=$1

bridge=br0

# put the $tap interface up
ip link set up dev $tap

# adding $tap to bridge interface $bridge...
brctl addif $bridge $tap

exit 0
        

You can now run qemu with tap network interfaces.

2. Running Qemu to test a new kernel

This is the command to launch Qemu with the previous kernel on a x86_64 plateform with a vnc output:

qemu-system-x86_64                                      \
  -snapshot                                             \
  -curses                                               \
  -no-kqemu                                             \
  -hda /dev/sda                                         \
  -kernel /usr/src/linux-2.6.26.5/arch/x86/boot/bzImage \
  -append "root=/dev/hda1"                              \
  -vnc www.gnuwakes.org:0

Explanation:

-snapshot
           Write to temporary files instead of disk image files. In this case,
           the raw disk image you use is not written back.

-hda file
-hdb file
-hdc file
-hdd file
           Use file as hard disk 0, 1, 2 or 3 image.

-vnc d
           Normally, QEMU uses SDL to display the VGA output.  With this
           option, you can have QEMU listen on VNC display d and redirect the
           VGA display over the VNC session.

-kernel bzImage
           Use bzImage as kernel image.

-append cmdline
           Use cmdline as kernel command line
           "root=/dev/hda1" ==> /dev/sda1 (if physical disk is SATA)

-initrd file
           Use file as initial ram disk.
          

To launch Qemu on an x86 compatible architecture without kqemu, on a physical disk image with the newly compiled kernel:

qemu                                                    \
  -no-kqemu                                             \
  -hda /dev/sda                                         \
  -kernel /usr/src/linux-2.6.26.5/arch/x86/boot/bzImage \
  -append "root=/dev/hda1"
          

Pay attention to the file /etc/fstab when trying to boot on a physical partition. The root device with Qemu is always an hda device (ie /dev/hda1), but on your machine it can be something else, like /dev/sda1. Example of /etc/fstab when booting your physical machine:

# cat /etc/fstab
/dev/sda1     /        ext3    errors=remount-ro    0    1
proc          /proc    proc    defaults             0    0
sysfs         /sys     sysfs   defaults             0    0
          

When booting with Qemu, it must seem like this:

# cat /etc/fstab
/dev/hda1     /        ext3    errors=remount-ro    0    1
proc          /proc    proc    defaults             0    0
sysfs         /sys     sysfs   defaults             0    0
          

3. Running VM as deamon with VNC

To run Qemu with a bridged network and VNC, run:

#!/usr/bin/ksh

root=/wakes/vm

image=$root/devlab.img

pidfile=$root/devlab.pid

memory=128

tap=tap1

vnc=1

mac=52:54:00:12:34:58

case $1 in
  start)
    # with tun/tap network
    /usr/local/bin/qemu -daemonize -M pc -m $memory -hda $image \
      -pidfile $pidfile -net nic,vlan=0,macaddr=$mac \
      -net tap,vlan=0,ifname=$tap,script=/etc/qemu-ifup \
      -boot c -vnc :$vnc -localtime -k fr
  ;;
  stop)
    kill $(cat $pidfile)
    rm $pidfile
  ;;
  console)
    vncviewer :$vnc
  ;;
  install)
    /usr/local/bin/qemu -M pc -m $memory -hda $image -localtime \
      -net nic,vlan=0,macaddr=$mac \
      -net tap,vlan=0,ifname=$tap,script=/etc/qemu-ifup \
      -boot d -cdrom /wakes/iso/wakes.iso -vnc :$vnc -k fr
  ;;
esac

exit 0

          

4. Running VMs with TAP network

And without VNC:

#!/usr/bin/ksh

root=$(cd $(dirname $(readlink -f $0))/..; pwd)

vm_name=$(basename $0 .sh)

img=$root/vmdisk/$vm_name.img

pidfile=$root/vmdisk/$vm_name.pid

qemu=/usr/kvm/bin/qemu-system-x86_64

mac=$(print $vm_name | md5sum | \
  sed 's/^\(..\)\(..\)\(..\)\(..\).*$/52:54:\1:\2:\3:\4/')

[ ! -f "$img" ] && qemu-img create $img 10G

case $1 in
  install)
    $qemu -boot d -hda $img \
      -cdrom $root/iso/wakes-alpha1-001-i386.iso
  ;;
  start)
    $qemu -boot c -hda $img -pidfile $pidfile \
      -net nic,vlan=0,macaddr=$mac \
      -net tap,vlan=0,ifname=$vm_name,script=/etc/qemu-ifup 
  ;;
  stop)
    kill $(cat $pidfile)
    rm $pidfile
  ;;
  *)
    print -u2 "usage: $0 install|start|stop"
    exit 1
  ;;
esac

exit 0

        

5. Running Qemu with ncurses library

Comment out the following lines in /scripts/init-top/console_setup in initrd:

if [ -f /etc/console-setup/boottime.kmap.gz ] && type loadkeys >/dev/null; then
       eval loadkeys /etc/console-setup/boottime.kmap.gz $verbose
fi

6. Ultimate Qemu script with VIRTIO

#!/usr/bin/ksh

root=$(cd $(dirname $(readlink -f $0))/..; pwd)

wakes=/windows/perso/wakes

mem=512

vm_name=$(basename $0 .sh)

img=$wakes/vmdisk/$vm_name.img

pidfile=$wakes/vmdisk/$vm_name.pid

qemu=/usr/kvm/bin/qemu-system-x86_64

cdrom=$wakes/iso/wakes-full-alpha1-???-i386.iso

mac=$(print $vm_name | md5sum | \
  sed 's/^\(..\)\(..\)\(..\)\(..\).*$/52:54:\1:\2:\3:\4/')

[ ! -f "$img" ] && qemu-img create $img 10G

case $1 in
  install)
    $qemu -name $vm_name -boot once=d -hda $img -cdrom $cdrom
  ;;
  start)
    $qemu -name $vm_name -boot c -hda $img -pidfile $pidfile -cdrom $cdrom \
      -net nic,vlan=0,macaddr=$mac -m $mem -vga vmware -k fr \
      -net tap,vlan=0,ifname=$vm_name,script=/etc/qemu-ifup 
  ;;
  stop)
    kill $(cat $pidfile)
    rm $pidfile
  ;;
  ssh)
    xterm -T $vm_name -bg black -fg green -e \
      ssh -Y -o StrictHostKeyChecking=no $vm_name 2> /dev/null &
  ;;
  ncurses_start)
    xterm -geometry 80x25 -title "$vm_name console" -e \
      $qemu -name $vm_name -boot c \
      -drive file=$img,if=virtio,index=0,media=disk,boot=on \
      -pidfile $pidfile -cdrom $cdrom \
      -net nic,vlan=0,macaddr=$mac,model=virtio -m $mem -vga vmware -curses \
      -net tap,vlan=0,ifname=$vm_name,script=/etc/qemu-ifup 2> /dev/null &
  ;;
  failsafe)
    xterm -geometry 80x25 -title "$vm_name console" -e \
      $qemu -name $vm_name -boot c \
      -drive file=$img,if=virtio,index=0,media=disk,boot=on \
      -pidfile $pidfile -cdrom $cdrom \
      -kernel /boot/vmlinuz-failsafe -initrd /boot/initrd-failsafe \
      -append "root=/dev/mapper/rootvg-lvol0" \
      -net nic,vlan=0,macaddr=$mac,model=virtio -m $mem -vga vmware -curses \
      -net tap,vlan=0,ifname=$vm_name,script=/etc/qemu-ifup 2> /dev/null &
  ;;
  *)
    print -u2 "usage: $0 install|start|stop|ncurses_start|ssh"
    exit 1
  ;;
esac

exit 0

7. Kernel configuration

First, create the allno.config file. This file will be used to compile a Qemu compatible kernel.

cat << EOF > allno.config
# allno.config

CONFIG_BINFMT_ELF=y
CONFIG_IDE=y
CONFIG_BLK_DEV_IDE=y
CONFIG_HAVE_IDE=y
CONFIG_BLK_DEV_IDEDISK=y
CONFIG_IDE_GENERIC=y
CONFIG_VIDEO_SELECT=y
CONFIG_EXT3_FS=y
CONFIG_MPENTIUMII=y
CONFIG_SYSVIPC=y
CONFIG_TMPFS=y
CONFIG_IOSCHED_DEADLINE=y
CONFIG_NET=y
CONFIG_UNIX=y
CONFIG_INET=y
CONFIG_PACKET=y
CONFIG_NETDEVICES=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_IP_MULTICAST=y
CONFIG_IP_MROUTE=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_INOTIFY=y
CONFIG_INOTIFY_USER=y
CONFIG_ISO9660_FS=y
CONFIG_JOLIET=y
CONFIG_UDF_FS=y
CONFIG_UDF_NLS=y
CONFIG_BLK_DEV_IDECD=y
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
EOF
          

Then compile the kernel.

make mrproper
make allnoconfig
make 
          

Explanation:

        "make config"      Plain text interface.
        "make menuconfig"  Text based color menus, radiolists & dialogs.
        "make xconfig"     X windows (Qt) based configuration tool.
        "make gconfig"     X windows (Gtk) based configuration tool.
        "make oldconfig"   Default all questions based on the contents of
                           your existing ./.config file and asking about
                           new config symbols.
        "make silentoldconfig"
                           Like above, but avoids cluttering the screen
                           with questions already answered.
        "make defconfig"   Create a ./.config file by using the default
                           symbol values from arch/$ARCH/defconfig.
        "make allyesconfig"
                           Create a ./.config file by setting symbol
                           values to 'y' as much as possible.
        "make allmodconfig"
                           Create a ./.config file by setting symbol
                           values to 'm' as much as possible.
        "make allnoconfig" Create a ./.config file by setting symbol
                           values to 'n' as much as possible.
        "make randconfig"  Create a ./.config file by setting symbol
                           values to random values.

   The allyesconfig/allmodconfig/allnoconfig/randconfig variants can
   also use the environment variable KCONFIG_ALLCONFIG to specify a
   filename that contains config options that the user requires to be
   set to a specific value.  If KCONFIG_ALLCONFIG=filename is not used,
   "make *config" checks for a file named "all{yes/mod/no/random}.config"
   for symbol values that are to be forced.  If this file is not found,
   it checks for a file named "all.config" to contain forced values.
          

In our case, the make allnoconfig variants will check for the file allno.config for symbol values that are to be forced (if the environment variable KCONFIG_ALLCONFIG is not used).

kernel allno.config with sda disk support:

########################################
# Executable file formats / Emulations #
########################################

# Kernel support for ELF binaries
CONFIG_BINFMT_ELF=y

################
# File systems #
################

# Ext3 journalling file system support
CONFIG_EXT3_FS=y

# /proc file system support
CONFIG_PROC_FS=y

# Virtual memory file system support (former shm fs)
CONFIG_TMPFS=y

# Inotify file change notification support
CONFIG_INOTIFY=y

# Inotify support for userspace
CONFIG_INOTIFY_USER=y

# ISO 9660 CDROM file system support
CONFIG_ISO9660_FS=y

###############################
# Processor type and features #
###############################

# Pentium-II/Celeron(pre-Coppermine)
CONFIG_MPENTIUMII=y

# Paravirtualized guest support
CONFIG_PARAVIRT_GUEST=y
# KVM Guest support
CONFIG_KVM_GUEST=y
# KVM paravirtualized clock
CONFIG_KVM_CLOCK=y

#################
# General setup #
#################

# Prompt for development and/or incomplete code/drivers
CONFIG_EXPERIMENTAL=y

# System V IPC
CONFIG_SYSVIPC=y

# Initial RAM filesystem and RAM disk (initramfs/initrd) support
CONFIG_BLK_DEV_INITRD=y

# Optimize for size
CONFIG_CC_OPTIMIZE_FOR_SIZE=y

# Kernel .config support
CONFIG_IKCONFIG=y

# Enable access to .config through /proc/config.gz
CONFIG_IKCONFIG_PROC=y

##########################
# Enable the block layer #
##########################

# Enable the block layer
CONFIG_BLOCK=y

# Deadline I/O scheduler
CONFIG_IOSCHED_DEADLINE=y

######################
# Networking support #
######################

# Networking support
CONFIG_NET=y
# Packet socket
#CONFIG_PACKET=y
# Unix domain sockets
CONFIG_UNIX=y
# TCP/IP networking
CONFIG_INET=y

##########################
# Bus options (PCI etc.) #
##########################

# PCI support
CONFIG_PCI=y

##################
# Device Drivers #
##################

# Block devices
CONFIG_BLK_DEV=y
# Virtio block driver (EXPERIMENTAL)
CONFIG_VIRTIO_BLK=y

# Network device support
CONFIG_NETDEVICES=y
# Ethernet (10 or 100Mbit)
CONFIG_NET_ETHERNET=y
# EISA, VLB, PCI and on board controllers
CONFIG_NET_PCI=y
# RealTek RTL-8139 C+ PCI Fast Ethernet Adapter support
CONFIG_8139CP=y
# PCI NE2000 and clones support (This driver also works for RealTek RTL-8029)
CONFIG_NE2K_PCI=y
# Virtio network driver (EXPERIMENTAL)
CONFIG_VIRTIO_NET=y

# Serial ATA (prod) and Parallel ATA (experimental)
CONFIG_ATA=y
# ATA SFF support (SFF is the legacy IDE interface)
CONFIG_ATA_SFF=y
# Intel PATA MPIIX support
CONFIG_ATA_PIIX=y

# SCSI device support
CONFIG_SCSI=y
# SCSI disk support
CONFIG_BLK_DEV_SD=y
# SCSI CDROM support
CONFIG_BLK_DEV_SR=y

# Multiple devices driver support (RAID and LVM)
CONFIG_MD=y
# Device mapper support
CONFIG_BLK_DEV_DM=y

##################
# Virtualization #
##################

# Virtualization
CONFIG_VIRTUALIZATION=y

# PCI driver for virtio devices (EXPERIMENTAL)
CONFIG_VIRTIO_PCI=y

With modules support:


# Enable loadable module support
CONFIG_MODULES=y

# Module unloading
CONFIG_MODULE_UNLOAD=y

########################################
# Executable file formats / Emulations #
########################################

# Kernel support for ELF binaries
CONFIG_BINFMT_ELF=y

################
# File systems #
################

# Ext3 journalling file system support
CONFIG_EXT3_FS=m

# /proc file system support
CONFIG_PROC_FS=y

# Virtual memory file system support (former shm fs)
CONFIG_TMPFS=y

# Inotify file change notification support
CONFIG_INOTIFY=y

# Inotify support for userspace
CONFIG_INOTIFY_USER=y

# ISO 9660 CDROM file system support
CONFIG_ISO9660_FS=m

###############################
# Processor type and features #
###############################

# Pentium-II/Celeron(pre-Coppermine)
CONFIG_MPENTIUMII=y

# Paravirtualized guest support
CONFIG_PARAVIRT_GUEST=y
# KVM Guest support
CONFIG_KVM_GUEST=y
# KVM paravirtualized clock
CONFIG_KVM_CLOCK=y

#################
# General setup #
#################

# Prompt for development and/or incomplete code/drivers
CONFIG_EXPERIMENTAL=y

# System V IPC
CONFIG_SYSVIPC=y

# Initial RAM filesystem and RAM disk (initramfs/initrd) support
CONFIG_BLK_DEV_INITRD=y

# Optimize for size
CONFIG_CC_OPTIMIZE_FOR_SIZE=y

# Kernel .config support
CONFIG_IKCONFIG=y

# Enable access to .config through /proc/config.gz
CONFIG_IKCONFIG_PROC=y

##########################
# Enable the block layer #
##########################

# Enable the block layer
CONFIG_BLOCK=y

# Deadline I/O scheduler
CONFIG_IOSCHED_DEADLINE=y

######################
# Networking support #
######################

# Networking support
CONFIG_NET=y
# Packet socket
#CONFIG_PACKET=y
# Unix domain sockets
CONFIG_UNIX=m
# TCP/IP networking
CONFIG_INET=y

##########################
# Bus options (PCI etc.) #
##########################

# PCI support
CONFIG_PCI=y

##################
# Device Drivers #
##################

# Block devices
CONFIG_BLK_DEV=y
# Virtio block driver (EXPERIMENTAL)
CONFIG_VIRTIO_BLK=m

# Network device support
CONFIG_NETDEVICES=y
# Ethernet (10 or 100Mbit)
CONFIG_NET_ETHERNET=y
# EISA, VLB, PCI and on board controllers
CONFIG_NET_PCI=y
# RealTek RTL-8139 C+ PCI Fast Ethernet Adapter support
CONFIG_8139CP=m
# PCI NE2000 and clones support (This driver also works for RealTek RTL-8029)
CONFIG_NE2K_PCI=m
# Virtio network driver (EXPERIMENTAL)
CONFIG_VIRTIO_NET=m

# Serial ATA (prod) and Parallel ATA (experimental)
CONFIG_ATA=m
# ATA SFF support (SFF is the legacy IDE interface)
CONFIG_ATA_SFF=y
# Intel PATA MPIIX support
CONFIG_ATA_PIIX=m

# SCSI device support
CONFIG_SCSI=m
# SCSI disk support
CONFIG_BLK_DEV_SD=m
# SCSI CDROM support
CONFIG_BLK_DEV_SR=m

# Multiple devices driver support (RAID and LVM)
CONFIG_MD=y
# Device mapper support
CONFIG_BLK_DEV_DM=m
##################
# Virtualization #
##################

# Virtualization
CONFIG_VIRTUALIZATION=y

# PCI driver for virtio devices (EXPERIMENTAL)
CONFIG_VIRTIO_PCI=m

Chapter 15. Java

Java installation:

cd /usr/lib/seamonkey-1.1.9/plugins
ln -s /usr/java/plugin/i386/ns7/libjavaplugin_oji.so .

export PATH=$PATH:/usr/java/bin
export PLUGIN_HOME=/usr/lib/seamonkey-1.1.9/plugins
export JAVA_HOME=/usr/java

http://java.com/en/download/installed.jsp
        

Chapter 16. Silc server

Create new public key pair:

silcd -C /etc/silc

Adjust private key permissions:

chmod 600 /etc/silc/silcd.prv

To allow remote connections, modify /etc/silc/silcd.conf:

Secondary { ip = "192.168.1.7"; port = 706; };

add the group nobody:

groupadd nobody

start the silc server:

silcd

and run the silc client:

silc -c 192.168.1.7

adjust /usr/share/fvwm/system.fvwm2rc:

 + "Chat%mini.telnet.xpm%"             Exec exec \
   xterm -title Chat -geometry 80x24-0+0 -name Chat -e silc -c 192.168.1.7

Chapter 17. MySQL

Install MySQL package:

wkpkg -i mysql

Install mysql group:

groupadd mysql

Install mysql user:

useradd -g mysql mysql

Make /var/mysql writable for mysql user:

chown mysql:mysql /var/mysql

Install initial database:

mysql_install_db --user=mysql

Start MySQL server:

/usr/share/mysql/mysql.server start

Other MySQL commands:

/usr/bin/mysql_secure_installation
mysqladmin -u root password 'new-password'
mysqladmin -u root -h devlab01 password 'new-password'
#/usr/bin/mysqld_safe &
#mysqld_safe --user=mysql &

Chapter 18. Xorg

1. Xterm

Add in the file /usr/share/X11/app-defaults/XTerm:

*charClass: 33:48,35:48,37-38:48,43-47:48,58:48,61:48,63-64:48,95:48,126:48

2. Screenshots

Take screenshot:

xwd -root -out root.xwd

3. Change keyboard layout

Create a dedicated file in the folder /etc/X11/xorg.conf.d:

mkdir -p /etc/X11/xorg.conf.d
cat <<EOF > /etc/X11/xorg.conf.d/00-keyboard.conf
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "fr"
        Option "XkbModel" "pc104"
EndSection
EOF
systemctl restart xdm

Chapter 19. FVWM

Num lock issue: /usr/share/fvwm/bindings

IgnoreModifiers L25

wallpaper:

xv -root -max -quit picture.jpg

menu font: /usr/share/fvwm/decorations

Chapter 20. VirtualBox

Table of Contents

1. VirtualBox Additions

1. VirtualBox Additions

Create an OS release file for compatibility:

touch /etc/lfs-release

Prepare the kernel to build external modules:

cd /usr/src/linux
make mrproper
cp /boot/config-4.8.13 .config
make prepare
make scripts
ln -s ../generated/uapi/linux/version.h include/linux/version.h

Get the install script from the VBox Additions cdrom:

mount -o ro /dev/sr0 /mnt
rsync -acvhP /mnt/VBoxLinuxAdditions.run /tmp
umount /mnt

Run the install script:

cd /tmp
./VBoxLinuxAdditions.run

Cleanup:

rm /etc/lfs-release /tmp/VBoxLinuxAdditions.run

Restart xdm:

systemctl restart xdm

After login, run the VirtualBox clients:

VBoxClient-all

Chapter 21. Tuning

Table of Contents

1. Memory
2. I/O
3. todo

1. Memory

1.1. Monitor the memory

watch -n 1 -d grep ^Commit /proc/meminfo
watch -n 1 -d free -m
ps -eo vsz,rss,pid,args | sed 1d | sort -n
sar -r
sar -S
vmstat 1

1.2. Allocate memory

Program overcommit:

/*
 *
 *   overcommit.c
 *
 *   Allocate memory given the size in argument.
 *
 *   Guillaume Kielwasser 2013/10/12
 *
 */

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#define VERSION "0.1"

char *prog_name = NULL;

int usage ()
{
  fprintf (stderr, "Usage: %s [-Vh] [-m] mem_Mb\n", prog_name);
  exit (EXIT_FAILURE);
}

int main (int argc, char **argv)
{
  int opt;
  int V_FLAG = 0, H_FLAG = 0, M_FLAG = 0;
  char *version = VERSION;
  char *ptr = NULL;
  size_t mem = 0;
  unsigned long i = 0;

  prog_name = argv[0];

  while ((opt = getopt (argc, argv, "Vhm")) != -1) {
    switch (opt) {
      case 'V':
        V_FLAG = 1;
        break;
      case 'h':
        H_FLAG = 1;
        break;
      case 'm':
        M_FLAG = 1;
        break;
      default:
        usage ();
    }
  }

  if (V_FLAG) {
    printf ("%s version %s\n", prog_name, version);
    return (EXIT_SUCCESS);
  }

  if (H_FLAG)
    usage ();

  if (argc != optind + 1)
    usage ();

  if ((mem = 1024*1024 * (size_t) atoi (argv[optind])) == 0) {
    fprintf (stderr, "%s: %s not a number\n",
      prog_name, argv[optind]);
    exit (EXIT_FAILURE);
  }

  if ((ptr = (char *) malloc (mem)) == NULL) {
    fprintf (stderr, "%s: malloc %lu failed (%s)\n",
      prog_name, mem, strerror (errno));
    exit (EXIT_FAILURE);
  }

  if (M_FLAG) {
    for (i=0; i<mem; i++)
      memset (ptr++, 0, 1);
  }

  while (1) {
    sleep (1);
  }

  return (EXIT_SUCCESS);
}

Makefile:

CC = gcc

CFLAGS = -s -Wall -O3

overcommit: overcommit.c
        $(CC) $(CFLAGS) -o overcommit overcommit.c

1.3. Over commit

1.3.1. Heuristic overcommit

Set the overcommit_memory tunable to 0:

sysctl -w vm.overcommit_memory=0

Obvious overcommits of address space are refused. Allows overcommit to reduce swap usage. This feature can be very useful because there are a lot of programs that malloc() huge amounts of memory "just-in-case" and don't use much of it.

Example on a system with 2Gb of RAM and 2Gb of swap:

$ grep -E 'MemTotal:|SwapTotal:' /proc/meminfo
MemTotal:        1986160 kB
SwapTotal:       2030588 kB

asking 3Gb of memory works:

$ ./overcommit 3000

but asking for 3.5Gb is not permitted (considered here as obvious overcommit):

$ ./overcommit 3500
./overcommit: malloc 3670016000 failed (Cannot allocate memory)

FYI: /proc/meminfo CommitLimit has nothing to do with the obvious limit calculation; it only servers in "never overcommit" mode.

1.3.1.1. Allocate and use the memory
$ grep ^Commit /proc/meminfo
CommitLimit:     3023668 kB
Committed_AS:    1148268 kB
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939        821       1118          0         55        419
-/+ buffers/cache:        345       1593
Swap:         1982         16       1966
./overcommit -m 1000
$ ps -eo vsz,rss,pid,args | grep 'overcommi[t]'
1028160 1024404 6728 ./overcommit -m 1000
$ grep ^Commit /proc/meminfo
CommitLimit:     3023668 kB
Committed_AS:    2170544 kB
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939       1823        116          0         56        419
-/+ buffers/cache:       1347        592
Swap:         1982         16       1966
1.3.1.2. Allocate but don't use the memory
$ grep ^Commit /proc/meminfo
CommitLimit:     3023668 kB
Committed_AS:    1145828 kB
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939        821       1117          0         56        419
-/+ buffers/cache:        345       1594
Swap:         1982         16       1966
./overcommit 1000
$ ps -eo vsz,rss,pid,args | grep 'overcommi[t]'
1028160  356  7380 ./overcommit 1000
$ grep ^Commit /proc/meminfo
CommitLimit:     3023668 kB
Committed_AS:    2170132 kB
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939        821       1117          0         56        419
-/+ buffers/cache:        345       1594
Swap:         1982         16       1966
1.3.1.3. Allocate more than the physical memory
$ grep ^Commit /proc/meminfo
CommitLimit:     3023668 kB
Committed_AS:    1143952 kB
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939        830       1109          0         57        420
-/+ buffers/cache:        352       1587
Swap:         1982         16       1966
./overcommit 2900 &
./overcommit 2900 &
./overcommit 2900 &
$ ps -eo vsz,rss,pid,args | grep 'overcommi[t]'
2973760  356  7941 ./overcommit 2900
2973760  356  7942 ./overcommit 2900
2973760  356  7943 ./overcommit 2900
$ grep ^Commit /proc/meminfo
CommitLimit:     3023668 kB
Committed_AS:   10053432 kB
             total       used       free     shared    buffers     cached
Mem:          1939        830       1109          0         57        420
-/+ buffers/cache:        352       1587
Swap:         1982         16       1966
$ sar -r
14:02:01    kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit  kbactive   kbinact
14:03:01      1135508    850652     42,83     58984    430348   1145256     28,51    362912    364516
14:04:01      1134036    852124     42,90     59032    430412   1145320     28,51    364476    364584
14:05:01      1134460    851700     42,88     59108    430292   1145192     28,51    364272    364772
14:06:01      1135304    850856     42,84     59196    430292  10054664    250,32    363160    364884
14:07:01      1134660    851500     42,87     59256    430312  10054680    250,32    363236    364980
14:08:01      1137496    848664     42,73     59360    430296  10054600    250,32    360792    364796
Average:      1142628    843532     42,47     40850    300155   1811622     45,10    361707    352409
1.3.1.4. Out of memory killer
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939        581       1358          0          4         68
-/+ buffers/cache:        509       1430
Swap:         1982          0       1982
$ grep ^Commit /proc/meminfo
CommitLimit:     3023668 kB
Committed_AS:    1444952 kB
./overcommit -m 3000
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939       1868         71          0          4         74
-/+ buffers/cache:       1789        150
Swap:         1982       1768        214
$ grep ^Commit /proc/meminfo
CommitLimit:     3023668 kB
Committed_AS:    4497040 kB
./overcommit -m 2000
$ ./overcommit -m 3000
Killed
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939       1867         71          0          0         47
-/+ buffers/cache:       1819        120
Swap:         1982        801       1181
$ grep ^Commit /proc/meminfo
CommitLimit:     3023668 kB
Committed_AS:    3473256 kB
Oct 13 18:04:24 voyager kernel: [158113.978944] Out of memory: Kill process 31659 (overcommit) score 766 or sacrifice child
Oct 13 18:04:24 voyager kernel: [158113.978947] Killed process 31659 (overcommit) total-vm:3076160kB, anon-rss:1266632kB, file-rss:364kB

1.3.2. Always overcommit

Set the overcommit_memory tunable to 1.

sysctl -w vm.overcommit_memory=1

When this flag is 1, the kernel pretends there is always enough memory until it actually runs out.

$ grep ^Commit /proc/meminfo
CommitLimit:     3023668 kB
Committed_AS:    1331804 kB
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939        575       1363          0          3         83
-/+ buffers/cache:        489       1450
Swap:         1982          0       1982

Let's allocate 95Tb of memory:

./overcommit 100000000
$ ps -eo vsz,rss,pid,args | grep 'overcommi[t]'
102400004160 356 19884 ./overcommit 100000000
$ grep ^Commit /proc/meminfo
CommitLimit:     3023668 kB
Committed_AS:   102401332116 kB
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939        576       1362          0          3         83
-/+ buffers/cache:        490       1449
Swap:         1982          0       1982
$ sar -r
21:00:02    kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit  kbactive   kbinact
21:01:02      1558000    428160     21.56      1480     63636   1341020     62.27    136816    172588
21:02:01      1402080    584080     29.41      2520     83792   1338016     33.31    164544    301580
21:03:01      1396800    589360     29.67      2552     88672 615741392   15329.35    165416    305964
21:04:01      1398452    587708     29.59      3312     84956   1333036     33.19    166904    302732
21:05:01      1396364    589796     29.70      3328     85044   1333036     33.19    169356    302828
21:06:01      1391520    594640     29.94      3644     86600 102401333260   2549359.16    172152    304568
21:07:01      1386324    599836     30.20     10256    100260 102401331020   2549359.11    162880    319300
21:08:01      1382360    603800     30.40     10448    100420 102401331660   2549359.12    166580    319156
Average:       537358   1448802     72.94    127415    279140 555181698   13821.67    797146    501741

1.3.3. Don't overcommit

Set the overcommit_memory tunable to 2.

sysctl -w vm.overcommit_memory=2

When this flag is 2, the kernel uses a "never overcommit" policy that attempts to prevent any overcommit of memory. When overcommit_memory is set to 2, the total committed address space of the system is not permitted to exceed swap plus the vm.overcommit_ratio percentage of physical RAM, ie, the CommitLimit of /proc/meminfo.

$ grep ^Commit /proc/meminfo
CommitLimit:     3023668 kB
Committed_AS:    1330612 kB
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939        594       1344          0         10        100
-/+ buffers/cache:        484       1455
Swap:         1982          0       1982
./overcommit 2000
./overcommit: malloc 2097152000 failed (Cannot allocate memory)

As 1Gb of memory was already commited (Committed_AS), asking for 2 more Gb is not permitted (limit is CommitLimit).

1.4. Buffers and cache

The buffers remember what's in directories, what file permissions are, and keep track of what memory is being written from or read to for a particular block device. The cache only contains the contents of the files themselves.

1.4.1. Drop caches

Writing to this will cause the kernel to drop clean caches, dentries and
inodes from memory, causing that memory to become free.

To free pagecache:
        echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
        echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
        echo 3 > /proc/sys/vm/drop_caches

As this is a non-destructive operation and dirty objects are not freeable, the
user should run `sync' first.
sync && echo 3 > /proc/sys/vm/drop_caches

1.4.2. Fill the buffers

1.4.2.1. With inode entries
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939        559       1380          0          0         81
-/+ buffers/cache:        477       1462
Swap:         1982          0       1982
find /usr -exec ls -l {} \; > /dev/null 2>&1
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939        846       1092          0        147         92
-/+ buffers/cache:        606       1333
Swap:         1982          0       1982
1.4.2.2. With raw device entries
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939        552       1386          0          0         77
-/+ buffers/cache:        474       1465
Swap:         1982          0       1982
dd if=/dev/sda of=/dev/null
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939       1806        133          0       1219         77
-/+ buffers/cache:        509       1430
Swap:         1982          0       1982

1.4.3. Fill the cache

$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939        557       1381          0          0         78
-/+ buffers/cache:        479       1460
Swap:         1982          0       1982
dd if=/dev/zero of=/tmp/dd.tmp bs=1024 count=1048576
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939       1619        319          0          2       1103
-/+ buffers/cache:        513       1425
Swap:         1982          0       1982

1.4.4. The cache effect on file reading

$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939        553       1386          0          0         78
-/+ buffers/cache:        474       1465
Swap:         1982          0       1982
$ dd if=/tmp/dd.tmp of=/dev/null
2097152+0 records in
2097152+0 records out
1073741824 bytes (1.1 GB) copied, 31.8524 s, 33.7 MB/s
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1939       1591        348          0          1       1111
-/+ buffers/cache:        477       1461
Swap:         1982          0       1982
$ dd if=/tmp/dd.tmp of=/dev/null
2097152+0 records in
2097152+0 records out
1073741824 bytes (1.1 GB) copied, 1.61037 s, 667 MB/s

1.5. The difference among VIRT, RES, and SHR in top output

from http://www.linuxhowtos.org/System/Linux Memory Management.htm

VIRT stands for the virtual size of a process, which is the sum of memory it is actually using, memory it has mapped into itself (for instance the video card's RAM for the X server), files on disk that have been mapped into it (most notably shared libraries), and memory shared with other processes. VIRT represents how much memory the program is able to access at the present moment. RES stands for the resident size, which is an accurate representation of how much actual physical memory a process is consuming. (This also corresponds directly to the %MEM column.) This will virtually always be less than the VIRT size, since most programs depend on the C library. SHR indicates how much of the VIRT size is actually sharable memory or libraries). In the case of libraries, it does not necessarily mean that the entire library is resident. For example, if a program only uses a few functions in a library, the whole library is mapped and will be counted in VIRT and SHR, but only the parts of the library file containing the functions being used will actually be loaded in and be counted under RES.

1.5.1. VmData

./overcommit 2000
$ ps -eo vsz,rss,pid,args | grep 'overcommi[t]'
2052160  356  6179 ./overcommit 2000
$ grep ^Vm /proc/6179/status
VmPeak:  2052160 kB
VmSize:  2052160 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:       356 kB
VmRSS:       356 kB
VmData:  2048048 kB
VmStk:       136 kB
VmExe:         4 kB
VmLib:      1884 kB
VmPTE:        32 kB
VmSwap:        0 kB
 VmPeak                      peak virtual memory size
 VmSize                      total program size
 VmLck                       locked memory size
 VmHWM                       peak resident set size ("high water mark")
 VmRSS                       size of memory portions
 VmData                      size of data, stack, and text segments
 VmStk                       size of data, stack, and text segments
 VmExe                       size of text segment
 VmLib                       size of shared library code
 VmPTE                       size of page table entries
 VmSwap                      size of swap usage (the number of referred swapents)

1.5.2. VmRSS

./overcommit -m 1000
# ps -eo vsz,rss,pid,args | grep 'overcommi[t]'
1028160 1024404 6532 ./overcommit -m 1000
# grep ^Vm /proc/6532/status                   
VmPeak:  1028160 kB
VmSize:  1028160 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:   1024404 kB
VmRSS:   1024404 kB
VmData:  1024048 kB
VmStk:       136 kB
VmExe:         4 kB
VmLib:      1884 kB
VmPTE:      2028 kB
VmSwap:        0 kB

1.5.3. VmStk

stack.c:

#define SIZE 2147483648

main ()
{
  char   a[SIZE];
  while (1) {
    sleep (1);
  }
}
gcc -o stack stack.c
ulimit -s unlimited
./stack
$ ps -eo vsz,rss,pid,args | grep 'stac[k]$'
2101176  348 16403 ./stack
$ grep ^Vm /proc/16403/status
VmPeak:  2101176 kB
VmSize:  2101176 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:       348 kB
VmRSS:       348 kB
VmData:       40 kB
VmStk:   2097160 kB
VmExe:         4 kB
VmLib:      1884 kB
VmPTE:        28 kB
VmSwap:        0 kB

2. I/O

2.1. fio

with command line options

fio --minimal              \
    --ramp_time=1          \
    --runtime=3            \
    --prio=0               \
    --prioclass=1          \
    --name=sread           \
    --readwrite=read       \
    --blocksize=1k         \
    --direct=1             \
    --numjobs=2            \
    --thread               \
    --ioscheduler=deadline \
    --filename=/dev/sda

with config file

cat <<EOF > sread.fio
; -- start job file --

[sread]
ramp_time=1 
#loops=2 
runtime=5
prio=0 
prioclass=1 
name=sread 
readwrite=read 
blocksize=4k
direct=1 
numjobs=32
thread 
ioscheduler=deadline 
filename=/dev/sda

; -- end job file --
EOF

Run fio against the config file and grab the total IOPS:

fio --minimal sread.fio | cut -d';' -f8 | awk '{ sum+=$1 } END { print sum }'

See http://www.bluestop.org/fio/HOWTO.txt

2.2. ftrace

script:

#!/usr/bin/ksh

dir=/sys/kernel/debug/tracing

echo function > $dir/current_tracer
echo 4096     > $dir/buffer_size_kb
echo 1        > $dir/options/latency-format
echo $$       > $dir/set_ftrace_pid
echo 1        > $dir/tracing_on

exec dd if=/dev/sda of=/dev/null bs=512 count=1 iflag=direct

command:

ksh ftrace.sh; echo 0 > /sys/kernel/debug/tracing/tracing_on

look at the trace:

less -FX /sys/kernel/debug/tracing/trace

Get some particular kernel function trace:

buf=""

for f in SyS_exec SyS_read submit_bio __elv_add_request     \
         queue_unplugged  dio_await_completion io_schedule  \
         __switch_to finish_task_switch dio_bio_complete    \
         dio_complete touch_atime fsnotify SyS_exit_group
do
  buf="$buf: $f|"
done

re=$(print "$buf" | sed 's/|$//') 

grep -E "$re" /sys/kernel/debug/tracing/trace
      
      dd-2013    2.... 60685us+: SyS_execve <-sysenter_do_call
      dd-2013    3.... 101504us+: SyS_read <-sysenter_do_call
      dd-2013    3.... 101799us+: submit_bio <-__blockdev_direct_IO
      dd-2013    3d... 101926us+: __elv_add_request <-blk_flush_plug_list
      dd-2013    3d... 101945us+: queue_unplugged <-blk_flush_plug_list
      dd-2013    3.... 102216us+: dio_await_completion <-__blockdev_direct_IO
      dd-2013    3.... 102225us+: io_schedule <-dio_await_completion
      dd-2013    3d... 102438us!: __switch_to <-__schedule
      dd-2013    0d... 102958us+: finish_task_switch <-__schedule
      dd-2013    0.... 103012us+: dio_bio_complete <-dio_await_completion
      dd-2013    0.... 103105us+: dio_complete <-__blockdev_direct_IO
      dd-2013    0.... 103147us+: touch_atime <-generic_file_aio_read
      dd-2013    0.... 103170us+: fsnotify <-vfs_read
      dd-2013    0.... 114779us+: SyS_exit_group <-sysenter_do_call

2.3. btrace

Live monitoring

blktrace -d /dev/sda -o - | blkparse -i -

or

btrace /dev/sda

See http://www.cse.unsw.edu.au/~aaronc/iosched/doc/blktrace.html

Trace example:

dd if=/dev/sda of=/dev/null bs=512 count=1 iflag=direct
  8,0    0        1     0.000000000  2579  Q   R 0 + 1 [dd]
  8,0    0        2     0.000044978  2579  G   R 0 + 1 [dd]
  8,0    0        3     0.000055035  2579  P   N [dd]
  8,0    0        4     0.000066489  2579  I   R 0 + 1 [dd]
  8,0    0        5     0.000071797  2579  U   N [dd] 1
  8,0    0        6     0.000082692  2579  D   R 0 + 1 [dd]
  8,0    0        7     0.001489854     0  C   R 0 + 1 [0]

Explaination:

Q - queued
    This notes intent to queue io at the given location.
    No real requests exists yet.
G - get request
    To send any type of request to a block device,
    a struct request container must be allocated first.
P - plug
    When io is queued to a previously empty block device queue,
    Linux will plug the queue in anticipation of future ios being
    added before this data is needed. 
I - inserted
    A request is being sent to the io scheduler for addition to
    the internal queue and later service by the driver.
    The request is fully formed at this time. 
U - unplug
    Some request data already queued in the device, start sending
    requests to the driver. This may happen automatically if a timeout
    period has passed (see next entry) or if a number of requests
    have been added to the queue.
D - issued
    A request that previously resided on the block layer queue or
    in the io scheduler has been sent to the driver.
C - complete
    A previously issued request has been completed. The output will
    detail the sector and size of that request, as well as the
    success or failure of it.

Function trace

Q trace_block_bio_queue    -> generic_make_request_checks    blk-core.c
G trace_block_getrq        -> __get_request                  blk-core.c
P trace_block_plug         -> blk_queue_bio                  blk-core.c
I trace_block_rq_insert    -> __elv_add_request              elevator.c
U trace_block_unplug       -> queue_unplugged                blk-core.c
D trace_block_rq_issue     -> blk_peek_request               blk-core.c
C trace_block_rq_complete  -> blk_update_request             blk-core.c
      dd-2589    1.... 157357us+: SyS_read <-sysenter_do_call
Q     dd-2589    1.... 158025us+: generic_make_request_checks <-generic_make_request
Q     dd-2589    1d... 158082us+: acpi_pm_read <-ktime_get

G     dd-2589    1d... 158129us+: get_request <-blk_queue_bio
G     dd-2589    1d... 158178us+: acpi_pm_read <-ktime_get

P     dd-2589    1.... 158189us+: init_request_from_bio <-blk_queue_bio
P     dd-2589    1d... 158222us+: acpi_pm_read <-ktime_get

I     dd-2589    1d... 158277us+: __elv_add_request <-blk_flush_plug_list
I     dd-2589    1d... 158286us+: acpi_pm_read <-ktime_get

U     dd-2589    1d... 158322us+: queue_unplugged <-blk_flush_plug_list
U     dd-2589    1d... 158332us+: acpi_pm_read <-ktime_get

D     dd-2589    1d... 158363us+: blk_peek_request <-scsi_request_fn
D     dd-2589    1d... 158396us+: acpi_pm_read <-ktime_get

2.4. IO Scheduler

todo

3. todo

chrt -r -p 1 $$, ionice -c 1 -n 0 -p $$

dirty pages ratio write back; do writes without I/Os, all in cache;)

Chapter 22. Docker

1. Basic commands

List the running containers:

docker ps

List all containers (running and stopped):

docker ps -a

List the local images:

docker images

Test docker:

docker run --rm ubuntu /bin/echo 'Hello world'

2. Swarm mode

Make this server a manager node:

docker swarm init

Create a network for the common services:

docker network create -d overlay instance01

Create the local folders to hold the service data:

mkdir /mysql01 /joomla01

Start the mysql service:

docker service create          \
  --name mysql01               \
  --network instance01         \
  -e MYSQL_USER=joomla         \
  -e MYSQL_PASSWORD=joomla     \
  -e MYSQL_DATABASE=joomla     \
  -e MYSQL_ROOT_PASSWORD=mysql \
  --mount type=bind,target=/var/lib/mysql,source=/mysql01 \
  mysql:5.7.13
    

Start the joomla service:

docker service create          \
  --name joomla01              \
  --network instance01         \
  -p 8080:80                   \
  -e JOOMLA_DB_HOST=mysql01    \
  -e JOOMLA_DB_NAME=joomla     \
  -e JOOMLA_DB_USER=joomla     \
  -e JOOMLA_DB_PASSWORD=joomla \
  --mount type=bind,target=/var/www/html,source=/joomla01 \
  joomla:3.5.1-apache-php7
    

Install joomla via the web installer, then scale it:

docker service scale joomla01=5

Delete the services:

docker service rm mysql01 joomla01
docker network rm instance01
docker swarm leave --force

Part IV. Software Compilaton

Table of Contents

23. build

About this part

todo

Chapter 23. build

1. acl

wget http://www.gnuwakes.org/depot/1.0/main/sources/acl-2.2.52.src.tar.gz

tar -xf acl-2.2.52.src.tar.gz

wget http://www.gnuwakes.org/depot/1.0/main/sources/acl.patch
cd acl-2.2.52
patch -p1 < ../acl.patch 
cd ..

SOURCES_DIR=$PWD/acl-2.2.52
INSTALL_DIR=$PWD/acl-2.2.52-install
BUILD_DIR=$PWD/acl-2.2.52-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

rsync -a $SOURCES_DIR/ .
./configure --prefix=/usr --libexecdir=/usr/lib && \
  make && make DESTDIR=$INSTALL_DIR install install-dev install-lib

chmod -v 755 $INSTALL_DIR/usr/lib/libacl.so

mkdir -v $INSTALL_DIR/lib
mv -v $INSTALL_DIR/usr/lib/libacl.so.* $INSTALL_DIR/lib
ln -sfv ../../lib/$(readlink $INSTALL_DIR/usr/lib/libacl.so) \
  $INSTALL_DIR/usr/lib/libacl.so

2. attr

wget http://www.gnuwakes.org/depot/1.0/main/sources/attr-2.4.47.src.tar.gz

tar -xf attr-2.4.47.src.tar.gz

wget http://www.gnuwakes.org/depot/1.0/main/sources/attr.patch
cd attr-2.4.47
patch -p1 < ../attr.patch 
cd ..

SOURCES_DIR=$PWD/attr-2.4.47
INSTALL_DIR=$PWD/attr-2.4.47-install
BUILD_DIR=$PWD/attr-2.4.47-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

rsync -a $SOURCES_DIR/ .
./configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install install-dev install-lib

chmod -v 755 $INSTALL_DIR/usr/lib/libattr.so

mkdir -v $INSTALL_DIR/lib
mv -v $INSTALL_DIR/usr/lib/libattr.so.* $INSTALL_DIR/lib
ln -sfv ../../lib/$(readlink $INSTALL_DIR/usr/lib/libattr.so) \
  $INSTALL_DIR/usr/lib/libattr.so

3. autoconf

wget http://www.gnuwakes.org/depot/1.0/main/sources/autoconf-2.69.tar.xz

tar -xf autoconf-2.69.tar.xz

SOURCES_DIR=$PWD/autoconf-2.69
INSTALL_DIR=$PWD/autoconf-2.69-install
BUILD_DIR=$PWD/autoconf-2.69-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr \
  && make && make DESTDIR=$INSTALL_DIR install

4. automake

wget http://www.gnuwakes.org/depot/1.0/main/sources/automake-1.15.tar.xz

tar -xf automake-1.15.tar.xz

SOURCES_DIR=$PWD/automake-1.15
INSTALL_DIR=$PWD/automake-1.15-install
BUILD_DIR=$PWD/automake-1.15-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr --docdir=/usr/share/doc/automake-1.15 \
  && make && make DESTDIR=$INSTALL_DIR install

5. bash

wget http://www.gnuwakes.org/depot/1.0/main/sources/bash-4.3.30.tar.gz

tar -xf bash-4.3.30.tar.gz

wget http://www.gnuwakes.org/depot/1.0/main/sources/bash.patch
cd bash-4.3.30
patch -p1 < ../bash.patch 
cd ..

SOURCES_DIR=$PWD/bash-4.3.30
INSTALL_DIR=$PWD/bash-4.3.30-install
BUILD_DIR=$PWD/bash-4.3.30-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure                \
  --prefix=/usr                       \
  --bindir=/bin                       \
  --docdir=/usr/share/doc/bash-4.3.30 \
  --without-bash-malloc               \
  --with-installed-readline && \
  make && make DESTDIR=$INSTALL_DIR install

ln -vfs bash $INSTALL_DIR/bin/sh

6. bc

wget http://www.gnuwakes.org/depot/1.0/main/sources/bc-1.06.95.tar.bz2

tar -xf bc-1.06.95.tar.bz2

wget http://www.gnuwakes.org/depot/1.0/main/sources/bc.patch
cd bc-1.06.95
patch -p1 < ../bc.patch 
cd ..

SOURCES_DIR=$PWD/bc-1.06.95
INSTALL_DIR=$PWD/bc-1.06.95-install
BUILD_DIR=$PWD/bc-1.06.95-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure         \
  --prefix=/usr                \
  --with-readline              \
  --mandir=/usr/share/man      \
  --infodir=/usr/share/info && \
  make && make DESTDIR=$INSTALL_DIR install

7. binutils

wget http://www.gnuwakes.org/depot/1.0/main/sources/binutils-2.25.tar.bz2

tar -xf binutils-2.25.tar.bz2

SOURCES_DIR=$PWD/binutils-2.25
INSTALL_DIR=$PWD/binutils-2.25-install
BUILD_DIR=$PWD/binutils-2.25-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr --enable-shared --disable-werror && \
  make tooldir=/usr && make -k check && \
  make DESTDIR=$INSTALL_DIR tooldir=/usr install

8. bison

wget http://www.gnuwakes.org/depot/1.0/main/sources/bison-3.0.4.tar.xz

tar -xf bison-3.0.4.tar.xz

SOURCES_DIR=$PWD/bison-3.0.4
INSTALL_DIR=$PWD/bison-3.0.4-install
BUILD_DIR=$PWD/bison-3.0.4-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr --docdir=/usr/share/doc/bison-3.0.4 && \
  make && make DESTDIR=$INSTALL_DIR install

9. blktrace

wget https://www.gnuwakes.org/depot/1.1/main/sources/blktrace-2.0.0.tar.gz

tar -xf blktrace-2.0.0.tar.gz

SOURCES_DIR=$PWD/blktrace-2.0.0
INSTALL_DIR=$PWD/blktrace-2.0.0-install
BUILD_DIR=$PWD/blktrace-2.0.0-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e
cp -a $SOURCES_DIR/* .
make
make DESTDIR=$INSTALL_DIR prefix=/usr mandir=/usr/share/man install

10. bridge-utils

wget http://www.gnuwakes.org/depot/1.1/main/sources/bridge-utils-1.5.tar.gz

tar -xf bridge-utils-1.5.tar.gz

SOURCES_DIR=$PWD/bridge-utils-1.5
INSTALL_DIR=$PWD/bridge-utils-1.5-install
BUILD_DIR=$PWD/bridge-utils-1.5-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e

cp -rp $SOURCES_DIR/* .
autoconf
./configure --prefix=/usr --with-linux-headers=/dev/null
make
make DESTDIR=$INSTALL_DIR install

11. busybox

wget http://www.gnuwakes.org/depot/1.0/main/sources/busybox-1.23.2.tar.bz2

tar -xf busybox-1.23.2.tar.bz2

SOURCES_DIR=$PWD/busybox-1.23.2
INSTALL_DIR=$PWD/busybox-1.23.2-install
BUILD_DIR=$PWD/busybox-1.23.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

rsync -a $SOURCES_DIR/ . && \
  make defconfig && \
  sed -i '/CONFIG_INSTALL_APPLET_DONT/s/^.*$/CONFIG_INSTALL_APPLET_DONT=y/' \
    .config
  sed -i \
  '/CONFIG_INSTALL_APPLET_SYMLINKS/s/^.*$/# CONFIG_INSTALL_APPLET_SYMLINKS is not set/' .config && \
  make oldconfig && make && make CONFIG_PREFIX=$INSTALL_DIR install && \
  mkdir -pv $INSTALL_DIR/usr/share/man/man1 && \
  cp docs/busybox.1 $INSTALL_DIR/usr/share/man/man1

12. bzip2

wget http://www.gnuwakes.org/depot/1.0/main/sources/bzip2-1.0.6.tar.gz

tar -xf bzip2-1.0.6.tar.gz

wget http://www.gnuwakes.org/depot/1.0/main/sources/bzip2.patch
cd bzip2-1.0.6
patch -p1 < ../bzip2.patch 
cd ..

SOURCES_DIR=$PWD/bzip2-1.0.6
INSTALL_DIR=$PWD/bzip2-1.0.6-install
BUILD_DIR=$PWD/bzip2-1.0.6-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

rsync -a $SOURCES_DIR/ .

make -f Makefile-libbz2_so && \
make clean                 && \
make                       && \
make PREFIX=$INSTALL_DIR/usr install

mkdir -v $INSTALL_DIR/bin
mkdir -v $INSTALL_DIR/lib

cp -v bzip2-shared $INSTALL_DIR/bin/bzip2
cp -av libbz2.so* $INSTALL_DIR/lib
ln -sv ../../lib/libbz2.so.1.0 $INSTALL_DIR/usr/lib/libbz2.so
rm -v $INSTALL_DIR/usr/bin/{bunzip2,bzcat,bzip2}
ln -sv bzip2 $INSTALL_DIR/bin/bunzip2
ln -sv bzip2 $INSTALL_DIR/bin/bzcat

13. cacerts

wget http://www.gnuwakes.org/depot/1.1/main/sources/cacerts-1.0.tar.gz

tar -xf cacerts-1.0.tar.gz

SOURCES_DIR=$PWD/certs
INSTALL_DIR=$PWD/certs-install
BUILD_DIR=$PWD/certs-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e

mkdir -p $INSTALL_DIR/etc/ssl/certs
cp -rp $SOURCES_DIR/* $INSTALL_DIR/etc/ssl/certs

14. check

wget http://www.gnuwakes.org/depot/1.0/main/sources/check-0.9.14.tar.gz

tar -xf check-0.9.14.tar.gz

SOURCES_DIR=$PWD/check-0.9.14
INSTALL_DIR=$PWD/check-0.9.14-install
BUILD_DIR=$PWD/check-0.9.14-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make docdir=/usr/share/doc/check-0.9.14 \
  DESTDIR=$INSTALL_DIR install

15. cmake

wget https://www.gnuwakes.org/depot/1.1/main/sources/cmake-3.10.3.tar.gz

tar -xf cmake-3.10.3.tar.gz

SOURCES_DIR=$PWD/cmake-3.10.3
INSTALL_DIR=$PWD/cmake-3.10.3-install
BUILD_DIR=$PWD/cmake-3.10.3-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr \
  --docdir=share/doc/cmake-3.10 && \
  make && make DESTDIR=$INSTALL_DIR install

16. coreutils

wget http://www.gnuwakes.org/depot/1.0/main/sources/coreutils-8.23.tar.xz

tar -xf coreutils-8.23.tar.xz

wget http://www.gnuwakes.org/depot/1.0/main/sources/coreutils.patch
cd coreutils-8.23
patch -p1 < ../coreutils.patch 
cd ..

SOURCES_DIR=$PWD/coreutils-8.23
INSTALL_DIR=$PWD/coreutils-8.23-install
BUILD_DIR=$PWD/coreutils-8.23-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

FORCE_UNSAFE_CONFIGURE=1 $SOURCES_DIR/configure \
  --prefix=/usr --enable-no-install-program=kill,uptime && \
  make && make DESTDIR=$INSTALL_DIR install

# weird bug with confdir3 (iterative mkdir)
mv confdir3 /tmp/$$
rm -rf /tmp/$$

mkdir -v $INSTALL_DIR/bin
mkdir -v $INSTALL_DIR/usr/sbin
mkdir -v $INSTALL_DIR/usr/share/man/man8

mv -v $INSTALL_DIR/usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} \
  $INSTALL_DIR/bin
mv -v $INSTALL_DIR/usr/bin/{false,ln,ls,mkdir,mknod,mv,pwd,rm} \
  $INSTALL_DIR/bin
mv -v $INSTALL_DIR/usr/bin/{rmdir,stty,sync,true,uname} $INSTALL_DIR/bin
mv -v $INSTALL_DIR/usr/bin/chroot $INSTALL_DIR/usr/sbin
mv -v $INSTALL_DIR/usr/share/man/man1/chroot.1 \
  $INSTALL_DIR/usr/share/man/man8/chroot.8
sed -i s/\"1\"/\"8\"/1 $INSTALL_DIR/usr/share/man/man8/chroot.8
mv -v $INSTALL_DIR/usr/bin/{head,sleep,nice,test,[} $INSTALL_DIR/bin

17. cpio

wget http://www.gnuwakes.org/depot/1.0/main/sources/cpio-2.11.tar.bz2

tar -xf cpio-2.11.tar.bz2

wget http://www.gnuwakes.org/depot/1.0/main/sources/cpio.patch
cd cpio-2.11
patch -p1 < ../cpio.patch 
cd ..

SOURCES_DIR=$PWD/cpio-2.11
INSTALL_DIR=$PWD/cpio-2.11-install
BUILD_DIR=$PWD/cpio-2.11-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e

$SOURCES_DIR/configure \
  --prefix=/usr        \
  --bindir=/bin        \
  --enable-mt          \
  --with-rmt=/usr/libexec/rmt

# confdir3 bug
mv confdir3 /tmp/$$; rm -rf /tmp/$$

make

mkdir -pv doc/html

makeinfo --html -o doc/html $SOURCES_DIR/doc/cpio.texi

makeinfo --html --no-split -o doc/cpio.html \
  $SOURCES_DIR/doc/cpio.texi

makeinfo --plaintext -o doc/cpio.txt \
  $SOURCES_DIR/doc/cpio.texi

make DESTDIR=$INSTALL_DIR install

install -v -m755 -d $INSTALL_DIR/usr/share/doc/cpio-2.11/html

install -v -m644    doc/html/* \
                    $INSTALL_DIR/usr/share/doc/cpio-2.11/html

install -v -m644    doc/cpio.{html,txt} \
                    $INSTALL_DIR/usr/share/doc/cpio-2.11

print "build completed ok."

18. curl

wget http://www.gnuwakes.org/depot/1.1/main/sources/curl-7.43.0.tar.gz

tar -xf curl-7.43.0.tar.gz

wget http://www.gnuwakes.org/depot/1.1/main/sources/curl.patch
cd curl-7.43.0
patch -p1 < ../curl.patch 
cd ..

SOURCES_DIR=$PWD/curl-7.43.0
INSTALL_DIR=$PWD/curl-7.43.0-install
BUILD_DIR=$PWD/curl-7.43.0-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr --libdir=/lib64 && \
  make && make DESTDIR=$INSTALL_DIR install

19. dbus

wget http://www.gnuwakes.org/depot/1.0/main/sources/dbus-1.8.16.tar.gz

tar -xf dbus-1.8.16.tar.gz

SOURCES_DIR=$PWD/dbus-1.8.16
INSTALL_DIR=$PWD/dbus-1.8.16-install
BUILD_DIR=$PWD/dbus-1.8.16-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure                \
  --prefix=/usr                       \
  --sysconfdir=/etc                   \
  --localstatedir=/var                \
  --docdir=/usr/share/doc/dbus-1.8.16 \
  --with-console-auth-dir=/run/console && \
  make && make DESTDIR=$INSTALL_DIR install

mv -v $INSTALL_DIR/usr/lib/libdbus-1.so.* $INSTALL_DIR/lib
ln -sfv ../../lib/$(readlink $INSTALL_DIR/usr/lib/libdbus-1.so) \
  $INSTALL_DIR/usr/lib/libdbus-1.so

mkdir -pv $INSTALL_DIR/var/lib
ln -sfv /etc/machine-id $INSTALL_DIR/var/lib/dbus

# /var/run is a symlink in systemd package
#so we can't have a directory here
rm -vrf $INSTALL_DIR/var/run

20. diffutils

wget http://www.gnuwakes.org/depot/1.0/main/sources/diffutils-3.3.tar.xz

tar -xf diffutils-3.3.tar.xz

wget http://www.gnuwakes.org/depot/1.0/main/sources/diffutils.patch
cd diffutils-3.3
patch -p1 < ../diffutils.patch 
cd ..

SOURCES_DIR=$PWD/diffutils-3.3
INSTALL_DIR=$PWD/diffutils-3.3-install
BUILD_DIR=$PWD/diffutils-3.3-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

21. docbook-xml

wget https://www.gnuwakes.org/depot/1.1/main/sources/docbook-xml-4.5.tar.gz

tar -xf docbook-xml-4.5.tar.gz

SOURCES_DIR=$PWD/docbook-xml-4.5
INSTALL_DIR=$PWD/docbook-xml-4.5-install
BUILD_DIR=$PWD/docbook-xml-4.5-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

#cd $SOURCES_DIR && \
#  make && make DESTDIR=$INSTALL_DIR install && make clean
#mkdir -p $INSTALL_DIR/var/wkpkg/run/dummy
#cd ..
#cp -r Buildfile build infos patchs procedures sources \
#  $INSTALL_DIR/var/wkpkg/run/dummy
#mkdir $INSTALL_DIR/var/wkpkg/run/dummy/binaries

cd $SOURCES_DIR


install -v -d -m755 $INSTALL_DIR/usr/share/xml/docbook/xml-dtd-4.5 &&
install -v -d -m755 $INSTALL_DIR/etc/xml &&
chown -R root:root . &&
cp -v -af docbook.cat *.dtd ent/ *.mod \
  $INSTALL_DIR/usr/share/xml/docbook/xml-dtd-4.5


if [ ! -e $INSTALL_DIR/etc/xml/docbook ]; then
  xmlcatalog --noout --create $INSTALL_DIR/etc/xml/docbook
fi &&
xmlcatalog --noout --add "public" \
  "-//OASIS//DTD DocBook XML V4.5//EN" \
  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" \
  $INSTALL_DIR/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
  "-//OASIS//DTD DocBook XML CALS Table Model V4.5//EN" \
  "file:///usr/share/xml/docbook/xml-dtd-4.5/calstblx.dtd" \
  $INSTALL_DIR/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
  "-//OASIS//DTD XML Exchange Table Model 19990315//EN" \
  "file:///usr/share/xml/docbook/xml-dtd-4.5/soextblx.dtd" \
  $INSTALL_DIR/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
  "-//OASIS//ELEMENTS DocBook XML Information Pool V4.5//EN" \
  "file:///usr/share/xml/docbook/xml-dtd-4.5/dbpoolx.mod" \
  $INSTALL_DIR/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
  "-//OASIS//ELEMENTS DocBook XML Document Hierarchy V4.5//EN" \
  "file:///usr/share/xml/docbook/xml-dtd-4.5/dbhierx.mod" \
  $INSTALL_DIR/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
  "-//OASIS//ELEMENTS DocBook XML HTML Tables V4.5//EN" \
  "file:///usr/share/xml/docbook/xml-dtd-4.5/htmltblx.mod" \
  $INSTALL_DIR/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
  "-//OASIS//ENTITIES DocBook XML Notations V4.5//EN" \
  "file:///usr/share/xml/docbook/xml-dtd-4.5/dbnotnx.mod" \
  $INSTALL_DIR/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
  "-//OASIS//ENTITIES DocBook XML Character Entities V4.5//EN" \
  "file:///usr/share/xml/docbook/xml-dtd-4.5/dbcentx.mod" \
  $INSTALL_DIR/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
  "-//OASIS//ENTITIES DocBook XML Additional General Entities V4.5//EN" \
  "file:///usr/share/xml/docbook/xml-dtd-4.5/dbgenent.mod" \
  $INSTALL_DIR/etc/xml/docbook &&
xmlcatalog --noout --add "rewriteSystem" \
  "http://www.oasis-open.org/docbook/xml/4.5" \
  "file:///usr/share/xml/docbook/xml-dtd-4.5" \
  $INSTALL_DIR/etc/xml/docbook &&
xmlcatalog --noout --add "rewriteURI" \
  "http://www.oasis-open.org/docbook/xml/4.5" \
  "file:///usr/share/xml/docbook/xml-dtd-4.5" \
  $INSTALL_DIR/etc/xml/docbook


if [ ! -e $INSTALL_DIR/etc/xml/catalog ]; then
  xmlcatalog --noout --create $INSTALL_DIR/etc/xml/catalog
fi &&
xmlcatalog --noout --add "delegatePublic" \
  "-//OASIS//ENTITIES DocBook XML" \
  "file:///etc/xml/docbook" \
  $INSTALL_DIR/etc/xml/catalog &&
xmlcatalog --noout --add "delegatePublic" \
  "-//OASIS//DTD DocBook XML" \
  "file:///etc/xml/docbook" \
  $INSTALL_DIR/etc/xml/catalog &&
xmlcatalog --noout --add "delegateSystem" \
  "http://www.oasis-open.org/docbook/" \
  "file:///etc/xml/docbook" \
  $INSTALL_DIR/etc/xml/catalog &&
xmlcatalog --noout --add "delegateURI" \
  "http://www.oasis-open.org/docbook/" \
  "file:///etc/xml/docbook" \
  $INSTALL_DIR/etc/xml/catalog


for DTDVERSION in 4.1.2 4.2 4.3 4.4
do
xmlcatalog --noout --add "public" \
  "-//OASIS//DTD DocBook XML V$DTDVERSION//EN" \
  "http://www.oasis-open.org/docbook/xml/$DTDVERSION/docbookx.dtd" \
  $INSTALL_DIR/etc/xml/docbook
xmlcatalog --noout --add "rewriteSystem" \
  "http://www.oasis-open.org/docbook/xml/$DTDVERSION" \
  "file:///usr/share/xml/docbook/xml-dtd-4.5" \
  $INSTALL_DIR/etc/xml/docbook
xmlcatalog --noout --add "rewriteURI" \
  "http://www.oasis-open.org/docbook/xml/$DTDVERSION" \
  "file:///usr/share/xml/docbook/xml-dtd-4.5" \
  $INSTALL_DIR/etc/xml/docbook
xmlcatalog --noout --add "delegateSystem" \
  "http://www.oasis-open.org/docbook/xml/$DTDVERSION/" \
  "file:///etc/xml/docbook" \
  $INSTALL_DIR/etc/xml/catalog
xmlcatalog --noout --add "delegateURI" \
  "http://www.oasis-open.org/docbook/xml/$DTDVERSION/" \
  "file:///etc/xml/docbook" \
  $INSTALL_DIR/etc/xml/catalog
done



22. docbook

wget https://www.gnuwakes.org/depot/1.1/main/sources/docbook-4.5.tar.bz2

tar -xf docbook-4.5.tar.bz2

wget https://www.gnuwakes.org/depot/1.1/main/sources/docbook.patch
cd docbook-4.5
patch -p1 < ../docbook.patch 
cd ..

SOURCES_DIR=$PWD/docbook-4.5
INSTALL_DIR=$PWD/docbook-4.5-install
BUILD_DIR=$PWD/docbook-4.5-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e
set -u

#
# sgml-common
#

cd $BUILD_DIR

cp -r $SOURCES_DIR/docbook-4.5/sgml-common-0.6.3 .
cd sgml-common-0.6.3

autoreconf -f -i
./configure --prefix=/usr --sysconfdir=/etc
make

make DESTDIR=$INSTALL_DIR docdir=/usr/share/doc install

# run the following and copy /etc/sgml in $INSTALL_DIR

# install-catalog --add /etc/sgml/sgml-ent.cat \
#  /usr/share/sgml/sgml-iso-entities-8879.1986/catalog

# install-catalog --add /etc/sgml/sgml-docbook.cat \
#  /etc/sgml/sgml-ent.cat

#
# docbook
#

cd $BUILD_DIR

cp -r $SOURCES_DIR/docbook-4.5/docbook-4.5 .
cd docbook-4.5

# removes the ENT definitions from the catalog file
sed -i -e '/ISO 8879/d' -e '/gml/d' docbook.cat

install -v -d $INSTALL_DIR/usr/share/sgml/docbook/sgml-dtd-4.5
chown -R root:root .

install -v docbook.cat \
  $INSTALL_DIR/usr/share/sgml/docbook/sgml-dtd-4.5/catalog
cp -v -af *.dtd *.mod *.dcl \
  $INSTALL_DIR/usr/share/sgml/docbook/sgml-dtd-4.5

cat >> $INSTALL_DIR/usr/share/sgml/docbook/sgml-dtd-4.5/catalog << "EOF"
-- Begin Single Major Version catalog changes --

PUBLIC "-//OASIS//DTD DocBook V4.4//EN" "docbook.dtd"
PUBLIC "-//OASIS//DTD DocBook V4.3//EN" "docbook.dtd"
PUBLIC "-//OASIS//DTD DocBook V4.2//EN" "docbook.dtd"
PUBLIC "-//OASIS//DTD DocBook V4.1//EN" "docbook.dtd"
PUBLIC "-//OASIS//DTD DocBook V4.0//EN" "docbook.dtd"

-- End Single Major Version catalog changes --
EOF

# run the following and copy /etc/sgml in $INSTALL_DIR

# install-catalog --add /etc/sgml/sgml-docbook-dtd-4.5.cat \
#   /usr/share/sgml/docbook/sgml-dtd-4.5/catalog &&

# install-catalog --add /etc/sgml/sgml-docbook-dtd-4.5.cat \
#  /etc/sgml/sgml-docbook.cat

#
# docbook-xml
#

cd $BUILD_DIR

cp -r $SOURCES_DIR/docbook-4.5/docbook-xml-4.5 .
cd docbook-xml-4.5

install -v -d -m755 $INSTALL_DIR/usr/share/xml/docbook/xml-dtd-4.5
install -v -d -m755 $INSTALL_DIR/etc/xml
chown -R root:root .
cp -v -af docbook.cat *.dtd ent/ *.mod \
  $INSTALL_DIR/usr/share/xml/docbook/xml-dtd-4.5

# run the xmlcatalog commands described here:
# http://www.linuxfromscratch.org/blfs/view/cvs/pst/docbook.html
# and copy the folder /etc/xml to $INSTALL_DIR

#
# docbook-xsl
#

cd $BUILD_DIR

cp -r $SOURCES_DIR/docbook-4.5/docbook-xsl-1.79.1 .
cd docbook-xsl-1.79.1

install -v -m755 -d \
  $INSTALL_DIR/usr/share/xml/docbook/xsl-stylesheets-1.79.1

cp -v -R VERSION assembly common eclipse epub epub3 extensions fo \
  highlighting html htmlhelp images javahelp lib manpages params  \
  profiling roundtrip slides template tests tools webhelp website \
  xhtml xhtml-1_1 xhtml5                                          \
  $INSTALL_DIR/usr/share/xml/docbook/xsl-stylesheets-1.79.1

ln -s VERSION \
  $INSTALL_DIR/usr/share/xml/docbook/xsl-stylesheets-1.79.1/VERSION.xsl

install -v -m644 -D README \
  $INSTALL_DIR/usr/share/doc/docbook-xsl-1.79.1/README.txt
install -v -m644    RELEASE-NOTES* NEWS* \
  $INSTALL_DIR/usr/share/doc/docbook-xsl-1.79.1

# run the xmlcatalog commands described here:
# http://www.linuxfromscratch.org/blfs/view/svn/pst/docbook-xsl.html
# and copy the folder /etc/xml to $INSTALL_DIR

23. docker

wget https://www.gnuwakes.org/depot/1.1/main/sources/docker-1.12.3.tgz

tar -xf docker-1.12.3.tgz

wget https://www.gnuwakes.org/depot/1.1/main/sources/docker.patch
cd docker
patch -p1 < ../docker.patch 
cd ..

SOURCES_DIR=$PWD/docker
INSTALL_DIR=$PWD/docker-install
BUILD_DIR=$PWD/docker-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

mkdir -vp $INSTALL_DIR/usr/bin $INSTALL_DIR/lib/systemd/system

cp -vp $SOURCES_DIR/systemd/* $INSTALL_DIR/lib/systemd/system
cp -vp $SOURCES_DIR/docker/* $INSTALL_DIR/usr/bin

24. doxygen

wget https://www.gnuwakes.org/depot/1.1/main/sources/doxygen-1.8.14.src.tar.gz

tar -xf doxygen-1.8.14.src.tar.gz

SOURCES_DIR=$PWD/doxygen-1.8.14
INSTALL_DIR=$PWD/doxygen-1.8.14-install
BUILD_DIR=$PWD/doxygen-1.8.14-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

cmake -G "Unix Makefiles"       \
    -DCMAKE_BUILD_TYPE=Release  \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -Wno-dev $SOURCES_DIR &&    \
make && make DESTDIR=$INSTALL_DIR install

25. dropbear

wget http://www.gnuwakes.org/depot/1.0/main/sources/dropbear-2015.67.tar.bz2

tar -xf dropbear-2015.67.tar.bz2

SOURCES_DIR=$PWD/dropbear-2015.67
INSTALL_DIR=$PWD/dropbear-2015.67-install
BUILD_DIR=$PWD/dropbear-2015.67-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

26. dummy

SOURCES_DIR=$PWD/dummy
INSTALL_DIR=$PWD/dummy-install
BUILD_DIR=$PWD/dummy-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

#cd $SOURCES_DIR && \
#  make && make DESTDIR=$INSTALL_DIR install && make clean
mkdir -p $INSTALL_DIR/var/wkpkg/run/dummy
cd ..
cp -r Buildfile build infos patchs procedures sources \
  $INSTALL_DIR/var/wkpkg/run/dummy
mkdir $INSTALL_DIR/var/wkpkg/run/dummy/binaries

27. e2fsprogs

wget http://www.gnuwakes.org/depot/1.0/main/sources/e2fsprogs-1.42.12.tar.gz

tar -xf e2fsprogs-1.42.12.tar.gz

wget http://www.gnuwakes.org/depot/1.0/main/sources/e2fsprogs.patch
cd e2fsprogs-1.42.12
patch -p1 < ../e2fsprogs.patch 
cd ..

SOURCES_DIR=$PWD/e2fsprogs-1.42.12
INSTALL_DIR=$PWD/e2fsprogs-1.42.12-install
BUILD_DIR=$PWD/e2fsprogs-1.42.12-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure    \
  --prefix=/usr           \
  --bindir=/bin           \
  --with-root-prefix=""   \
  --disable-libblkid      \
  --disable-libuuid       \
  --disable-uuidd         \
  --disable-fsck && \
  make && make DESTDIR=$INSTALL_DIR install && \
  make DESTDIR=$INSTALL_DIR install-libs

chmod -v u+w $INSTALL_DIR/usr/lib/{libcom_err,libe2p,libext2fs,libss}.a

gunzip -v $INSTALL_DIR/usr/share/info/libext2fs.info.gz
install-info --dir-file=$INSTALL_DIR/usr/share/info/dir \
  $INSTALL_DIR/usr/share/info/libext2fs.info

28. ex

wget http://www.gnuwakes.org/depot/1.0/main/sources/ex-050325.tar.bz2

tar -xf ex-050325.tar.bz2

SOURCES_DIR=$PWD/ex-050325
INSTALL_DIR=$PWD/ex-050325-install
BUILD_DIR=$PWD/ex-050325-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

rsync -a $SOURCES_DIR/ .
make TERMLIB=ncurses && make PREFIX=/usr BINDIR=/bin MANDIR=/usr/share/man \
  INSTALL=/usr/bin/install DESTDIR=$INSTALL_DIR install

29. expat

wget http://www.gnuwakes.org/depot/1.0/main/sources/expat-2.1.0.tar.gz

tar -xf expat-2.1.0.tar.gz

SOURCES_DIR=$PWD/expat-2.1.0
INSTALL_DIR=$PWD/expat-2.1.0-install
BUILD_DIR=$PWD/expat-2.1.0-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

install -v -dm755 $INSTALL_DIR/usr/share/doc/expat-2.1.0
install -v -m644 $SOURCES_DIR/doc/*.{html,png,css} \
  $INSTALL_DIR/usr/share/doc/expat-2.1.0

30. file

wget http://www.gnuwakes.org/depot/1.0/main/sources/file-5.22.tar.gz

tar -xf file-5.22.tar.gz

SOURCES_DIR=$PWD/file-5.22
INSTALL_DIR=$PWD/file-5.22-install
BUILD_DIR=$PWD/file-5.22-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make check && make DESTDIR=$INSTALL_DIR install

31. findutils

wget http://www.gnuwakes.org/depot/1.0/main/sources/findutils-4.4.2.tar.gz

tar -xf findutils-4.4.2.tar.gz

SOURCES_DIR=$PWD/findutils-4.4.2
INSTALL_DIR=$PWD/findutils-4.4.2-install
BUILD_DIR=$PWD/findutils-4.4.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr --localstatedir=/var/lib/locate && \
  make && make DESTDIR=$INSTALL_DIR install

# confdir3 bug
mv confdir3 /tmp/$$; rm -rf /tmp/$$

mkdir -v $INSTALL_DIR/bin
mv -v $INSTALL_DIR/usr/bin/find $INSTALL_DIR/bin
sed -i 's|find:=${BINDIR}|find:=/bin|' $INSTALL_DIR/usr/bin/updatedb

32. fio

wget https://www.gnuwakes.org/depot/1.1/main/sources/fio-2.15.tar.gz

tar -xf fio-2.15.tar.gz

SOURCES_DIR=$PWD/fio-fio-2.15
INSTALL_DIR=$PWD/fio-fio-2.15-install
BUILD_DIR=$PWD/fio-fio-2.15-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e
cp -a $SOURCES_DIR/* .
./configure --prefix=/usr
make
make DESTDIR=$INSTALL_DIR mandir=/usr/share/man install

33. flex

wget http://www.gnuwakes.org/depot/1.0/main/sources/flex-2.5.39.tar.bz2

tar -xf flex-2.5.39.tar.bz2

wget http://www.gnuwakes.org/depot/1.0/main/sources/flex.patch
cd flex-2.5.39
patch -p1 < ../flex.patch 
cd ..

SOURCES_DIR=$PWD/flex-2.5.39
INSTALL_DIR=$PWD/flex-2.5.39-install
BUILD_DIR=$PWD/flex-2.5.39-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr --docdir=/usr/share/doc/flex-2.5.39 && \
  make && make DESTDIR=$INSTALL_DIR install

ln -sv flex $INSTALL_DIR/usr/bin/lex

34. fontconfig

wget https://www.gnuwakes.org/depot/1.1/main/sources/fontconfig-2.13.0.tar.bz2

tar -xf fontconfig-2.13.0.tar.bz2

wget https://www.gnuwakes.org/depot/1.1/main/sources/fontconfig.patch
cd fontconfig-2.13.0
patch -p1 < ../fontconfig.patch 
cd ..

SOURCES_DIR=$PWD/fontconfig-2.13.0
INSTALL_DIR=$PWD/fontconfig-2.13.0-install
BUILD_DIR=$PWD/fontconfig-2.13.0-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

cd $SOURCES_DIR
./configure --prefix=/usr                       \
  --sysconfdir=/etc                             \
  --localstatedir=/var                          \
  --disable-docs                                \
  --docdir=/usr/share/doc/fontconfig-2.13.0 &&  \
  make && make DESTDIR=$INSTALL_DIR install && make distclean

35. freetype

wget https://www.gnuwakes.org/depot/1.1/main/sources/freetype-2.9.tar.bz2

tar -xf freetype-2.9.tar.bz2

SOURCES_DIR=$PWD/freetype-2.9
INSTALL_DIR=$PWD/freetype-2.9-install
BUILD_DIR=$PWD/freetype-2.9-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

36. fvwm

wget https://www.gnuwakes.org/depot/1.1/main/sources/fvwm-2.6.7.tar.gz

tar -xf fvwm-2.6.7.tar.gz

SOURCES_DIR=$PWD/fvwm-2.6.7
INSTALL_DIR=$PWD/fvwm-2.6.7-install
BUILD_DIR=$PWD/fvwm-2.6.7-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr \
  --sysconfdir=/etc --localstatedir=/var && \
  make && make DESTDIR=$INSTALL_DIR install

37. gawk

wget http://www.gnuwakes.org/depot/1.0/main/sources/gawk-4.1.1.tar.xz

tar -xf gawk-4.1.1.tar.xz

SOURCES_DIR=$PWD/gawk-4.1.1
INSTALL_DIR=$PWD/gawk-4.1.1-install
BUILD_DIR=$PWD/gawk-4.1.1-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

mkdir -pv $INSTALL_DIR/usr/share/doc/gawk-4.1.1
cp -v $SOURCES_DIR/doc/{awkforai.txt,*.{eps,pdf,jpg}} \
  $INSTALL_DIR/usr/share/doc/gawk-4.1.1

38. gcc

wget http://www.gnuwakes.org/depot/1.0/main/sources/gcc-4.9.2.tar.bz2

tar -xf gcc-4.9.2.tar.bz2

SOURCES_DIR=$PWD/gcc-4.9.2
INSTALL_DIR=$PWD/gcc-4.9.2-install
BUILD_DIR=$PWD/gcc-4.9.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e

ulimit -s 32768

$SOURCES_DIR/configure     \
  --prefix=/usr            \
  --enable-languages=c,c++ \
  --disable-multilib       \
  --disable-bootstrap      \
  --with-system-zlib &&    \
  make && make DESTDIR=$INSTALL_DIR install

# post install
cd $INSTALL_DIR
mkdir lib
ln -sv /usr/bin/cpp lib
ln -sv gcc usr/bin/cc
install -v -dm755 usr/lib/bfd-plugins
ln -sfv /usr/libexec/gcc/$(gcc -dumpmachine)/4.9.2/liblto_plugin.so \
  usr/lib/bfd-plugins/
mkdir -pv usr/share/gdb/auto-load/usr/lib64
mv -v usr/lib64/*gdb.py usr/share/gdb/auto-load/usr/lib64

39. gdbm

wget http://www.gnuwakes.org/depot/1.0/main/sources/gdbm-1.11.tar.gz

tar -xf gdbm-1.11.tar.gz

SOURCES_DIR=$PWD/gdbm-1.11
INSTALL_DIR=$PWD/gdbm-1.11-install
BUILD_DIR=$PWD/gdbm-1.11-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr --enable-libgdbm-compat && \
  make && make DESTDIR=$INSTALL_DIR install

40. gettext

wget http://www.gnuwakes.org/depot/1.0/main/sources/gettext-0.19.4.tar.xz

tar -xf gettext-0.19.4.tar.xz

SOURCES_DIR=$PWD/gettext-0.19.4
INSTALL_DIR=$PWD/gettext-0.19.4-install
BUILD_DIR=$PWD/gettext-0.19.4-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr \
  --docdir=/usr/share/doc/gettext-0.19.4 && \
  make && make DESTDIR=$INSTALL_DIR install

41. git

wget http://www.gnuwakes.org/depot/1.1/main/sources/git-v2.9.2.tar.gz

tar -xf git-v2.9.2.tar.gz

SOURCES_DIR=$PWD/git-2.9.2
INSTALL_DIR=$PWD/git-2.9.2-install
BUILD_DIR=$PWD/git-2.9.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

cp -rp $SOURCES_DIR/* .
autoconf && \
  ./configure --prefix=/usr --without-tcltk && \
  make && make DESTDIR=$INSTALL_DIR install

42. glib

wget https://www.gnuwakes.org/depot/1.1/main/sources/glib-2.52.3.tar.xz

tar -xf glib-2.52.3.tar.xz

SOURCES_DIR=$PWD/glib-2.52.3
INSTALL_DIR=$PWD/glib-2.52.3-install
BUILD_DIR=$PWD/glib-2.52.3-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install
# clean source dir
cd $SOURCES_DIR
rm -rf config.lt libtool config.log
find . | grep -E "(__pycache__|\.pyc$|\.pyo$)" | xargs rm -rf

43. glibc

wget http://www.gnuwakes.org/depot/1.0/main/sources/glibc-2.21.tar.xz

tar -xf glibc-2.21.tar.xz

wget http://www.gnuwakes.org/depot/1.0/main/sources/glibc.patch
cd glibc-2.21
patch -p1 < ../glibc.patch 
cd ..

SOURCES_DIR=$PWD/glibc-2.21
INSTALL_DIR=$PWD/glibc-2.21-install
BUILD_DIR=$PWD/glibc-2.21-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure   \
  --prefix=/usr          \
  --disable-profile      \
  --enable-kernel=2.6.32 \
  --enable-obsolete-rpc  \
&& \
  make && make install_root=$INSTALL_DIR install

#
#  post install
#

# nscd
# we don't create /var/run/nscd as /var/run is a symlink to /run
# which is a tmpfs fs fir systemd
cp -v $SOURCES_DIR/nscd/nscd.conf $INSTALL_DIR/etc/nscd.conf
mkdir -pv $INSTALL_DIR/var/db/nscd

install -v -Dm644 $SOURCES_DIR/nscd/nscd.tmpfiles \
  $INSTALL_DIR/usr/lib/tmpfiles.d/nscd.conf
install -v -Dm644 $SOURCES_DIR/nscd/nscd.service \
  $INSTALL_DIR/lib/systemd/system/nscd.service

# zoneinfo
tar -xf $SOURCES_DIR/tzdata2015a.tar.gz

ZONEINFO=$INSTALL_DIR/usr/share/zoneinfo
mkdir -pv $ZONEINFO/{posix,right}

for tz in etcetera southamerica northamerica europe africa antarctica  \
  asia australasia backward pacificnew systemv
do
  zic -L /dev/null   -d $ZONEINFO       -y "sh yearistype.sh" ${tz}
  zic -L /dev/null   -d $ZONEINFO/posix -y "sh yearistype.sh" ${tz}
  zic -L leapseconds -d $ZONEINFO/right -y "sh yearistype.sh" ${tz}
done

cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO
zic -d $ZONEINFO -p America/New_York
unset ZONEINFO

# ld
rm $INSTALL_DIR/etc/ld.so.cache
cat > $INSTALL_DIR/etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf

/lib64
/usr/lib64

/usr/local/lib
/opt/lib

EOF

cat >> $INSTALL_DIR/etc/ld.so.conf << "EOF"
# Add an include directory
include /etc/ld.so.conf.d/*.conf

EOF
mkdir -pv $INSTALL_DIR/etc/ld.so.conf.d

# nsswitch
cat > $INSTALL_DIR/etc/nsswitch.conf << "EOF"
# Begin /etc/nsswitch.conf

passwd: files
group: files
shadow: files

hosts: files dns myhostname
networks: files

protocols: files
services: files
ethers: files
rpc: files

# End /etc/nsswitch.conf
EOF

# netgroup
touch $INSTALL_DIR/etc/netgroup

44. gmp

wget http://www.gnuwakes.org/depot/1.0/main/sources/gmp-6.0.0a.tar.xz

tar -xf gmp-6.0.0a.tar.xz

SOURCES_DIR=$PWD/gmp-6.0.0
INSTALL_DIR=$PWD/gmp-6.0.0-install
BUILD_DIR=$PWD/gmp-6.0.0-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr --enable-cxx            \
  --docdir=/usr/share/doc/gmp-6.0.0a && make && make html && \
  make DESTDIR=$INSTALL_DIR install &&                       \
  make DESTDIR=$INSTALL_DIR install-html

# result must be 188
make check 2>&1 | tee gmp-check-log && \
  awk '/tests passed/{total+=$2} ; END{print total}' gmp-check-log

45. gperf

wget http://www.gnuwakes.org/depot/1.0/main/sources/gperf-3.0.4.tar.gz

tar -xf gperf-3.0.4.tar.gz

SOURCES_DIR=$PWD/gperf-3.0.4
INSTALL_DIR=$PWD/gperf-3.0.4-install
BUILD_DIR=$PWD/gperf-3.0.4-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr \
  --docdir=/usr/share/doc/gperf-3.0.4 && \
  make && make DESTDIR=$INSTALL_DIR install

46. graphviz

wget https://www.gnuwakes.org/depot/1.1/main/sources/graphviz-2.40.1.tar.gz

tar -xf graphviz-2.40.1.tar.gz

SOURCES_DIR=$PWD/graphviz-2.40.1
INSTALL_DIR=$PWD/graphviz-2.40.1-install
BUILD_DIR=$PWD/graphviz-2.40.1-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

47. grep

wget http://www.gnuwakes.org/depot/1.0/main/sources/grep-2.21.tar.xz

tar -xf grep-2.21.tar.xz

wget http://www.gnuwakes.org/depot/1.0/main/sources/grep.patch
cd grep-2.21
patch -p1 < ../grep.patch 
cd ..

SOURCES_DIR=$PWD/grep-2.21
INSTALL_DIR=$PWD/grep-2.21-install
BUILD_DIR=$PWD/grep-2.21-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr --bindir=/bin && \
  make && make DESTDIR=$INSTALL_DIR install

48. groff

wget http://www.gnuwakes.org/depot/1.0/main/sources/groff-1.22.3.tar.gz

tar -xf groff-1.22.3.tar.gz

SOURCES_DIR=$PWD/groff-1.22.3
INSTALL_DIR=$PWD/groff-1.22.3-install
BUILD_DIR=$PWD/groff-1.22.3-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

PAGE=A4 $SOURCES_DIR/configure --prefix=/usr && make && \
  make DESTDIR=$INSTALL_DIR install

49. grub

wget http://www.gnuwakes.org/depot/1.0/main/sources/grub-2.02~beta2.tar.xz

tar -xf grub-2.02~beta2.tar.xz

wget http://www.gnuwakes.org/depot/1.0/main/sources/grub.patch
cd grub-2.02~beta2
patch -p1 < ../grub.patch 
cd ..

SOURCES_DIR=$PWD/grub-2.02~beta2
INSTALL_DIR=$PWD/grub-2.02~beta2-install
BUILD_DIR=$PWD/grub-2.02~beta2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure   \
  --prefix=/usr          \
  --sbindir=/sbin        \
  --sysconfdir=/etc      \
  --disable-grub-emu-usb \
  --disable-efiemu       \
  --disable-werror && \
  make && make DESTDIR=$INSTALL_DIR install

50. gzip

wget http://www.gnuwakes.org/depot/1.0/main/sources/gzip-1.6.tar.xz

tar -xf gzip-1.6.tar.xz

SOURCES_DIR=$PWD/gzip-1.6
INSTALL_DIR=$PWD/gzip-1.6-install
BUILD_DIR=$PWD/gzip-1.6-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr --bindir=/bin && \
  make && make DESTDIR=$INSTALL_DIR install

# don't move uncompress to another filesystem as gunzip, it's a hardlink
mkdir -pv $INSTALL_DIR/usr/bin
mv -v $INSTALL_DIR/bin/{gzexe,zcmp,zdiff,zegrep} \
  $INSTALL_DIR/usr/bin
mv -v $INSTALL_DIR/bin/{zfgrep,zforce,zgrep,zless,zmore,znew} \
  $INSTALL_DIR/usr/bin

51. iana-etc

wget http://www.gnuwakes.org/depot/1.0/main/sources/iana-etc-2.30.tar.bz2

tar -xf iana-etc-2.30.tar.bz2

SOURCES_DIR=$PWD/iana-etc-2.30
INSTALL_DIR=$PWD/iana-etc-2.30-install
BUILD_DIR=$PWD/iana-etc-2.30-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

rsync -a $SOURCES_DIR/ .
make && make DESTDIR=$INSTALL_DIR install

52. inetutils

wget http://www.gnuwakes.org/depot/1.0/main/sources/inetutils-1.9.2.tar.gz

tar -xf inetutils-1.9.2.tar.gz

wget http://www.gnuwakes.org/depot/1.0/main/sources/inetutils.patch
cd inetutils-1.9.2
patch -p1 < ../inetutils.patch 
cd ..

SOURCES_DIR=$PWD/inetutils-1.9.2
INSTALL_DIR=$PWD/inetutils-1.9.2-install
BUILD_DIR=$PWD/inetutils-1.9.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure \
  --prefix=/usr        \
  --localstatedir=/var \
  --disable-logger     \
  --disable-whois      \
  --disable-servers && \
  make && make DESTDIR=$INSTALL_DIR install

# confdir3 bug
mv confdir3 /tmp/$$; rm -rf /tmp/$$

mkdir -v $INSTALL_DIR/bin $INSTALL_DIR/sbin
mv -v $INSTALL_DIR/usr/bin/{hostname,ping,ping6,traceroute} $INSTALL_DIR/bin
mv -v $INSTALL_DIR/usr/bin/ifconfig $INSTALL_DIR/sbin

53. intltool

wget http://www.gnuwakes.org/depot/1.0/main/sources/intltool-0.50.2.tar.gz

tar -xf intltool-0.50.2.tar.gz

SOURCES_DIR=$PWD/intltool-0.50.2
INSTALL_DIR=$PWD/intltool-0.50.2-install
BUILD_DIR=$PWD/intltool-0.50.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

install -v -Dm644 $SOURCES_DIR/doc/I18N-HOWTO \
  $INSTALL_DIR/usr/share/doc/intltool-0.50.2/I18N-HOWTO

54. iproute2

wget http://www.gnuwakes.org/depot/1.0/main/sources/iproute2-3.19.0.tar.xz

tar -xf iproute2-3.19.0.tar.xz

SOURCES_DIR=$PWD/iproute2-3.19.0
INSTALL_DIR=$PWD/iproute2-3.19.0-install
BUILD_DIR=$PWD/iproute2-3.19.0-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

rsync -a $SOURCES_DIR/ .

# remove arpd program
sed -i '/^TARGETS/s@arpd@@g' misc/Makefile
sed -i /ARPD/d Makefile
sed -i 's/arpd.8//' man/man8/Makefile

make && make DOCDIR=/usr/share/doc/iproute2-3.19.0 \
  DESTDIR=$INSTALL_DIR install

55. iptables

wget http://www.gnuwakes.org/depot/1.1/main/sources/iptables-1.6.0.tar.bz2

tar -xf iptables-1.6.0.tar.bz2

SOURCES_DIR=$PWD/iptables-1.6.0
INSTALL_DIR=$PWD/iptables-1.6.0-install
BUILD_DIR=$PWD/iptables-1.6.0-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e

cp -rp $SOURCES_DIR/* .
./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib64
make
make DESTDIR=$INSTALL_DIR install

56. kbd

wget http://www.gnuwakes.org/depot/1.0/main/sources/kbd-2.0.2.tar.gz

tar -xf kbd-2.0.2.tar.gz

wget http://www.gnuwakes.org/depot/1.0/main/sources/kbd.patch
cd kbd-2.0.2
patch -p1 < ../kbd.patch 
cd ..

SOURCES_DIR=$PWD/kbd-2.0.2
INSTALL_DIR=$PWD/kbd-2.0.2-install
BUILD_DIR=$PWD/kbd-2.0.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

# this package needs the "check" package!
set -e

$SOURCES_DIR/configure --prefix=/usr \
  --disable-vlock && make && make DESTDIR=$INSTALL_DIR install

mkdir -pv $INSTALL_DIR/usr/share/doc/kbd-2.0.2
cp -R -v $SOURCES_DIR/docs/doc/* $INSTALL_DIR/usr/share/doc/kbd-2.0.2

57. kmod

wget http://www.gnuwakes.org/depot/1.0/main/sources/kmod-19.tar.xz

tar -xf kmod-19.tar.xz

SOURCES_DIR=$PWD/kmod-19
INSTALL_DIR=$PWD/kmod-19-install
BUILD_DIR=$PWD/kmod-19-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr          \
          --bindir=/bin                       \
          --sysconfdir=/etc                   \
          --with-rootlibdir=/lib              \
          --with-xz                           \
          --with-zlib && \
  make && make DESTDIR=$INSTALL_DIR install

mkdir -v $INSTALL_DIR/sbin
for target in depmod insmod lsmod modinfo modprobe rmmod
do
  ln -sv /bin/kmod $INSTALL_DIR/sbin/$target
done

ln -sv kmod $INSTALL_DIR/bin/lsmod

58. ksh

wget http://www.gnuwakes.org/depot/1.0/main/sources/ksh_93u+20120229.tar.gz

tar -xf ksh_93u+20120229.tar.gz

SOURCES_DIR=$PWD/ksh-93u+
INSTALL_DIR=$PWD/ksh-93u+-install
BUILD_DIR=$PWD/ksh-93u+-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

cp -r $SOURCES_DIR/* .

./bin/package make

mkdir -p $INSTALL_DIR/bin $INSTALL_DIR/usr/share/man/man1
cp arch/linux.i386-64/bin/ksh $INSTALL_DIR/bin
cp arch/linux.i386-64/man/man1/sh.1 $INSTALL_DIR/usr/share/man/man1/ksh.1

59. less

wget http://www.gnuwakes.org/depot/1.0/main/sources/less-458.tar.gz

tar -xf less-458.tar.gz

SOURCES_DIR=$PWD/less-458
INSTALL_DIR=$PWD/less-458-install
BUILD_DIR=$PWD/less-458-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/ --sysconfdir=/etc \
  --datarootdir=/usr/share && \
  make && make DESTDIR=$INSTALL_DIR install

60. libaio

wget https://www.gnuwakes.org/depot/1.1/main/sources/libaio-0.3.110-1.tar.gz

tar -xf libaio-0.3.110-1.tar.gz

SOURCES_DIR=$PWD/libaio-0.3.110-1
INSTALL_DIR=$PWD/libaio-0.3.110-1-install
BUILD_DIR=$PWD/libaio-0.3.110-1-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e
cp -a $SOURCES_DIR/* .
make
make prefix=$INSTALL_DIR/usr install

61. libarchive

wget http://www.gnuwakes.org/depot/1.0/main/sources/libarchive-v3.1.2-576-gae93c62.tar.gz

tar -xf libarchive-v3.1.2-576-gae93c62.tar.gz

wget http://www.gnuwakes.org/depot/1.0/main/sources/libarchive.patch
cd libarchive-libarchive-ae93c62
patch -p1 < ../libarchive.patch 
cd ..

SOURCES_DIR=$PWD/libarchive-libarchive-ae93c62
INSTALL_DIR=$PWD/libarchive-libarchive-ae93c62-install
BUILD_DIR=$PWD/libarchive-libarchive-ae93c62-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

62. libcap

wget http://www.gnuwakes.org/depot/1.0/main/sources/libcap-2.24.tar.xz

tar -xf libcap-2.24.tar.xz

SOURCES_DIR=$PWD/libcap-2.24
INSTALL_DIR=$PWD/libcap-2.24-install
BUILD_DIR=$PWD/libcap-2.24-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

rsync -a $SOURCES_DIR/ .
make && make RAISE_SETFCAP=no prefix=$INSTALL_DIR/usr install
chmod -v 755 $INSTALL_DIR/usr/lib64/libcap.so

mkdir -v $INSTALL_DIR/lib64
mv -v $INSTALL_DIR/usr/lib64/libcap.so.* $INSTALL_DIR/lib64
ln -sfv ../../lib64/$(readlink $INSTALL_DIR/usr/lib64/libcap.so) \
  $INSTALL_DIR/usr/lib64/libcap.so

63. libelf

wget https://www.gnuwakes.org/depot/1.1/main/sources/libelf-0.8.13.tar.gz

tar -xf libelf-0.8.13.tar.gz

SOURCES_DIR=$PWD/libelf-0.8.13
INSTALL_DIR=$PWD/libelf-0.8.13-install
BUILD_DIR=$PWD/libelf-0.8.13-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make instroot=$INSTALL_DIR install

64. libffi

wget https://www.gnuwakes.org/depot/1.1/main/sources/libffi-3.2.1.tar.gz

tar -xf libffi-3.2.1.tar.gz

SOURCES_DIR=$PWD/libffi-3.2.1
INSTALL_DIR=$PWD/libffi-3.2.1-install
BUILD_DIR=$PWD/libffi-3.2.1-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

65. libgudev

wget https://www.gnuwakes.org/depot/1.1/main/sources/libgudev-231.tar.xz

tar -xf libgudev-231.tar.xz

SOURCES_DIR=$PWD/libgudev-231
INSTALL_DIR=$PWD/libgudev-231-install
BUILD_DIR=$PWD/libgudev-231-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr \
  --disable-umockdev && \
  make && make DESTDIR=$INSTALL_DIR install

66. libmnl

wget http://www.gnuwakes.org/depot/1.1/main/sources/libmnl-1.0.4.tar.bz2

tar -xf libmnl-1.0.4.tar.bz2

SOURCES_DIR=$PWD/libmnl-1.0.4
INSTALL_DIR=$PWD/libmnl-1.0.4-install
BUILD_DIR=$PWD/libmnl-1.0.4-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e

$SOURCES_DIR/configure --prefix=/usr
make
make DESTDIR=$INSTALL_DIR install

67. libmtdev

wget https://www.gnuwakes.org/depot/1.1/main/sources/mtdev-1.1.5.tar.gz

tar -xf mtdev-1.1.5.tar.gz

SOURCES_DIR=$PWD/mtdev-1.1.5
INSTALL_DIR=$PWD/mtdev-1.1.5-install
BUILD_DIR=$PWD/mtdev-1.1.5-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

68. libnftnl

wget http://www.gnuwakes.org/depot/1.1/main/sources/libnftnl-1.0.6.tar.bz2

tar -xf libnftnl-1.0.6.tar.bz2

SOURCES_DIR=$PWD/libnftnl-1.0.6
INSTALL_DIR=$PWD/libnftnl-1.0.6-install
BUILD_DIR=$PWD/libnftnl-1.0.6-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e

$SOURCES_DIR/configure --prefix=/usr
make
make DESTDIR=$INSTALL_DIR install

69. libpcre

wget https://www.gnuwakes.org/depot/1.1/main/sources/pcre-8.41.tar.bz2

tar -xf pcre-8.41.tar.bz2

SOURCES_DIR=$PWD/pcre-8.41
INSTALL_DIR=$PWD/pcre-8.41-install
BUILD_DIR=$PWD/pcre-8.41-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr \
  --enable-unicode-properties        \
  --enable-pcre16                    \
  --enable-pcre32                    \
  --enable-pcregrep-libz             \
  --enable-pcregrep-libbz2           \
  --enable-pcretest-libreadline &&   \
  make && make DESTDIR=$INSTALL_DIR install

70. libpipeline

wget http://www.gnuwakes.org/depot/1.0/main/sources/libpipeline-1.4.0.tar.gz

tar -xf libpipeline-1.4.0.tar.gz

SOURCES_DIR=$PWD/libpipeline-1.4.0
INSTALL_DIR=$PWD/libpipeline-1.4.0-install
BUILD_DIR=$PWD/libpipeline-1.4.0-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

71. libpng

wget https://www.gnuwakes.org/depot/1.1/main/sources/libpng-1.6.32.tar.xz

tar -xf libpng-1.6.32.tar.xz

SOURCES_DIR=$PWD/libpng-1.6.32
INSTALL_DIR=$PWD/libpng-1.6.32-install
BUILD_DIR=$PWD/libpng-1.6.32-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

72. libstdc++

wget http://www.gnuwakes.org/depot/1.0/main/sources/gcc-4.9.2.tar.bz2

tar -xf gcc-4.9.2.tar.bz2

SOURCES_DIR=$PWD/gcc-4.9.2
INSTALL_DIR=$PWD/gcc-4.9.2-install
BUILD_DIR=$PWD/gcc-4.9.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e

ulimit -s 32768

$SOURCES_DIR/configure     \
  --prefix=/usr            \
  --enable-languages=c,c++ \
  --disable-multilib       \
  --disable-bootstrap      \
  --with-system-zlib &&    \
  make && make DESTDIR=$INSTALL_DIR \
  install-target-libgcc install-target-libstdc++-v3

# move a misplaced file that make ldconfig return an error
mkdir -pv $INSTALL_DIR/usr/share/gdb/auto-load/usr/lib64
mv -v $INSTALL_DIR/usr/lib64/*gdb.py \
  $INSTALL_DIR/usr/share/gdb/auto-load/usr/lib64

73. libtalloc

wget https://www.gnuwakes.org/depot/1.1/main/sources/talloc-2.1.11.tar.gz

tar -xf talloc-2.1.11.tar.gz

SOURCES_DIR=$PWD/talloc-2.1.11
INSTALL_DIR=$PWD/talloc-2.1.11-install
BUILD_DIR=$PWD/talloc-2.1.11-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

cd $SOURCES_DIR && \
  ./configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install
# clean source dir
find . -type f -name "*.pyc" -delete
rm -rf bin .lock-wscript

74. libtar

wget http://www.gnuwakes.org/depot/1.0/main/sources/libtar-1.2.20.tar.gz

tar -xf libtar-1.2.20.tar.gz

wget http://www.gnuwakes.org/depot/1.0/main/sources/libtar.patch
cd libtar
patch -p1 < ../libtar.patch 
cd ..

SOURCES_DIR=$PWD/libtar
INSTALL_DIR=$PWD/libtar-install
BUILD_DIR=$PWD/libtar-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

75. libtool

wget http://www.gnuwakes.org/depot/1.0/main/sources/libtool-2.4.6.tar.xz

tar -xf libtool-2.4.6.tar.xz

SOURCES_DIR=$PWD/libtool-2.4.6
INSTALL_DIR=$PWD/libtool-2.4.6-install
BUILD_DIR=$PWD/libtool-2.4.6-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

76. libwacom

wget https://www.gnuwakes.org/depot/1.1/main/sources/libwacom-0.26.tar.bz2

tar -xf libwacom-0.26.tar.bz2

SOURCES_DIR=$PWD/libwacom-0.26
INSTALL_DIR=$PWD/libwacom-0.26-install
BUILD_DIR=$PWD/libwacom-0.26-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

77. libxml2

wget http://www.gnuwakes.org/depot/1.1/main/sources/libxml2-2.9.4.tar.gz

tar -xf libxml2-2.9.4.tar.gz

SOURCES_DIR=$PWD/libxml2-2.9.4
INSTALL_DIR=$PWD/libxml2-2.9.4-install
BUILD_DIR=$PWD/libxml2-2.9.4-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install 

78. libxslt

wget http://www.gnuwakes.org/depot/1.1/main/sources/libxslt-1.1.29.tar.gz

tar -xf libxslt-1.1.29.tar.gz

SOURCES_DIR=$PWD/libxslt-1.1.29
INSTALL_DIR=$PWD/libxslt-1.1.29-install
BUILD_DIR=$PWD/libxslt-1.1.29-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install 

79. linux-4.8.13

SOURCES_DIR=$PWD/linux-4.8.13
INSTALL_DIR=$PWD/linux-4.8.13-install
BUILD_DIR=$PWD/linux-4.8.13-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

cd $INSTALL_DIR
ver=$(<../infos/Version)
mkdir -v boot
rsync -a /boot/*-$ver boot
mkdir -pv lib/modules
rsync -a /lib/modules/$ver lib/modules

if [ -d /lib/firmware ]
then
  rsync -a /lib/firmware lib
fi

80. linux-headers-4.8.13

SOURCES_DIR=$PWD/linux-headers-4.8.13
INSTALL_DIR=$PWD/linux-headers-4.8.13-install
BUILD_DIR=$PWD/linux-headers-4.8.13-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

#
# To install the kernel headers, run the following commands:
#
#  cd /usr/src/linux
#  make mrproper
#  make INSTALL_HDR_PATH=$BUILD_DIR headers_install
#  find $BUILD_DIR/ \( -name .install -o -name ..install.cmd \) -delete
#  cp -rv $BUILD_DIR/include/* $INSTALL_DIR/usr/include
#

kernel_src=/usr/src/linux

if [ ! -d "$kernel_src" ]
then
  print "Please install the kernel sources in $kernel_src first"
  return 1
fi

cd "$kernel_src"
make mrproper
make INSTALL_HDR_PATH=$BUILD_DIR headers_install
find $BUILD_DIR/ \( -name .install -o -name ..install.cmd \) -delete
mkdir -pv $INSTALL_DIR/usr/include
cp -rv $BUILD_DIR/include/* $INSTALL_DIR/usr/include

81. linux-sources-4.8.13

wget https://www.gnuwakes.org/depot/1.1/main/sources/linux-4.8.13.tar.xz

tar -xf linux-4.8.13.tar.xz

wget https://www.gnuwakes.org/depot/1.1/main/sources/linux-sources-4.8.13.patch
cd linux-4.8.13
patch -p1 < ../linux-sources-4.8.13.patch 
cd ..

SOURCES_DIR=$PWD/linux-4.8.13
INSTALL_DIR=$PWD/linux-4.8.13-install
BUILD_DIR=$PWD/linux-4.8.13-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

VERSION=$(ls $SOURCES_DIR/config-* | awk -F'-' '{ print $NF }')

mkdir -vp $INSTALL_DIR/usr/src/linux-$VERSION
cd $INSTALL_DIR/usr/src/linux-$VERSION

rsync -a --exclude "config-$VERSION" $SOURCES_DIR/ .
cd ..

ln -s linux-$VERSION linux

cd linux
make mrproper
cp $SOURCES_DIR/config-$VERSION .config
make prepare
make scripts
ln -s ../generated/uapi/linux/version.h include/linux/version.h

82. llvm

wget https://www.gnuwakes.org/depot/1.1/main/sources/llvm-3.9.1.src.tar.xz

tar -xf llvm-3.9.1.src.tar.xz

wget https://www.gnuwakes.org/depot/1.1/main/sources/llvm.patch
cd llvm-3.9.1.src
patch -p1 < ../llvm.patch 
cd ..

SOURCES_DIR=$PWD/llvm-3.9.1.src
INSTALL_DIR=$PWD/llvm-3.9.1.src-install
BUILD_DIR=$PWD/llvm-3.9.1.src-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

cmake -DCMAKE_BUILD_TYPE=Release        \
  -DCMAKE_INSTALL_PREFIX=/usr           \
  -DLLVM_TARGETS_TO_BUILD='X86;AMDGPU'  \
  -DLLVM_BUILD_LLVM_DYLIB=ON            \
  $SOURCES_DIR &&                       \
make && make DESTDIR=$INSTALL_DIR install

83. lvm2

wget http://www.gnuwakes.org/depot/1.0/main/sources/LVM2.2.02.116.tgz

tar -xf LVM2.2.02.116.tgz

SOURCES_DIR=$PWD/LVM2.2.02.116
INSTALL_DIR=$PWD/LVM2.2.02.116-install
BUILD_DIR=$PWD/LVM2.2.02.116-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure \
  --prefix=/usr        \
  --exec-prefix=       \
  --with-confdir=/etc  \
  --enable-applib      \
  --enable-cmdlib      \
  --enable-pkgconfig   \
  --enable-udev_sync && \
  make && make DESTDIR=$INSTALL_DIR install

84. m4

wget http://www.gnuwakes.org/depot/1.0/main/sources/m4-1.4.17.tar.xz

tar -xf m4-1.4.17.tar.xz

SOURCES_DIR=$PWD/m4-1.4.17
INSTALL_DIR=$PWD/m4-1.4.17-install
BUILD_DIR=$PWD/m4-1.4.17-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

85. make

wget http://www.gnuwakes.org/depot/1.0/main/sources/make-4.1.tar.bz2

tar -xf make-4.1.tar.bz2

SOURCES_DIR=$PWD/make-4.1
INSTALL_DIR=$PWD/make-4.1-install
BUILD_DIR=$PWD/make-4.1-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

86. man-db

wget http://www.gnuwakes.org/depot/1.0/main/sources/man-db-2.7.1.tar.xz

tar -xf man-db-2.7.1.tar.xz

SOURCES_DIR=$PWD/man-db-2.7.1
INSTALL_DIR=$PWD/man-db-2.7.1-install
BUILD_DIR=$PWD/man-db-2.7.1-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure                 \
  --prefix=/usr                        \
  --docdir=/usr/share/doc/man-db-2.7.1 \
  --sysconfdir=/etc                    \
  --disable-setuid                     \
  --with-browser=/usr/bin/lynx         \
  --with-vgrind=/usr/bin/vgrind        \
  --with-grap=/usr/bin/grap && \
  make && make DESTDIR=$INSTALL_DIR install

# confdir3 bug
mv confdir3 /tmp/$$; rm -rf /tmp/$$

sed -i "s:man root:root root:g" $INSTALL_DIR/usr/lib/tmpfiles.d/man-db.conf

87. man-pages

wget http://www.gnuwakes.org/depot/1.0/main/sources/man-pages-3.79.tar.xz

tar -xf man-pages-3.79.tar.xz

SOURCES_DIR=$PWD/man-pages-3.79
INSTALL_DIR=$PWD/man-pages-3.79-install
BUILD_DIR=$PWD/man-pages-3.79-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

rsync -a $SOURCES_DIR/ .
make DESTDIR=$INSTALL_DIR install

88. meson

wget https://www.gnuwakes.org/depot/1.1/main/sources/meson-0.45.0.tar.gz

tar -xf meson-0.45.0.tar.gz

SOURCES_DIR=$PWD/meson-0.45.0
INSTALL_DIR=$PWD/meson-0.45.0-install
BUILD_DIR=$PWD/meson-0.45.0-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

cd $SOURCES_DIR
python3 setup.py bdist
tar -C $INSTALL_DIR -xf dist/*.tar.gz
# clean source folder
rm -rf build dist
find . | grep -E "(__pycache__|\.pyc$|\.pyo$)" | xargs rm -rf

89. mkinitramfs

wget https://www.gnuwakes.org/depot/1.1/main/sources/mkinitramfs.tar.gz

tar -xf mkinitramfs.tar.gz

SOURCES_DIR=$PWD/mkinitramfs
INSTALL_DIR=$PWD/mkinitramfs-install
BUILD_DIR=$PWD/mkinitramfs-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

mkdir -pv $INSTALL_DIR/usr/share/mkinitramfs
mkdir -pv $INSTALL_DIR/sbin

for f in init.in clear wakes_banner
do
  cp -v $SOURCES_DIR/$f $INSTALL_DIR/usr/share/mkinitramfs
done

cp -v $SOURCES_DIR/mkinitramfs $INSTALL_DIR/sbin

90. mpc

wget http://www.gnuwakes.org/depot/1.0/main/sources/mpc-1.0.2.tar.gz

tar -xf mpc-1.0.2.tar.gz

SOURCES_DIR=$PWD/mpc-1.0.2
INSTALL_DIR=$PWD/mpc-1.0.2-install
BUILD_DIR=$PWD/mpc-1.0.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr --docdir=/usr/share/doc/mpc-1.0.2 && \
  make && make html && make check && make DESTDIR=$INSTALL_DIR install && \
  make DESTDIR=$INSTALL_DIR install-html

91. mpfr

wget http://www.gnuwakes.org/depot/1.0/main/sources/mpfr-3.1.2.tar.xz

tar -xf mpfr-3.1.2.tar.xz

wget http://www.gnuwakes.org/depot/1.0/main/sources/mpfr.patch
cd mpfr-3.1.2
patch -p1 < ../mpfr.patch 
cd ..

SOURCES_DIR=$PWD/mpfr-3.1.2
INSTALL_DIR=$PWD/mpfr-3.1.2-install
BUILD_DIR=$PWD/mpfr-3.1.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr --enable-thread-safe    \
  --docdir=/usr/share/doc/mpfr-3.1.2 && make && make html && \
  make check && make DESTDIR=$INSTALL_DIR install &&         \
  make DESTDIR=$INSTALL_DIR install-html

92. ncurses

wget http://www.gnuwakes.org/depot/1.0/main/sources/ncurses-5.9.tar.gz

tar -xf ncurses-5.9.tar.gz

SOURCES_DIR=$PWD/ncurses-5.9
INSTALL_DIR=$PWD/ncurses-5.9-install
BUILD_DIR=$PWD/ncurses-5.9-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure      \
    --prefix=/usr           \
    --mandir=/usr/share/man \
    --with-shared           \
    --without-debug         \
    --enable-pc-files       \
    --enable-widec &&       \
  make && make DESTDIR=$INSTALL_DIR install

# Move the shared libraries to the /lib directory,
# where they are expected to reside:
mkdir $INSTALL_DIR/lib
mv -v $INSTALL_DIR/usr/lib/libncursesw.so.5* $INSTALL_DIR/lib
ln -sfv ../../lib/$(readlink $INSTALL_DIR/usr/lib/libncursesw.so) \
  $INSTALL_DIR/usr/lib/libncursesw.so

# Many applications still expect the linker to be able to find
# non-wide-character Ncurses libraries. Do the trick.
for lib in ncurses form panel menu
do
  rm -vf                    $INSTALL_DIR/usr/lib/lib${lib}.so
  echo "INPUT(-l${lib}w)" > $INSTALL_DIR/usr/lib/lib${lib}.so
  ln -sfv lib${lib}w.a      $INSTALL_DIR/usr/lib/lib${lib}.a
  ln -sfv ${lib}w.pc        $INSTALL_DIR/usr/lib/pkgconfig/${lib}.pc
done
ln -sfv libncurses++w.a $INSTALL_DIR/usr/lib/libncurses++.a

# make sure that old applications that look for -lcurses
# at build time are still buildable:
rm -vf                     $INSTALL_DIR/usr/lib/libcursesw.so
echo "INPUT(-lncursesw)" > $INSTALL_DIR/usr/lib/libcursesw.so
ln -sfv libncurses.so      $INSTALL_DIR/usr/lib/libcurses.so
ln -sfv libncursesw.a      $INSTALL_DIR/usr/lib/libcursesw.a
ln -sfv libncurses.a       $INSTALL_DIR/usr/lib/libcurses.a

# install the Ncurses documentation:
mkdir -pv $INSTALL_DIR/usr/share/doc/ncurses-5.9
cp -v -R ../sources/doc/* $INSTALL_DIR/usr/share/doc/ncurses-5.9

93. ninja

wget https://www.gnuwakes.org/depot/1.1/main/sources/ninja-v1.8.2.tar.gz

tar -xf ninja-v1.8.2.tar.gz

SOURCES_DIR=$PWD/ninja-1.8.2
INSTALL_DIR=$PWD/ninja-1.8.2-install
BUILD_DIR=$PWD/ninja-1.8.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

cd $SOURCES_DIR
./configure.py --bootstrap
mkdir -p $INSTALL_DIR/usr/bin
mv ninja $INSTALL_DIR/usr/bin
chmod 555 $INSTALL_DIR/usr/bin/ninja
# clean source folder
rm -rf build build.ninja
find . | grep -E "(__pycache__|\.pyc$|\.pyo$)" | xargs rm -rf

94. openssh

wget http://www.gnuwakes.org/depot/1.0/main/sources/openssh-6.7p1.tar.gz

tar -xf openssh-6.7p1.tar.gz

wget http://www.gnuwakes.org/depot/1.0/main/sources/openssh.patch
cd openssh-6.7p1
patch -p1 < ../openssh.patch 
cd ..

SOURCES_DIR=$PWD/openssh-6.7p1
INSTALL_DIR=$PWD/openssh-6.7p1-install
BUILD_DIR=$PWD/openssh-6.7p1-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure                 \
  --prefix=/usr                        \
  --sysconfdir=/etc/ssh                \
  --with-privsep-path=/var/lib/sshd && \
  make && make DESTDIR=$INSTALL_DIR install

install -v -m755 $SOURCES_DIR/contrib/ssh-copy-id $INSTALL_DIR/usr/bin
install -v -m644 $SOURCES_DIR/contrib/ssh-copy-id.1 \
  $INSTALL_DIR/usr/share/man/man1
install -v -m755 -d $INSTALL_DIR/usr/share/doc/openssh-6.7p1
install -v -m644 $SOURCES_DIR/INSTALL $SOURCES_DIR/LICENCE \
  $SOURCES_DIR/OVERVIEW $SOURCES_DIR/README* \
  $INSTALL_DIR/usr/share/doc/openssh-6.7p1

mkdir -pv $INSTALL_DIR/lib/systemd/system
cp -v $SOURCES_DIR/sshd.service $INSTALL_DIR/lib/systemd/system

95. openssl

wget http://www.gnuwakes.org/depot/1.0/main/sources/openssl-1.0.2.tar.gz

tar -xf openssl-1.0.2.tar.gz

wget http://www.gnuwakes.org/depot/1.0/main/sources/openssl.patch
cd openssl-1.0.2
patch -p1 < ../openssl.patch 
cd ..

SOURCES_DIR=$PWD/openssl-1.0.2
INSTALL_DIR=$PWD/openssl-1.0.2-install
BUILD_DIR=$PWD/openssl-1.0.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

rsync -a $SOURCES_DIR/ .

./config --prefix=/usr         \
         --openssldir=/etc/ssl \
         --libdir=lib          \
         shared                \
         zlib-dynamic &&       \
  make

make MANDIR=/usr/share/man MANSUFFIX=ssl \
  INSTALL_PREFIX=$INSTALL_DIR install && \
  install -dv -m755 $INSTALL_DIR/usr/share/doc/openssl-1.0.2 && \
  cp -vfr doc/* $INSTALL_DIR/usr/share/doc/openssl-1.0.2

96. parted

wget http://www.gnuwakes.org/depot/1.0/main/sources/parted-3.2.tar.xz

tar -xf parted-3.2.tar.xz

SOURCES_DIR=$PWD/parted-3.2
INSTALL_DIR=$PWD/parted-3.2-install
BUILD_DIR=$PWD/parted-3.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

97. patch

wget http://www.gnuwakes.org/depot/1.0/main/sources/patch-2.7.4.tar.xz

tar -xf patch-2.7.4.tar.xz

SOURCES_DIR=$PWD/patch-2.7.4
INSTALL_DIR=$PWD/patch-2.7.4-install
BUILD_DIR=$PWD/patch-2.7.4-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

98. perl

wget http://www.gnuwakes.org/depot/1.0/main/sources/perl-5.20.2.tar.bz2

tar -xf perl-5.20.2.tar.bz2

SOURCES_DIR=$PWD/perl-5.20.2
INSTALL_DIR=$PWD/perl-5.20.2-install
BUILD_DIR=$PWD/perl-5.20.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

rsync -a $SOURCES_DIR/ .

export BUILD_ZLIB=False
export BUILD_BZIP2=0

sh Configure -des               \
  -Dprefix=/usr                 \
  -Dvendorprefix=/usr           \
  -Dman1dir=/usr/share/man/man1 \
  -Dman3dir=/usr/share/man/man3 \
  -Dpager="/usr/bin/less -isR"  \
  -Duseshrplib && \
  make && make DESTDIR=$INSTALL_DIR install

99. pkg-config

wget http://www.gnuwakes.org/depot/1.0/main/sources/pkg-config-0.28.tar.gz

tar -xf pkg-config-0.28.tar.gz

SOURCES_DIR=$PWD/pkg-config-0.28
INSTALL_DIR=$PWD/pkg-config-0.28-install
BUILD_DIR=$PWD/pkg-config-0.28-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure                         \
    --prefix=/usr                              \
    --with-internal-glib                       \
    --disable-host-tool                        \
    --docdir=/usr/share/doc/pkg-config-0.28 && \
  make && make check && make DESTDIR=$INSTALL_DIR install

100. procps-ng

wget http://www.gnuwakes.org/depot/1.0/main/sources/procps-ng-3.3.10.tar.xz

tar -xf procps-ng-3.3.10.tar.xz

wget http://www.gnuwakes.org/depot/1.0/main/sources/procps-ng.patch
cd procps-ng-3.3.10
patch -p1 < ../procps-ng.patch 
cd ..

SOURCES_DIR=$PWD/procps-ng-3.3.10
INSTALL_DIR=$PWD/procps-ng-3.3.10-install
BUILD_DIR=$PWD/procps-ng-3.3.10-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure                     \
  --prefix=/usr                            \
  --exec-prefix=                           \
  --libdir=/usr/lib                        \
  --docdir=/usr/share/doc/procps-ng-3.3.10 \
  --disable-static                         \
  --disable-kill && \
  make && make DESTDIR=$INSTALL_DIR install

mv -v $INSTALL_DIR/usr/bin/pidof $INSTALL_DIR/bin

mkdir -v $INSTALL_DIR/lib
mv -v $INSTALL_DIR/usr/lib/libprocps.so.* $INSTALL_DIR/lib
ln -sfv ../../lib/$(readlink $INSTALL_DIR/usr/lib/libprocps.so) \
  $INSTALL_DIR/usr/lib/libprocps.so

101. psmisc

wget http://www.gnuwakes.org/depot/1.0/main/sources/psmisc-22.21.tar.gz

tar -xf psmisc-22.21.tar.gz

SOURCES_DIR=$PWD/psmisc-22.21
INSTALL_DIR=$PWD/psmisc-22.21-install
BUILD_DIR=$PWD/psmisc-22.21-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

mkdir -v $INSTALL_DIR/bin
mv -v $INSTALL_DIR/usr/bin/fuser   $INSTALL_DIR/bin
mv -v $INSTALL_DIR/usr/bin/killall $INSTALL_DIR/bin

102. python2-mako

wget https://www.gnuwakes.org/depot/1.1/main/sources/Mako-1.0.7.tar.gz

tar -xf Mako-1.0.7.tar.gz

SOURCES_DIR=$PWD/Mako-1.0.7
INSTALL_DIR=$PWD/Mako-1.0.7-install
BUILD_DIR=$PWD/Mako-1.0.7-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

cd $SOURCES_DIR
python2 setup.py bdist
tar -C $INSTALL_DIR -xf dist/Mako-1.0.7.linux-x86_64.tar.gz
rm -rf build dist

103. python2

wget https://www.gnuwakes.org/depot/1.1/main/sources/Python-2.7.14.tar.xz

tar -xf Python-2.7.14.tar.xz

SOURCES_DIR=$PWD/Python-2.7.14
INSTALL_DIR=$PWD/Python-2.7.14-install
BUILD_DIR=$PWD/Python-2.7.14-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

# build with -fPIC to make the static library position-independent
$SOURCES_DIR/configure --prefix=/usr && \
  make EXTRA_CFLAGS="-fPIC" && make DESTDIR=$INSTALL_DIR install
# clean source dir
find $SOURCES_DIR -type f -name "*.pyc" -delete
find $SOURCES_DIR -type f -name "*.pyo" -delete

104. python3-mako

wget https://www.gnuwakes.org/depot/1.1/main/sources/Mako-1.0.7.tar.gz

tar -xf Mako-1.0.7.tar.gz

SOURCES_DIR=$PWD/Mako-1.0.7
INSTALL_DIR=$PWD/Mako-1.0.7-install
BUILD_DIR=$PWD/Mako-1.0.7-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

cd $SOURCES_DIR
python3 setup.py bdist
tar -C $INSTALL_DIR -xf dist/Mako-1.0.7.linux-x86_64.tar.gz
rm -rf build dist

105. python3

wget https://www.gnuwakes.org/depot/1.1/main/sources/Python-3.6.5.tar.xz

tar -xf Python-3.6.5.tar.xz

wget https://www.gnuwakes.org/depot/1.1/main/sources/python3.patch
cd Python-3.6.5
patch -p1 < ../python3.patch 
cd ..

SOURCES_DIR=$PWD/Python-3.6.5
INSTALL_DIR=$PWD/Python-3.6.5-install
BUILD_DIR=$PWD/Python-3.6.5-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

106. readline

wget http://www.gnuwakes.org/depot/1.0/main/sources/readline-6.3.tar.gz

tar -xf readline-6.3.tar.gz

wget http://www.gnuwakes.org/depot/1.0/main/sources/readline.patch
cd readline-6.3
patch -p1 < ../readline.patch 
cd ..

SOURCES_DIR=$PWD/readline-6.3
INSTALL_DIR=$PWD/readline-6.3-install
BUILD_DIR=$PWD/readline-6.3-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr \
  --docdir=/usr/share/doc/readline-6.3 && \
  make SHLIB_LIBS=-lncurses && \
  make DESTDIR=$INSTALL_DIR SHLIB_LIBS=-lncurses install

mkdir -v $INSTALL_DIR/lib
mv -v $INSTALL_DIR/usr/lib/lib{readline,history}.so.* $INSTALL_DIR/lib
ln -sfv ../../lib/$(readlink $INSTALL_DIR/usr/lib/libreadline.so) \
  $INSTALL_DIR/usr/lib/libreadline.so
ln -sfv ../../lib/$(readlink $INSTALL_DIR/usr/lib/libhistory.so ) \
  $INSTALL_DIR/usr/lib/libhistory.so

install -v -m644 $SOURCES_DIR/doc/*.{ps,pdf,html,dvi} \
  $INSTALL_DIR/usr/share/doc/readline-6.3

107. rsync

wget http://www.gnuwakes.org/depot/1.0/main/sources/rsync-3.1.1.tar.gz

tar -xf rsync-3.1.1.tar.gz

SOURCES_DIR=$PWD/rsync-3.1.1
INSTALL_DIR=$PWD/rsync-3.1.1-install
BUILD_DIR=$PWD/rsync-3.1.1-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

108. sed

wget http://www.gnuwakes.org/depot/1.0/main/sources/sed-4.2.2.tar.bz2

tar -xf sed-4.2.2.tar.bz2

SOURCES_DIR=$PWD/sed-4.2.2
INSTALL_DIR=$PWD/sed-4.2.2-install
BUILD_DIR=$PWD/sed-4.2.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure \
  --prefix=/usr --bindir=/bin --htmldir=/usr/share/doc/sed-4.2.2 && \
  make && make html && make check && make DESTDIR=$INSTALL_DIR install && \
  make DESTDIR=$INSTALL_DIR -C doc install-html

109. shadow

wget http://www.gnuwakes.org/depot/1.0/main/sources/shadow-4.2.1.tar.xz

tar -xf shadow-4.2.1.tar.xz

wget http://www.gnuwakes.org/depot/1.0/main/sources/shadow.patch
cd shadow-4.2.1
patch -p1 < ../shadow.patch 
cd ..

SOURCES_DIR=$PWD/shadow-4.2.1
INSTALL_DIR=$PWD/shadow-4.2.1-install
BUILD_DIR=$PWD/shadow-4.2.1-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --sysconfdir=/etc --with-group-name-max-length=32 && \
  make && make DESTDIR=$INSTALL_DIR install
mv -v $INSTALL_DIR/usr/bin/passwd $INSTALL_DIR/bin

110. strace

wget http://www.gnuwakes.org/depot/1.0/main/sources/strace-4.10.tar.xz

tar -xf strace-4.10.tar.xz

SOURCES_DIR=$PWD/strace-4.10
INSTALL_DIR=$PWD/strace-4.10-install
BUILD_DIR=$PWD/strace-4.10-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

111. systemd

wget https://www.gnuwakes.org/depot/1.1/main/sources/systemd-v230.tar.gz

tar -xf systemd-v230.tar.gz

wget https://www.gnuwakes.org/depot/1.1/main/sources/systemd.patch
cd systemd-230
patch -p1 < ../systemd.patch 
cd ..

SOURCES_DIR=$PWD/systemd-230
INSTALL_DIR=$PWD/systemd-230-install
BUILD_DIR=$PWD/systemd-230-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e

$SOURCES_DIR/autogen.sh

$SOURCES_DIR/configure       \
  CFLAGS='-g -O0 -ftrapv'    \
  --enable-kdbus             \
  --sysconfdir=/etc          \
  --localstatedir=/var       \
  --libdir=/usr/lib64        \
  --with-rootprefix=/        \
  --with-rootlibdir=/lib64 

make

make DESTDIR=$INSTALL_DIR install

mkdir -v $INSTALL_DIR/sbin
for tool in runlevel reboot shutdown poweroff halt telinit
do
  ln -sfv /bin/systemctl $INSTALL_DIR/sbin/${tool}
done
ln -sfv /lib/systemd/systemd $INSTALL_DIR/sbin/init

# needed by systemd to boot
mkdir -v $INSTALL_DIR/run
# systemd requires that the /run mount point exists. systemd also
# requires that /var/run is a a symlink to /run.
ln -vs /run $INSTALL_DIR/var/run

# disable screen clearing
mkdir -pv $INSTALL_DIR/etc/systemd/system/getty@tty1.service.d
cat > $INSTALL_DIR/etc/systemd/system/getty@tty1.service.d/noclear.conf << EOF
[Service]
TTYVTDisallocate=no
EOF

# disable console errors in fsck
for f in $INSTALL_DIR/lib/systemd/system/systemd-fsck@.service \
  $INSTALL_DIR/lib/systemd/system/systemd-fsck-root.service
do
  sed -i '/^StandardOutput=/s/^.*$/StandardOutput=journal/' $f
done

112. tar

wget http://www.gnuwakes.org/depot/1.0/main/sources/tar-1.28.tar.xz

tar -xf tar-1.28.tar.xz

SOURCES_DIR=$PWD/tar-1.28
INSTALL_DIR=$PWD/tar-1.28-install
BUILD_DIR=$PWD/tar-1.28-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

FORCE_UNSAFE_CONFIGURE=1 $SOURCES_DIR/configure --prefix=/usr \
  --bindir=/bin && make && make DESTDIR=$INSTALL_DIR install

make -C doc install-html docdir=$INSTALL_DIR/usr/share/doc/tar-1.28

# confdir3 bug
mv confdir3 /tmp/$$; rm -rf /tmp/$$

113. texinfo

wget http://www.gnuwakes.org/depot/1.0/main/sources/texinfo-5.2.tar.xz

tar -xf texinfo-5.2.tar.xz

wget http://www.gnuwakes.org/depot/1.0/main/sources/texinfo.patch
cd texinfo-5.2
patch -p1 < ../texinfo.patch 
cd ..

SOURCES_DIR=$PWD/texinfo-5.2
INSTALL_DIR=$PWD/texinfo-5.2-install
BUILD_DIR=$PWD/texinfo-5.2-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

make TEXMF=$INSTALL_DIR/usr/share/texmf install-tex

cd $INSTALL_DIR/usr/share/info
rm -v dir
for f in *
do
  install-info $f dir 2>/dev/null
done
cd -

114. unzip

wget https://www.gnuwakes.org/depot/1.1/main/sources/unzip60.tar.gz

tar -xf unzip60.tar.gz

SOURCES_DIR=$PWD/unzip60
INSTALL_DIR=$PWD/unzip60-install
BUILD_DIR=$PWD/unzip60-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e

cp -r $SOURCES_DIR/* .

make -f unix/Makefile generic

make prefix=$INSTALL_DIR/usr MANDIR=$INSTALL_DIR/usr/share/man/man1 \
  -f unix/Makefile install

115. util-linux

wget http://www.gnuwakes.org/depot/1.1/main/sources/util-linux-2.28.tar.xz

tar -xf util-linux-2.28.tar.xz

SOURCES_DIR=$PWD/util-linux-2.28
INSTALL_DIR=$PWD/util-linux-2.28-install
BUILD_DIR=$PWD/util-linux-2.28-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure                            \
  ADJTIME_PATH=/var/lib/hwclock/adjtime           \
  --docdir=/usr/share/doc/util-linux-2.28         \
  --disable-chfn-chsh                             \
  --disable-login                                 \
  --disable-nologin                               \
  --disable-su                                    \
  --disable-setpriv                               \
  --disable-runuser                               \
  --disable-pylibmount                            \
  --disable-static                                \
  --without-python                                \
  --without-systemd                               \
  --without-systemdsystemunitdir &&               \
  make && make DESTDIR=$INSTALL_DIR install

mkdir -pv $INSTALL_DIR/var/lib/hwclock

116. vim

wget http://www.gnuwakes.org/depot/1.0/main/sources/vim-7.4.tar.bz2

tar -xf vim-7.4.tar.bz2

wget http://www.gnuwakes.org/depot/1.0/main/sources/vim.patch
cd vim74
patch -p1 < ../vim.patch 
cd ..

SOURCES_DIR=$PWD/vim74
INSTALL_DIR=$PWD/vim74-install
BUILD_DIR=$PWD/vim74-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

rsync -a $SOURCES_DIR/ .
./configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

mkdir -vp $INSTALL_DIR/usr/share/doc
ln -sv ../vim/vim74/doc $INSTALL_DIR/usr/share/doc/vim-7.4

mkdir -v $INSTALL_DIR/etc
cat > $INSTALL_DIR/etc/vimrc << "EOF"
" Begin /etc/vimrc

set nocompatible
set backspace=2
syntax on
if (&term == "iterm") || (&term == "putty")
set background=dark
endif

" End /etc/vimrc
EOF

117. wget

wget http://www.gnuwakes.org/depot/1.0/main/sources/wget-1.16.1.tar.xz

tar -xf wget-1.16.1.tar.xz

SOURCES_DIR=$PWD/wget-1.16.1
INSTALL_DIR=$PWD/wget-1.16.1-install
BUILD_DIR=$PWD/wget-1.16.1-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr      \
                       --sysconfdir=/etc  \
                       --with-ssl=openssl && \
  make && make DESTDIR=$INSTALL_DIR install

118. which

wget https://www.gnuwakes.org/depot/1.1/main/sources/which-2.21.tar.gz

tar -xf which-2.21.tar.gz

SOURCES_DIR=$PWD/which-2.21
INSTALL_DIR=$PWD/which-2.21-install
BUILD_DIR=$PWD/which-2.21-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr \
  --sysconfdir=/etc --localstatedir=/var && \
  make && make DESTDIR=$INSTALL_DIR install

119. wkpkg

wget https://www.gnuwakes.org/depot/1.1/main/sources/wkpkg-1.1.tar.gz

tar -xf wkpkg-1.1.tar.gz

SOURCES_DIR=$PWD/wkpkg-1.1
INSTALL_DIR=$PWD/wkpkg-1.1-install
BUILD_DIR=$PWD/wkpkg-1.1-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

set -e

# don't create the /var/wkpkg folders here because of the chroot
# install that use them already (conflict). Just the bin folder.

rsync -a $SOURCES_DIR/ .

make -C wkpkg

mkdir -v $INSTALL_DIR/bin
cp -v wkpkg/wkpkg scripts/* $INSTALL_DIR/bin
mkdir -vp $INSTALL_DIR/etc/ssl/certs
cp -dv certs/* $INSTALL_DIR/etc/ssl/certs

120. xml-parser

wget http://www.gnuwakes.org/depot/1.0/main/sources/XML-Parser-2.44.tar.gz

tar -xf XML-Parser-2.44.tar.gz

SOURCES_DIR=$PWD/XML-Parser-2.44
INSTALL_DIR=$PWD/XML-Parser-2.44-install
BUILD_DIR=$PWD/XML-Parser-2.44-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

rsync -a $SOURCES_DIR/ .
perl Makefile.PL && make && make DESTDIR=$INSTALL_DIR install

121. xorg

SOURCES_DIR=$PWD/xorg
INSTALL_DIR=$PWD/xorg-install
BUILD_DIR=$PWD/xorg-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

cd $SOURCES_DIR

mkdir driver/xf86-video-amdgpu/m4
mkdir driver/xf86-video-ati/m4
rm -rf lib/libepoxy/m4/

patch -p0 < patch/libinput.patch
patch -p0 < patch/xf86-video-nested.patch
patch -p0 < patch/xf86-video-r128.patch
patch -p0 < patch/xf86-video-s3virge.patch
patch -p0 < patch/xf86-video-savage.patch
patch -p0 < patch/xf86-video-tseng.patch
patch -p0 < patch/xf86-video-v4l.patch
patch -p0 < patch/rendercheck.patch
patch -p0 < patch/xdm.patch
patch -p0 < patch/xserver.patch

export PKG_CONFIG_PATH="/usr/lib64/pkgconfig"
export LOCALSTATEDIR="/var"
export CONFFLAGS="--sysconfdir=/etc"

# build (45m48.33s)
time ./util/modular/build.sh --autoresume resume.file /usr

rm -rf /usr/share/doc/libxcb

tar -C / -T pkg.files -cf xorg.tar

cd $INSTALL_DIR
tar -xf $SOURCES_DIR/xorg.tar

122. xorriso

wget http://www.gnuwakes.org/depot/1.0/main/sources/xorriso-1.4.0.tar.gz

tar -xf xorriso-1.4.0.tar.gz

SOURCES_DIR=$PWD/xorriso-1.4.0
INSTALL_DIR=$PWD/xorriso-1.4.0-install
BUILD_DIR=$PWD/xorriso-1.4.0-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

rsync -a $SOURCES_DIR/ .
./configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

123. xterm

wget https://www.gnuwakes.org/depot/1.1/main/sources/xterm-331.tar.gz

tar -xf xterm-331.tar.gz

SOURCES_DIR=$PWD/xterm-331
INSTALL_DIR=$PWD/xterm-331-install
BUILD_DIR=$PWD/xterm-331-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

124. xz

wget http://www.gnuwakes.org/depot/1.0/main/sources/xz-5.2.0.tar.xz

tar -xf xz-5.2.0.tar.xz

SOURCES_DIR=$PWD/xz-5.2.0
INSTALL_DIR=$PWD/xz-5.2.0-install
BUILD_DIR=$PWD/xz-5.2.0-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr --docdir=/usr/share/doc/xz-5.2.0 && \
  make && make DESTDIR=$INSTALL_DIR install

mkdir -v $INSTALL_DIR/bin $INSTALL_DIR/lib
mv -v $INSTALL_DIR/usr/bin/{lzma,unlzma,lzcat,xz,unxz,xzcat} $INSTALL_DIR/bin
mv -v $INSTALL_DIR/usr/lib/liblzma.so.* $INSTALL_DIR/lib
ln -svf ../../lib/$(readlink $INSTALL_DIR/usr/lib/liblzma.so) \
  $INSTALL_DIR/usr/lib/liblzma.so

125. zlib

wget https://www.gnuwakes.org/depot/1.1/main/sources/zlib-1.2.11.tar.gz

tar -xf zlib-1.2.11.tar.gz

SOURCES_DIR=$PWD/zlib-1.2.11
INSTALL_DIR=$PWD/zlib-1.2.11-install
BUILD_DIR=$PWD/zlib-1.2.11-build

mkdir $INSTALL_DIR $BUILD_DIR
cd $BUILD_DIR

$SOURCES_DIR/configure --prefix=/usr && \
  make && make DESTDIR=$INSTALL_DIR install

Appendix A. GNU Free Documentation License

Version 1.3, 3 November 2008

Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.

Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

0. PREAMBLE

The purpose of this License is to make a manual, textbook, or other functional and useful document “free” in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.

This License is a kind of “copyleft”, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.

We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.

1. APPLICABILITY AND DEFINITIONS

This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The “Document”, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as “you”. You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.

A “Modified Version” of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.

A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document’s overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.

The “Invariant Sections” are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.

The “Cover Texts” are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.

A “Transparent” copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not “Transparent” is called “Opaque”.

Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.

The “Title Page” means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, “Title Page” means the text near the most prominent appearance of the work’s title, preceding the beginning of the body of the text.

The “publisher” means any person or entity that distributes copies of the Document to the public.

A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this definition.

The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.

2. VERBATIM COPYING

You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.

You may also lend copies, under the same conditions stated above, and you may publicly display copies.

3. COPYING IN QUANTITY

If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document’s license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.

If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.

If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.

It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.

4. MODIFICATIONS

You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:

  1. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.
  2. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement.
  3. State on the Title page the name of the publisher of the Modified Version, as the publisher.
  4. Preserve all the copyright notices of the Document.
  5. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
  6. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
  7. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document’s license notice.
  8. Include an unaltered copy of this License.
  9. Preserve the section Entitled “History”, Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled “History” in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
  10. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the “History” section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.
  11. For any section Entitled “Acknowledgements” or “Dedications”, Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.
  12. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.
  13. Delete any section Entitled “Endorsements”. Such a section may not be included in the Modified Version.
  14. Do not retitle any existing section to be Entitled “Endorsements” or to conflict in title with any Invariant Section.
  15. Preserve any Warranty Disclaimers.

If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version’s license notice. These titles must be distinct from any other section titles.

You may add a section Entitled “Endorsements”, provided it contains nothing but endorsements of your Modified Version by various parties — for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.

You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.

The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.

5. COMBINING DOCUMENTS

You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.

The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.

In the combination, you must combine any sections Entitled “History” in the various original documents, forming one section Entitled “History”; likewise combine any sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You must delete all sections Entitled “Endorsements”.

6. COLLECTIONS OF DOCUMENTS

You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.

You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.

7. AGGREGATION WITH INDEPENDENT WORKS

A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation’s users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.

If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document’s Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.

8. TRANSLATION

Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.

If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “History”, the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.

9. TERMINATION

You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License.

However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.

Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.

Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, receipt of a copy of some or all of the same material does not give you any rights to use it.

10. FUTURE REVISIONS OF THIS LICENSE

The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See Copyleft.

Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License “or any later version” applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document specifies that a proxy can decide which future versions of this License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Document.

11. RELICENSING

“Massive Multiauthor Collaboration Site” (or “MMC Site”) means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A “Massive Multiauthor Collaboration” (or “MMC”) contained in the site means any set of copyrightable works thus published on the MMC site.

“CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization.

“Incorporate” means to publish or republish a Document, in whole or in part, as part of another Document.

An MMC is “eligible for relicensing” if it is licensed under this License, and if all works that were first published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008.

The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing.

ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:

Copyright © YEAR YOUR NAME

Permission is granted to copy, distribute and/or modify this document under the
terms of the GNU Free Documentation License, Version 1.3 or any later version
published by the Free Software Foundation; with no Invariant Sections, no
Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in
the section entitled “GNU Free Documentation License”.

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the “with… Texts.” line with this:

with the Invariant Sections being LIST THEIR TITLES, with the Front-Cover Texts
being LIST, and with the Back-Cover Texts being LIST.

If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation.

If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.