Home

Awesome

lfs-me

Linux from Scratch made (more) easy. A simple fakeroot based package manager for LFS, heavily inspired by Archlinux.

Description

lfs-me is a package manager that is completely written in bash. It was created in order to make installing Linux From Scratch easier and provide the author a learning experience about how package management can be done from scratch.

lfs-me can keep track of what packages and files have been installed on the system, for more information about the package index see the Index section. Although lfs-me supports inter package dependencies, it cannot automatically resolve them, only show you which dependencies are missing.

Packages are created in the form of a PKGBUILD file ( very similar to those used by Archlinux ). PKGBUILD files are bash scripts that get loaded by the package manager and contain variables and functions that describe how the software is to be downloaded, built and installed. You can create a package by copying PKGBUILD.proto. The exact process is described in the PKGBUILD section.

WARNING You should be aware that you should not under any circumstances use lfs-me in a production environment ( outside a virtual machine or chroot ) if you don't know what you are doing and how it works. This might break your system horribly if you try to install packages in there.

Package Format

The packages are simple tarballs with xz compression that contain some extra files with meta information:

Index

To keep track of what packages and what files are installed on the system, the metadata files (sha1sums, PKGBUILD etc.) get installed into the package index. The package index is a directory structure of the following form:

$install_prefix/$index_dir
├── $pkgname
│   └── $pkgver
│       ├── sha1sums
│       ├── PKGBUILD
│       ├── DIRS
│       ├── FILES
│       └── LINKS
└── version

Where $... are the respective values of the variables. The file version contains the version of the index format to prevent corruption when using an older/newer version of lfs-me.

PKGBUILD

Create a new package by copying and modifying PKGBUILD.proto. The PKGBUILD is loaded by lfs-me and then the different functions are executed.

Variables:

Predefined variables:

Those variables are provided by lfs-me and mustn't be changed in the PKGBUILD.

Functions:

If you don't include a function it falls back to its default behavior. The functions are executed in the following order:

  1. lfs_me_prepare(): Extract the source files and run configure scripts etc.
  2. lfs_me_build(): Do the actual compilation ( make ).
  3. lfs_me_check(): Run unit tests.
  4. lfs_me_install(): Install the built files into the fakeroot_dir
  5. lfs_me_preinstall(): This function is executed before a package gets installed to the system.
  6. lfs_me_postinstall(): This function is executed after a package has been installed ( into the actual filesystem ). It isn't executed when the package is created. You can use this to create users and groups or update info pages for example.
  7. lfs_me_preremove(): This function is executed before a package gets removed from the system.
  8. lfs_me_postremove(): This function is executed after a package has been removed from the system.

Dependencies:

dependencies is an array that contains all the dependencies. A dependency can be a single package name or a package name, followed by a comparator followed by a version number. Valid comparators are >, <, >=, <= and =. Those dependencies can be inversed to be conflicts by preceding them with !. Most packages should be in conflict with themselves for example, so that you can't install multiple conflicting versions in parallel.

Example: depencencies=( 'linux>=3.2' 'bash' '!tmux' #in conflict with tmux )

Command line usage

lfs-me mode file [options]

Modes

modeparameterdescription
backuplistList all backup files.
backupmergeFind all bakup files and ask how to merge them.
buildPKGBUILD-fileBuild the package specified by the PKGBUILD
checkdepsPKGBUILD-fileCheck if all dependencies are met.
checkdepspackage.pkgCheck if all dependencies are met.
checkdepspackageCheck if all dependencies are met.
checkdepspackage pkgverCheck if all dependencies are met.
rebuildpackage.pkgRebuild a package from an existing one.
rebuildpkgnameRebuild a package from an existing one.
rebuildpkgname pkgverRebuild a package from an existing one.
installpackage.pkgInstall a package to the system
removepackage.pkgRemove a package from the system and index.
removepkgname pkgverRemove a package from the system and index.
removepkgnameRemove a package from the system and index.
indexaddpackage.pkgAdd a package to the package index without installing it.
indexremovepackage.pkgRemove a package from the index without removing it from the system.
indexremovepkgname pkgverRemove a package from the index without removing it from the system.
indexremovepkgnameRemove a package from the index without removing it from the system.
indexlistList all packages in the package index.
indexlistsearchtermSearch for packages in the index.
listpackage.pkgList all files of a package.
listpkgname pkgverList all files of a package.
listpkgnameList all files of a package.
checkpackage.pkgCheck the installed files
checkpkgname pkgverCheck the installed files
checkpkgnameCheck the installed files
checksumsPKGBUILD-fileCreate checksums for downloaded source files specified in the sources array in the PKGBUILD
downloadPKGBUILD-fileDownload the source files specified in the sources array in the PKGBUILD
ownerfileList all packages that own a file.

Options

shortlongdescription
-b--build-dirSpecify build directory
-D--debugEnable debug mode
-f--fakeroot-dirSpecify fakeroot directory (see predefined variables)
-h--helpShow help output
-i--index-dirSpecify index directory
-l--log-dirSpecify log directory
--no-checksDon't run tests
--no-colorDisable color
--no-downloadsDon't download sources
--ignore-checksumsDon't check checksums
-p--prefixSpecify installation prefix
-s--sourcesSpecify directory where sources are stored
-t--show-timeShow execution time at the end.
--no-timeDon't show execution time at the end.
--no-cert-checkDon't check SSL certificates.
--no-logsDon't log output. (needed for menus during build)
--versionShow version number.

Configuration file

You can create the configuration file ~/.lfs-me to set default values for variables used by lfs-me. You can use the following variables:

Example:

sources_dir=~/src
install_prefix=~/local/
index_dir=/var/lfs-me/index
show_color=false

In this case, the index is stored in ~/local/var/lfs-me/index

Typical scenario

Here is a typical scenario on how to create, build and install a package with lfs-me.

  1. Create the PKGBUILD from PKGBUILD.proto and save it as foo-0.1.1
  2. Download the source files into ~/downloads: lfs-me download foo-0.1.1 -s ~/downloads
  3. Calculate the checksums for the downloaded sources: lfs-me checksums foo-0.1.1 -s ~/downloads
  4. Edit the PKGBUILD to include the checksums.
  5. Build the package: lfs-me build foo-0.1.1 -s ~/downloads
  6. Install the package into /mnt/lfs for example ( you can omit the prefix to install to /): sudo lfs-me install foo-0.1.1.pkg -p /mnt/lfs
  7. Check the installed files: lfs-me check foo 0.1.1 -p /mnt/lfs

lfs-me in action

To see lfs-me in action take a look at my collection of packages at https://github.com/FSMaxB/lfs-me-repos .