The Expect package contains tools for automating, via scripted dialogues, interactive applications such as telnet, ftp, passwd, fsck, rlogin, and tip. Expect is also useful for testing these same applications as well as easing all sorts of tasks that are prohibitively difficult with anything else. The DejaGnu framework is written in Expect.
Expect needs PTYs to work. Verify that the PTYs are working properly inside the chroot environment by performing a simple test:
python3 -c 'from pty import spawn; spawn(["echo", "ok"])'
This command should output ok.
If, instead, the output includes OSError: out of pty devices, then the
environment is not set up for proper PTY operation. You need to
exit from the chroot environment, read Section 7.3,
“Preparing Virtual Kernel File Systems” again, and ensure the
devpts file system (and other
virtual kernel file systems) mounted correctly. Then reenter the
chroot environment following Section 7.4,
“Entering the Chroot Environment”. This issue needs to be
resolved before continuing, or the test suites requiring Expect
(for example the test suites of Bash, Binutils, GCC, GDBM, and of
course Expect itself) will fail catastrophically, and other subtle
breakages may also happen.
Create the PKGBUILD for the Expect package with the following commands:
mkdir /sources/expect
cd /sources/expect
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>
pkgname="expect"
pkgver="5.45.4"
pkgrel="2"
pkgdesc="The Expect package contains tools for automating, via scripted dialogues, interactive applications."
arch=('x86'
'x86_64')
url="https://core.tcl.tk/expect/"
license=('PD')
groups=('core')
depends=('glibc'
'tcl')
optdepends=('tk')
makedepends=('bash'
'binutils'
'coreutils'
'diffutils'
'gcc'
'grep'
'make'
'patch'
'sed')
source=('https://prdownloads.sourceforge.net/expect/expect5.45.4.tar.gz'
'https://www.linuxfromscratch.org/patches/lfs/development/expect-5.45.4-gcc14-1.patch)
md5sums=('00fce8de158422f5ccd2666512329bd2'
'0b8b5ac411d011263ad40b0664c669f0)
prepare(){
cd "${pkgname}${pkgver}"
# Allow the package with gcc-14.1 or later
patch -Np1 -i "../${pkgname}-${pkgver}-gcc14-1.patch"
}
build() {
# Remove -Werror from CFLAGS
CFLAGS=${CFLAGS/-Werror=format-security/}
cd "${pkgname}${pkgver}"
./configure --prefix=/usr \
--with-tcl=/usr/lib \
--enable-shared \
--disable-rpath \
--disable-werror \
--mandir=/usr/share/man \
--with-tclinclude=/usr/include
make
}
check() {
cd "${pkgname}${pkgver}"
make test
}
package() {
cd "${pkgname}${pkgver}"
make DESTDIR="${pkgdir}" install
ln -svf "${pkgname}${pkgver}/lib${pkgname}${pkgver}.so" "${pkgdir}/usr/lib"
}
REALEOF
The meaning of the configure options:
--with-tcl=/usr/lib
This parameter is needed to tell configure where the tclConfig.sh script is located.
--with-tclinclude=/usr/include
This explicitly tells Expect where to find Expect's internal headers.
Prepare the build directory for the pacman user and build the package:
chown -R root:pacman . chmod 2775 . chmod 664 PKGBUILD su pacman -c 'makepkg -L --nodeps'
Add the newly created package to the central package repository:
cp expect-5.45.4-2-$(uname -m).pkg.tar.xz \
/srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
/srv/pacman/repos/LFS/expect-5.45.4-2-$(uname -m).pkg.tar.xz
Update the local cache and install the Expect package:
pacman -Syu pacman -S expect --overwrite \* -dd --noconfirm
Finally, copy the source files into the source repository and clean up the build directory:
mkdir /srv/pacman/source/LFS/expect cp PKGBUILD /srv/pacman/source/LFS/expect cd /sources rm -rf expect