Skip to content

Build Notes and Decisions for Release 0.0.8

unxmaal edited this page Jan 30, 2022 · 9 revisions

Release Goals

  • minimal bootstrap contains only the essentials required for tdnf to fetch and install packages
  • packages provided via tdnf
  • core subset of packages compiled with clang

Minimal Bootstrap

Requirements

  • IRIX chroot
  • Create a list of packages that tdnf requires
  • Build the packages
  • Install packages into chroot
  • Create a tarball of /usr/sgug from chroot after package installation
  • testing to ensure tdnf can fetch and install packages

IRIX chroot

chroot creation

# as root
cd /root
mkdir -p chroot
cd chroot

mkdir -p dev
mkdir -p usr
mkdir -p usr/sgug
rsync -av /bin .
rsync -av /dev .
rsync -av /etc .
rsync -av /lib .
rsync -av /lib32 .
rsync -av /sbin .
rsync -av /usr/bin usr/
rsync -av /usr/sbin usr/
rsync -av /usr/etc usr/.
rsync -av /usr/lib usr/.
rsync -av /usr/lib32 usr/.
rsync -av /usr/sgug/etc usr/sgug/etc/.
cd ..

tar cvzf irix_chroot.tar.gz chroot

# as non-root user
sudo tar xvzf irix_chroot.tar.gz 
# if you don't untar with sudo, it won't create the devices properly

chroot usage

Test the chroot after extracting it

# note that '/bin/csh' is absolute only within the context of the chroot
sudo chroot ./chroot /bin/csh
# run 'ls' to confirm the chroot works
ls
# run sgugshell to confirm that works
/usr/sgug/bin/sgugshell

Notes on creating devices

# you shouldn't have to do this, but note that IRIX devices have different ids than Linux ones
sudo mknod -m 666 ./chroot/dev/ptmx c 10 14
sudo mknod -m 644 ./chroot/dev/random c 39 0
sudo mknod -m 644 ./chroot/dev/urandom c 39 0
sudo mknod -m 666 ./chroot/dev/zero c 37 0
sudo mknod -m 666 ./chroot/dev/tty c 2 0

Creating the Minimal Bootstrap List

sgug-rpm-tools

I tried to use https://github.com/sgidevnet/sgug-rpm-tools but have found several deficiencies.

sgug_minimal_computer

  • The first phase uses sgug_minimal_computer to create the minimal list of packages for a release
    • this program is biased within its code to select packages for a full deploy, vs just the reqs for a tdnf-installed release
    • it does not seem to resolve all dependencies

sgug_world_builder

  • The second phase uses sgug_world_builder to generate a script 'worldrebuilder.sh' from the 'releasepackages.lst' created by sgug_minimal_computer
  • worldrebuilder.sh is extremely flawed
    • by default it warns you not to use it and exits
    • it uses many hardcoded paths
    • its first action is to rm -rf ~/rpmbuild
    • it conflates its input and output directories

Unx's current modified method

This involves a lot of hackery.

Compilertron

Thanks to Vlad's efforts, Compilertron can query sgug-rse's DNF repos.

After many experiments I've determined that while tdnf shows rpm as a requirement, it does not show all of rpm's requirements.

#run compilertron
docker-compose up -d compilertron
# exec into the container
docker exec -it compilertron bash
# get the tree for each dep
mkdir -p tmp
cd tmp
for i in bash tdnf sgugshell mksh tar unzip gzip bzip2 cpio xz libdb zstd; do sgug-dnf  repoquery --requires --tree $i > $i.txt ; done
# now copy all of these to a desktop with a good editor. you'll need it.
scp *.txt you@yourdesktop:some/path/.

Text Munging

Each of these files will contain the dependency tree rendered like this:

gzip-0:1.9-2.sgug.mips
 \_ coreutils-0:8.30-7.sgug.mips [7: libgcc_s.so.1, libc.so.1, libintl.so.8, libpthread.so, libiconv.so.2, ncurses, coreutils-common = 8.30-7.sgug]
 |   \_ coreutils-common-0:8.30-7.sgug.mips [0: ]
 |   \_ gettext-0:0.19.8.1-4.sgug.mips [17: libgcc_s.so.1, libm.so, libc.so.1, /usr/sgug/bin/sh, libpthread.so, libdicl-0.1.so.0, libglib-2.0.so.0, libiconv.so.2, libtinfo.so, libxml2.so.2, libxml2.so.2(LIBXML2_2.4.30),

In your editor, do whatever fancy find'n'replace is required to remove the ASCII tree drawings, so that each line begins with the package names.

Further munge this by cutting based on ':', and sort and uniq. I do this in one line:

cat *.txt | cut -d':' -f1 | sort -u > rollup.txt

Edit rollup.txt and remove '-0', '-1', and sometimes '-2'. Sort and uniq again.

The resulting file will have a list of packages but these will not necessarily be the same as the sgug-rse package.

For example, you might see

bzip2
bzip2-libs

Before you delete an entry, test with 'ls -la ~/sgug-rse.git/packages/| grep bzip2` and look for bzip2-libs.

In most cases there will only be 'bzip2', but it doesn't take very long to confirm.

Finally, name your munged list 'releasepackages.lst'.

Working with Git

You should create your own branch for working with sgug-rse. This should be based on the 0.0.8alpha branch.

cd ~/sgug-rse.git
git fetch -a
git checkout 0.0.8alpha
git checkout -b unx_0.0.8alpha
cp ~/path/to/my/new/releasepackages.lst ~/sgug-rse.git/.

Building the packages

We need to build fresh new packages. This ensures we have any changes and that any interdependent packages are matched to their latest versions.

Worldrebuilder

I've modified the worldrebuilder.sh script created by sgug_world_builder and modified it for safety and sanity.

https://gist.github.com/unxmaal/a0968a8a28311fdc1a229fe70b6d3495

This version shouldn't delete your ~/rpmbuild and might output to the proper locations. You'd better check for yourself.

At the very least, fix the initial path vars for your home directory.

Initial setup

mkdir -p ~/tiny_build
cd ~/tiny_build
mkdir -p output/{PROGRESS,RPMS,SRPMS}

Append the packages and SRPMs to the script

for i in $(cat ~/sgug-rse.git/releasepackages.lst) ; do _bn=$(basename $(find ~/rpmbuild/SRPMS -name $i\*.rpm|sort -u|tail -n1) ) ; echo "doPackageBuild '$i' '$_bn'" ; done > do_list.txt

Confirm this list looks relatively sane, then append it to this script.

cat do_list.txt >> worldrebuilder.sh

Run worldrebuilder

cd ~/tiny_build
# worldrebuilder will create its own ephemeral rpmbuild directory at the location you specify. 
bash -x worldrebuilder.sh /usr/people/edodd/btw/tiny_build/rpmbuild

Monitoring progress

You can watch progress by tailing the logs in ~/tiny_build/output/PROGRESS

Installing the Packages Into Chroot

Initialize the rpmdb

As your non-root user

sudo rpm --root="${_tinybuild}/chroot" --initdb

Install all of the rpms

The packages are very opinionated, and seem to have file-level dependencies that aren't listed in their specs.

I gave up trying to solve that problem and hit it real hard with the --nodeps hammer.

sudo rpm -ivh  --root=/usr/people/YOURS/tiny_build/chroot output/RPMS/noarch/*.rpm output/RPMS/mips/*.rpm --nodeps

Test the chroot again

sudo chroot ./chroot /bin/csh
# run 'ls' to confirm the chroot works
ls
# run sgugshell to confirm that works
/usr/sgug/bin/sgugshell
# test a few other sgug binaries. 
# Note that thus far, applications needing a network won't work inside a chroot. This includes tdnf.
# Also, rpm seems to segfault within a chroot.

Create the sgug-rse minimal tarball

From within the chroot

sudo chroot ./chroot /bin/csh
/usr/sgug/bin/sgugshell
cd /usr
tar cvf sgug_yourtest.tar sgug
exit

Copy the tarball to /usr/.

sudo cp ~/tiny_build/chroot/usr/sgug_yourtest.tar /usr/.

Extracting and testing the sgug-rse minimal tarball

WARNING: the next few steps can be destructive if you screw up. Don't screw up.

  • Log out of every shell or terminal on your SGI.
  • Log back in
  • su as root
  • Do NOT run any /usr/sgug binaries or shells
  • Relocate /usr/sgug, then extract sgug_yourtest.tar
cd /usr
mv sgug sgug_working
tar cvf sgug_yourtest.tar
  • Test the new deploy
# Still as root, continuing from before
/usr/sgug/bin/sgugshell
# test rpm
rpm -qa
# test tdnf
tdnf list
  • Each of these commands should work. tdnf should be able to fetch and install rpms from the dnf repos.

Compiling with clang

To compile packages with clang, uncomment the two 'export' lines in worldrebuilder.sh, rpmbuildPackage().

Porting with clang