├── .gitattributes ├── .gitignore ├── .pylintrc ├── AUTHORS ├── COPYING ├── MANIFEST.in ├── Makefile ├── README ├── arch ├── alpha.toml ├── amd64.toml ├── arm.toml ├── arm64.toml ├── hppa.toml ├── ia64.toml ├── loong.toml ├── m68k.toml ├── mips.toml ├── ppc.toml ├── riscv.toml ├── s390.toml ├── sh.toml ├── sparc.toml └── x86.toml ├── bin ├── catalyst ├── catalyst.git └── pylint ├── catalyst ├── __init__.py ├── base │ ├── __init__.py │ ├── clearbase.py │ ├── genbase.py │ ├── resume.py │ ├── stagebase.py │ └── targetbase.py ├── config.py ├── context.py ├── defaults.py ├── fileops.py ├── log.py ├── main.py ├── support.py ├── targets │ ├── __init__.py │ ├── diskimage_stage1.py │ ├── diskimage_stage2.py │ ├── embedded.py │ ├── livecd_stage1.py │ ├── livecd_stage2.py │ ├── netboot.py │ ├── snapshot.py │ ├── stage1.py │ ├── stage2.py │ ├── stage3.py │ └── stage4.py └── version.py ├── diskimage └── files │ └── .keep ├── doc ├── .gitignore ├── HOWTO.txt ├── asciidoc.conf ├── catalyst-config.5.txt ├── catalyst-spec.5.txt ├── catalyst.1.txt ├── make_subarch_table_guidexml.py └── make_target_table.py ├── etc ├── catalyst.conf └── catalystrc ├── examples ├── README ├── fsscript.sh.example ├── generic_stage_template.spec ├── livecd-stage1_template.spec ├── livecd-stage2_template.spec ├── netboot_template.spec ├── snapshot_template.spec └── stage4_template.spec ├── files └── .gitignore ├── livecd ├── cdtar │ ├── aboot-1.0_pre20040408-r2-cdtar.tar.bz2 │ ├── arcload-0.43-r1.tbz2 │ └── isolinux-elilo-memtest86+-cdtar.tar.bz2 └── files │ ├── README.txt │ ├── generic.motd.txt │ ├── livecd-bash_profile │ ├── livecd-bashrc │ ├── livecd-local.start │ ├── livecd.motd.txt │ └── minimal.motd.txt ├── setup.py ├── targets ├── diskimage-stage1 │ ├── chroot.sh │ ├── controller.sh │ └── preclean-chroot.sh ├── diskimage-stage2 │ └── controller.sh ├── embedded │ ├── chroot.sh │ ├── controller.sh │ ├── fs-runscript.sh │ ├── preclean-chroot.sh │ └── unmerge.sh ├── livecd-stage1 │ ├── chroot.sh │ ├── controller.sh │ └── preclean-chroot.sh ├── livecd-stage2 │ └── controller.sh ├── netboot │ ├── controller.sh │ ├── copyfile.sh │ ├── nb-busybox.cf │ └── pkg.sh ├── stage1 │ ├── build.py │ ├── chroot.sh │ ├── controller.sh │ └── preclean-chroot.sh ├── stage2 │ ├── chroot.sh │ ├── controller.sh │ └── preclean-chroot.sh ├── stage3 │ ├── chroot.sh │ ├── controller.sh │ └── preclean-chroot.sh ├── stage4 │ ├── chroot.sh │ ├── controller.sh │ └── preclean-chroot.sh └── support │ ├── chroot-functions.sh │ ├── create-iso.sh │ ├── create-qcow2.sh │ ├── depclean.sh │ ├── diskimagefs-update.sh │ ├── functions.sh │ ├── iso-bootloader-setup.sh │ ├── kmerge.sh │ ├── livecdfs-update.sh │ ├── mips-arcload_conf.sh │ ├── netboot-final.sh │ ├── pre-distkmerge.sh │ ├── pre-kmerge.sh │ ├── qcow2-grub-install.sh │ ├── rc-update.sh │ ├── target_image_setup.sh │ └── unmerge.sh └── testpath /.gitattributes: -------------------------------------------------------------------------------- 1 | AUTHORS ident 2 | ChangeLog ident 3 | README ident 4 | catalyst ident 5 | *.py ident 6 | *.sh ident 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[co] 2 | 3 | /build/ 4 | /dist/ 5 | /files/ 6 | /MANIFEST 7 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | The copyright for catalyst is held by the Gentoo Foundation and by each 2 | of the individual contributors. 3 | 4 | 5 | Original Authors: 6 | ----------------- 7 | John Davis 8 | Daniel Robbins 9 | 10 | 11 | Significant contributors (including the first catalyst3 rewrite): 12 | ----------------------------------------------------------------- 13 | Andrew Gaffney 14 | Chris Gianelloni 15 | 16 | 17 | Contributors: 18 | ------------- 19 | Eric Edgar 20 | Andrew Gaffney 21 | Chris Gianelloni 22 | David Bryson 23 | Mike Frysinger 24 | Rob Holland 25 | Robin H. Johnson 26 | Joshua Kinard 27 | Stuart Longland 28 | Guy Martin 29 | Daniel Ostrow 30 | Robert Paskowitz 31 | Diego Pettenò 32 | Matsuu Takuto 33 | Lars Weiler 34 | Gustavo Zacarias 35 | Raúl Porcel 36 | Jorge Manuel B. S. Vicetto 37 | W. Trevor King 38 | Matt Turner 39 | Anthony G. Basile 40 | Ben Kohler 41 | Brian Dolbec 42 | Douglas Freed 43 | Dylan Baker 44 | Jeremy Olexa 45 | Kevin Zhao 46 | Rick Farina (Zero_Chaos) 47 | Sebastian Pipping 48 | Yuta SATOH 49 | William Hubbs 50 | 51 | Maintainers: 52 | ------------ 53 | Catalyst maintainers 54 | Release Engineering 55 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS 2 | include ChangeLog 3 | include COPYING 4 | include Makefile 5 | recursive-include doc *.conf *.py HOWTO.txt catalyst*.txt 6 | recursive-include examples README *.example *.spec 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011 Sebastian Pipping 2 | # Licensed under GPL v2 or later 3 | 4 | PACKAGE_VERSION = $(shell PYTHONPATH=. python -c 'import catalyst; print(catalyst.__version__)') 5 | MAN_PAGE_SOURCES = $(wildcard doc/*.?.txt) 6 | MAN_PAGES = $(patsubst doc/%.txt,files/%,$(MAN_PAGE_SOURCES)) 7 | MAN_PAGE_INCLUDES = doc/subarches.generated.txt doc/targets.generated.txt 8 | DOC_SOURCES = $(filter-out $(MAN_PAGE_SOURCES) $(MAN_PAGE_INCLUDES),$(wildcard doc/*.txt)) 9 | DOCS = $(patsubst doc/%.txt,files/%.html,$(DOC_SOURCES)) 10 | DOC_SIDE_EFFECTS = files/docbook-xsl.css doc/subarches.generated.xml 11 | EXTRA_DIST = $(MAN_PAGES) $(DOCS) $(DOC_SIDE_EFFECTS) 12 | GENERATED_FILES = $(MAN_PAGES) $(MAN_PAGE_INCLUDES) $(DOCS) $(DOC_SIDE_EFFECTS) 13 | 14 | distdir = catalyst-$(PACKAGE_VERSION) 15 | 16 | 17 | all: $(EXTRA_DIST) 18 | 19 | files: 20 | mkdir files 21 | 22 | $(MAN_PAGES): files/%: doc/%.txt doc/asciidoc.conf Makefile catalyst | files 23 | a2x --conf-file=doc/asciidoc.conf --attribute="catalystversion=$(PACKAGE_VERSION)" \ 24 | --format=manpage -D files "$<" 25 | 26 | # Additional dependencies due to inclusion 27 | files/catalyst.1: doc/subarches.generated.txt | files 28 | files/catalyst-spec.5: doc/subarches.generated.txt doc/targets.generated.txt | files 29 | 30 | doc/subarches.generated.txt doc/subarches.generated.xml: $(wildcard arch/*.toml) doc/make_subarch_table_guidexml.py 31 | ./doc/make_subarch_table_guidexml.py 32 | 33 | doc/targets.generated.txt: doc/make_target_table.py $(wildcard catalyst/targets/*.py) 34 | PYTHONPATH=. "./$<" > "$@" 35 | 36 | $(DOCS): files/%.html: doc/%.txt doc/asciidoc.conf Makefile | files 37 | a2x --conf-file=doc/asciidoc.conf --attribute="catalystversion=$(PACKAGE_VERSION)" \ 38 | --format=xhtml -D files "$<" 39 | 40 | $(DOC_SIDE_EFFECTS): $(firstword $(DOCS)) 41 | 42 | clean: 43 | rm -f $(GENERATED_FILES) 44 | find -name '*.pyo' -delete 45 | 46 | check-git-repository: 47 | git diff --quiet || { echo 'STOP, you have uncommitted changes in the working directory' ; false ; } 48 | git diff --cached --quiet || { echo 'STOP, you have uncommitted changes in the index' ; false ; } 49 | 50 | dist: check-git-repository $(EXTRA_DIST) 51 | rm -Rf "$(distdir)" "$(distdir)".tar "$(distdir)".tar.bz2 52 | mkdir "$(distdir)" 53 | git ls-files -z | xargs -0 cp --no-dereference --parents --target-directory="$(distdir)" \ 54 | $(EXTRA_DIST) 55 | tar cf "$(distdir)".tar "$(distdir)" 56 | bzip2 -9v "$(distdir)".tar 57 | rm -Rf "$(distdir)" 58 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Licensing 2 | ======================== 3 | 4 | Originally, Catalyst was copyrighted by the Gentoo Foundation, Inc. and was 5 | released under the terms of the GNU General Public License v.2.1. Since this 6 | is a fork of that project, all new code is no longer copyrighted to the Gentoo 7 | Foundation. Currently, copyright is held by the individual authors for their 8 | contributions. For more information, please consult COPYING. 9 | 10 | Disclaimer 11 | ======================== 12 | 13 | This software is covered by no warranty or guarantee of functionality. It is 14 | provided to the public for use in creating source-based distributions in a 15 | simple and reproducable manner. Use at your own risk. 16 | 17 | Requirements 18 | ======================= 19 | 20 | - Python 3.8 or greater 21 | - A generic stage3 tarball for your architecture 22 | - A squashfs ebuild repository snapshot 23 | - Or an ebuild git repo with sys-fs/squashfs-tools-ng and dev-vcs/git 24 | 25 | What is catalyst? 26 | ======================== 27 | 28 | Catalyst is a release building tool, used by Gentoo Linux. With catalyst, 29 | you are able to completely customize your Gentoo install by customizing 30 | the very tools that are used to install a system. Official Gentoo Linux release 31 | media is built with catalyst. 32 | 33 | Catalyst is capable of: 34 | 35 | - Building installation stages 36 | - Building bootable LiveCDs 37 | - Building netboot images 38 | 39 | Configuring catalyst 40 | ======================== 41 | 42 | After emerging/installing catalyst, the first (and probably only) thing 43 | that you will have to do is edit /etc/catalyst/catalyst.conf to your liking. 44 | 45 | If you are not using an ebuild for the installation, you should create a 46 | /etc/catalyst directory, and copy catalyst.conf and catalystrc from the 47 | distribution tarball's files directory. 48 | 49 | Example catalyst.conf: 50 | 51 | distdir="/var/cache/distfiles" 52 | options="pkgcache kerncache" 53 | sharedir="/usr/share/catalyst" 54 | 55 | There are many more options that can be set, but those defaults are good 56 | for out of the box operation. For more documentation on what you can do 57 | with catalyst, please check the man page or the online documentation at: 58 | https://wiki.gentoo.org/wiki/Catalyst 59 | 60 | Bugs 61 | ======================== 62 | 63 | If you have questions or wish to help with development, contact the 64 | gentoo-catalyst@lists.gentoo.org mailing list. Bug reports should be 65 | filed at http://tinyurl.com/79slrk (https://bugs.gentoo.org) under the 66 | "Catalyst" component of the "Gentoo Hosted Projects" product. 67 | -------------------------------------------------------------------------------- /arch/alpha.toml: -------------------------------------------------------------------------------- 1 | [alpha.alpha] 2 | COMMON_FLAGS = "-mieee -pipe -O2 -mcpu=ev4" 3 | CHOST = "alpha-unknown-linux-gnu" 4 | 5 | [alpha.ev4] 6 | COMMON_FLAGS = "-mieee -pipe -O2 -mcpu=ev4" 7 | CHOST = "alpha-unknown-linux-gnu" 8 | 9 | [alpha.ev45] 10 | COMMON_FLAGS = "-mieee -pipe -O2 -mcpu=ev45" 11 | CHOST = "alpha-unknown-linux-gnu" 12 | 13 | [alpha.ev5] 14 | COMMON_FLAGS = "-mieee -pipe -O2 -mcpu=ev5" 15 | CHOST = "alpha-unknown-linux-gnu" 16 | 17 | [alpha.ev56] 18 | COMMON_FLAGS = "-mieee -pipe -O2 -mcpu=ev56" 19 | CHOST = "alpha-unknown-linux-gnu" 20 | 21 | [alpha.pca56] 22 | COMMON_FLAGS = "-mieee -pipe -O2 -mcpu=pca56" 23 | CHOST = "alpha-unknown-linux-gnu" 24 | 25 | [alpha.ev6] 26 | COMMON_FLAGS = "-mieee -pipe -O2 -mcpu=ev6" 27 | CHOST = "alpha-unknown-linux-gnu" 28 | 29 | [alpha.ev67] 30 | COMMON_FLAGS = "-mieee -pipe -O2 -mcpu=ev67" 31 | CHOST = "alpha-unknown-linux-gnu" 32 | 33 | -------------------------------------------------------------------------------- /arch/amd64.toml: -------------------------------------------------------------------------------- 1 | [amd64.amd64] 2 | COMMON_FLAGS = "-O2 -pipe" 3 | 4 | [amd64.x86_64] 5 | COMMON_FLAGS = "-O2 -pipe" 6 | 7 | [amd64.k8] 8 | COMMON_FLAGS = "-O2 -march=k8 -pipe" 9 | CPU_FLAGS_X86 = [ "mmx", "mmxext", "3dnow", "3dnowext", "sse", "sse2",] 10 | 11 | [amd64.nocona] 12 | COMMON_FLAGS = "-O2 -march=nocona -pipe" 13 | CPU_FLAGS_X86 = [ "mmx", "mmxext", "sse", "sse2", "sse3",] 14 | 15 | [amd64.core2] 16 | COMMON_FLAGS = "-O2 -march=core2 -pipe" 17 | CPU_FLAGS_X86 = [ "mmx", "mmxext", "sse", "sse2", "sse3", "ssse3",] 18 | 19 | [amd64.k8-sse3] 20 | COMMON_FLAGS = "-O2 -march=k8-sse3 -pipe" 21 | CPU_FLAGS_X86 = [ "mmx", "mmxext", "3dnow", "3dnowext", "sse", "sse2", "sse3",] 22 | 23 | [amd64.amdfam10] 24 | COMMON_FLAGS = "-O2 -march=amdfam10 -pipe" 25 | CPU_FLAGS_X86 = [ "mmx", "mmxext", "3dnow", "3dnowext", "sse", "sse2", "sse3", "sse4a",] 26 | 27 | [amd64.x32] 28 | COMMON_FLAGS = "-O2 -pipe" 29 | 30 | -------------------------------------------------------------------------------- /arch/arm.toml: -------------------------------------------------------------------------------- 1 | [arm.arm] 2 | COMMON_FLAGS = "-O2 -pipe" 3 | CHOST = "arm-unknown-linux-gnu" 4 | 5 | [arm.armv4l] 6 | COMMON_FLAGS = "-O2 -pipe -march=armv4" 7 | CHOST = "armv4l-unknown-linux-gnu" 8 | 9 | [arm.armv4tl] 10 | COMMON_FLAGS = "-O2 -pipe -march=armv4t" 11 | CHOST = "armv4tl-softfloat-linux-gnueabi" 12 | 13 | [arm.armv5tl] 14 | COMMON_FLAGS = "-O2 -pipe -march=armv5t" 15 | CHOST = "armv5tl-softfloat-linux-gnueabi" 16 | 17 | [arm.armv5tel] 18 | COMMON_FLAGS = "-O2 -pipe -march=armv5te" 19 | CHOST = "armv5tel-softfloat-linux-gnueabi" 20 | 21 | [arm.armv5tejl] 22 | COMMON_FLAGS = "-O2 -pipe -march=armv5te" 23 | CHOST = "armv5tejl-softfloat-linux-gnueabi" 24 | 25 | [arm.armv6j] 26 | COMMON_FLAGS = "-O2 -pipe -march=armv6j -mfpu=vfp -mfloat-abi=softfp" 27 | CHOST = "armv6j-softfp-linux-gnueabi" 28 | 29 | [arm.armv6z] 30 | COMMON_FLAGS = "-O2 -pipe -march=armv6z -mfpu=vfp -mfloat-abi=softfp" 31 | CHOST = "armv6z-softfp-linux-gnueabi" 32 | 33 | [arm.armv6zk] 34 | COMMON_FLAGS = "-O2 -pipe -march=armv6zk -mfpu=vfp -mfloat-abi=softfp" 35 | CHOST = "armv6zk-softfp-linux-gnueabi" 36 | 37 | [arm.armv7a] 38 | COMMON_FLAGS = "-O2 -pipe -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp" 39 | CHOST = "armv7a-softfp-linux-gnueabi" 40 | 41 | [arm.armv6j_hardfp] 42 | COMMON_FLAGS = "-O2 -pipe -march=armv6j -mfpu=vfp -mfloat-abi=hard" 43 | CHOST = "armv6j-unknown-linux-gnueabihf" 44 | 45 | [arm.armv6j_hardfp_musl] 46 | COMMON_FLAGS = "-O2 -pipe -march=armv6j -mfpu=vfp -mfloat-abi=hard" 47 | CHOST = "armv6j-unknown-linux-musleabihf" 48 | 49 | [arm.armv7a_hardfp] 50 | COMMON_FLAGS = "-O2 -pipe -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard" 51 | CHOST = "armv7a-unknown-linux-gnueabihf" 52 | 53 | [arm.armv7a_hardfp_musl] 54 | COMMON_FLAGS = "-O2 -pipe -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard" 55 | CHOST = "armv7a-unknown-linux-musleabihf" 56 | 57 | [arm.armeb] 58 | COMMON_FLAGS = "-O2 -pipe" 59 | CHOST = "armeb-unknown-linux-gnu" 60 | 61 | [arm.armv5teb] 62 | COMMON_FLAGS = "-O2 -pipe -mcpu=xscale" 63 | CHOST = "armv5teb-softfloat-linux-gnueabi" 64 | 65 | -------------------------------------------------------------------------------- /arch/arm64.toml: -------------------------------------------------------------------------------- 1 | [arm64.arm64] 2 | COMMON_FLAGS = "-O2 -pipe" 3 | CHOST = "aarch64-unknown-linux-gnu" 4 | 5 | [arm64.aarch64] 6 | COMMON_FLAGS = "-O2 -pipe" 7 | CHOST = "aarch64-unknown-linux-gnu" 8 | 9 | [arm64.aarch64_be] 10 | COMMON_FLAGS = "-O2 -pipe" 11 | CHOST = "aarch64_be-unknown-linux-gnu" 12 | -------------------------------------------------------------------------------- /arch/hppa.toml: -------------------------------------------------------------------------------- 1 | [hppa."hppa1.1"] 2 | COMMON_FLAGS = "-O2 -pipe -march=1.1" 3 | CHOST = "hppa1.1-unknown-linux-gnu" 4 | 5 | [hppa."hppa2.0"] 6 | COMMON_FLAGS = "-O2 -pipe -march=2.0" 7 | CHOST = "hppa2.0-unknown-linux-gnu" 8 | 9 | -------------------------------------------------------------------------------- /arch/ia64.toml: -------------------------------------------------------------------------------- 1 | [ia64.ia64] 2 | COMMON_FLAGS = "-O2 -pipe" 3 | CHOST = "ia64-unknown-linux-gnu" 4 | 5 | -------------------------------------------------------------------------------- /arch/loong.toml: -------------------------------------------------------------------------------- 1 | [loong.loong] 2 | COMMON_FLAGS = " -pipe -O2 -march=loongarch64 " 3 | CHOST = "loongarch64-unknown-linux-gnu" 4 | 5 | -------------------------------------------------------------------------------- /arch/m68k.toml: -------------------------------------------------------------------------------- 1 | [m68k.m68k] 2 | COMMON_FLAGS = " -pipe -O2" 3 | CHOST = "m68k-unknown-linux-gnu" 4 | 5 | [m68k.m68k_a32] 6 | COMMON_FLAGS = " -pipe -O2 -malign-int" 7 | 8 | [m68k.m68k_musl] 9 | COMMON_FLAGS = " -pipe -O2" 10 | -------------------------------------------------------------------------------- /arch/ppc.toml: -------------------------------------------------------------------------------- 1 | [setarch.ppc] 2 | arch = "linux32" 3 | if_build = "ppc64" 4 | 5 | [ppc64.970] 6 | COMMON_FLAGS = "-O2 -pipe -mcpu=970 -mtune=970" 7 | CHOST = "powerpc64-unknown-linux-gnu" 8 | USE = [ "altivec",] 9 | 10 | [ppc64.cell] 11 | COMMON_FLAGS = "-O2 -pipe -mcpu=cell -mtune=cell" 12 | CHOST = "powerpc64-unknown-linux-gnu" 13 | USE = [ "altivec", "ibm",] 14 | 15 | [ppc64.power5] 16 | COMMON_FLAGS = "-O2 -pipe -mcpu=power5 -mtune=power5" 17 | CHOST = "powerpc64-unknown-linux-gnu" 18 | USE = [ "ibm",] 19 | 20 | [ppc64.power6] 21 | COMMON_FLAGS = "-O2 -pipe -mcpu=power6 -mtune=power6" 22 | CHOST = "powerpc64-unknown-linux-gnu" 23 | USE = [ "altivec", "ibm",] 24 | 25 | [ppc64.power7] 26 | COMMON_FLAGS = "-O2 -pipe -mcpu=power7 -mtune=power7" 27 | CHOST = "powerpc64-unknown-linux-gnu" 28 | USE = [ "altivec", "ibm",] 29 | 30 | [ppc64.power7le] 31 | COMMON_FLAGS = "-O2 -pipe -mcpu=power7 -mtune=power7" 32 | CHOST = "powerpc64le-unknown-linux-gnu" 33 | USE = [ "altivec", "ibm",] 34 | 35 | [ppc64.power8] 36 | COMMON_FLAGS = "-O2 -pipe -mcpu=power8 -mtune=power8" 37 | CHOST = "powerpc64-unknown-linux-gnu" 38 | USE = [ "altivec", "ibm",] 39 | 40 | [ppc64.power8le] 41 | COMMON_FLAGS = "-O2 -pipe -mcpu=power8 -mtune=power8" 42 | CHOST = "powerpc64le-unknown-linux-gnu" 43 | USE = [ "altivec", "ibm",] 44 | 45 | [ppc64.power9] 46 | COMMON_FLAGS = "-O2 -pipe -mcpu=power9 -mtune=power9" 47 | CHOST = "powerpc64-unknown-linux-gnu" 48 | USE = [ "altivec", "ibm",] 49 | 50 | [ppc64.power9le] 51 | COMMON_FLAGS = "-O2 -pipe -mcpu=power9 -mtune=power9" 52 | CHOST = "powerpc64le-unknown-linux-gnu" 53 | USE = [ "altivec", "ibm",] 54 | 55 | [ppc64.ppc64] 56 | COMMON_FLAGS = "-O2 -pipe" 57 | CHOST = "powerpc64-unknown-linux-gnu" 58 | 59 | [ppc64.powerpc64] 60 | COMMON_FLAGS = "-O2 -pipe" 61 | CHOST = "powerpc64-unknown-linux-gnu" 62 | 63 | [ppc64.ppc64le] 64 | COMMON_FLAGS = "-O2 -pipe" 65 | CHOST = "powerpc64le-unknown-linux-gnu" 66 | 67 | [ppc64.powerpc64le] 68 | COMMON_FLAGS = "-O2 -pipe" 69 | CHOST = "powerpc64le-unknown-linux-gnu" 70 | 71 | [ppc.g3] 72 | CHOST = "powerpc-unknown-linux-gnu" 73 | COMMON_FLAGS = "-O2 -mcpu=G3 -mtune=G3 -pipe" 74 | 75 | [ppc.g4] 76 | CHOST = "powerpc-unknown-linux-gnu" 77 | COMMON_FLAGS = "-O2 -mcpu=G4 -mtune=G4 -maltivec -mabi=altivec -pipe" 78 | USE = [ "altivec",] 79 | 80 | [ppc.g5] 81 | CHOST = "powerpc-unknown-linux-gnu" 82 | COMMON_FLAGS = "-O2 -mcpu=G5 -mtune=G5 -maltivec -mabi=altivec -pipe" 83 | USE = [ "altivec",] 84 | 85 | [ppc.ppc] 86 | CHOST = "powerpc-unknown-linux-gnu" 87 | COMMON_FLAGS = "-O2 -mcpu=powerpc -mtune=powerpc -pipe" 88 | 89 | [ppc.powerpc] 90 | CHOST = "powerpc-unknown-linux-gnu" 91 | COMMON_FLAGS = "-O2 -mcpu=powerpc -mtune=powerpc -pipe" 92 | -------------------------------------------------------------------------------- /arch/riscv.toml: -------------------------------------------------------------------------------- 1 | [riscv.riscv] 2 | COMMON_FLAGS = "-O2 -pipe" 3 | CHOST = "riscv64-unknown-linux-gnu" 4 | 5 | [riscv.rv64_multilib] 6 | COMMON_FLAGS = "-O2 -pipe" 7 | CHOST = "riscv64-unknown-linux-gnu" 8 | 9 | [riscv.rv64_lp64d] 10 | COMMON_FLAGS = "-O2 -pipe" 11 | CHOST = "riscv64-unknown-linux-gnu" 12 | 13 | [riscv.rv64_lp64d_musl] 14 | COMMON_FLAGS = "-O2 -pipe" 15 | CHOST = "riscv64-gentoo-linux-musl" 16 | 17 | [riscv.rv64_lp64] 18 | COMMON_FLAGS = "-O2 -pipe" 19 | CHOST = "riscv64-unknown-linux-gnu" 20 | 21 | [riscv.rv64_lp64_musl] 22 | COMMON_FLAGS = "-O2 -pipe" 23 | CHOST = "riscv64-gentoo-linux-musl" 24 | 25 | [riscv.rv32_ilp32d] 26 | COMMON_FLAGS = "-O2 -pipe" 27 | CHOST = "riscv32-unknown-linux-gnu" 28 | 29 | [riscv.rv32_ilp32d_musl] 30 | COMMON_FLAGS = "-O2 -pipe" 31 | CHOST = "riscv32-unknown-linux-musl" 32 | 33 | [riscv.rv32_ilp32] 34 | COMMON_FLAGS = "-O2 -pipe" 35 | CHOST = "riscv32-unknown-linux-gnu" 36 | 37 | [riscv.rv32_ilp32_musl] 38 | COMMON_FLAGS = "-O2 -pipe" 39 | CHOST = "riscv32-unknown-linux-musl" 40 | -------------------------------------------------------------------------------- /arch/s390.toml: -------------------------------------------------------------------------------- 1 | [setarch.s390] 2 | arch = "s390" 3 | if_build = "s390x" 4 | 5 | [s390.s390] 6 | COMMON_FLAGS = "-O2 -pipe" 7 | CHOST = "s390-ibm-linux-gnu" 8 | 9 | [s390x.s390x] 10 | COMMON_FLAGS = "-O2 -pipe -march=z10" 11 | 12 | -------------------------------------------------------------------------------- /arch/sh.toml: -------------------------------------------------------------------------------- 1 | [sh.sh] 2 | COMMON_FLAGS = "-O2 -pipe" 3 | CHOST = "sh-unknown-linux-gnu" 4 | 5 | [sh.sh2] 6 | COMMON_FLAGS = "-O2 -m2 -pipe" 7 | CHOST = "sh2-unknown-linux-gnu" 8 | 9 | [sh.sh2a] 10 | COMMON_FLAGS = "-O2 -m2a -pipe" 11 | CHOST = "sh2a-unknown-linux-gnu" 12 | 13 | [sh.sh3] 14 | COMMON_FLAGS = "-O2 -m3 -pipe" 15 | CHOST = "sh3-unknown-linux-gnu" 16 | 17 | [sh.sh4] 18 | COMMON_FLAGS = "-O2 -m4 -pipe" 19 | CHOST = "sh4-unknown-linux-gnu" 20 | 21 | [sh.sh4a] 22 | COMMON_FLAGS = "-O2 -m4a -pipe" 23 | CHOST = "sh4a-unknown-linux-gnu" 24 | 25 | [sh.sheb] 26 | COMMON_FLAGS = "-O2 -pipe" 27 | CHOST = "sheb-unknown-linux-gnu" 28 | 29 | [sh.sh2eb] 30 | COMMON_FLAGS = "-O2 -m2 -pipe" 31 | CHOST = "sh2eb-unknown-linux-gnu" 32 | 33 | [sh.sh2aeb] 34 | COMMON_FLAGS = "-O2 -m2a -pipe" 35 | CHOST = "sh2aeb-unknown-linux-gnu" 36 | 37 | [sh.sh3eb] 38 | COMMON_FLAGS = "-O2 -m3 -pipe" 39 | CHOST = "sh3eb-unknown-linux-gnu" 40 | 41 | [sh.sh4eb] 42 | COMMON_FLAGS = "-O2 -m4 -pipe" 43 | CHOST = "sh4eb-unknown-linux-gnu" 44 | 45 | [sh.sh4aeb] 46 | COMMON_FLAGS = "-O2 -m4a -pipe" 47 | CHOST = "sh4aeb-unknown-linux-gnu" 48 | 49 | -------------------------------------------------------------------------------- /arch/sparc.toml: -------------------------------------------------------------------------------- 1 | [setarch.sparc] 2 | arch = "linux32" 3 | if_build = "sparc64" 4 | 5 | [sparc.sparc] 6 | COMMON_FLAGS = "-O2 -mcpu=ultrasparc -pipe" 7 | CHOST = "sparc-unknown-linux-gnu" 8 | 9 | [sparc64.sparc64] 10 | COMMON_FLAGS = "-O2 -mcpu=ultrasparc -pipe" 11 | CHOST = "sparc64-unknown-linux-gnu" 12 | 13 | -------------------------------------------------------------------------------- /arch/x86.toml: -------------------------------------------------------------------------------- 1 | [setarch.x86] 2 | arch = "linux32" 3 | if_build = "x86_64" 4 | 5 | [x86.x86] 6 | 7 | [x86.i486] 8 | COMMON_FLAGS = "-O2 -march=i486 -pipe" 9 | CHOST = "i486-pc-linux-gnu" 10 | 11 | [x86.i586] 12 | COMMON_FLAGS = "-O2 -march=i586 -pipe" 13 | CHOST = "i586-pc-linux-gnu" 14 | 15 | [x86.i686] 16 | COMMON_FLAGS = "-O2 -march=i686 -pipe" 17 | 18 | [x86.pentium] 19 | COMMON_FLAGS = "-O2 -march=i586 -pipe" 20 | CHOST = "i586-pc-linux-gnu" 21 | 22 | [x86.pentium2] 23 | COMMON_FLAGS = "-O2 -march=pentium2 -pipe" 24 | CPU_FLAGS_X86 = [ "mmx",] 25 | 26 | [x86.pentium3] 27 | COMMON_FLAGS = "-O2 -march=pentium3 -pipe" 28 | CPU_FLAGS_X86 = [ "mmx", "mmxext", "sse",] 29 | 30 | [x86.pentiumpro] 31 | COMMON_FLAGS = "-O2 -march=i686 -pipe" 32 | 33 | [x86.pentium-mmx] 34 | COMMON_FLAGS = "-O2 -march=pentium-mmx -pipe" 35 | CPU_FLAGS_X86 = [ "mmx",] 36 | 37 | [x86.k6] 38 | COMMON_FLAGS = "-O2 -march=k6 -pipe" 39 | CPU_FLAGS_X86 = [ "mmx",] 40 | 41 | [x86.k6-2] 42 | COMMON_FLAGS = "-O2 -march=k6-2 -pipe" 43 | CPU_FLAGS_X86 = [ "mmx", "3dnow",] 44 | 45 | [x86.athlon] 46 | COMMON_FLAGS = "-O2 -march=athlon -pipe" 47 | CPU_FLAGS_X86 = [ "mmx", "mmxext", "3dnow", "3dnowext",] 48 | 49 | [x86.athlon-xp] 50 | COMMON_FLAGS = "-O2 -march=athlon-xp -pipe" 51 | CPU_FLAGS_X86 = [ "mmx", "mmxext", "3dnow", "3dnowext", "sse",] 52 | 53 | [x86.i686-ssemath] 54 | COMMON_FLAGS = "-O2 -march=i686 -msse2 -mfpmath=sse -pipe" 55 | CPU_FLAGS_X86 = [ "mmx", "mmxext", "sse", "sse2",] 56 | -------------------------------------------------------------------------------- /bin/catalyst: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 -OO 2 | 3 | import sys 4 | 5 | # This block ensures that ^C interrupts are handled quietly. 6 | try: 7 | import signal 8 | 9 | def exithandler(_signum, _frame): 10 | signal.signal(signal.SIGINT, signal.SIG_IGN) 11 | signal.signal(signal.SIGTERM, signal.SIG_IGN) 12 | print() 13 | sys.exit(1) 14 | 15 | signal.signal(signal.SIGINT, exithandler) 16 | signal.signal(signal.SIGTERM, exithandler) 17 | signal.signal(signal.SIGPIPE, signal.SIG_DFL) 18 | 19 | except KeyboardInterrupt: 20 | print() 21 | sys.exit(1) 22 | 23 | 24 | from catalyst.main import main 25 | 26 | try: 27 | main(sys.argv[1:]) 28 | except KeyboardInterrupt: 29 | print("Aborted.") 30 | sys.exit(130) 31 | sys.exit(0) 32 | -------------------------------------------------------------------------------- /bin/catalyst.git: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # -*- coding: utf-8 -*- 3 | # Copyright 1999-2015 Gentoo Foundation 4 | # Distributed under the terms of the GNU General Public License v2 5 | 6 | """Run catalyst from git using local modules/scripts.""" 7 | 8 | import os 9 | import sys 10 | import tempfile 11 | 12 | from snakeoil import process 13 | 14 | 15 | def main(argv): 16 | """The main entry point""" 17 | source_root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) 18 | 19 | pympath = source_root 20 | pythonpath = os.environ.get('PYTHONPATH') 21 | if pythonpath is None: 22 | pythonpath = pympath 23 | else: 24 | pythonpath = pympath + ':' + pythonpath 25 | os.environ['PYTHONPATH'] = pythonpath 26 | 27 | with tempfile.NamedTemporaryFile(prefix='catalyst.conf.') as conf: 28 | # Set up a config file with paths to the local tree. 29 | conf.write( 30 | ('sharedir=%(source_root)s\n' 31 | 'shdir=%(source_root)s/targets\n' 32 | 'envscript=%(source_root)s/etc/catalystrc\n' 33 | % {'source_root': source_root}).encode('utf8') 34 | ) 35 | conf.flush() 36 | argv = [ 37 | '--config', os.path.join(source_root, 'etc', 'catalyst.conf'), 38 | '--config', conf.name, 39 | ] + argv 40 | 41 | cmd = [os.path.join(source_root, 'bin', 'catalyst')] 42 | pid = os.fork() 43 | if pid == 0: 44 | os.execvp(cmd[0], cmd + argv) 45 | (_pid, status) = os.waitpid(pid, 0) 46 | process.exit_as_status(status) 47 | 48 | 49 | if __name__ == '__main__': 50 | main(sys.argv[1:]) 51 | -------------------------------------------------------------------------------- /bin/pylint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # Copyright 1999-2015 Gentoo Foundation 3 | # Distributed under the terms of the GNU General Public License v2 4 | 5 | """Run pylint with the right settings.""" 6 | 7 | import os 8 | import sys 9 | 10 | 11 | def find_all_modules(source_root): 12 | """Locate all python modules in the tree for scanning""" 13 | ret = [] 14 | 15 | for root, _dirs, files in os.walk(source_root, topdown=False): 16 | # Add all of the .py modules in the tree. 17 | ret += [os.path.join(root, x) for x in files if x.endswith('.py')] 18 | 19 | # Add the main scripts that don't end in .py. 20 | ret += [os.path.join(source_root, 'bin', x) 21 | for x in ('catalyst', 'pylint')] 22 | 23 | return ret 24 | 25 | 26 | def main(argv): 27 | """The main entry point""" 28 | source_root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) 29 | 30 | if not argv: 31 | argv = find_all_modules(source_root) 32 | 33 | pympath = source_root 34 | pythonpath = os.environ.get('PYTHONPATH') 35 | if pythonpath is None: 36 | pythonpath = pympath 37 | else: 38 | pythonpath = pympath + ':' + pythonpath 39 | os.environ['PYTHONPATH'] = pythonpath 40 | 41 | pylintrc = os.path.join(source_root, '.pylintrc') 42 | cmd = ['pylint', '--rcfile', pylintrc] 43 | os.execvp(cmd[0], cmd + argv) 44 | 45 | 46 | if __name__ == '__main__': 47 | main(sys.argv[1:]) 48 | -------------------------------------------------------------------------------- /catalyst/__init__.py: -------------------------------------------------------------------------------- 1 | "Catalyst is the release building tool used by Gentoo Linux" 2 | 3 | __maintainer__ = 'Catalyst ' 4 | 5 | try: 6 | from .verinfo import version as fullversion 7 | __version__ = fullversion.split('\n')[0].split()[1] 8 | except ImportError: 9 | from .version import get_version, __version__ 10 | fullversion = get_version(reset=True) 11 | -------------------------------------------------------------------------------- /catalyst/base/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gentoo/catalyst/4664d2c8ad34d9c703172fd3787da58f66029267/catalyst/base/__init__.py -------------------------------------------------------------------------------- /catalyst/base/clearbase.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | from catalyst import log 4 | from catalyst.support import countdown 5 | from catalyst.fileops import clear_dir 6 | 7 | 8 | class ClearBase(): 9 | """ 10 | This class does all of clearing after task completion 11 | """ 12 | 13 | def __init__(self, myspec): 14 | self.settings = myspec 15 | self.resume = None 16 | 17 | def clear_autoresume(self): 18 | """ Clean resume points since they are no longer needed """ 19 | if "autoresume" in self.settings["options"]: 20 | log.notice('Removing AutoResume Points ...') 21 | self.resume.clear_all() 22 | 23 | def remove_autoresume(self): 24 | """ Rmove all resume points since they are no longer needed """ 25 | if "autoresume" in self.settings["options"]: 26 | log.notice('Removing AutoResume ...') 27 | self.resume.clear_all(remove=True) 28 | 29 | def clear_chroot(self): 30 | log.notice('Clearing the chroot path ...') 31 | clear_dir(self.settings["chroot_path"], mode=0o755) 32 | 33 | def remove_chroot(self): 34 | log.notice('Removing the chroot path ...') 35 | clear_dir(self.settings["chroot_path"], mode=0o755, remove=True) 36 | 37 | def clear_packages(self, remove=False): 38 | if "pkgcache" in self.settings["options"]: 39 | log.notice('purging the pkgcache ...') 40 | clear_dir(self.settings["pkgcache_path"], remove=remove) 41 | 42 | def clear_kerncache(self, remove=False): 43 | if "kerncache" in self.settings["options"]: 44 | log.notice('purging the kerncache ...') 45 | clear_dir(self.settings["kerncache_path"], remove=remove) 46 | 47 | def purge(self, remove=False): 48 | countdown(10, "Purging Caches ...") 49 | if any(k in self.settings["options"] for k in ("purge", 50 | "purgeonly", "purgetmponly")): 51 | log.notice('purge(); clearing autoresume ...') 52 | self.clear_autoresume() 53 | 54 | log.notice('purge(); clearing chroot ...') 55 | self.clear_chroot() 56 | 57 | if "purgetmponly" not in self.settings["options"]: 58 | log.notice('purge(); clearing package cache ...') 59 | self.clear_packages(remove) 60 | 61 | log.notice('purge(); clearing kerncache ...') 62 | self.clear_kerncache(remove) 63 | -------------------------------------------------------------------------------- /catalyst/base/genbase.py: -------------------------------------------------------------------------------- 1 | 2 | import hashlib 3 | import io 4 | import os 5 | import gzip 6 | 7 | class GenBase(): 8 | """ 9 | Generates CONTENTS and DIGESTS files. 10 | """ 11 | 12 | def __init__(self, myspec): 13 | self.settings = myspec 14 | 15 | def generate_hash(self, filepath, name): 16 | h = hashlib.new(name) 17 | 18 | with open(filepath, 'rb') as f: 19 | while True: 20 | data = f.read(8192) 21 | if not data: 22 | break 23 | h.update(data) 24 | 25 | filename = os.path.split(filepath)[1] 26 | 27 | if self.settings['digest_format'] == 'bsd': 28 | return f'# {name.upper()} HASH\n{name.upper()} ({filename}) = {h.hexdigest()}\n' 29 | else: 30 | return f'# {name.upper()} HASH\n{h.hexdigest()} {filename}\n' 31 | 32 | def gen_contents_file(self, path): 33 | c = self.settings['contents_map'] 34 | 35 | with gzip.open(path + '.CONTENTS.gz', 'wt', encoding='utf-8') as file: 36 | file.write(c.contents(path, '', verbose=self.settings['VERBOSE'])) 37 | 38 | def gen_digest_file(self, path): 39 | if 'digests' not in self.settings: 40 | return 41 | 42 | with io.open(path + '.DIGESTS', 'w', encoding='utf-8') as file: 43 | for f in [path, path + '.CONTENTS.gz']: 44 | for i in self.settings['digests']: 45 | file.write(self.generate_hash(f, name=i)) 46 | 47 | with io.open(path + '.sha256', 'w', encoding='utf-8') as sha256file: 48 | sha256file.write(self.generate_hash(path, name='sha256')) 49 | -------------------------------------------------------------------------------- /catalyst/base/resume.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | '''resume.py 4 | 5 | Performs autoresume tracking file operations such as 6 | set, unset, is_set, is_unset, enabled, clear_all 7 | ''' 8 | 9 | import os 10 | 11 | from snakeoil import fileutils 12 | from snakeoil.osutils import pjoin, listdir_files 13 | 14 | from catalyst import log 15 | from catalyst.fileops import ensure_dirs, clear_dir 16 | 17 | 18 | class AutoResume(): 19 | '''Class for tracking and handling all aspects of 20 | the autoresume option and related files. 21 | ''' 22 | 23 | def __init__(self, basedir, mode=0o755): 24 | self.basedir = basedir 25 | ensure_dirs(basedir, mode=mode, fatal=True) 26 | self._points = {} 27 | self._init_points_() 28 | 29 | def _init_points_(self): 30 | '''Internal function which reads the autoresume directory and 31 | for existing autoresume points and adds them to our _points variable 32 | ''' 33 | existing = listdir_files(self.basedir, False) 34 | for point in existing: 35 | self._points[point] = pjoin(self.basedir, point) 36 | 37 | def enable(self, point, data=None): 38 | '''Sets the resume point 'ON' 39 | 40 | @param point: string. name of the resume point to enable 41 | @param data: string of information to store, or None 42 | @return boolean 43 | ''' 44 | if point in self._points and not data: 45 | return True 46 | fname = pjoin(self.basedir, point) 47 | if data: 48 | with open(fname, "w") as myf: 49 | myf.write(data) 50 | else: 51 | try: 52 | fileutils.touch(fname) 53 | self._points[point] = fname 54 | except Exception as e: 55 | log.error('AutoResumeError: %s', e) 56 | return False 57 | return True 58 | 59 | def get(self, point, no_lf=True): 60 | '''Gets any data stored inside a resume point 61 | 62 | @param point: string. name of the resume point to enable 63 | @return data: string of information stored, or None 64 | ''' 65 | if point in self._points: 66 | try: 67 | with open(self._points[point], 'r') as myf: 68 | data = myf.read() 69 | if data and no_lf: 70 | data = data.replace('\n', ' ') 71 | except OSError as e: 72 | log.error('AutoResumeError: %s', e) 73 | return None 74 | return data 75 | return None 76 | 77 | def disable(self, point): 78 | '''Sets the resume point 'OFF' 79 | 80 | @param point: string. name of the resume point to disable 81 | @return boolean 82 | ''' 83 | if point not in self._points: 84 | return True 85 | try: 86 | os.unlink(self._points[point]) 87 | self._points.pop(point) 88 | except Exception as e: 89 | log.error('AutoResumeError: %s', e) 90 | return False 91 | return True 92 | 93 | def is_enabled(self, point): 94 | '''Returns True if the resume point 'ON' 95 | 96 | @param point: string. name of the resume point enabled 97 | @return boolean 98 | ''' 99 | return point in self._points 100 | 101 | def is_disabled(self, point): 102 | '''Returns True if the resume point 'OFF' 103 | 104 | @param point: string. name of the resume point not enabled 105 | @return boolean 106 | ''' 107 | return point not in self._points 108 | 109 | @property 110 | def enabled(self): 111 | '''Returns a list of enabled points 112 | ''' 113 | return list(self._points) 114 | 115 | def clear_all(self, remove=False): 116 | '''Clear all active resume points 117 | 118 | @remove: boolean, passed through to clear_dir() 119 | @return boolean 120 | ''' 121 | if clear_dir(self.basedir, mode=0o755, remove=remove): 122 | self._points = {} 123 | return True 124 | return False 125 | -------------------------------------------------------------------------------- /catalyst/base/targetbase.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from abc import ABC, abstractmethod 4 | from pathlib import Path 5 | 6 | from catalyst.support import addl_arg_parse 7 | 8 | 9 | class TargetBase(ABC): 10 | """ 11 | The toplevel class for all targets. This is about as generic as we get. 12 | """ 13 | 14 | def __init__(self, myspec, addlargs): 15 | addl_arg_parse(myspec, addlargs, self.required_values, 16 | self.valid_values) 17 | self.settings = myspec 18 | self.env = { 19 | 'PATH': '/bin:/sbin:/usr/bin:/usr/sbin', 20 | 'TERM': os.getenv('TERM', 'dumb'), 21 | } 22 | self.snapshot = None 23 | 24 | def set_snapshot(self, treeish=None): 25 | # Make snapshots directory 26 | snapshot_dir = Path(self.settings['storedir'], 'snapshots') 27 | snapshot_dir.mkdir(mode=0o755, parents=True, exist_ok=True) 28 | 29 | repo_name = self.settings['repo_name'] 30 | if treeish is None: 31 | treeish = self.settings['snapshot_treeish'] 32 | 33 | self.snapshot = Path(snapshot_dir, 34 | f'{repo_name}-{treeish}.sqfs') 35 | 36 | @property 37 | @classmethod 38 | @abstractmethod 39 | def required_values(cls): 40 | return NotImplementedError 41 | 42 | @property 43 | @classmethod 44 | @abstractmethod 45 | def valid_values(cls): 46 | return NotImplementedError 47 | -------------------------------------------------------------------------------- /catalyst/config.py: -------------------------------------------------------------------------------- 1 | 2 | import re 3 | 4 | from catalyst import log 5 | from catalyst.support import CatalystError 6 | 7 | 8 | class ParserBase(): 9 | 10 | filename = "" 11 | lines = None 12 | values = None 13 | key_value_separator = "=" 14 | multiple_values = False 15 | empty_values = True 16 | eval_none = False 17 | 18 | def __getitem__(self, key): 19 | return self.values[key] 20 | 21 | def get_values(self): 22 | return self.values 23 | 24 | def dump(self): 25 | dump = "" 26 | for x in self.values: 27 | dump += x + " = " + repr(self.values[x]) + "\n" 28 | return dump 29 | 30 | def parse_file(self, filename): 31 | try: 32 | with open(filename, "r") as myf: 33 | self.lines = myf.readlines() 34 | except: 35 | raise CatalystError("Could not open file " + filename, 36 | print_traceback=True) 37 | self.filename = filename 38 | self.parse() 39 | 40 | def parse_lines(self, lines): 41 | self.lines = lines 42 | self.parse() 43 | 44 | def parse(self): 45 | values = {} 46 | cur_array = [] 47 | 48 | trailing_comment = re.compile(r'\s*#.*$') 49 | 50 | for x, myline in enumerate(self.lines): 51 | myline = myline.strip() 52 | 53 | # Force the line to be clean 54 | # Remove Comments ( anything following # ) 55 | myline = trailing_comment.sub("", myline) 56 | 57 | # Skip any blank lines 58 | if not myline: 59 | continue 60 | 61 | if self.key_value_separator in myline: 62 | # Split on the first occurence of the separator creating two strings in the array mobjs 63 | mobjs = myline.split(self.key_value_separator, 1) 64 | mobjs[1] = mobjs[1].strip().strip('"') 65 | 66 | # Start a new array using the first element of mobjs 67 | cur_array = [mobjs[0]] 68 | if mobjs[1]: 69 | # do any variable substitiution embeded in it with 70 | # the values already obtained 71 | mobjs[1] = mobjs[1] % values 72 | if self.multiple_values: 73 | # split on white space creating additional array elements 74 | subarray = mobjs[1].split() 75 | cur_array += subarray 76 | else: 77 | cur_array += [mobjs[1]] 78 | 79 | # Else add on to the last key we were working on 80 | else: 81 | if self.multiple_values: 82 | cur_array += myline.split() 83 | else: 84 | raise CatalystError("Syntax error: %s" % 85 | x, print_traceback=True) 86 | 87 | # XXX: Do we really still need this "single value is a string" behavior? 88 | if len(cur_array) == 2: 89 | values[cur_array[0]] = cur_array[1] 90 | else: 91 | values[cur_array[0]] = cur_array[1:] 92 | 93 | if not self.empty_values: 94 | # Make sure the list of keys is static since we modify inside the loop. 95 | for x in list(values.keys()): 96 | # Delete empty key pairs 97 | if not values[x]: 98 | log.warning('No value set for key "%s"; deleting', x) 99 | del values[x] 100 | 101 | if self.eval_none: 102 | # Make sure the list of keys is static since we modify inside the loop. 103 | for x in list(values.keys()): 104 | # reset None values 105 | if isinstance(values[x], str) and values[x].lower() in ['none']: 106 | log.info('None value found for key "%s"; reseting', x) 107 | values[x] = None 108 | self.values = values 109 | 110 | 111 | class SpecParser(ParserBase): 112 | 113 | key_value_separator = ':' 114 | multiple_values = True 115 | empty_values = False 116 | eval_none = True 117 | 118 | def __init__(self, filename=""): 119 | if filename: 120 | self.parse_file(filename) 121 | -------------------------------------------------------------------------------- /catalyst/context.py: -------------------------------------------------------------------------------- 1 | 2 | import contextlib 3 | import os 4 | 5 | from snakeoil.process.namespaces import setns, simple_unshare 6 | 7 | @contextlib.contextmanager 8 | def namespace(mount=False, uts=False, ipc=False, net=False, pid=False, 9 | user=False, hostname=None): 10 | namespaces = { 11 | (mount, "mnt"): None, 12 | (uts, "uts"): None, 13 | (ipc, "ipc"): None, 14 | (net, "net"): None, 15 | (pid, "pid"): None, 16 | (user, "user"): None, 17 | } 18 | 19 | dirs = { 20 | "root": None, 21 | "cwd": None, 22 | } 23 | 24 | # Save fds of current namespaces 25 | for ns in [ns for ns in namespaces if ns[0]]: 26 | fp = open(f"/proc/self/ns/{ns[1]}") 27 | namespaces[ns] = fp 28 | 29 | # Save fds of current directories 30 | if mount: 31 | for d in dirs: 32 | dirs[d] = os.open(f"/proc/self/{d}", os.O_RDONLY) 33 | 34 | simple_unshare(mount=mount, uts=uts, ipc=ipc, net=net, pid=pid, user=user, 35 | hostname=hostname) 36 | try: 37 | yield 38 | finally: 39 | for ns in [ns for ns in namespaces if ns[0]]: 40 | fp = namespaces[ns] 41 | setns(fp.fileno(), 0) 42 | fp.close() 43 | 44 | if mount: 45 | # Restore original root and cwd. Since we cannot directly chroot to 46 | # a fd, first change the current directory to the fd of the 47 | # original root, then chroot to "." 48 | 49 | os.fchdir(dirs["root"]) 50 | os.chroot(".") 51 | os.fchdir(dirs["cwd"]) 52 | 53 | for fd in dirs.values(): 54 | os.close(fd) 55 | -------------------------------------------------------------------------------- /catalyst/defaults.py: -------------------------------------------------------------------------------- 1 | 2 | import portage 3 | 4 | from collections import OrderedDict 5 | 6 | from DeComp.definitions import DECOMPRESSOR_SEARCH_ORDER 7 | from DeComp.definitions import COMPRESSOR_PROGRAM_OPTIONS, XATTRS_OPTIONS 8 | from DeComp.definitions import DECOMPRESSOR_PROGRAM_OPTIONS, LIST_XATTRS_OPTIONS 9 | 10 | 11 | valid_config_file_values = frozenset([ 12 | "binhost", 13 | "compression_mode", 14 | "digests", 15 | "digest_format", 16 | "distcc_hosts", 17 | "distdir", 18 | "envscript", 19 | "jobs", 20 | "load-average", 21 | "options", 22 | "port_logdir", 23 | "repo_basedir", 24 | "repo_name", 25 | "repos_storedir", 26 | "sharedir", 27 | "storedir", 28 | "target_distdir", 29 | "target_logdir", 30 | "target_pkgdir", 31 | "var_tmpfs_portage", 32 | ]) 33 | 34 | confdefaults = { 35 | "binhost": '', 36 | "comp_prog": COMPRESSOR_PROGRAM_OPTIONS['linux'], 37 | "compression_mode": 'lbzip2', 38 | "compressor_arch": None, 39 | "compressor_options": XATTRS_OPTIONS['linux'], 40 | "decomp_opt": DECOMPRESSOR_PROGRAM_OPTIONS['linux'], 41 | "decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER, 42 | "digest_format": 'linux', 43 | "distdir": portage.settings['DISTDIR'], 44 | "icecream": "/var/cache/icecream", 45 | 'list_xattrs_opt': LIST_XATTRS_OPTIONS['linux'], 46 | "port_conf": "/etc/portage", 47 | "binrepos_conf": "%(port_conf)s/binrepos.conf", 48 | "make_conf": "%(port_conf)s/make.conf", 49 | "repos_conf": "%(port_conf)s/repos.conf", 50 | "options": set(), 51 | "pkgdir": "/var/cache/binpkgs", 52 | "port_tmpdir": "/var/tmp/portage", 53 | "repo_basedir": "/var/db/repos", 54 | "repo_name": "gentoo", 55 | "repos_storedir": "%(storedir)s/repos", 56 | "sharedir": "/usr/share/catalyst", 57 | "shdir": "%(sharedir)s/targets", 58 | "storedir": "/var/tmp/catalyst", 59 | "target_distdir": "/var/cache/distfiles", 60 | "target_logdir": "/var/log/portage", 61 | "target_pkgdir": "/var/cache/binpkgs", 62 | } 63 | 64 | DEFAULT_CONFIG_FILE = '/etc/catalyst/catalyst.conf' 65 | 66 | PORT_LOGDIR_CLEAN = \ 67 | 'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete' 68 | 69 | MOUNT_DEFAULTS = OrderedDict([ 70 | ('proc', { 71 | 'enable': True, 72 | 'source': '/proc', 73 | 'target': '/proc', 74 | }), 75 | ('dev', { 76 | 'enable': True, 77 | 'source': '/dev', 78 | 'target': '/dev', 79 | }), 80 | ('devpts', { 81 | 'enable': True, 82 | 'source': '/dev/pts', 83 | 'target': '/dev/pts', 84 | }), 85 | ('shm', { 86 | 'enable': True, 87 | 'source': 'shm', 88 | 'target': '/dev/shm', 89 | }), 90 | ('run', { 91 | 'enable': True, 92 | 'source': 'tmpfs', 93 | 'target': '/run', 94 | }), 95 | ('distdir', { 96 | 'enable': True, 97 | 'source': 'config', 98 | 'target': 'config', 99 | }), 100 | ('pkgdir', { 101 | 'enable': False, 102 | 'source': 'config', 103 | 'target': 'config', 104 | }), 105 | ('port_tmpdir', { 106 | 'enable': True, 107 | 'source': 'maybe_tmpfs', 108 | 'target': '/var/tmp/portage', 109 | }), 110 | ('kerncache', { 111 | 'enable': False, 112 | 'source': 'config', 113 | 'target': '/tmp/kerncache', 114 | }), 115 | ('port_logdir', { 116 | 'enable': False, 117 | 'source': 'config', 118 | 'target': '/var/log/portage', 119 | }), 120 | ('ccache', { 121 | 'enable': False, 122 | 'source': 'config', 123 | 'target': '/var/tmp/ccache', 124 | }), 125 | ('icecream', { 126 | 'enable': False, 127 | 'source': ..., 128 | 'target': '/usr/lib/icecc/bin', 129 | }), 130 | ]) 131 | 132 | option_messages = { 133 | "autoresume": "Autoresuming support enabled.", 134 | "ccache": "Compiler cache support enabled.", 135 | "clear-autoresume": "Cleaning autoresume flags support enabled.", 136 | "distcc": "Distcc support enabled.", 137 | "icecream": "Icecream compiler cluster support enabled.", 138 | "kerncache": "Kernel cache support enabled.", 139 | "pkgcache": "Package cache support enabled.", 140 | "purge": "Purge support enabled.", 141 | "seedcache": "Seed cache support enabled.", 142 | } 143 | -------------------------------------------------------------------------------- /catalyst/fileops.py: -------------------------------------------------------------------------------- 1 | '''fileops.py 2 | 3 | Performs file operations such as pack/unpack, 4 | ensuring directories exist,... imports snakeoils osutils 5 | functions for use throughout catalyst. 6 | ''' 7 | 8 | import glob 9 | import os 10 | import shutil 11 | from stat import ST_UID, ST_GID, ST_MODE 12 | 13 | from snakeoil.osutils import ensure_dirs as snakeoil_ensure_dirs 14 | 15 | from catalyst import log 16 | from catalyst.support import CatalystError 17 | 18 | 19 | def ensure_dirs(path, gid=-1, uid=-1, mode=0o755, minimal=True, 20 | failback=None, fatal=False): 21 | '''Wrapper to snakeoil.osutil's ensure_dirs() 22 | This additionally allows for failures to run 23 | cleanup or other code and/or raise fatal errors. 24 | 25 | :param path: directory to ensure exists on disk 26 | :param gid: a valid GID to set any created directories to 27 | :param uid: a valid UID to set any created directories to 28 | :param mode: permissions to set any created directories to 29 | :param minimal: boolean controlling whether or not the specified mode 30 | must be enforced, or is the minimal permissions necessary. For example, 31 | if mode=0o755, minimal=True, and a directory exists with mode 0707, 32 | this will restore the missing group perms resulting in 757. 33 | :param failback: function to run in the event of a failed attemp 34 | to create the directory. 35 | :return: True if the directory could be created/ensured to have those 36 | permissions, False if not. 37 | ''' 38 | succeeded = snakeoil_ensure_dirs( 39 | path, gid=gid, uid=uid, mode=mode, minimal=minimal) 40 | if not succeeded: 41 | if failback: 42 | failback() 43 | if fatal: 44 | raise CatalystError( 45 | "Failed to create directory: %s" % path, print_traceback=True) 46 | return succeeded 47 | 48 | 49 | def clear_dir(target, mode=0o755, remove=False): 50 | '''Universal directory clearing function 51 | 52 | @target: string, path to be cleared or removed 53 | @mode: integer, desired mode to set the directory to 54 | @remove: boolean, passed through to clear_dir() 55 | @return boolean 56 | ''' 57 | log.debug('start: %s', target) 58 | if not target: 59 | log.debug('no target... returning') 60 | return False 61 | 62 | mystat = None 63 | if os.path.isdir(target) and not os.path.islink(target): 64 | log.notice('Emptying directory: %s', target) 65 | # stat the dir, delete the dir, recreate the dir and set 66 | # the proper perms and ownership 67 | try: 68 | log.debug('os.stat()') 69 | mystat = os.stat(target) 70 | log.debug('shutil.rmtree()') 71 | shutil.rmtree(target) 72 | except Exception: 73 | log.error('clear_dir failed', exc_info=True) 74 | return False 75 | elif os.path.exists(target): 76 | log.debug("Clearing (unlinking) non-directory: %s", target) 77 | os.unlink(target) 78 | else: 79 | log.debug("Conditions not met to clear: %s", target) 80 | log.debug(" isdir: %s", os.path.isdir(target)) 81 | log.debug(" islink: %s", os.path.islink(target)) 82 | log.debug(" exists: %s", os.path.exists(target)) 83 | 84 | if not remove: 85 | log.debug('ensure_dirs()') 86 | ensure_dirs(target, mode=mode) 87 | if mystat: 88 | os.chown(target, mystat[ST_UID], mystat[ST_GID]) 89 | os.chmod(target, mystat[ST_MODE]) 90 | 91 | log.debug('DONE, returning True') 92 | return True 93 | 94 | 95 | def clear_path(target_path): 96 | """Nuke |target_path| regardless of it being a dir, file or glob.""" 97 | targets = glob.iglob(target_path, recursive=True) 98 | for path in targets: 99 | clear_dir(path, remove=True) 100 | 101 | 102 | def move_path(src, dest): 103 | '''Move a source target to a new destination 104 | 105 | :param src: source path to move 106 | :param dest: destination path to move it to 107 | :returns: boolean 108 | ''' 109 | log.debug('Start move_path(%s, %s)', src, dest) 110 | if os.path.isdir(src) and not os.path.islink(src): 111 | if os.path.exists(dest): 112 | log.warning('Removing existing target destination: %s', dest) 113 | if not clear_dir(dest, remove=True): 114 | return False 115 | log.debug('Moving source...') 116 | try: 117 | shutil.move(src, dest) 118 | except Exception: 119 | log.error('move_path failed', exc_info=True) 120 | return False 121 | return True 122 | return False 123 | -------------------------------------------------------------------------------- /catalyst/log.py: -------------------------------------------------------------------------------- 1 | # Copyright 2003-2015 Gentoo Foundation 2 | # Distributed under the terms of the GNU General Public License v2 3 | 4 | """Logging related code 5 | 6 | This largely exposes the same interface as the logging module except we add 7 | another level "notice" between warning & info, and all output goes through 8 | the "catalyst" logger. 9 | """ 10 | 11 | import logging 12 | import logging.handlers 13 | import os 14 | import sys 15 | import time 16 | 17 | 18 | class CatalystLogger(logging.Logger): 19 | """Override the _log member to autosplit on new lines""" 20 | 21 | def _log(self, level, msg, args, **kwargs): 22 | """If given a multiline message, split it""" 23 | 24 | # Increment stacklevel to hide this function call 25 | stacklevel = kwargs.get("stacklevel", 1) 26 | kwargs["stacklevel"] = stacklevel + 1 27 | 28 | # We have to interpolate it first in case they spread things out 29 | # over multiple lines like: Bad Thing:\n%s\nGoodbye! 30 | msg %= args 31 | for line in msg.splitlines(): 32 | super(CatalystLogger, self)._log(level, line, (), **kwargs) 33 | 34 | 35 | # The logger that all output should go through. 36 | # This is ugly because we want to not perturb the logging module state. 37 | _klass = logging.getLoggerClass() 38 | logging.setLoggerClass(CatalystLogger) 39 | logger = logging.getLogger('catalyst') 40 | logging.setLoggerClass(_klass) 41 | del _klass 42 | 43 | 44 | # Set the notice level between warning and info. 45 | NOTICE = (logging.WARNING + logging.INFO) // 2 46 | logging.addLevelName(NOTICE, 'NOTICE') 47 | 48 | 49 | # The API we expose to consumers. 50 | def notice(msg, *args, **kwargs): 51 | """Log a notice message""" 52 | 53 | # Increment stacklevel to hide this function call 54 | stacklevel = kwargs.get("stacklevel", 1) 55 | kwargs["stacklevel"] = stacklevel + 1 56 | 57 | logger.log(NOTICE, msg, *args, **kwargs) 58 | 59 | 60 | def critical(msg, *args, **kwargs): 61 | """Log a critical message and then exit""" 62 | 63 | # Increment stacklevel to hide this function call 64 | stacklevel = kwargs.get("stacklevel", 1) 65 | kwargs["stacklevel"] = stacklevel + 1 66 | 67 | status = kwargs.pop('status', 1) 68 | logger.critical(msg, *args, **kwargs) 69 | sys.exit(status) 70 | 71 | 72 | error = logger.error 73 | warning = logger.warning 74 | info = logger.info 75 | debug = logger.debug 76 | 77 | 78 | class CatalystFormatter(logging.Formatter): 79 | """Mark bad messages with colors automatically""" 80 | 81 | _COLORS = { 82 | 'CRITICAL': '\033[1;35m', 83 | 'ERROR': '\033[1;31m', 84 | 'WARNING': '\033[1;33m', 85 | 'DEBUG': '\033[1;34m', 86 | } 87 | _NORMAL = '\033[0m' 88 | 89 | @staticmethod 90 | def detect_color(): 91 | """Figure out whether the runtime env wants color""" 92 | if 'NOCOLOR' in os.environ: 93 | return False 94 | return os.isatty(sys.stdout.fileno()) 95 | 96 | def __init__(self, *args, **kwargs): 97 | """Initialize""" 98 | color = kwargs.pop('color', None) 99 | if color is None: 100 | color = self.detect_color() 101 | if not color: 102 | self._COLORS = {} 103 | 104 | super(CatalystFormatter, self).__init__(*args, **kwargs) 105 | 106 | def format(self, record, **kwargs): 107 | """Format the |record| with our color settings""" 108 | msg = super(CatalystFormatter, self).format(record, **kwargs) 109 | color = self._COLORS.get(record.levelname) 110 | if color: 111 | return color + msg + self._NORMAL 112 | return msg 113 | 114 | 115 | # We define |debug| in global scope so people can call log.debug(), but it 116 | # makes the linter complain when we have a |debug| keyword. Since we don't 117 | # use that func in here, it's not a problem, so silence the warning. 118 | # pylint: disable=redefined-outer-name 119 | def setup_logging(level, output=None, debug=False, color=None): 120 | """Initialize the logging module using the |level| level""" 121 | # The incoming level will be things like "info", but setLevel wants 122 | # the numeric constant. Convert it here. 123 | level = logging.getLevelName(level.upper()) 124 | 125 | # The good stuff. 126 | fmt = '%(asctime)s: %(levelname)-8s: ' 127 | if debug: 128 | fmt += '%(filename)s:%(funcName)s:%(lineno)d: ' 129 | fmt += '%(message)s' 130 | 131 | # Figure out where to send the log output. 132 | if output is None: 133 | handler = logging.StreamHandler(stream=sys.stdout) 134 | else: 135 | handler = logging.FileHandler(output) 136 | 137 | # Use a date format that is readable by humans & machines. 138 | # Think e-mail/RFC 2822: 05 Oct 2013 18:58:50 EST 139 | tzname = time.strftime('%Z', time.localtime()) 140 | datefmt = '%d %b %Y %H:%M:%S ' + tzname 141 | formatter = CatalystFormatter(fmt, datefmt, color=color) 142 | handler.setFormatter(formatter) 143 | 144 | logger.addHandler(handler) 145 | logger.setLevel(level) 146 | -------------------------------------------------------------------------------- /catalyst/targets/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gentoo/catalyst/4664d2c8ad34d9c703172fd3787da58f66029267/catalyst/targets/__init__.py -------------------------------------------------------------------------------- /catalyst/targets/diskimage_stage1.py: -------------------------------------------------------------------------------- 1 | """ 2 | Disk image stage1 target 3 | """ 4 | # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. 5 | 6 | from catalyst.support import normpath 7 | 8 | from catalyst.base.stagebase import StageBase 9 | 10 | 11 | class diskimage_stage1(StageBase): 12 | """ 13 | Builder class for disk image stage1. 14 | """ 15 | required_values = frozenset([ 16 | "diskimage/packages", 17 | ]) 18 | valid_values = required_values | frozenset([ 19 | "diskimage/use", 20 | ]) 21 | 22 | def __init__(self, spec, addlargs): 23 | StageBase.__init__(self, spec, addlargs) 24 | 25 | def set_action_sequence(self): 26 | self.build_sequence.extend([ 27 | self.build_packages, 28 | ]) 29 | self.finish_sequence.extend([ 30 | self.clean, 31 | ]) 32 | self.set_completion_action_sequences() 33 | 34 | def set_spec_prefix(self): 35 | self.settings["spec_prefix"] = "diskimage" 36 | 37 | def set_catalyst_use(self): 38 | StageBase.set_catalyst_use(self) 39 | if "catalyst_use" in self.settings: 40 | self.settings["catalyst_use"].append("diskimage") 41 | else: 42 | self.settings["catalyst_use"] = ["diskiage"] 43 | 44 | def set_packages(self): 45 | StageBase.set_packages(self) 46 | if self.settings["spec_prefix"]+"/packages" in self.settings: 47 | if isinstance(self.settings[self.settings['spec_prefix']+'/packages'], str): 48 | self.settings[self.settings["spec_prefix"]+"/packages"] = \ 49 | self.settings[self.settings["spec_prefix"] + 50 | "/packages"].split() 51 | 52 | def set_pkgcache_path(self): 53 | if "pkgcache_path" in self.settings: 54 | if not isinstance(self.settings['pkgcache_path'], str): 55 | self.settings["pkgcache_path"] = normpath( 56 | ' '.join(self.settings["pkgcache_path"])) 57 | else: 58 | StageBase.set_pkgcache_path(self) 59 | -------------------------------------------------------------------------------- /catalyst/targets/diskimage_stage2.py: -------------------------------------------------------------------------------- 1 | """ 2 | Disk image stage2 target, builds upon previous disk image stage1 tarball 3 | """ 4 | # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. 5 | 6 | from catalyst.support import (normpath, file_locate, CatalystError) 7 | from catalyst.fileops import clear_dir 8 | from catalyst.base.stagebase import StageBase 9 | 10 | 11 | class diskimage_stage2(StageBase): 12 | """ 13 | Builder class for a disk image stage2 build. 14 | """ 15 | required_values = frozenset([ 16 | "boot/kernel", 17 | ]) 18 | valid_values = required_values | frozenset([ 19 | "diskimage/bootargs", 20 | "diskimage/depclean", 21 | "diskimage/empty", 22 | "diskimage/fsops", 23 | "diskimage/fsscript", 24 | "diskimage/gk_mainargs", 25 | "diskimage/modblacklist", 26 | "diskimage/motd", 27 | "diskimage/qcow2", 28 | "diskimage/qcow2_size", 29 | "diskimage/qcow2_efisize", 30 | "diskimage/qcow2_roottype", 31 | "diskimage/rcadd", 32 | "diskimage/rcdel", 33 | "diskimage/readme", 34 | "diskimage/rm", 35 | "diskimage/type", # generic, cloud-init, ssh, console 36 | "diskimage/sshkey", 37 | "diskimage/unmerge", 38 | "diskimage/users", 39 | "diskimage/verify", 40 | "diskimage/volid", 41 | "repos", 42 | ]) 43 | 44 | # Types of bootable disk images planned for (diskimage/type): 45 | # cloud-init - an image that starts cloud-init for configuration and then can be 46 | # used out of the box 47 | # console - an image that has an empty root password and allows passwordless 48 | # login on the console only 49 | # ssh - an image that populates /root/.ssh/authorized_keys and starts dhcp 50 | # as well as sshd; obviously not fit for public distribution 51 | # generic - an image with no means of logging in... needs postprocessing 52 | # no services are started 53 | 54 | def __init__(self, spec, addlargs): 55 | StageBase.__init__(self, spec, addlargs) 56 | if "diskimage/type" not in self.settings: 57 | self.settings["diskimage/type"] = "generic" 58 | 59 | file_locate(self.settings, ["controller_file"]) 60 | 61 | def set_spec_prefix(self): 62 | self.settings["spec_prefix"] = "diskimage" 63 | 64 | def set_target_path(self): 65 | '''Set the target path for the finished stage. 66 | 67 | This method runs the StageBase.set_target_path mehtod, 68 | and additionally creates a staging directory for assembling 69 | the final components needed to produce the iso image. 70 | ''' 71 | super(diskimage_stage2, self).set_target_path() 72 | clear_dir(self.settings['target_path']) 73 | 74 | def run_local(self): 75 | # what modules do we want to blacklist? 76 | if "diskimage/modblacklist" in self.settings: 77 | path = normpath(self.settings["chroot_path"] + 78 | "/etc/modprobe.d/blacklist.conf") 79 | try: 80 | with open(path, "a") as myf: 81 | myf.write("\n#Added by Catalyst:") 82 | # workaround until config.py is using configparser 83 | if isinstance(self.settings["diskimage/modblacklist"], str): 84 | self.settings["diskimage/modblacklist"] = self.settings[ 85 | "diskimage/modblacklist"].split() 86 | for x in self.settings["diskimage/modblacklist"]: 87 | myf.write("\nblacklist "+x) 88 | except Exception as e: 89 | raise CatalystError("Couldn't open " + 90 | self.settings["chroot_path"] + 91 | "/etc/modprobe.d/blacklist.conf.", 92 | print_traceback=True) from e 93 | 94 | def set_action_sequence(self): 95 | self.build_sequence.extend([ 96 | self.run_local, 97 | self.build_kernel 98 | ]) 99 | if "fetch" not in self.settings["options"]: 100 | self.build_sequence.extend([ 101 | self.preclean, 102 | self.diskimage_update, 103 | self.fsscript, 104 | self.rcupdate, 105 | self.unmerge, 106 | ]) 107 | self.finish_sequence.extend([ 108 | self.remove, 109 | self.empty, 110 | self.clean, 111 | self.create_qcow2, 112 | ]) 113 | self.set_completion_action_sequences() 114 | # our output is the qcow2, not a stage archive 115 | self.finish_sequence.remove(self.capture) 116 | -------------------------------------------------------------------------------- /catalyst/targets/embedded.py: -------------------------------------------------------------------------------- 1 | """ 2 | Enbedded target, similar to the stage2 target, builds upon a stage2 tarball. 3 | 4 | A stage2 tarball is unpacked, but instead 5 | of building a stage3, it emerges @system into another directory 6 | inside the stage2 system. This way, we do not have to emerge GCC/portage 7 | into the staged system. 8 | It may sound complicated but basically it runs 9 | ROOT=/tmp/submerge emerge --something foo bar . 10 | """ 11 | # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. 12 | 13 | from catalyst import log 14 | from catalyst.support import normpath 15 | from catalyst.base.stagebase import StageBase 16 | 17 | 18 | class embedded(StageBase): 19 | """ 20 | Builder class for embedded target 21 | """ 22 | required_values = frozenset() 23 | valid_values = required_values | frozenset([ 24 | "boot/kernel", 25 | "embedded/empty", 26 | "embedded/fs-finish", 27 | "embedded/fs-ops", 28 | "embedded/fs-prepare", 29 | "embedded/fs-type", 30 | "embedded/linuxrc", 31 | "embedded/mergeroot", 32 | "embedded/packages", 33 | "embedded/rm", 34 | "embedded/root_overlay", 35 | "embedded/runscript", 36 | "embedded/unmerge", 37 | "embedded/use", 38 | ]) 39 | 40 | def __init__(self, spec, addlargs): 41 | StageBase.__init__(self, spec, addlargs) 42 | 43 | def set_action_sequence(self): 44 | self.build_sequence.extend([ 45 | self.build_kernel, 46 | self.build_packages, 47 | self.root_overlay, 48 | self.fsscript, 49 | self.unmerge, 50 | ]) 51 | self.finish_sequence.extend([ 52 | self.remove, 53 | self.empty, 54 | self.clean, 55 | self.capture, 56 | ]) 57 | self.set_completion_action_sequences() 58 | 59 | def set_root_path(self): 60 | self.settings["root_path"] = normpath("/tmp/mergeroot") 61 | log.info('embedded root path is %s', self.settings['root_path']) 62 | -------------------------------------------------------------------------------- /catalyst/targets/livecd_stage1.py: -------------------------------------------------------------------------------- 1 | """ 2 | LiveCD stage1 target 3 | """ 4 | # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. 5 | 6 | from catalyst.support import normpath 7 | 8 | from catalyst.base.stagebase import StageBase 9 | 10 | 11 | class livecd_stage1(StageBase): 12 | """ 13 | Builder class for LiveCD stage1. 14 | """ 15 | required_values = frozenset([ 16 | "livecd/packages", 17 | ]) 18 | valid_values = required_values | frozenset([ 19 | "livecd/use", 20 | ]) 21 | 22 | def __init__(self, spec, addlargs): 23 | StageBase.__init__(self, spec, addlargs) 24 | 25 | def set_action_sequence(self): 26 | self.build_sequence.extend([ 27 | self.build_packages, 28 | ]) 29 | self.finish_sequence.extend([ 30 | self.clean, 31 | ]) 32 | self.set_completion_action_sequences() 33 | 34 | def set_spec_prefix(self): 35 | self.settings["spec_prefix"] = "livecd" 36 | 37 | def set_catalyst_use(self): 38 | StageBase.set_catalyst_use(self) 39 | if "catalyst_use" in self.settings: 40 | self.settings["catalyst_use"].append("livecd") 41 | else: 42 | self.settings["catalyst_use"] = ["livecd"] 43 | 44 | def set_packages(self): 45 | StageBase.set_packages(self) 46 | if self.settings["spec_prefix"]+"/packages" in self.settings: 47 | if isinstance(self.settings[self.settings['spec_prefix']+'/packages'], str): 48 | self.settings[self.settings["spec_prefix"]+"/packages"] = \ 49 | self.settings[self.settings["spec_prefix"] + 50 | "/packages"].split() 51 | 52 | def set_pkgcache_path(self): 53 | if "pkgcache_path" in self.settings: 54 | if not isinstance(self.settings['pkgcache_path'], str): 55 | self.settings["pkgcache_path"] = normpath( 56 | ' '.join(self.settings["pkgcache_path"])) 57 | else: 58 | StageBase.set_pkgcache_path(self) 59 | -------------------------------------------------------------------------------- /catalyst/targets/livecd_stage2.py: -------------------------------------------------------------------------------- 1 | """ 2 | LiveCD stage2 target, builds upon previous LiveCD stage1 tarball 3 | """ 4 | # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. 5 | 6 | from catalyst.support import (normpath, file_locate, CatalystError) 7 | from catalyst.fileops import clear_dir 8 | from catalyst.base.stagebase import StageBase 9 | 10 | 11 | class livecd_stage2(StageBase): 12 | """ 13 | Builder class for a LiveCD stage2 build. 14 | """ 15 | required_values = frozenset([ 16 | "boot/kernel", 17 | ]) 18 | valid_values = required_values | frozenset([ 19 | "livecd/bootargs", 20 | "livecd/cdtar", 21 | "livecd/depclean", 22 | "livecd/empty", 23 | "livecd/fsops", 24 | "livecd/fsscript", 25 | "livecd/fstype", 26 | "livecd/gk_mainargs", 27 | "livecd/iso", 28 | "livecd/linuxrc", 29 | "livecd/modblacklist", 30 | "livecd/motd", 31 | "livecd/overlay", 32 | "livecd/rcadd", 33 | "livecd/rcdel", 34 | "livecd/readme", 35 | "livecd/rm", 36 | "livecd/root_overlay", 37 | "livecd/type", 38 | "livecd/unmerge", 39 | "livecd/users", 40 | "livecd/verify", 41 | "livecd/volid", 42 | "repos", 43 | ]) 44 | 45 | def __init__(self, spec, addlargs): 46 | StageBase.__init__(self, spec, addlargs) 47 | if "livecd/type" not in self.settings: 48 | self.settings["livecd/type"] = "generic-livecd" 49 | 50 | file_locate(self.settings, ["cdtar", "controller_file"]) 51 | 52 | def set_spec_prefix(self): 53 | self.settings["spec_prefix"] = "livecd" 54 | 55 | def set_target_path(self): 56 | '''Set the target path for the finished stage. 57 | 58 | This method runs the StageBase.set_target_path mehtod, 59 | and additionally creates a staging directory for assembling 60 | the final components needed to produce the iso image. 61 | ''' 62 | super(livecd_stage2, self).set_target_path() 63 | clear_dir(self.settings['target_path']) 64 | 65 | def run_local(self): 66 | # what modules do we want to blacklist? 67 | if "livecd/modblacklist" in self.settings: 68 | path = normpath(self.settings["chroot_path"] + 69 | "/etc/modprobe.d/blacklist.conf") 70 | try: 71 | with open(path, "a") as myf: 72 | myf.write("\n#Added by Catalyst:") 73 | # workaround until config.py is using configparser 74 | if isinstance(self.settings["livecd/modblacklist"], str): 75 | self.settings["livecd/modblacklist"] = self.settings[ 76 | "livecd/modblacklist"].split() 77 | for x in self.settings["livecd/modblacklist"]: 78 | myf.write("\nblacklist "+x) 79 | except Exception as e: 80 | raise CatalystError("Couldn't open " + 81 | self.settings["chroot_path"] + 82 | "/etc/modprobe.d/blacklist.conf.", 83 | print_traceback=True) from e 84 | 85 | def set_action_sequence(self): 86 | self.build_sequence.extend([ 87 | self.run_local, 88 | self.build_kernel 89 | ]) 90 | if "fetch" not in self.settings["options"]: 91 | self.build_sequence.extend([ 92 | self.bootloader, 93 | self.preclean, 94 | self.livecd_update, 95 | self.root_overlay, 96 | self.fsscript, 97 | self.rcupdate, 98 | self.unmerge, 99 | ]) 100 | self.finish_sequence.extend([ 101 | self.remove, 102 | self.empty, 103 | self.clean, 104 | self.target_setup, 105 | self.setup_overlay, 106 | self.create_iso, 107 | ]) 108 | self.set_completion_action_sequences() 109 | -------------------------------------------------------------------------------- /catalyst/targets/netboot.py: -------------------------------------------------------------------------------- 1 | """ 2 | netboot target, version 2 3 | """ 4 | # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. 5 | 6 | import os 7 | 8 | from catalyst import log 9 | from catalyst.support import (CatalystError, normpath, cmd) 10 | from catalyst.fileops import (ensure_dirs, clear_dir, clear_path) 11 | 12 | from catalyst.base.stagebase import StageBase 13 | 14 | 15 | class netboot(StageBase): 16 | """ 17 | Builder class for a netboot build, version 2 18 | """ 19 | required_values = frozenset([ 20 | "boot/kernel", 21 | ]) 22 | valid_values = required_values | frozenset([ 23 | "netboot/busybox_config", 24 | "netboot/extra_files", 25 | "netboot/linuxrc", 26 | "netboot/overlay", 27 | "netboot/packages", 28 | "netboot/root_overlay", 29 | "netboot/use", 30 | ]) 31 | 32 | def __init__(self, spec, addlargs): 33 | if "netboot/packages" in addlargs: 34 | if isinstance(addlargs['netboot/packages'], str): 35 | loopy = [addlargs["netboot/packages"]] 36 | else: 37 | loopy = addlargs["netboot/packages"] 38 | 39 | for x in loopy: 40 | self.valid_values |= {"netboot/packages/"+x+"/files"} 41 | 42 | StageBase.__init__(self, spec, addlargs) 43 | self.settings["merge_path"] = normpath("/tmp/image/") 44 | 45 | def set_target_path(self): 46 | self.settings["target_path"] = normpath(self.settings["storedir"]+"/builds/" + 47 | self.settings["target_subpath"]) 48 | if "autoresume" in self.settings["options"] \ 49 | and self.resume.is_enabled("setup_target_path"): 50 | log.notice( 51 | 'Resume point detected, skipping target path setup operation...') 52 | else: 53 | # first clean up any existing target stuff 54 | clear_path(self.settings['target_path']) 55 | self.resume.enable("setup_target_path") 56 | ensure_dirs(self.settings["storedir"]+"/builds/") 57 | 58 | def copy_files_to_image(self): 59 | # copies specific files from the buildroot to merge_path 60 | myfiles = [] 61 | 62 | # check for autoresume point 63 | if "autoresume" in self.settings["options"] \ 64 | and self.resume.is_enabled("copy_files_to_image"): 65 | log.notice( 66 | 'Resume point detected, skipping target path setup operation...') 67 | else: 68 | if "netboot/packages" in self.settings: 69 | if isinstance(self.settings['netboot/packages'], str): 70 | loopy = [self.settings["netboot/packages"]] 71 | else: 72 | loopy = self.settings["netboot/packages"] 73 | 74 | for x in loopy: 75 | if "netboot/packages/"+x+"/files" in self.settings: 76 | if isinstance(self.settings['netboot/packages/'+x+'/files'], list): 77 | myfiles.extend( 78 | self.settings["netboot/packages/"+x+"/files"]) 79 | else: 80 | myfiles.append( 81 | self.settings["netboot/packages/"+x+"/files"]) 82 | 83 | if "netboot/extra_files" in self.settings: 84 | if isinstance(self.settings['netboot/extra_files'], list): 85 | myfiles.extend(self.settings["netboot/extra_files"]) 86 | else: 87 | myfiles.append(self.settings["netboot/extra_files"]) 88 | 89 | cmd([self.settings['controller_file'], 'image'] + 90 | myfiles, env=self.env) 91 | 92 | self.resume.enable("copy_files_to_image") 93 | 94 | def setup_overlay(self): 95 | if "autoresume" in self.settings["options"] \ 96 | and self.resume.is_enabled("setup_overlay"): 97 | log.notice( 98 | 'Resume point detected, skipping setup_overlay operation...') 99 | else: 100 | if "netboot/overlay" in self.settings: 101 | for x in self.settings["netboot/overlay"]: 102 | if os.path.exists(x): 103 | cmd(['rsync', '-a', x + '/', 104 | self.settings['chroot_path'] + self.settings['merge_path']], 105 | env=self.env) 106 | self.resume.enable("setup_overlay") 107 | 108 | def move_kernels(self): 109 | # we're done, move the kernels to builds/* 110 | # no auto resume here as we always want the 111 | # freshest images moved 112 | cmd([self.settings['controller_file'], 'final'], env=self.env) 113 | log.notice('Netboot Build Finished!') 114 | 115 | def remove(self): 116 | if "autoresume" in self.settings["options"] \ 117 | and self.resume.is_enabled("remove"): 118 | log.notice('Resume point detected, skipping remove operation...') 119 | else: 120 | if self.settings["spec_prefix"]+"/rm" in self.settings: 121 | for x in self.settings[self.settings["spec_prefix"]+"/rm"]: 122 | # we're going to shell out for all these cleaning operations, 123 | # so we get easy glob handling 124 | log.notice('netboot: removing %s', x) 125 | clear_path(self.settings['chroot_path'] + 126 | self.settings['merge_path'] + x) 127 | 128 | def empty(self): 129 | if "autoresume" in self.settings["options"] \ 130 | and self.resume.is_enabled("empty"): 131 | log.notice('Resume point detected, skipping empty operation...') 132 | else: 133 | if "netboot/empty" in self.settings: 134 | if isinstance(self.settings['netboot/empty'], str): 135 | self.settings["netboot/empty"] = self.settings["netboot/empty"].split() 136 | for x in self.settings["netboot/empty"]: 137 | myemp = self.settings["chroot_path"] + \ 138 | self.settings["merge_path"] + x 139 | if not os.path.isdir(myemp): 140 | log.warning( 141 | 'not a directory or does not exist, skipping "empty" operation: %s', x) 142 | continue 143 | log.info('Emptying directory %s', x) 144 | # stat the dir, delete the dir, recreate the dir and set 145 | # the proper perms and ownership 146 | clear_dir(myemp) 147 | self.resume.enable("empty") 148 | 149 | def set_action_sequence(self): 150 | self.build_sequence.extend([ 151 | self.build_packages, 152 | self.root_overlay, 153 | self.copy_files_to_image, 154 | self.setup_overlay, 155 | self.build_kernel, 156 | self.move_kernels, 157 | self.remove, 158 | self.empty, 159 | ]) 160 | self.finish_sequence.extend([ 161 | self.clean, 162 | self.clear_autoresume, 163 | ]) 164 | -------------------------------------------------------------------------------- /catalyst/targets/snapshot.py: -------------------------------------------------------------------------------- 1 | """ 2 | Snapshot target 3 | """ 4 | 5 | import subprocess 6 | import sys 7 | 8 | import fasteners 9 | 10 | from pathlib import Path 11 | 12 | from catalyst import log 13 | from catalyst.base.targetbase import TargetBase 14 | from catalyst.support import CatalystError, command 15 | 16 | class snapshot(TargetBase): 17 | """ 18 | Builder class for snapshots. 19 | """ 20 | required_values = frozenset([ 21 | 'target', 22 | ]) 23 | valid_values = required_values | frozenset([ 24 | 'snapshot_treeish', 25 | ]) 26 | 27 | def __init__(self, myspec, addlargs): 28 | TargetBase.__init__(self, myspec, addlargs) 29 | 30 | self.git = command('git') 31 | self.ebuild_repo = Path(self.settings['repos_storedir'], 32 | self.settings['repo_name']).with_suffix('.git') 33 | self.gitdir = str(self.ebuild_repo) 34 | 35 | def update_ebuild_repo(self) -> str: 36 | repouri = 'https://anongit.gentoo.org/git/repo/sync/gentoo.git' 37 | 38 | if self.ebuild_repo.is_dir(): 39 | git_cmds = [ 40 | [self.git, '-C', self.gitdir, 'fetch', '--quiet', '--depth=1'], 41 | [self.git, '-C', self.gitdir, 'update-ref', 'HEAD', 'FETCH_HEAD'], 42 | [self.git, '-C', self.gitdir, 'gc', '--quiet'], 43 | ] 44 | else: 45 | git_cmds = [ 46 | [self.git, 'clone', '--quiet', '--depth=1', '--bare', 47 | # Set some config options to enable git gc to clean everything 48 | # except what we just fetched. See git-gc(1). 49 | '-c', 'gc.reflogExpire=0', 50 | '-c', 'gc.reflogExpireUnreachable=0', 51 | '-c', 'gc.rerereresolved=0', 52 | '-c', 'gc.rerereunresolved=0', 53 | '-c', 'gc.pruneExpire=now', 54 | '--branch=stable', 55 | repouri, self.gitdir], 56 | ] 57 | 58 | try: 59 | for cmd in git_cmds: 60 | log.notice('>>> ' + ' '.join(cmd)) 61 | subprocess.run(cmd, 62 | capture_output=True, 63 | check=True, 64 | encoding='utf-8', 65 | close_fds=False) 66 | 67 | sp = subprocess.run([self.git, '-C', self.gitdir, 'rev-parse', 'stable'], 68 | capture_output=True, 69 | check=True, 70 | encoding='utf-8', 71 | close_fds=False) 72 | return sp.stdout.rstrip() 73 | 74 | except subprocess.CalledProcessError as e: 75 | raise CatalystError(f'{e.cmd} failed with return code' 76 | f'{e.returncode}\n' 77 | f'{e.output}\n') from e 78 | 79 | def run(self): 80 | if self.settings['snapshot_treeish'] == 'stable': 81 | treeish = self.update_ebuild_repo() 82 | else: 83 | treeish = self.settings['snapshot_treeish'] 84 | 85 | self.set_snapshot(treeish) 86 | 87 | git_cmd = [self.git, '-C', self.gitdir, 'archive', '--format=tar', 88 | treeish] 89 | tar2sqfs_cmd = [command('tar2sqfs'), str(self.snapshot), '-q', '-f', 90 | '-j1', '-c', 'gzip'] 91 | 92 | log.notice('Creating %s tree snapshot %s from %s', 93 | self.settings['repo_name'], treeish, self.gitdir) 94 | log.notice('>>> ' + ' '.join([*git_cmd, '|'])) 95 | log.notice(' ' + ' '.join(tar2sqfs_cmd)) 96 | 97 | with fasteners.InterProcessLock(self.snapshot.with_suffix('.lock')): 98 | git = subprocess.Popen(git_cmd, 99 | stdout=subprocess.PIPE, 100 | stderr=sys.stderr, 101 | close_fds=False) 102 | tar2sqfs = subprocess.Popen(tar2sqfs_cmd, 103 | stdin=git.stdout, 104 | stdout=sys.stdout, 105 | stderr=sys.stderr, 106 | close_fds=False) 107 | git.stdout.close() 108 | git.wait() 109 | tar2sqfs.wait() 110 | 111 | if tar2sqfs.returncode == 0: 112 | log.notice('Wrote snapshot to %s', self.snapshot) 113 | else: 114 | log.error('Failed to create snapshot') 115 | return tar2sqfs.returncode == 0 116 | -------------------------------------------------------------------------------- /catalyst/targets/stage1.py: -------------------------------------------------------------------------------- 1 | """ 2 | stage1 target 3 | """ 4 | # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. 5 | 6 | from catalyst import log 7 | from catalyst.support import normpath 8 | from catalyst.fileops import move_path 9 | from catalyst.base.stagebase import StageBase 10 | 11 | class stage1(StageBase): 12 | """ 13 | Builder class for a stage1 installation tarball build. 14 | """ 15 | required_values = frozenset() 16 | valid_values = required_values | frozenset([ 17 | "chost", 18 | "update_seed", 19 | "update_seed_command", 20 | ]) 21 | 22 | def __init__(self, spec, addlargs): 23 | StageBase.__init__(self, spec, addlargs) 24 | 25 | def set_root_path(self): 26 | # sets the root path, relative to 'chroot_path', of the stage1 root 27 | self.settings["root_path"] = normpath("/tmp/stage1root") 28 | log.info('stage1 root path is %s', self.settings['root_path']) 29 | 30 | def set_cleanables(self): 31 | StageBase.set_cleanables(self) 32 | self.settings["cleanables"].extend([ 33 | self.settings["port_conf"] + "/package*", 34 | ]) 35 | 36 | # XXX: How do these override_foo() functions differ from the ones in StageBase and why aren't they in stage3_target? 37 | # XXY: It appears the difference is that these functions are actually doing something and the ones in stagebase don't :-( 38 | # XXZ: I have a wierd suspicion that it's the difference in capitolization 39 | 40 | def override_chost(self): 41 | if "chost" in self.settings: 42 | self.settings["CHOST"] = self.settings["chost"] 43 | 44 | def override_common_flags(self): 45 | if "common_flags" in self.settings: 46 | self.settings["COMMON_FLAGS"] = self.settings["common_flags"] 47 | 48 | def override_cflags(self): 49 | if "cflags" in self.settings: 50 | self.settings["CFLAGS"] = self.settings["cflags"] 51 | 52 | def override_cxxflags(self): 53 | if "cxxflags" in self.settings: 54 | self.settings["CXXFLAGS"] = self.settings["cxxflags"] 55 | 56 | def override_fcflags(self): 57 | if "fcflags" in self.settings: 58 | self.settings["FCFLAGS"] = self.settings["fcflags"] 59 | 60 | def override_fflags(self): 61 | if "fflags" in self.settings: 62 | self.settings["FFLAGS"] = self.settings["fflags"] 63 | 64 | def override_ldflags(self): 65 | if "ldflags" in self.settings: 66 | self.settings["LDFLAGS"] = self.settings["ldflags"] 67 | 68 | def set_repos(self): 69 | StageBase.set_repos(self) 70 | if "repos" in self.settings: 71 | log.warning( 72 | 'Using an overlay for earlier stages could cause build issues.\n' 73 | "If you break it, you buy it. Don't complain to us about it.\n" 74 | "Don't say we did not warn you.") 75 | 76 | def set_completion_action_sequences(self): 77 | '''Override function for stage1 78 | 79 | Its purpose is to move the new stage1root out of the seed stage 80 | and rename it to the stage1 chroot_path after cleaning the seed stage 81 | chroot for re-use in stage2 without the need to unpack it. 82 | ''' 83 | if "fetch" not in self.settings["options"]: 84 | self.finish_sequence.append(self.capture) 85 | if "keepwork" in self.settings["options"]: 86 | self.finish_sequence.append(self.clear_autoresume) 87 | elif "seedcache" in self.settings["options"]: 88 | self.finish_sequence.append(self.remove_autoresume) 89 | self.finish_sequence.append(self.clean_stage1) 90 | else: 91 | self.finish_sequence.append(self.remove_autoresume) 92 | self.finish_sequence.append(self.remove_chroot) 93 | 94 | def clean_stage1(self): 95 | '''seedcache is enabled, so salvage the /tmp/stage1root, 96 | remove the seed chroot''' 97 | log.notice('Salvaging the stage1root from the chroot path ...') 98 | # move the self.settings["stage_path"] outside of the self.settings["chroot_path"] 99 | tmp_path = normpath(self.settings["storedir"] + "/tmp/" + "stage1root") 100 | if move_path(self.settings["stage_path"], tmp_path): 101 | self.remove_chroot() 102 | # move it to self.settings["chroot_path"] 103 | if not move_path(tmp_path, self.settings["chroot_path"]): 104 | log.error( 105 | 'clean_stage1 failed, see previous log messages for details') 106 | return False 107 | log.notice( 108 | 'Successfully moved and cleaned the stage1root for the seedcache') 109 | return True 110 | log.error( 111 | 'clean_stage1 failed to move the stage1root to a temporary loation') 112 | return False 113 | -------------------------------------------------------------------------------- /catalyst/targets/stage2.py: -------------------------------------------------------------------------------- 1 | """ 2 | stage2 target, builds upon previous stage1 tarball 3 | """ 4 | # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. 5 | 6 | 7 | from catalyst import log 8 | from catalyst.base.stagebase import StageBase 9 | 10 | 11 | class stage2(StageBase): 12 | """ 13 | Builder class for a stage2 installation tarball build. 14 | """ 15 | required_values = frozenset() 16 | valid_values = required_values | frozenset([ 17 | "chost", 18 | ]) 19 | 20 | def __init__(self, spec, addlargs): 21 | StageBase.__init__(self, spec, addlargs) 22 | 23 | # XXX: How do these override_foo() functions differ from the ones in 24 | # StageBase and why aren't they in stage3_target? 25 | 26 | def override_chost(self): 27 | if "chost" in self.settings: 28 | self.settings["CHOST"] = self.settings["chost"] 29 | 30 | def override_cflags(self): 31 | if "cflags" in self.settings: 32 | self.settings["CFLAGS"] = self.settings["cflags"] 33 | 34 | def override_cxxflags(self): 35 | if "cxxflags" in self.settings: 36 | self.settings["CXXFLAGS"] = self.settings["cxxflags"] 37 | 38 | def override_ldflags(self): 39 | if "ldflags" in self.settings: 40 | self.settings["LDFLAGS"] = self.settings["ldflags"] 41 | 42 | def set_repos(self): 43 | StageBase.set_repos(self) 44 | if "repos" in self.settings: 45 | log.warning( 46 | 'Using an overlay for earlier stages could cause build issues.\n' 47 | "If you break it, you buy it. Don't complain to us about it.\n" 48 | "Don't say we did not warn you.") 49 | -------------------------------------------------------------------------------- /catalyst/targets/stage3.py: -------------------------------------------------------------------------------- 1 | """ 2 | stage3 target, builds upon previous stage2/stage3 tarball 3 | """ 4 | # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. 5 | 6 | from catalyst import log 7 | from catalyst.base.stagebase import StageBase 8 | 9 | 10 | class stage3(StageBase): 11 | """ 12 | Builder class for a stage3 installation tarball build. 13 | """ 14 | required_values = frozenset() 15 | valid_values = frozenset() 16 | 17 | def __init__(self, spec, addlargs): 18 | StageBase.__init__(self, spec, addlargs) 19 | 20 | def set_repos(self): 21 | StageBase.set_repos(self) 22 | if "repos" in self.settings: 23 | log.warning( 24 | 'Using an overlay for earlier stages could cause build issues.\n' 25 | "If you break it, you buy it. Don't complain to us about it.\n" 26 | "Don't say we did not warn you.") 27 | -------------------------------------------------------------------------------- /catalyst/targets/stage4.py: -------------------------------------------------------------------------------- 1 | """ 2 | stage4 target, builds upon previous stage3/stage4 tarball 3 | """ 4 | # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. 5 | 6 | from catalyst.base.stagebase import StageBase 7 | 8 | 9 | class stage4(StageBase): 10 | """ 11 | Builder class for stage4. 12 | """ 13 | required_values = frozenset([ 14 | "stage4/packages", 15 | ]) 16 | valid_values = required_values | frozenset([ 17 | "boot/kernel", 18 | "repos", 19 | "stage4/empty", 20 | "stage4/fsscript", 21 | "stage4/gk_mainargs", 22 | "stage4/groups", 23 | "stage4/linuxrc", 24 | "stage4/rcadd", 25 | "stage4/rcdel", 26 | "stage4/rm", 27 | "stage4/root_overlay", 28 | "stage4/ssh_public_keys", 29 | "stage4/unmerge", 30 | "stage4/use", 31 | "stage4/users", 32 | ]) 33 | 34 | def __init__(self, spec, addlargs): 35 | StageBase.__init__(self, spec, addlargs) 36 | 37 | def set_cleanables(self): 38 | StageBase.set_cleanables(self) 39 | 40 | # We want to allow stage4's fsscript to generate a default 41 | # /etc/resolv.conf 42 | self.settings["cleanables"].remove('/etc/resolv.conf') 43 | 44 | def set_action_sequence(self): 45 | self.build_sequence.extend([ 46 | self.build_packages, 47 | self.build_kernel, 48 | self.bootloader, 49 | self.root_overlay, 50 | self.fsscript, 51 | self.preclean, 52 | self.rcupdate, 53 | self.unmerge, 54 | ]) 55 | self.finish_sequence.extend([ 56 | self.remove, 57 | self.groups, 58 | self.users, 59 | self.ssh_public_keys, 60 | self.empty, 61 | self.clean, 62 | ]) 63 | self.set_completion_action_sequences() 64 | -------------------------------------------------------------------------------- /catalyst/version.py: -------------------------------------------------------------------------------- 1 | '''Version information and/or git version information 2 | ''' 3 | 4 | import os 5 | 6 | from snakeoil.version import get_git_version as get_ver 7 | 8 | __version__ = "4.0.0" 9 | _ver = None 10 | 11 | 12 | def get_git_version(version=__version__): 13 | """Return: a string describing our version.""" 14 | # pylint: disable=global-statement 15 | global _ver 16 | cwd = os.path.dirname(os.path.abspath(__file__)) 17 | version_info = get_ver(cwd) 18 | 19 | if not version_info: 20 | s = "extended version info unavailable" 21 | elif version_info['tag'] == __version__: 22 | s = 'released %s' % (version_info['date'],) 23 | else: 24 | s = ('vcs version %s, date %s' % 25 | (version_info['rev'], version_info['date'])) 26 | 27 | _ver = 'Catalyst %s\n%s' % (version, s) 28 | 29 | return _ver 30 | 31 | 32 | def get_version(reset=False): 33 | '''Returns a saved release version string or the 34 | generated git release version. 35 | ''' 36 | # pylint: disable=global-statement 37 | global __version__, _ver 38 | if _ver and not reset: 39 | return _ver 40 | try: # getting the fixed version 41 | from .verinfo import version 42 | _ver = version 43 | __version__ = version.split('\n')[0].split()[1] 44 | except ImportError: # get the live version 45 | version = get_git_version() 46 | return version 47 | 48 | 49 | def set_release_version(version, root=None): 50 | '''Saves the release version along with the 51 | git log release information 52 | 53 | @param version: string 54 | @param root: string, optional alternate root path to save to 55 | ''' 56 | #global __version__ 57 | filename = "verinfo.py" 58 | if not root: 59 | path = os.path.join(os.path.dirname(__file__), filename) 60 | else: 61 | path = os.path.join(root, filename) 62 | #__version__ = version 63 | ver = get_git_version(version) 64 | with open(path, 'w') as f: 65 | f.write("version = {0!r}".format(ver)) 66 | -------------------------------------------------------------------------------- /diskimage/files/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gentoo/catalyst/4664d2c8ad34d9c703172fd3787da58f66029267/diskimage/files/.keep -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | subarches.generated.txt 2 | subarches.generated.xml 3 | targets.generated.txt 4 | targets.generated.xml 5 | -------------------------------------------------------------------------------- /doc/asciidoc.conf: -------------------------------------------------------------------------------- 1 | # 2 | # asciidoc.conf for catalyst's man page 3 | # 4 | -------------------------------------------------------------------------------- /doc/catalyst-config.5.txt: -------------------------------------------------------------------------------- 1 | CATALYST-CONFIG(5) 2 | ================ 3 | :man source: catalyst {catalystversion} 4 | :man manual: catalyst {catalystversion} 5 | 6 | 7 | NAME 8 | ---- 9 | catalyst-config - Catalyst configuration files 10 | 11 | 12 | SYNOPSIS 13 | -------- 14 | *catalyst* ['OPTIONS'] *-c* 'FILE' 15 | 16 | 17 | DESCRIPTION 18 | ----------- 19 | 20 | *catalyst(1)* reads the configuration file given with `-c` or 21 | `--config` on the command line. The file contains keyword-argument 22 | pairs using a POSIX Shell variable syntax. Lines starting with `#` 23 | and empty lines are interpreted as comments. For example: 24 | 25 | --------------------------------- 26 | # /etc/catalyst/catalyst.conf 27 | 28 | digests="auto" 29 | envscript="/etc/catalyst/catalystrc" 30 | options="autoresume bindist kerncache pkgcache seedcache" 31 | --------------------------------- 32 | 33 | The possible keywords and their meanings are as follows: 34 | 35 | Basic configuration 36 | ~~~~~~~~~~~~~~~~~~~ 37 | 38 | *digests*:: 39 | Create a `.DIGESTS` file containing the hash output from any of the 40 | supported options below. Adding them all may take a long time. 41 | (example: `md5 sha1 sha512 whirlpool`). Enabling ANY digest will 42 | generate `.sha256` file in addition `.DIGESTS` file. The set of 43 | supported hashes is dependent on the version of Python. To see the 44 | set of hashes supported by the version of Python in use, run 45 | + 46 | --------------------------------- 47 | $ python3 -c 'import hashlib; print(hashlib.algorithms_available)' 48 | --------------------------------- 49 | 50 | *envscript*:: 51 | Environment script location, which allows users to set options such as 52 | HTTP proxies, `GENTOO_MIRRORS`, or any other environment variables 53 | needed for building. The envscript file sets environment variables 54 | using POSIX shell notation: 55 | + 56 | --------------------------------- 57 | export FOO="bar" 58 | --------------------------------- 59 | 60 | *options*:: 61 | Set different build-time options (example: `autoresume bindist 62 | kerncache pkgcache seedcache`). Supported values: 63 | + 64 | -- 65 | autoresume:: 66 | Attempt to resume a failed build. Clear the autoresume flags with the 67 | `-a` option to the catalyst command line. `-p` will clear the 68 | autoresume flags as well as your pkgcache and kerncache. 69 | 70 | bindist:: 71 | Enable the `bindist` `USE` flag. This is recommended if you will be 72 | redistributing builds, but see the package specific definitions for 73 | details. 74 | 75 | ccache:: 76 | Enable build time ccache support. WARNING: ccache has been known to 77 | cause random build failures and bugs reported with ccache enabled may 78 | be closed invalid. 79 | 80 | distcc:: 81 | Enable distcc support for building. You have to set distcc_hosts in 82 | your config file. 83 | 84 | icecream:: 85 | Enable icecream compiler cluster support for building. 86 | 87 | kerncache:: 88 | Keep a copy of the built kernel and modules. This is useful if your 89 | build dies during `livecd-stage2`. 90 | 91 | pkgcache:: 92 | Enable `--usepkg` and `--buildpkg` for most *emerge(1)* runs. This is 93 | useful if your build dies prematurely. However, you may experience 94 | linking problems. See the *BINARY PACKAGE DEPENDENCIES* section for 95 | details. 96 | 97 | seedcache:: 98 | Use the build output of a previous target if it exists to speed up the 99 | creation of a new stage. This avoids unpacking the seed tarball. 100 | 101 | versioned_cache:: 102 | Name the cache directories (packagecache, kerncache) based on the version of a 103 | spec file. 104 | -- 105 | 106 | Repository settings 107 | ~~~~~~~~~~~~~~~~~~~ 108 | 109 | *distdir*:: 110 | Defines the location of your local source file repository. 111 | Defaults to the host's DISTDIR. 112 | 113 | *repos_storedir*:: 114 | The directory in which git repositories exist for use by the snapshot target. 115 | Defaults to `${storedir}/repos`. 116 | 117 | *repo_basedir*:: 118 | The target repository directory to contain the primary repo (e.g., 119 | gentoo repo) and any other repos. The default location is 120 | `/var/db/repos`. 121 | 122 | *repo_name*:: 123 | The name of the main repository (e.g. gentoo). The git repository at 124 | `${repos_storedir}/${repo_name}.git` will be used to produce the portdir sqfs 125 | snapshot. 126 | 127 | *target_distdir*:: 128 | Defines the location of the local source file repository in the 129 | target. This will be written to the target's make.conf if it is not 130 | the default value of `/var/cache/distfiles`. 131 | 132 | *target_pkgdir*:: 133 | Defines the location of binary packages in the target. This will be 134 | written to the target's make.conf if it is not the default value of 135 | `/var/cache/binpkgs`. 136 | 137 | Other settings 138 | ~~~~~~~~~~~~~~ 139 | 140 | *distcc_hosts*:: 141 | These are the hosts used as distcc slaves when distcc is enabled in 142 | your `catalyst.conf` (example: `127.0.0.1 192.168.0.1`). It follows 143 | the same syntax as `distcc-config --set-hosts`. 144 | 145 | *jobs*:: 146 | Integral value passed to *emerge(1)* as the parameter to --jobs and is 147 | used to define *MAKEOPTS* during the target build. 148 | 149 | *load-average*:: 150 | Floating-point value passed to *emerge(1)* as the parameter to 151 | --load-average and is used to define *MAKEOPTS* during the target 152 | build. 153 | 154 | *sharedir*:: 155 | Catalyst runtime script location. `/usr/share/catalyst` should work for 156 | most default installations. If you are running catalyst from a Git 157 | checkout, you should change this to point to your checkout directory. 158 | 159 | *storedir*:: 160 | Location for built seeds, temporary files, and caches (example: 161 | `/var/tmp/catalyst`). 162 | 163 | *port_logdir*:: 164 | Location for build logs (example: `/var/tmp/catalyst/tmp`). This dir 165 | will be automatically cleaned of all logs over 30 days old. If left 166 | undefined the logs will remain in the build directory as usual and get 167 | cleaned every time a stage build is restarted. 168 | 169 | *var_tmpfs_portage*:: 170 | Set the size of a `/var/tmp/portage` tmpfs in gigabytes (example: 171 | `16`). If set, this mounts a tmpfs for `/var/tmp/portage` so building 172 | takes place in RAM. This feature requires a pretty large tmpfs 173 | ({open,libre}office needs ~8GB to build). WARNING: If you use too 174 | much RAM everything will fail horribly and it is not our fault. 175 | 176 | 177 | BINARY PACKAGE DEPENDENCIES 178 | --------------------------- 179 | This section is only important if you are using binary packages to 180 | build your stages (by enabling the `pkgcache` option and restarting 181 | incomplete builds). 182 | 183 | Packages generated by catalyst builds are namespaced: 184 | 185 | If versioned_cache is set: 186 | --------------------------------- 187 | .../packages//--/Packages 188 | --------------------------------- 189 | Otherwise: 190 | --------------------------------- 191 | .../packages//-/Packages 192 | --------------------------------- 193 | 194 | 195 | FILES 196 | ----- 197 | An example configuration file can be found at 198 | `/etc/catalyst/catalyst.conf`. 199 | 200 | 201 | BUGS 202 | ---- 203 | An up-to-date list of Catalyst bugs can always be found listed on the Gentoo 204 | Linux bug-tracking system at `https://bugs.gentoo.org`. 205 | 206 | 207 | SEE ALSO 208 | -------- 209 | *catalyst(1)* 210 | *catalyst-spec(5)* 211 | -------------------------------------------------------------------------------- /doc/catalyst.1.txt: -------------------------------------------------------------------------------- 1 | CATALYST(1) 2 | =========== 3 | :man source: catalyst {catalystversion} 4 | :man manual: catalyst {catalystversion} 5 | 6 | 7 | NAME 8 | ---- 9 | catalyst - The Gentoo Linux Release Engineering meta-tool 10 | 11 | 12 | SYNOPSIS 13 | -------- 14 | *catalyst* ['OPTIONS'] [*-f* 'FILE' | *-C* 'KEY'='VALUE' ... | *-s* 'DATE'] 15 | 16 | 17 | DESCRIPTION 18 | ----------- 19 | *catalyst* is the tool that the Gentoo Release Engineering team 20 | utilizes to build all Gentoo Linux releases. It is capable of building 21 | installation stages, bootable LiveCDs, and netboot images. 22 | 23 | For more information, please visit the *catalyst* project page 24 | on the web at 'https://wiki.gentoo.org/wiki/Catalyst'. 25 | 26 | 27 | OPTIONS 28 | ------- 29 | *--clear-autoresume*:: 30 | *-a*:: 31 | This option is to be used to clear any autoresume points that have been saved 32 | for this target. It is used in conjunction with *-f*, *-C*, or both. 33 | 34 | *--config*|*-c* 'FILE':: 35 | Tell *catalyst* to use a user-defined configuration file. A sample 36 | configuration file is installed at '/etc/catalyst/catalyst.conf'. 37 | 38 | *--debug*:: 39 | *-d*:: 40 | Enable debugging mode 41 | 42 | *--enter-chroot*:: 43 | Enter the chroot before starting the build. 44 | 45 | *--fetchonly*:: 46 | *-F*:: 47 | This tells *catalyst* to only fetch distfiles for the given packages without 48 | performing any building. 49 | 50 | *--file*|*-f* 'FILE':: 51 | Tell *catalyst* to use the user supplied specfile. 52 | 53 | *--help*:: 54 | *-h*:: 55 | Print the help message and exit 56 | 57 | *--purge*:: 58 | *-p*:: 59 | Tell *catalyst* to clear all temporary directories, package caches, and 60 | autoresume flags for the given target. 61 | 62 | *--snapshot*|*-s* 'DATE':: 63 | Create a Portage snapshot using the specified identifier stamp. 64 | 65 | *--verbose*:: 66 | *-v*:: 67 | Enable verbose mode. 68 | 69 | *--version*:: 70 | *-V*:: 71 | Print the version information and exit 72 | 73 | 74 | EXAMPLES 75 | -------- 76 | Using the specfile option (*-f*, *--file*) to build a stage target: 77 | --------------------------------------------------- 78 | # catalyst -f stage1-specfile.spec 79 | --------------------------------------------------- 80 | 81 | Using the snapshot option (*-s*, *--snapshot*) to package a Portage snapshot 82 | using the datestamp 20051208: 83 | --------------------------------------------------- 84 | # catalyst -s 20051208 85 | --------------------------------------------------- 86 | 87 | 88 | FILES 89 | ----- 90 | Example specfiles can be found in '/usr/share/doc/catalyst-{catalystversion}/examples'. 91 | An example configuration file can be found at '/etc/catalyst/catalyst.conf'. 92 | 93 | 94 | SUPPORTED ARCHITECTURES 95 | ----------------------- 96 | The following table shows the list of supported architectures as well as 97 | the list of valid strings for key 'subarch'. 98 | 99 | include::subarches.generated.txt[tabsize=4] 100 | 101 | 102 | BUGS 103 | ---- 104 | An up-to-date list of Catalyst bugs can always be found listed on the Gentoo 105 | Linux bug-tracking system at 'https://bugs.gentoo.org'. 106 | 107 | 108 | NOTES 109 | ----- 110 | *catalyst* is conceptually derived from the Gentoo livecd-ng and Gentoo 111 | stager projects, both of which were used to create pre-1.4 Gentoo releases. 112 | 113 | *catalyst* was originally conceived and coded by both Daniel Robbins and 114 | John Davis. It is currently maintained by the Catalyst Project Team and 115 | has been mostly re-written. 116 | 117 | 118 | AUTHORS 119 | ------- 120 | - John Davis 121 | - Chris Gianelloni 122 | - Raul Porcel 123 | - Sebastian Pipping 124 | - Matt Turner 125 | 126 | 127 | SEE ALSO 128 | -------- 129 | *catalyst-config(5)* 130 | *catalyst-spec(5)* 131 | 132 | Also, a more in-depth examination of Catalyst options and procedures can be found 133 | linked from the *catalyst* project page, which is located at 134 | 'https://wiki.gentoo.org/wiki/Catalyst'. 135 | -------------------------------------------------------------------------------- /doc/make_subarch_table_guidexml.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Licensed under GPL v2 or later 3 | 4 | 5 | import pathlib 6 | import sys 7 | import textwrap 8 | import tomli 9 | 10 | 11 | def write_guidexml(arch_to_subarch): 12 | with open('doc/subarches.generated.xml', 'w') as f: 13 | f.write(textwrap.dedent("""\ 14 | 15 | 16 | 17 | 18 | 19 | """)) 20 | for arch, subarches in sorted(arch_to_subarch.items()): 21 | f.write(textwrap.dedent("""\ 22 | 23 | %s 24 | %s 25 | 26 | """) % (arch, '\n'.join(textwrap.wrap(' '.join(sorted(subarches)), 60)))) 27 | f.write("
ArchitectureSub-architectures
\n") 28 | 29 | 30 | def write_asciidoc(arch_to_subarch): 31 | with open('doc/subarches.generated.txt', 'w') as f: 32 | for arch, subarches in sorted(arch_to_subarch.items()): 33 | f.write('*%s*::\n' % arch) 34 | f.write(' %s\n' % ', '.join(sorted(subarches))) 35 | f.write('\n') 36 | 37 | 38 | def main(_argv): 39 | arch_to_subarch = {} 40 | p = pathlib.Path('arch') 41 | 42 | for file in p.glob('*.toml'): 43 | with file.open('rb') as f: 44 | data = tomli.load(f) 45 | 46 | for arch in [x for x in data if x != 'setarch']: 47 | arch_to_subarch.update({arch: list(data[arch].keys())}) 48 | 49 | write_guidexml(arch_to_subarch) 50 | write_asciidoc(arch_to_subarch) 51 | 52 | 53 | if __name__ == '__main__': 54 | main(sys.argv[1:]) 55 | -------------------------------------------------------------------------------- /doc/make_target_table.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (C) 2012 W. Trevor King 3 | # Copyright (C) 2012 Sebastian Pipping 4 | # Copyright (C) 2013 Brian dolbec 5 | # Licensed under GPL v2 or later 6 | 7 | # This script should be run from the root of the catalyst source. 8 | # source the testpath file then run "doc/make_target_table.py" 9 | 10 | 11 | import glob 12 | import locale 13 | import os 14 | import sys 15 | 16 | 17 | def main(_argv): 18 | source_root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) 19 | 20 | # Force consistent sorting order. 21 | locale.setlocale(locale.LC_COLLATE, 'C') 22 | 23 | targets = list() 24 | for filename in glob.glob(os.path.join(source_root, 'catalyst/targets/*.py')): 25 | if '__init__' in filename: 26 | continue 27 | 28 | name = os.path.basename(filename)[0:-3] 29 | target_name = name.replace('_', '-') 30 | module_name = 'catalyst.targets.' + name 31 | 32 | __import__(module_name) 33 | module = sys.modules[module_name] 34 | 35 | targets.append((target_name, module)) 36 | 37 | for target_name, module in sorted(targets, key=lambda x: x[0]): 38 | print('`%s`;;' % target_name) 39 | # Replace blank lines with `+` (asciidoc list item continuation) 40 | print(module.__doc__.strip().replace('\n\n', '\n+\n')) 41 | print('') 42 | 43 | 44 | if __name__ == '__main__': 45 | main(sys.argv[1:]) 46 | -------------------------------------------------------------------------------- /etc/catalyst.conf: -------------------------------------------------------------------------------- 1 | # /etc/catalyst/catalyst.conf 2 | 3 | # Simple descriptions of catalyst settings. Please refer to the online 4 | # documentation for more information. 5 | 6 | # Creates a .DIGESTS file containing the hash output from each of the selected 7 | # hashes. 8 | # 9 | # To see a list of supported hashes, run 10 | # 11 | # $ python3 -c 'import hashlib; print(hashlib.algorithms_available)' 12 | # 13 | digests = ["blake2b", "sha512"] 14 | 15 | # envscript allows users to set options such as http proxies, MAKEOPTS, 16 | # GENTOO_MIRRORS, or any other environment variables needed for building. 17 | # The envscript file sets environment variables like so: 18 | # export FOO="bar" 19 | envscript = "/etc/catalyst/catalystrc" 20 | 21 | # options set different build-time options for catalyst. 22 | options = [ 23 | # Attempt to resume a failed build, clear the autoresume flags with the 24 | # -a option to the catalyst cmdline. -p will clear the autoresume 25 | # flags as well as your pkgcache and kerncache 26 | "autoresume", 27 | 28 | # Enables the bindist USE flag, please see package specific definition, 29 | # however, it is suggested to enable this if redistributing builds. 30 | # This optional USE flag is normally cleaned from the make.conf file on 31 | # completion of the stage. For a non-cleaned version, use 32 | # sticky-config also (see below) 33 | "bindist", 34 | 35 | # Enable FEATURES=ccache 36 | # "ccache", 37 | 38 | # Enable FEATURES=distcc. Make sure to set distcc_hosts too. 39 | # "distcc", 40 | 41 | # Enable FEATURES=icecream 42 | # "icecream", 43 | 44 | # Prevents the removal of the working chroot path and any autoresume 45 | # files or points. 46 | # "keepwork", 47 | 48 | # keeps a tbz2 of your built kernel and modules (useful if your 49 | # build stops in livecd-stage2) 50 | "kerncache", 51 | 52 | # Build and use binary packages 53 | "pkgcache", 54 | 55 | # Use the build output of a previous target if it exists rather than 56 | # the tarball 57 | "seedcache", 58 | 59 | # enables the code that will keep any internal 'catalyst_use' flags 60 | # added to the USE= for building the stage. These are usually added 61 | # for legal or specific needs in building the the early stage. Mostly 62 | # it is the 'bindist' USE flag option that is used for legal reasons, 63 | # please see its specific definition. It will also keep any 64 | # /etc/portage/package.* files or directories. 65 | # "sticky-config", 66 | ] 67 | 68 | # port_logdir is where all build logs will be kept. This dir will be automatically cleaned 69 | # of ALL files over 7 days old. If left undefined the logs will remain in the build directory 70 | # as usual and get cleaned every time a stage build is restarted. 71 | # port_logdir = "/var/tmp/catalyst/logs" 72 | 73 | # var_tmpfs_portage will mount a tmpfs for /var/tmp/portage so building takes place in RAM 74 | # this feature requires a pretty large tmpfs ({open,libre}office needs ~8GB to build) 75 | # WARNING: If you use too much RAM everything will fail horribly and it is not our fault. 76 | # set size of /var/tmp/portage tmpfs in gigabytes 77 | # var_tmpfs_portage = 16 78 | 79 | # Integral value passed to emerge as the parameter to --jobs and is used to 80 | # define MAKEOPTS during the target build. 81 | # jobs = 4 82 | 83 | # Floating-point value passed to emerge as the parameter to --load-average and 84 | # is used to define MAKEOPTS during the target build. 85 | # load-average = 4.0 86 | 87 | # If you want catalyst to drop a binrepos.conf into /etc/portage, then 88 | # define the binhost here. This value is concatenated with the configuration 89 | # option binrepo_path in the spec file to obtain the src-uri. 90 | # binhost = "https://gentoo.osuosl.org/releases/" 91 | -------------------------------------------------------------------------------- /etc/catalystrc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # export BINPKG_COMPRESS="gzip" 4 | # export BINPKG_COMPRESS_FLAGS="-7" 5 | -------------------------------------------------------------------------------- /examples/README: -------------------------------------------------------------------------------- 1 | For further examples, see the releases/weekly/specs directory [1] in 2 | the releng Git repository [2]. 3 | 4 | [1]: https://gitweb.gentoo.org/proj/releng.git/tree/releases/weekly/specs 5 | [2]: https://gitweb.gentoo.org/proj/releng.git 6 | -------------------------------------------------------------------------------- /examples/fsscript.sh.example: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This is an example fsscript for use with the livecd-stage2 target (key 4 | # livecd/fsscript). This file is copied into the rootfs of the CD after the 5 | # kernel(s) and any external modules have been compiled and is then executed 6 | # within the context of the chroot. 7 | 8 | # Example, I want to add specific nameservers to the CD's resolv.conf: 9 | echo "192.168.0.1" >> /etc/resolv.conf 10 | -------------------------------------------------------------------------------- /examples/generic_stage_template.spec: -------------------------------------------------------------------------------- 1 | # generic installation stage specfile 2 | # used to build a stage1, stage2, or stage3 installation tarball 3 | 4 | # The subarch can be any of the supported catalyst subarches (like athlon-xp). 5 | # Refer to "man catalyst" or 6 | # for supported subarches 7 | # example: 8 | # subarch: athlon-xp 9 | subarch: 10 | 11 | # The version stamp is an identifier for the build. It can be anything you wish 12 | # it to be, but it is usually a date. 13 | # example: 14 | # version_stamp: 2006.1 15 | version_stamp: 16 | 17 | # The target specifies what target we want catalyst to do. For stages, the 18 | # supported targets are: stage1 stage2 stage3 19 | # example: 20 | # target: stage2 21 | target: 22 | 23 | # The rel_type defines what kind of build we are doing. This is merely another 24 | # identifier, but it useful for allowing multiple concurrent builds. Usually, 25 | # default will suffice. 26 | # example: 27 | # rel_type: default 28 | rel_type: 29 | 30 | # This is the system profile to be used by catalyst to build this target. It is 31 | # specified as a relative path from /var/db/repos/gentoo/profiles. 32 | # example: 33 | # profile: default-linux/x86/2006.1 34 | profile: 35 | 36 | # This specifies which snapshot to use for building this target. 37 | # example: 38 | # snapshot: 2006.1.tar.bz2 39 | snapshot: 40 | 41 | # This specifies where the seed stage comes from for this target, The path is 42 | # relative to $clst_sharedir/builds. The rel_type is also used as a path prefix 43 | # for the seed. It must be a complete filename including the extension. 44 | # example: 45 | # default/stage3-x86-2006.1.tar.bz2 46 | source_subpath: 47 | 48 | # The prefered compression/decompression command and algorithm to use 49 | # for creating the final stage tarballs. For decompression the configured 50 | # method will be used if the file's extension is one of it's types listed. 51 | # Otherwise it will pick one that does. Of course you must ensure to have 52 | # the correct package installed that supplies that command/algorithm type. 53 | # available options are: 54 | # Name Compressor Extension 55 | # "rsync" : None 56 | # "lbzip2" : tar.bz2 57 | # "bzip2" : tar.bz2 58 | # "tar" : tar 59 | # "xz" : tar.xz 60 | # "pixz" : tar.xz 61 | # "gzip" : tar.gz 62 | # "squashfs" : squashfs, sfs 63 | # 64 | compression_mode: lbzip2 65 | 66 | # Optional arch specification which applies only to the squashfs commpression modes 67 | # default is None 68 | compressor_arch": 69 | 70 | # Optional compressor options to add to the compression command 71 | # Defaults to a predetermined set of xattribute options 72 | # To disable the defaults uncomment the following line 73 | #compressor_options": None 74 | # Or to specify your own (overrides the defaults) 75 | # uncomment this next line and add your own options. 76 | #compressor_options": 77 | 78 | # The search order to use for determining the decompressor 79 | # to use on the source file. i.e. check the extensions it is capable of 80 | # decompressing to find a match. Use the list above for the modes available. 81 | #Note: rsync is a special case, do not include it below. 82 | # 83 | decompressor_search_order: lbzip2 bzip2 tar pixz xz gzip squashfs 84 | 85 | # This is an optional directory containing portage configuration files. It 86 | # follows the same syntax as /etc/portage and should be consistent across all 87 | # targets to minimize problems. 88 | # example: 89 | # portage_confdir: /etc/portage 90 | portage_confdir: 91 | 92 | # This option specifies the location of the ebuild repositories that you would 93 | # like to have used when building this target. It takes a space-separated list 94 | # of directory names. 95 | # example: 96 | # repos: /usr/local/portage 97 | repos: 98 | 99 | # This option specifies the names of ebuild repositories that you would like to 100 | # leave configured in the resulting build. It takes a space-separated list of 101 | # names. This only affects the configuration; the contents are never kept. 102 | # example: 103 | # keep_repos: kde qt 104 | keep_repos: 105 | 106 | # This allows the optional directory containing the output packages for 107 | # catalyst. Mainly used as a way for different spec files to access the same 108 | # cache directory. Default behavior is for this location to be autogenerated 109 | # by catalyst based on the spec file. 110 | # example: 111 | # pkgcache_path: /tmp/packages 112 | pkgcache_path: 113 | 114 | # These options are only available when building a stage1 or stage2 target and 115 | # are all optional. These allow for emulating the changes possible during ai 116 | # bootstrap. Some possible uses of these would be building embedded stages 117 | # requiring a different CHOST or building a stage2 with NPTL support from a 118 | # stage1 tarball that is built without it. 119 | # If left blank, then the catalyst defaults from arch.py are used. 120 | 121 | # This option is used to change the CHOST from what is default in the profile 122 | # to whatever you specify. This is useful for building NPTL, for example. 123 | # example: 124 | # chost: i686-pc-linux-gnu 125 | chost: 126 | 127 | # This option allows you to change the default CFLAGS that will be used in 128 | # building this stage. This really should remain generic, as putting 129 | # optimizations flags here will build a stage1 tarball that is no longer 130 | # generic. 131 | # example: 132 | # cflags: -Os -pipe -fomit-frame-pointer -mcpu=i686 133 | cflags: 134 | 135 | # This is for setting the CXXFLAGS. Generally, this would be set to the same 136 | # as CFLAGS. In fact, it will mirror CFLAGS by default. 137 | # example: 138 | # cxxflags: -Os -pipe -fomit-frame-pointer -mcpu=i686 139 | cxxflags: 140 | 141 | # Setting this option sets LDFLAGS in make.conf in your stage. This would be 142 | # useful for setting up an embedded or hardened system. 143 | # example: 144 | # ldflags: -Wl,-O1 -Wl,-z,now 145 | ldflags: 146 | -------------------------------------------------------------------------------- /examples/livecd-stage1_template.spec: -------------------------------------------------------------------------------- 1 | # livecd-stage1 example specfile 2 | # used to build a livecd-stage1 3 | 4 | # The subarch can be any of the supported catalyst subarches (like athlon-xp). 5 | # Refer to "man catalyst" or 6 | # for supported subarches 7 | # example: 8 | # subarch: athlon-xp 9 | subarch: 10 | 11 | # The version stamp is an identifier for the build. It can be anything you wish 12 | # it to be, but it is usually a date. 13 | # example: 14 | # version_stamp: 2006.1 15 | version_stamp: 16 | 17 | # The target specifies what target we want catalyst to do. For building a CD, 18 | # we start with livecd-stage1 as our target. 19 | # example: 20 | # target: livecd-stage1 21 | target: 22 | 23 | # The rel_type defines what kind of build we are doing. This is merely another 24 | # identifier, but it useful for allowing multiple concurrent builds. Usually, 25 | # default will suffice. 26 | # example: 27 | # rel_type: default 28 | rel_type: 29 | 30 | # This is the system profile to be used by catalyst to build this target. It is 31 | # specified as a relative path from /var/db/repos/gentoo/profiles. 32 | # example: 33 | # profile: default-linux/x86/2006.1 34 | profile: 35 | 36 | # This specifies which snapshot to use for building this target. 37 | # example: 38 | # snapshot: 2006.1 39 | snapshot: 40 | 41 | # This specifies where the seed stage comes from for this target, The path is 42 | # relative to $clst_sharedir/builds. The rel_type is also used as a path prefix 43 | # for the seed. 44 | # example: 45 | # default/stage3-x86-2006.1 46 | source_subpath: 47 | 48 | # This is an optional directory containing portage configuration files. It 49 | # follows the same syntax as /etc/portage and should be consistent across all 50 | # targets to minimize problems. 51 | # example: 52 | # portage_confdir: /etc/portage 53 | portage_confdir: 54 | 55 | # This option specifies the location of the ebuild repositories that you would 56 | # like to have used when building this target. It takes a space-separated list 57 | # of directory names. 58 | # example: 59 | # repos: /usr/local/portage 60 | repos: 61 | 62 | # This option specifies the names of ebuild repositories that you would like to 63 | # leave configured in the resulting build. It takes a space-separated list of 64 | # names. This only affects the configuration; the contents are never kept. 65 | # example: 66 | # keep_repos: kde qt 67 | keep_repos: 68 | 69 | # This allows the optional directory containing the output packages for 70 | # catalyst. Mainly used as a way for different spec files to access the same 71 | # cache directory. Default behavior is for this location to be autogenerated 72 | # by catalyst based on the spec file. 73 | # example: 74 | # pkgcache_path: /tmp/packages 75 | pkgcache_path: 76 | 77 | # The livecd-stage1 target is where you will build packages for your CD. These 78 | # packages can be built with customized USE settings. The settings here are 79 | # additive to the default USE configured by the profile. For building release 80 | # media, the first thing we do is disable all default USE flags with -* and then 81 | # begin to set our own. 82 | # example: 83 | # livecd/use: -* ipv6 socks5 livecd fbcon ncurses readline ssl 84 | livecd/use: 85 | 86 | # This is the set of packages that we will merge into the CD's filesystem. They 87 | # will be built with the USE flags configured above. These packages must not 88 | # depend on a configured kernel. If the package requires a configured kernel, 89 | # then it will be defined elsewhere. 90 | # example: 91 | # livecd/packages: livecd-tools dhcpcd acpid apmd gentoo-sources coldplug fxload irssi gpm syslog-ng parted links raidtools dosfstools nfs-utils jfsutils xfsprogs e2fsprogs reiserfsprogs ntfsprogs pwgen rp-pppoe screen mirrorselect penggy iputils hwdata-knoppix hwsetup lvm2 evms vim pptpclient mdadm ethtool wireless-tools prism54-firmware wpa_supplicant 92 | livecd/packages: 93 | -------------------------------------------------------------------------------- /examples/netboot_template.spec: -------------------------------------------------------------------------------- 1 | subarch: mips3 2 | version_stamp: 2006.0 3 | target: netboot 4 | rel_type: default 5 | profile: uclibc/mips 6 | snapshot: 20060107 7 | source_subpath: default/stage3-mips-uclibc-mips3-2006.126 8 | 9 | # This option specifies the location of the ebuild repositories that you would 10 | # like to have used when building this target. It takes a space-separated list 11 | # of directory names. 12 | # example: 13 | # repos: /usr/local/portage 14 | repos: 15 | 16 | boot/kernel: ip22r4k ip22r5k ip27r10k ip28r10k ip30r10k ip32r5k 17 | boot/kernel/ip22r4k/sources: =mips-sources-2.6.14.5 18 | boot/kernel/ip22r5k/sources: =mips-sources-2.6.14.5 19 | boot/kernel/ip27r10k/sources: =mips-sources-2.6.14.5 20 | boot/kernel/ip28r10k/sources: =mips-sources-2.6.14.5 21 | boot/kernel/ip30r10k/sources: =mips-sources-2.6.14.5 22 | boot/kernel/ip32r5k/sources: =mips-sources-2.6.14.5 23 | 24 | boot/kernel/ip22r4k/config: /usr/share/genkernel/mips/ip22r4k-2006_0.cf 25 | boot/kernel/ip22r5k/config: /usr/share/genkernel/mips/ip22r5k-2006_0.cf 26 | boot/kernel/ip27r10k/config: /usr/share/genkernel/mips/ip27r10k-2006_0.cf 27 | boot/kernel/ip28r10k/config: /usr/share/genkernel/mips/ip28r10k-2006_0.cf 28 | boot/kernel/ip30r10k/config: /usr/share/genkernel/mips/ip30r10k-2006_0.cf 29 | boot/kernel/ip32r5k/config: /usr/share/genkernel/mips/ip32r5k-2006_0.cf 30 | 31 | boot/kernel/ip22r4k/use: -doc 32 | boot/kernel/ip22r5k/use: -doc 33 | boot/kernel/ip27r10k/use: -doc ip27 34 | boot/kernel/ip28r10k/use: -doc ip28 35 | boot/kernel/ip30r10k/use: -doc ip30 36 | boot/kernel/ip32r5k/use: -doc 37 | 38 | boot/kernel/ip22r4k/gk_kernargs: --kernel-cross-compile=mips-unknown-linux-gnu- --makeopts=-j2 39 | boot/kernel/ip22r5k/gk_kernargs: --kernel-cross-compile=mips-unknown-linux-gnu- --makeopts=-j2 40 | boot/kernel/ip27r10k/gk_kernargs: --kernel-cross-compile=mips64-unknown-linux-gnu- --makeopts=-j2 41 | boot/kernel/ip28r10k/gk_kernargs: --kernel-cross-compile=mips64-unknown-linux-gnu- --makeopts=-j2 42 | boot/kernel/ip30r10k/gk_kernargs: --kernel-cross-compile=mips64-unknown-linux-gnu- --makeopts=-j2 43 | boot/kernel/ip32r5k/gk_kernargs: --kernel-cross-compile=mips64-unknown-linux-gnu- --makeopts=-j2 44 | 45 | netboot/builddate: 20060107 46 | netboot/busybox_config: /usr/share/genkernel/mips/nb-busybox.cf 47 | 48 | netboot/use: 49 | -* 50 | multicall 51 | readline 52 | ssl 53 | 54 | netboot/packages: 55 | com_err 56 | dropbear 57 | dvhtool 58 | e2fsprogs 59 | gcc-mips64 60 | jfsutils 61 | mdadm 62 | nano 63 | ncurses 64 | openssl 65 | popt 66 | portmap 67 | reiserfsprogs 68 | rsync 69 | sdparm 70 | ss 71 | ttcp 72 | uclibc 73 | util-linux 74 | wget 75 | xfsprogs 76 | 77 | netboot/packages/com_err/files: 78 | /lib/libcom_err.so 79 | /lib/libcom_err.so.2 80 | /lib/libcom_err.so.2.1 81 | /usr/bin/compile_et 82 | /usr/lib/libcom_err.so 83 | 84 | netboot/packages/dropbear/files: 85 | /usr/bin/dbclient 86 | /usr/bin/dbscp 87 | /usr/bin/dropbearconvert 88 | /usr/bin/dropbearkey 89 | /usr/bin/dropbearmulti 90 | /usr/sbin/dropbear 91 | 92 | netboot/packages/dvhtool/files: 93 | /usr/sbin/dvhtool 94 | 95 | netboot/packages/e2fsprogs/files: 96 | /bin/chattr 97 | /bin/lsattr 98 | /bin/uuidgen 99 | /lib/libblkid.so 100 | /lib/libblkid.so.1 101 | /lib/libblkid.so.1.0 102 | /lib/libe2p.so 103 | /lib/libe2p.so.2 104 | /lib/libe2p.so.2.3 105 | /lib/libext2fs.so 106 | /lib/libext2fs.so.2 107 | /lib/libext2fs.so.2.4 108 | /lib/libuuid.so 109 | /lib/libuuid.so.1 110 | /lib/libuuid.so.1.2 111 | /sbin/badblocks 112 | /sbin/blkid 113 | /sbin/debugfs 114 | /sbin/dumpe2fs 115 | /sbin/e2fsck 116 | /sbin/e2image 117 | /sbin/e2label 118 | /sbin/filefrag 119 | /sbin/findfs 120 | /sbin/fsck 121 | /sbin/fsck.ext2 122 | /sbin/fsck.ext3 123 | /sbin/logsave 124 | /sbin/mke2fs 125 | /sbin/mkfs.ext2 126 | /sbin/mkfs.ext3 127 | /sbin/resize2fs 128 | /sbin/tune2fs 129 | /usr/lib/e2initrd_helper 130 | /usr/lib/libblkid.so 131 | /usr/lib/libe2p.so 132 | /usr/lib/libext2fs.so 133 | /usr/lib/libuuid.so 134 | /usr/sbin/mklost+found 135 | 136 | netboot/packages/jfsutils/files: 137 | /sbin/fsck.jfs 138 | /sbin/jfs_fsck 139 | /sbin/jfs_mkfs 140 | /sbin/jfs_tune 141 | /sbin/mkfs.jfs 142 | 143 | netboot/packages/mdadm/files: 144 | /etc/mdadm.conf 145 | /sbin/mdadm 146 | 147 | netboot/packages/nano/files: 148 | /bin/nano 149 | /bin/rnano 150 | /usr/bin/nano 151 | 152 | netboot/packages/ncurses/files: 153 | /etc/terminfo 154 | /lib/libcurses.so 155 | /lib/libncurses.so 156 | /lib/libncurses.so.5 157 | /lib/libncurses.so.5.4 158 | /usr/bin/toe 159 | /usr/lib/libcurses.so 160 | /usr/lib/libform.so 161 | /usr/lib/libform.so.5 162 | /usr/lib/libform.so.5.4 163 | /usr/lib/libmenu.so 164 | /usr/lib/libmenu.so.5 165 | /usr/lib/libmenu.so.5.4 166 | /usr/lib/libncurses.so 167 | /usr/lib/libpanel.so 168 | /usr/lib/libpanel.so.5 169 | /usr/lib/libpanel.so.5.4 170 | /usr/lib/terminfo 171 | /usr/share/tabset/std 172 | /usr/share/tabset/stdcrt 173 | /usr/share/tabset/vt100 174 | /usr/share/tabset/vt300 175 | /usr/share/terminfo/a/ansi 176 | /usr/share/terminfo/d/dumb 177 | /usr/share/terminfo/e/eterm 178 | /usr/share/terminfo/l/linux 179 | /usr/share/terminfo/r/rxvt 180 | /usr/share/terminfo/s/screen 181 | /usr/share/terminfo/s/sun 182 | /usr/share/terminfo/v/vt100 183 | /usr/share/terminfo/v/vt102 184 | /usr/share/terminfo/v/vt200 185 | /usr/share/terminfo/v/vt220 186 | /usr/share/terminfo/v/vt52 187 | /usr/share/terminfo/x/xterm 188 | /usr/share/terminfo/x/xterm-color 189 | /usr/share/terminfo/x/xterm-xfree86 190 | 191 | netboot/packages/openssl/files: 192 | /usr/lib/libcrypto.so 193 | /usr/lib/libcrypto.so.0 194 | /usr/lib/libcrypto.so.0.9.7 195 | /usr/lib/libssl.so 196 | /usr/lib/libssl.so.0 197 | /usr/lib/libssl.so.0.9.7 198 | 199 | netboot/packages/popt/files: 200 | /usr/lib/libpopt.so 201 | /usr/lib/libpopt.so.0 202 | /usr/lib/libpopt.so.0.0.0 203 | 204 | netboot/packages/portmap/files: 205 | /sbin/portmap 206 | 207 | netboot/packages/reiserfsprogs/files: 208 | /sbin/fsck.reiserfs 209 | /sbin/mkfs.reiserfs 210 | /sbin/mkreiserfs 211 | /sbin/reiserfsck 212 | /sbin/reiserfstune 213 | 214 | netboot/packages/rsync/files: 215 | /usr/bin/rsync 216 | 217 | netboot/packages/sdparm/files: 218 | /usr/bin/sdparm 219 | 220 | netboot/packages/ss/files: 221 | /lib/libss.so 222 | /lib/libss.so.2 223 | /lib/libss.so.2.0 224 | /usr/bin/mk_cmds 225 | /usr/lib/libss.so 226 | 227 | netboot/packages/ttcp/files: 228 | /usr/bin/ttcp 229 | 230 | netboot/packages/uclibc/files: 231 | /etc/ld.so.cache 232 | /lib/ld-uClibc-0.9.27.so 233 | /lib/ld-uClibc.so.0 234 | /lib/libc.so.0 235 | /lib/libcrypt-0.9.27.so 236 | /lib/libcrypt.so.0 237 | /lib/libdl-0.9.27.so 238 | /lib/libdl.so.0 239 | /lib/libm-0.9.27.so 240 | /lib/libm.so.0 241 | /lib/libnsl-0.9.27.so 242 | /lib/libnsl.so.0 243 | /lib/libpthread-0.9.27.so 244 | /lib/libpthread.so.0 245 | /lib/libresolv-0.9.27.so 246 | /lib/libresolv.so.0 247 | /lib/librt-0.9.27.so 248 | /lib/librt.so.0 249 | /lib/libthread_db-0.9.27.so 250 | /lib/libthread_db.so.1 251 | /lib/libuClibc-0.9.27.so 252 | /lib/libutil-0.9.27.so 253 | /lib/libutil.so.0 254 | /sbin/ldconfig 255 | /usr/bin/getent 256 | /usr/bin/ldd 257 | /usr/lib/Scrt1.o 258 | /usr/lib/crt0.o 259 | /usr/lib/crt1.o 260 | /usr/lib/crti.o 261 | /usr/lib/crtn.o 262 | /usr/lib/libc.so 263 | /usr/lib/libcrypt.so 264 | /usr/lib/libdl.so 265 | /usr/lib/libm.so 266 | /usr/lib/libnsl.so 267 | /usr/lib/libpthread.so 268 | /usr/lib/libresolv.so 269 | /usr/lib/librt.so 270 | /usr/lib/libthread_db.so 271 | /usr/lib/libutil.so 272 | 273 | netboot/packages/util-linux/files: 274 | /sbin/fdisk 275 | /sbin/mkfs 276 | /sbin/mkswap 277 | /sbin/swapoff 278 | /sbin/swapon 279 | /usr/bin/ddate 280 | /usr/bin/setterm 281 | /usr/bin/whereis 282 | 283 | netboot/packages/wget/files: 284 | /usr/bin/wget 285 | 286 | netboot/packages/xfsprogs/files: 287 | /bin/xfs_copy 288 | /bin/xfs_growfs 289 | /bin/xfs_info 290 | /lib/libhandle.so 291 | /lib/libhandle.so.1 292 | /lib/libhandle.so.1.0.3 293 | /sbin/fsck.xfs 294 | /sbin/mkfs.xfs 295 | /sbin/xfs_repair 296 | 297 | # Setting the option overrides the location of the pkgcache 298 | pkgcache_path: 299 | 300 | # Setting the option overrides the location of the kerncache 301 | kerncache_path: 302 | 303 | -------------------------------------------------------------------------------- /examples/snapshot_template.spec: -------------------------------------------------------------------------------- 1 | # portage snapshot example specfile 2 | 3 | # This is the target for creating a snapshot. 4 | # example: 5 | # target: snapshot 6 | target: 7 | 8 | # The version stamp is an identifier for the build. It can be anything you wish 9 | # it to be, but it is usually a date. 10 | # example: 11 | # version_stamp: 2006.1 12 | version_stamp: 13 | -------------------------------------------------------------------------------- /files/.gitignore: -------------------------------------------------------------------------------- 1 | catalyst.1 2 | catalyst-config.5 3 | catalyst-spec.5 4 | *.html 5 | *.css 6 | -------------------------------------------------------------------------------- /livecd/cdtar/aboot-1.0_pre20040408-r2-cdtar.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gentoo/catalyst/4664d2c8ad34d9c703172fd3787da58f66029267/livecd/cdtar/aboot-1.0_pre20040408-r2-cdtar.tar.bz2 -------------------------------------------------------------------------------- /livecd/cdtar/arcload-0.43-r1.tbz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gentoo/catalyst/4664d2c8ad34d9c703172fd3787da58f66029267/livecd/cdtar/arcload-0.43-r1.tbz2 -------------------------------------------------------------------------------- /livecd/cdtar/isolinux-elilo-memtest86+-cdtar.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gentoo/catalyst/4664d2c8ad34d9c703172fd3787da58f66029267/livecd/cdtar/isolinux-elilo-memtest86+-cdtar.tar.bz2 -------------------------------------------------------------------------------- /livecd/files/README.txt: -------------------------------------------------------------------------------- 1 | 2 | This lists the possible command line options that can be used to tweak the boot 3 | process of this CD. This lists the Gentoo-specific options, along with a few 4 | options that are built-in to the kernel, but that have been proven very useful 5 | to our users. Also, all options that start with "do" have a "no" inverse, that 6 | does the opposite. For example, "doscsi" enables SCSI support in the initial 7 | ramdisk boot, while "noscsi" disables it. 8 | 9 | 10 | Hardware options: 11 | acpi=on This loads support for ACPI and also causes the acpid daemon to 12 | be started by the CD on boot. This is only needed if your 13 | system requires ACPI to function properly. This is not 14 | required for Hyperthreading support. 15 | acpi=off Completely disables ACPI. This is useful on some older systems 16 | and is also a requirement for using APM. This will disable any 17 | Hyperthreading support of your processor. 18 | console=X This sets up serial console access for the CD. The first 19 | option is the device, usually ttyS0 on x86, followed by any 20 | connection options, which are comma separated. The default 21 | options are 9600,8,n,1. 22 | dmraid=X This allows for passing options to the device-mapper RAID 23 | subsystem. Options should be encapsulated in quotes. 24 | doapm This loads APM driver support. This requires you to also use 25 | acpi=off. 26 | dopcmcia This loads support for PCMCIA and Cardbus hardware and also 27 | causes the pcmcia cardmgr to be started by the CD on boot. 28 | This is only required when booting from PCMCIA/Cardbus devices. 29 | doscsi This loads support for most SCSI controllers. This is also a 30 | requirement for booting most USB devices, as they use the SCSI 31 | subsystem of the kernel. 32 | hda=stroke This allows you to partition the whole hard disk even when your 33 | BIOS is unable to handle large disks. This option is only used 34 | on machines with an older BIOS. Replace hda with the device 35 | that is requiring this option. 36 | ide=nodma This forces the disabling of DMA in the kernel and is required 37 | by some IDE chipsets and also by some CDROM drives. If your 38 | system is having trouble reading from your IDE CDROM, try this 39 | option. This also disables the default hdparm settings from 40 | being executed. 41 | noapic This disables the Advanced Programmable Interrupt Controller 42 | that is present on newer motherboards. It has been known to 43 | cause some problems on older hardware. 44 | nodetect This disables all of the autodetection done by the CD, 45 | including device autodetection and DHCP probing. This is 46 | useful for doing debugging of a failing CD or driver. 47 | nodhcp This disables DHCP probing on detected network cards. This is 48 | useful on networks with only static addresses. 49 | nodmraid Disables support for device-mapper RAID, such as that used for 50 | on-board IDE/SATA RAID controllers. 51 | nofirewire This disables the loading of Firewire modules. This should 52 | only be necessary if your Firewire hardware is causing 53 | a problem with booting the CD. 54 | nogpm This diables gpm console mouse support. 55 | nohotplug This disables the loading of the hotplug and coldplug init 56 | scripts at boot. This is useful for doing debugging of a 57 | failing CD or driver. 58 | nokeymap This disables the keymap selection used to select non-US 59 | keyboard layouts. 60 | nolapic This disables the local APIC on Uniprocessor kernels. 61 | nosata This disables the loading of Serial ATA modules. This is used 62 | if your system is having problems with the SATA subsystem. 63 | nosmp This disables SMP, or Symmetric Multiprocessing, on SMP-enabled 64 | kernels. This is useful for debugging SMP-related issues with 65 | certain drivers and motherboards. 66 | nosound This disables sound support and volume setting. This is useful 67 | for systems where sound support causes problems. 68 | nousb This disables the autoloading of USB modules. This is useful 69 | for debugging USB issues. 70 | slowusb This adds some extra pauses into the boot process for slow 71 | USB CDROMs, like in the IBM BladeCenter. 72 | Volume/Device Management: 73 | doevms This enables support for IBM's pluggable EVMS, or Enterprise 74 | Volume Management System. This is not safe to use with lvm2. 75 | dolvm This enables support for Linux's Logical Volume Management. 76 | This is not safe to use with evms2. 77 | Screen reader access: 78 | speakup.synth=synth starts speakup using a given synthesizer. 79 | supported synths are acntpc, acntsa, apollo, audptr, bns, 80 | decext, dectlk, dtlk, keypc, ltlk, spkout and txprt. 81 | Also, soft is supported for software speech and dummy is 82 | supported for testing. 83 | speakup.quiet=1 sets the synthesizer not to speak until a key is pressed. 84 | speakup_SYNTH.port=n sets the port for internal synthesizers. 85 | speakup_SYNTH.ser=n sets the serial port for external synthesizers. 86 | Other options: 87 | debug Enables debugging code. This might get messy, as it displays 88 | a lot of data to the screen. 89 | docache This caches the entire runtime portion of the CD into RAM, 90 | which allows you to umount /mnt/cdrom and mount another CDROM. 91 | This option requires that you have at least twice as much 92 | available RAM as the size of the CD. 93 | doload=X This causes the initial ramdisk to load any module listed, as 94 | well as dependencies. Replace X with the module name. 95 | Multiple modules can be specified by a comma-separated list. 96 | dosshd Starts sshd on boot, which is useful for unattended installs. 97 | passwd=foo Sets whatever follows the equals as the root password, which 98 | is required for dosshd since we scramble the root password. 99 | noload=X This causes the initial ramdisk to skip the loading of a 100 | specific module that may be causing a problem. Syntax matches 101 | that of doload. 102 | nogui This causes an X-enabled LiveCD to not automatically start X, 103 | but rather, to drop to the command line instead. 104 | nonfs Disables the starting of portmap/nfsmount on boot. 105 | scandelay This causes the CD to pause for 10 seconds during certain 106 | portions the boot process to allow for devices that are slow to 107 | initialize to be ready for use. 108 | scandelay=X This allows you to specify a given delay, in seconds, to be 109 | added to certain portions of the boot process to allow for 110 | devices that are slow to initialize to be ready for use. 111 | Replace X with the number of seconds to pause. 112 | -------------------------------------------------------------------------------- /livecd/files/generic.motd.txt: -------------------------------------------------------------------------------- 1 | ##GREETING 2 | 3 | The root password on this system has been auto-scrambled for security. 4 | 5 | If any ethernet adapters were detected at boot, they should be auto-configured 6 | if DHCP is available on your network. Type "net-setup eth0" to specify eth0 IP 7 | address settings by hand. 8 | 9 | Check /etc/kernels/kernel-config-* for kernel configuration(s). 10 | -------------------------------------------------------------------------------- /livecd/files/livecd-bash_profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #This file is sourced by bash when you log in interactively. 4 | [[ -f ~/.bashrc ]] && source ~/.bashrc 5 | -------------------------------------------------------------------------------- /livecd/files/livecd-bashrc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | -------------------------------------------------------------------------------- /livecd/files/livecd-local.start: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # /etc/conf.d/local.start 3 | 4 | # This is a good place to load any misc. 5 | # programs on startup ( 1>&2 ) 6 | 7 | #if [ -d /usr/livecd/db ] 8 | #then 9 | # ln -sf /usr/livecd/db /var/db 10 | #fi 11 | 12 | if [ -d /usr/livecd/profiles ] 13 | then 14 | ln -sf /usr/livecd/profiles /var/db/repos/gentoo/profiles 15 | fi 16 | 17 | if [ -d /usr/livecd/eclass ] 18 | then 19 | ln -sf /usr/livecd/eclass /var/db/repos/gentoo/eclass 20 | fi 21 | -------------------------------------------------------------------------------- /livecd/files/livecd.motd.txt: -------------------------------------------------------------------------------- 1 | The latest version of the Handbook is always available from the Gentoo web 2 | site by typing "links https://wiki.gentoo.org/wiki/Handbook". 3 | 4 | To start an ssh server on this system, type "/etc/init.d/sshd start". If you 5 | need to log in remotely as root, type "passwd root" to reset root's password 6 | to a known value. 7 | 8 | Please report any bugs you find to https://bugs.gentoo.org. Be sure to include 9 | detailed information about how to reproduce the bug you are reporting. 10 | 11 | Thank you for using Gentoo Linux! 12 | -------------------------------------------------------------------------------- /livecd/files/minimal.motd.txt: -------------------------------------------------------------------------------- 1 | The latest version of the Handbook is always available from the Gentoo web 2 | site by typing "links https://wiki.gentoo.org/wiki/Handbook". 3 | 4 | To start an ssh server on this system, type "/etc/init.d/sshd start". If you 5 | need to log in remotely as root, type "passwd root" to reset root's password 6 | to a known value. 7 | 8 | Please report any bugs you find to https://bugs.gentoo.org. Be sure to include 9 | detailed information about how to reproduce the bug you are reporting. 10 | 11 | Thank you for using Gentoo Linux! 12 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Catalyst is a release building tool used by Gentoo Linux""" 3 | 4 | import codecs as _codecs 5 | from distutils.core import setup as _setup, Command as _Command 6 | from email.utils import parseaddr as _parseaddr 7 | import os as _os 8 | 9 | from catalyst import __version__, __maintainer__ 10 | from catalyst.version import set_release_version as _set_release_version 11 | from catalyst.version import get_version as _get_version 12 | 13 | 14 | _this_dir = _os.path.dirname(__file__) 15 | _package_name = 'catalyst' 16 | _maintainer_name, _maintainer_email = _parseaddr(__maintainer__) 17 | 18 | 19 | def _posix_path(path): 20 | """Convert a native path to a POSIX path 21 | 22 | Distutils wants all paths to be written in the Unix convention 23 | (i.e. slash-separated) [1], so that's what we'll do here. 24 | 25 | [1]: https://docs.python.org/2/distutils/setupscript.html 26 | """ 27 | if _os.path.sep != '/': 28 | return path.replace(_os.path.sep, '/') 29 | return path 30 | 31 | 32 | def _files(prefix, root): 33 | """Iterate through all the file paths under `root` 34 | 35 | Yielding `(target_dir, (file_source_paths, ...))` tuples. 36 | """ 37 | for dirpath, _dirnames, filenames in _os.walk(root): 38 | reldir = _os.path.relpath(dirpath, root) 39 | install_directory = _posix_path( 40 | _os.path.join(prefix, reldir)) 41 | file_source_paths = [ 42 | _posix_path(_os.path.join(dirpath, filename)) 43 | for filename in filenames] 44 | yield (install_directory, file_source_paths) 45 | 46 | 47 | _data_files = [('/etc/catalyst', ['etc/catalyst.conf', 'etc/catalystrc']), 48 | ('/usr/share/man/man1', ['files/catalyst.1']), 49 | ('/usr/share/man/man5', 50 | ['files/catalyst-config.5', 'files/catalyst-spec.5']) 51 | ] 52 | _data_files.extend(_files('share/catalyst/arch', 'arch')) 53 | _data_files.extend(_files('share/catalyst/livecd', 'livecd')) 54 | _data_files.extend(_files('share/catalyst/targets', 'targets')) 55 | 56 | 57 | class set_version(_Command): 58 | '''Saves the specified release version information 59 | ''' 60 | description = "hardcode script's version using VERSION from environment" 61 | user_options = [] # [(long_name, short_name, desc),] 62 | 63 | def initialize_options(self): 64 | pass 65 | 66 | def finalize_options(self): 67 | pass 68 | 69 | def run(self): 70 | # pylint: disable=global-statement 71 | global __version__ 72 | try: 73 | version = _os.environ['VERSION'] 74 | except KeyError: 75 | print("Try setting 'VERSION=x.y.z' on the command line... Aborting") 76 | return 77 | _set_release_version(version) 78 | __version__ = _get_version() 79 | print("Version set to:\n", __version__) 80 | 81 | 82 | _setup( 83 | name=_package_name, 84 | version=__version__, 85 | maintainer=_maintainer_name, 86 | maintainer_email=_maintainer_email, 87 | url='https://wiki.gentoo.org/wiki/Catalyst', 88 | download_url='http://distfiles.gentoo.org/distfiles/{0}-{1}.tar.bz2'.format( 89 | _package_name, __version__), 90 | license='GNU General Public License (GPL)', 91 | platforms=['all'], 92 | description=__doc__, 93 | long_description=_codecs.open( 94 | _os.path.join(_this_dir, 'README'), 'r', 'utf-8').read(), 95 | classifiers=[ 96 | 'Development Status :: 5 - Production/Stable', 97 | 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)', 98 | 'Intended Audience :: System Administrators', 99 | 'Operating System :: POSIX', 100 | 'Topic :: System :: Archiving :: Packaging', 101 | 'Topic :: System :: Installation/Setup', 102 | 'Topic :: System :: Software Distribution', 103 | 'Programming Language :: Python :: 3', 104 | 'Programming Language :: Python :: 3.8', 105 | ], 106 | scripts=['bin/{0}'.format(_package_name)], 107 | packages=[ 108 | _package_name, 109 | '{0}.base'.format(_package_name), 110 | '{0}.targets'.format(_package_name), 111 | ], 112 | data_files=_data_files, 113 | provides=[_package_name], 114 | cmdclass={ 115 | 'set_version': set_version 116 | }, 117 | ) 118 | -------------------------------------------------------------------------------- /targets/diskimage-stage1/chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | run_merge --update --deep --newuse "${clst_packages}" 6 | -------------------------------------------------------------------------------- /targets/diskimage-stage1/controller.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ${clst_shdir}/support/functions.sh 4 | 5 | ## START RUNSCRIPT 6 | 7 | case $1 in 8 | build_packages) 9 | shift 10 | export clst_packages="$*" 11 | mkdir -p ${clst_chroot_path}/tmp 12 | exec_in_chroot \ 13 | ${clst_shdir}/${clst_target}/chroot.sh 14 | ;; 15 | esac 16 | exit $? 17 | -------------------------------------------------------------------------------- /targets/diskimage-stage1/preclean-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | cleanup_stages 6 | -------------------------------------------------------------------------------- /targets/diskimage-stage2/controller.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ${clst_shdir}/support/functions.sh 4 | 5 | case $1 in 6 | pre-kmerge) 7 | # Sets up the build environment before any kernels are compiled 8 | exec_in_chroot ${clst_shdir}/support/pre-kmerge.sh 9 | ;; 10 | 11 | kernel) 12 | shift 13 | export kname="$1" 14 | 15 | [ -n "${clst_linuxrc}" ] && \ 16 | copy_to_chroot ${clst_linuxrc} /tmp/linuxrc 17 | exec_in_chroot ${clst_shdir}/support/kmerge.sh 18 | delete_from_chroot /tmp/linuxrc 19 | 20 | extract_modules ${clst_chroot_path} ${kname} 21 | ;; 22 | 23 | pre-distkmerge) 24 | # Install dracut 25 | exec_in_chroot ${clst_shdir}/support/pre-distkmerge.sh 26 | ;; 27 | preclean) 28 | ;; 29 | 30 | diskimage-update) 31 | # We need to install grub's EFI files and do very basic configuration 32 | exec_in_chroot ${clst_shdir}/support/diskimagefs-update.sh 33 | ;; 34 | 35 | rc-update) 36 | exec_in_chroot ${clst_shdir}/support/rc-update.sh 37 | ;; 38 | fsscript) 39 | exec_in_chroot ${clst_fsscript} 40 | ;; 41 | 42 | clean) 43 | ;; 44 | 45 | unmerge) 46 | [ "${clst_diskimage_depclean}" != "no" ] && exec_in_chroot ${clst_shdir}/support/depclean.sh 47 | shift 48 | export clst_packages="$*" 49 | exec_in_chroot ${clst_shdir}/support/unmerge.sh 50 | ;; 51 | qcow2) 52 | shift 53 | ${clst_shdir}/support/create-qcow2.sh $1 54 | ;; 55 | esac 56 | exit $? 57 | -------------------------------------------------------------------------------- /targets/embedded/chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | echo "Installing dependencies..." 6 | ROOT=/ run_merge -o "${clst_embedded_packages}" 7 | 8 | export ROOT="${clst_root_path}" 9 | mkdir -p "$ROOT" 10 | 11 | INSTALL_MASK="${clst_install_mask}" \ 12 | run_merge -1 -O "${clst_embedded_packages}" 13 | -------------------------------------------------------------------------------- /targets/embedded/controller.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ${clst_shdir}/support/functions.sh 4 | 5 | case ${1} in 6 | build_packages) 7 | shift 8 | export clst_packages="$*" 9 | exec_in_chroot \ 10 | ${clst_shdir}/${clst_target}/chroot.sh 11 | ;; 12 | 13 | preclean) 14 | ;; 15 | 16 | # package) 17 | # export root_fs_path="${clst_chroot_path}/tmp/mergeroot" 18 | # install -d ${clst_image_path} 19 | 20 | # ${clst_shdir}/embedded/fs-runscript.sh \ 21 | # ${clst_embedded_fs_type} || exit 1 22 | # imagesize=`du -sk ${clst_image_path}/root.img | cut -f1` 23 | # echo "Created ${clst_embedded_fs_type} image at \ 24 | # ${clst_image_path}/root.img" 25 | # echo "Image size: ${imagesize}k" 26 | # ;; 27 | 28 | pre-kmerge) 29 | # Sets up the build environment before any kernels are compiled 30 | exec_in_chroot ${clst_shdir}/support/pre-kmerge.sh 31 | ;; 32 | 33 | kernel) 34 | shift 35 | export kname="${1}" 36 | 37 | [ -n "${clst_linuxrc}" ] && \ 38 | copy_to_chroot ${clst_linuxrc} /tmp/linuxrc 39 | exec_in_chroot ${clst_shdir}/support/kmerge.sh 40 | delete_from_chroot /tmp/linuxrc 41 | ;; 42 | 43 | target_image_setup) 44 | shift 45 | ${clst_shdir}/support/target_image_setup.sh ${1} 46 | 47 | ;; 48 | livecd-update) 49 | # Now, finalize and tweak the livecd fs (inside of the chroot) 50 | exec_in_chroot ${clst_shdir}/support/livecdfs-update.sh 51 | ;; 52 | 53 | bootloader) 54 | shift 55 | # Here is where we poke in our identifier 56 | touch ${1}/livecd 57 | 58 | ${clst_shdir}/support/iso-bootloader-setup.sh ${1} 59 | ;; 60 | 61 | iso) 62 | shift 63 | ${clst_shdir}/support/create-iso.sh ${1} 64 | ;; 65 | 66 | clean) 67 | ;; 68 | 69 | *) 70 | ;; 71 | 72 | esac 73 | exit $? 74 | -------------------------------------------------------------------------------- /targets/embedded/fs-runscript.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | die() { 4 | echo "${1}" 5 | exit 1 6 | } 7 | 8 | # 1 = mkfs path, 2 = fs name, 3 = pkg name 9 | fs_check() { 10 | if [ ! -e ${1} ]; then 11 | die "You must install ${3} in order to produce ${2} images" 12 | fi 13 | } 14 | 15 | case ${1} in 16 | jffs2) 17 | fs_check /usr/sbin/mkfs.jffs2 jffs2 sys-fs/mtd 18 | mkfs.jffs2 --root=${root_fs_path} --output=${clst_image_path}/root.img\ 19 | ${clst_embedded_fs_ops} || die "Could not create a jffs2 filesystem" 20 | ;; 21 | 22 | squashfs) 23 | fs_check /usr/bin/gensquashfs squashfs sys-fs/squashfs-tools-ng 24 | gensquashfs -k -D ${root_fs_path} -q ${clst_embedded_fs_ops} \ 25 | ${clst_image_path}/root.img || 26 | die "Could not create a squashfs filesystem" 27 | ;; 28 | esac 29 | exit $? 30 | -------------------------------------------------------------------------------- /targets/embedded/preclean-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | cleanup_stages 6 | -------------------------------------------------------------------------------- /targets/embedded/unmerge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ${clst_CHROOT} ${clst_chroot_path} /bin/bash << EOF 4 | ROOT=/tmp/mergeroot emerge -C $* || exit 1 5 | EOF 6 | -------------------------------------------------------------------------------- /targets/livecd-stage1/chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | run_merge --update --deep --newuse "${clst_packages}" 6 | -------------------------------------------------------------------------------- /targets/livecd-stage1/controller.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ${clst_shdir}/support/functions.sh 4 | 5 | ## START RUNSCRIPT 6 | 7 | case $1 in 8 | build_packages) 9 | shift 10 | export clst_packages="$*" 11 | mkdir -p ${clst_chroot_path}/usr/livecd ${clst_chroot_path}/tmp 12 | exec_in_chroot \ 13 | ${clst_shdir}/${clst_target}/chroot.sh 14 | ;; 15 | esac 16 | exit $? 17 | -------------------------------------------------------------------------------- /targets/livecd-stage1/preclean-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | cleanup_stages 6 | -------------------------------------------------------------------------------- /targets/livecd-stage2/controller.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ${clst_shdir}/support/functions.sh 4 | 5 | case $1 in 6 | pre-kmerge) 7 | # Sets up the build environment before any kernels are compiled 8 | exec_in_chroot ${clst_shdir}/support/pre-kmerge.sh 9 | ;; 10 | 11 | kernel) 12 | shift 13 | export kname="$1" 14 | 15 | [ -n "${clst_linuxrc}" ] && \ 16 | copy_to_chroot ${clst_linuxrc} /tmp/linuxrc 17 | exec_in_chroot ${clst_shdir}/support/kmerge.sh 18 | delete_from_chroot /tmp/linuxrc 19 | 20 | extract_modules ${clst_chroot_path} ${kname} 21 | ;; 22 | 23 | pre-distkmerge) 24 | # Install dracut 25 | exec_in_chroot ${clst_shdir}/support/pre-distkmerge.sh 26 | ;; 27 | 28 | preclean) 29 | # Move over the motd (if applicable) 30 | case ${clst_livecd_type} in 31 | gentoo-*) 32 | if [ -n "${clst_livecd_motd}" ] 33 | then 34 | echo "Using livecd/motd is not supported with livecd/type" 35 | echo "${clst_livecd_type}. You should switch to using" 36 | echo "generic-livecd instead." 37 | fi 38 | cp -pPR ${clst_sharedir}/livecd/files/*.motd.txt ${clst_chroot_path}/etc 39 | ;; 40 | *) 41 | if [ -n "${clst_livecd_motd}" ] 42 | then 43 | cp -pPR ${clst_livecd_motd} ${clst_chroot_path}/etc/motd 44 | fi 45 | ;; 46 | esac 47 | 48 | # move over the environment 49 | cp -f ${clst_sharedir}/livecd/files/livecd-bashrc \ 50 | ${clst_chroot_path}/root/.bashrc 51 | cp -f ${clst_sharedir}/livecd/files/livecd-bash_profile \ 52 | ${clst_chroot_path}/root/.bash_profile 53 | cp -f ${clst_sharedir}/livecd/files/livecd-local.start \ 54 | ${clst_chroot_path}/etc/conf.d/local.start 55 | ;; 56 | 57 | livecd-update) 58 | # Now, finalize and tweak the livecd fs (inside of the chroot) 59 | exec_in_chroot ${clst_shdir}/support/livecdfs-update.sh 60 | ;; 61 | 62 | rc-update) 63 | exec_in_chroot ${clst_shdir}/support/rc-update.sh 64 | ;; 65 | 66 | fsscript) 67 | exec_in_chroot ${clst_fsscript} 68 | ;; 69 | 70 | clean) 71 | if [ "${clst_livecd_type}" = "gentoo-release-minimal" ] 72 | then 73 | # Clean out man, info and doc files 74 | rm -rf ${clst_chroot_path}/usr/share/{man,doc,info}/* 75 | fi 76 | ;; 77 | 78 | bootloader) 79 | shift 80 | # Here is where we poke in our identifier 81 | touch $1/livecd 82 | 83 | # We create a firmware directory, if necessary 84 | if [ -e ${clst_chroot_path}/lib/firmware.tar.bz2 ] 85 | then 86 | echo "Creating firmware directory in $1" 87 | mkdir -p $1/firmware 88 | # TODO: Unpack firmware into $1/firmware and remove it from the 89 | # chroot so newer livecd-tools/genkernel can find it and unpack it. 90 | fi 91 | 92 | # Move over the readme (if applicable) 93 | if [ -n "${clst_livecd_readme}" ] 94 | then 95 | cp -f ${clst_livecd_readme} $1/README.txt 96 | else 97 | cp -f ${clst_sharedir}/livecd/files/README.txt $1 98 | fi 99 | 100 | if [ -e ${clst_chroot_path}/boot/memtest86plus/ ]; then 101 | cp -rv ${clst_chroot_path}/boot/memtest86plus/* $1 102 | fi 103 | 104 | case ${clst_livecd_type} in 105 | gentoo-release-livecd) 106 | mkdir -p $1/snapshots 107 | if [ -n "${clst_livecd_overlay}" ] 108 | then 109 | if [ -e ${clst_livecd_overlay}/snapshots/${clst_snapshot_path} ] 110 | then 111 | echo "ERROR: You have a snapshot in your overlay, please" 112 | echo "remove it, since catalyst adds it automatically." 113 | exit 1 114 | fi 115 | fi 116 | cp -f ${clst_snapshot_path}{,.DIGESTS} $1/snapshots 117 | ;; 118 | gentoo-release-livedvd) 119 | targets="distfiles snapshots stages" 120 | for i in ${targets} 121 | do 122 | mkdir -p $1/$i 123 | if [ -n "${clst_livecd_overlay}" ] 124 | then 125 | if [ -e ${clst_livecd_overlay}/$i ] && \ 126 | [ -n "$(ls ${clst_livecd_overlay}/$i |grep -v README)" ] 127 | then 128 | echo "ERROR: You have files in $i in your overlay!" 129 | echo "This directory is now populated by catalyst." 130 | exit 1 131 | fi 132 | fi 133 | case ${target} in 134 | distfiles) 135 | ### TODO: make this fetch the distfiles 136 | continue 137 | ;; 138 | snapshots) 139 | cp -f ${clst_snapshot_path}{,.DIGESTS} $1/snapshots 140 | ;; 141 | stages) 142 | ### TODO: make this copy stages 143 | continue 144 | ;; 145 | esac 146 | done 147 | ;; 148 | esac 149 | 150 | ${clst_shdir}/support/iso-bootloader-setup.sh $1 151 | ;; 152 | 153 | unmerge) 154 | [ "${clst_livecd_depclean}" != "no" ] && exec_in_chroot ${clst_shdir}/support/depclean.sh 155 | shift 156 | export clst_packages="$*" 157 | exec_in_chroot ${clst_shdir}/support/unmerge.sh 158 | ;; 159 | 160 | target_image_setup) 161 | shift 162 | ${clst_shdir}/support/target_image_setup.sh $1 163 | ;; 164 | 165 | iso) 166 | shift 167 | ${clst_shdir}/support/create-iso.sh $1 168 | ;; 169 | esac 170 | exit $? 171 | -------------------------------------------------------------------------------- /targets/netboot/controller.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ${clst_shdir}/support/functions.sh 4 | 5 | case ${1} in 6 | build_packages) 7 | echo ">>> Building packages ..." 8 | shift 9 | ROOT="/" \ 10 | clst_packages="$*" \ 11 | exec_in_chroot \ 12 | ${clst_shdir}/${clst_target}/pkg.sh 13 | ;; 14 | 15 | pre-kmerge) 16 | # Sets up the build environment before any kernels are compiled 17 | exec_in_chroot ${clst_shdir}/support/pre-kmerge.sh 18 | ;; 19 | 20 | kernel) 21 | shift 22 | export kname="$1" 23 | 24 | [ -n "${clst_linuxrc}" ] && \ 25 | copy_to_chroot ${clst_linuxrc} /tmp/linuxrc 26 | [ -n "${clst_busybox_config}" ] && \ 27 | copy_to_chroot ${clst_busybox_config} /tmp/busy-config 28 | 29 | exec_in_chroot ${clst_shdir}/support/kmerge.sh 30 | 31 | delete_from_chroot /tmp/linuxrc 32 | delete_from_chroot /tmp/busy-config 33 | 34 | extract_modules ${clst_chroot_path} ${kname} 35 | ;; 36 | 37 | image) 38 | # Creates the base initramfs image for the netboot 39 | echo -e ">>> Preparing Image ..." 40 | shift 41 | 42 | # Copy remaining files over to the initramfs target 43 | clst_files="${@}" \ 44 | exec_in_chroot \ 45 | ${clst_shdir}/${clst_target}/copyfile.sh 46 | ;; 47 | 48 | final) 49 | # For each arch, fetch the kernel images and put them in builds/ 50 | echo -e ">>> Copying completed kernels to ${clst_target_path}/ ..." 51 | ${clst_shdir}/support/netboot-final.sh 52 | ;; 53 | 54 | clean) 55 | exit 0;; 56 | 57 | *) 58 | exit 1;; 59 | esac 60 | 61 | exit $? 62 | -------------------------------------------------------------------------------- /targets/netboot/copyfile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | update_env_settings 6 | 7 | echo ">>> Copying initramfs files to ${clst_merge_path} (in chroot) ..." 8 | [ ! -d "${clst_merge_path}" ] && mkdir -p ${clst_merge_path} 9 | for f in ${clst_files} 10 | do 11 | # copy it to the merge path 12 | cp -pPRf --parents $(eval echo ${f}) ${clst_merge_path} 13 | 14 | # if the file is an ELF binary, strip unneeded stuff from it 15 | if [ -x "${f}" ] && [ ! -L "${f}" ]; then 16 | if [ "$(head -c 4 ${f} 2>/dev/null | tail -c 3)" = "ELF" ]; then 17 | strip -R .comment -R .note ${clst_merge_path}${f} 18 | fi 19 | fi 20 | done 21 | -------------------------------------------------------------------------------- /targets/netboot/pkg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | update_env_settings 6 | 7 | setup_features 8 | 9 | show_debug 10 | 11 | # START BUILD 12 | 13 | ROOT="$ROOT" run_merge ${clst_packages} 14 | -------------------------------------------------------------------------------- /targets/stage1/build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import os 4 | import sys 5 | import portage 6 | from portage.dep import dep_getkey 7 | from portage.util import grabfile_package, stack_lists 8 | 9 | # this loads files from the profiles ... 10 | # wrap it here to take care of the different 11 | # ways portage handles stacked profiles 12 | 13 | 14 | def scan_profile(path): 15 | return stack_lists([grabfile_package(os.path.join(x, path)) for x in portage.settings.profiles], incremental=1) 16 | 17 | 18 | # loaded the stacked packages / packages.build files 19 | pkgs = scan_profile("packages") 20 | buildpkgs = scan_profile("packages.build") 21 | 22 | # go through the packages list and strip off all the 23 | # crap to get just the / ... then 24 | # search the buildpkg list for it ... if it's found, 25 | # we replace the buildpkg item with the one in the 26 | # system profile (it may have <,>,=,etc... operators 27 | # and version numbers) 28 | for pkg in pkgs: 29 | try: 30 | bidx = buildpkgs.index(dep_getkey(pkg)) 31 | buildpkgs[bidx] = pkg 32 | if buildpkgs[bidx][0:1] == "*": 33 | buildpkgs[bidx] = buildpkgs[bidx][1:] 34 | except Exception: 35 | pass 36 | 37 | for b in buildpkgs: 38 | sys.stdout.write(b + " ") 39 | -------------------------------------------------------------------------------- /targets/stage1/chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | for module_path in /usr/lib/*/site-packages/portage/__init__.py; do 6 | # Find the python interpreter 7 | interpreter=$(echo $module_path | cut -d/ -f4) 8 | 9 | buildpkgs=($($interpreter /tmp/build.py 2>/dev/null)) 10 | [[ $? == 0 ]] && break 11 | done 12 | 13 | ## Sanity check profile 14 | if [[ ${#buildpkgs[@]} -eq 0 ]]; then 15 | echo "Your profile seems to be broken." 16 | echo "Could not build a list of build packages." 17 | echo "Double check your ${clst_port_conf}/make.profile link and the 'packages' files." 18 | exit 1 19 | fi 20 | 21 | # Setup our environment 22 | [ -n "${clst_BINDIST}" ] && BINDIST="bindist" 23 | BOOTSTRAP_USE="$(portageq envvar BOOTSTRAP_USE)" 24 | 25 | FEATURES="${FEATURES} nodoc noman noinfo" 26 | 27 | sed -i -e 's:BINPKG_COMPRESS="bzip2":BINPKG_COMPRESS="zstd":' \ 28 | /usr/share/portage/config/make.globals 29 | 30 | # We need to ensure the base stage3 has USE="bindist" 31 | # if BINDIST is set to avoid issues with openssl / openssh 32 | [ -e ${clst_make_conf} ] && echo "USE=\"${BINDIST} ${USE}\"" >> ${clst_make_conf} 33 | 34 | # Update stage3 35 | if [ -n "${clst_update_seed}" ]; then 36 | if [ "${clst_update_seed}" == "yes" ]; then 37 | echo "Updating seed stage..." 38 | if [ -n "${clst_update_seed_command}" ]; then 39 | ROOT=/ run_merge --buildpkg=n "${clst_update_seed_command}" 40 | elif grep -q '^\[changed-subslot\]' /usr/share/portage/config/sets/portage.conf; then 41 | ROOT=/ run_merge --ignore-built-slot-operator-deps y @changed-subslot 42 | else 43 | ROOT=/ run_merge --update --deep --newuse --complete-graph --rebuild-if-new-ver gcc 44 | fi 45 | elif [ "${clst_update_seed}" != "no" ]; then 46 | echo "Invalid setting for update_seed: ${clst_update_seed}" 47 | exit 1 48 | fi 49 | 50 | # reset emerge options for the target 51 | clst_update_seed=no setup_emerge_opts 52 | else 53 | echo "Skipping seed stage update..." 54 | fi 55 | 56 | # Clear USE 57 | [ -e ${clst_make_conf} ] && sed -i -e "/^USE=\"${BINDIST} ${USE}\"/d" ${clst_make_conf} 58 | 59 | export ROOT="${clst_root_path}" 60 | mkdir -p "$ROOT" 61 | 62 | ## START BUILD 63 | # First, we drop in a known-good baselayout 64 | [ -e ${clst_make_conf} ] && echo "USE=\"${USE} build\"" >> ${clst_make_conf} 65 | run_merge --oneshot --nodeps sys-apps/baselayout 66 | sed -i "/USE=\"${USE} build\"/d" ${clst_make_conf} 67 | 68 | echo "$locales" > /etc/locale.gen 69 | for etc in /etc "$ROOT"/etc; do 70 | echo "LANG=C.UTF8" > ${etc}/env.d/02locale 71 | done 72 | update_env_settings 73 | 74 | # Now, we install our packages 75 | if [ -e ${clst_make_conf} ]; then 76 | echo "CATALYST_USE=\"-* build ${BINDIST} ${clst_CATALYST_USE}\"" >> ${clst_make_conf} 77 | echo "USE=\"\${CATALYST_USE} ${USE} ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"" >> ${clst_make_conf} 78 | 79 | for useexpand in ${clst_HOSTUSEEXPAND}; do 80 | x="clst_${useexpand}" 81 | echo "${useexpand}=\"${!x}\"" \ 82 | >> ${clst_make_conf} 83 | done 84 | fi 85 | 86 | run_merge --implicit-system-deps=n --oneshot "${buildpkgs[@]}" 87 | 88 | # TODO: Drop this when locale-gen in stable glibc supports ROOT. 89 | # 90 | # locale-gen does not support the ROOT variable, and as such glibc simply does 91 | # not run locale-gen when ROOT is set. Since we've set LANG, we need to run 92 | # locale-gen explicitly. 93 | if [ -x "$(command -v locale-gen)" ]; then 94 | locale-gen --destdir "$ROOT"/ || die "locale-gen failed" 95 | fi 96 | 97 | # Why are we removing these? Don't we need them for final make.conf? 98 | for useexpand in ${clst_HOSTUSEEXPAND}; do 99 | x="clst_${useexpand}" 100 | sed -i "/${useexpand}=\"${!x}\"/d" \ 101 | ${clst_make_conf} 102 | done 103 | 104 | # Clear USE 105 | [ -e ${clst_make_conf} ] && sed -i -e "/^CATALYST_USE/d" ${clst_make_conf} 106 | [ -e ${clst_make_conf} ] && sed -i -e "/^USE=\"/s/\${CATALYST_USE} ${USE} ${BOOTSTRAP_USE}//" ${clst_make_conf} 107 | -------------------------------------------------------------------------------- /targets/stage1/controller.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source "${clst_shdir}/support/functions.sh" 4 | 5 | case "$1" in 6 | run) 7 | cp "${clst_shdir}/stage1/build.py" "${clst_chroot_path}/tmp" 8 | 9 | # Setup "ROOT in chroot" dir 10 | install -d "${clst_stage_path}/etc" 11 | install -d "${clst_stage_path}/${clst_port_conf}" 12 | 13 | # Setup make.conf and make.profile link in "ROOT in chroot": 14 | copy_to_chroot "${clst_chroot_path}${clst_make_conf}" "${clst_root_path}${clst_port_conf}" 15 | 16 | # Enter chroot, execute our build script 17 | exec_in_chroot \ 18 | "${clst_shdir}/${clst_target}/chroot.sh" \ 19 | || exit 1 20 | ;; 21 | 22 | preclean) 23 | exec_in_chroot "${clst_shdir}/${clst_target}/preclean-chroot.sh" || exit 1 24 | ;; 25 | 26 | clean) 27 | exit 0 28 | ;; 29 | 30 | *) 31 | exit 1 32 | ;; 33 | esac 34 | exit $? 35 | -------------------------------------------------------------------------------- /targets/stage1/preclean-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export RUN_DEFAULT_FUNCS="no" 4 | export ROOT=/tmp/stage1root 5 | 6 | source /tmp/chroot-functions.sh 7 | 8 | update_env_settings 9 | show_debug 10 | 11 | setup_gcc 12 | setup_binutils 13 | 14 | # Stage1 is not going to have anything in zoneinfo, so save our Factory timezone 15 | if [ -d "${ROOT}/usr/share/zoneinfo" ] 16 | then 17 | rm -f "${ROOT}/etc/localtime" 18 | ln -s ../usr/share/zoneinfo/Factory "${ROOT}/etc/localtime" 19 | else 20 | echo UTC > "${ROOT}/etc/TZ" 21 | fi 22 | 23 | # Clean out man, info and doc files 24 | rm -rf "${ROOT}"/usr/share/{man,doc,info}/* 25 | 26 | # unset ROOT for safety (even though cleanup_stages doesn't use it) 27 | unset ROOT 28 | cleanup_stages 29 | -------------------------------------------------------------------------------- /targets/stage2/chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | # Setup the environment 6 | export FEATURES="${FEATURES} nodoc noman noinfo" 7 | export CONFIG_PROTECT="-* /etc/locale.gen" 8 | 9 | echo "$locales" > /etc/locale.gen 10 | 11 | ## START BUILD 12 | ${clst_repo_basedir}/${clst_repo_name}/scripts/bootstrap.sh ${bootstrap_opts[@]} || exit 1 13 | 14 | # Replace modified /etc/locale.gen with default 15 | etc-update --automode -5 16 | -------------------------------------------------------------------------------- /targets/stage2/controller.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ${clst_shdir}/support/functions.sh 4 | 5 | case $1 in 6 | run) 7 | shift 8 | export clst_packages="$*" 9 | exec_in_chroot \ 10 | ${clst_shdir}/${clst_target}/chroot.sh 11 | ;; 12 | 13 | preclean) 14 | exec_in_chroot ${clst_shdir}/${clst_target}/preclean-chroot.sh 15 | ;; 16 | 17 | clean) 18 | exit 0 19 | ;; 20 | 21 | *) 22 | exit 1 23 | ;; 24 | esac 25 | exit $? 26 | -------------------------------------------------------------------------------- /targets/stage2/preclean-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export RUN_DEFAULT_FUNCS="no" 4 | 5 | source /tmp/chroot-functions.sh 6 | 7 | update_env_settings 8 | show_debug 9 | 10 | cleanup_stages 11 | 12 | if [ -n "${clst_CCACHE}" ] 13 | then 14 | run_merge -C dev-util/ccache 15 | fi 16 | 17 | if [ -n "${clst_DISTCC}" ] 18 | then 19 | run_merge -C sys-devel/distcc 20 | fi 21 | 22 | if [ -n "${clst_ICECREAM}" ] 23 | then 24 | run_merge -C sys-devel/icecream 25 | fi 26 | -------------------------------------------------------------------------------- /targets/stage3/chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | export CONFIG_PROTECT="-* /etc/locale.gen" 6 | 7 | echo "$locales" > /etc/locale.gen 8 | 9 | run_merge -e --update --deep --with-bdeps=y @system 10 | 11 | # Replace modified /etc/locale.gen with default 12 | etc-update --automode -5 13 | -------------------------------------------------------------------------------- /targets/stage3/controller.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ${clst_shdir}/support/functions.sh 4 | 5 | case $1 in 6 | run) 7 | shift 8 | export clst_packages="$*" 9 | exec_in_chroot ${clst_shdir}/${clst_target}/chroot.sh 10 | ;; 11 | 12 | preclean) 13 | exec_in_chroot ${clst_shdir}/${clst_target}/preclean-chroot.sh 14 | ;; 15 | 16 | clean) 17 | exit 0 18 | ;; 19 | 20 | *) 21 | exit 1 22 | ;; 23 | esac 24 | exit $? 25 | -------------------------------------------------------------------------------- /targets/stage3/preclean-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export RUN_DEFAULT_FUNCS="no" 4 | 5 | source /tmp/chroot-functions.sh 6 | 7 | update_env_settings 8 | show_debug 9 | 10 | cleanup_stages 11 | 12 | if [ -n "${clst_DISTCC}" ] 13 | then 14 | portageq has_version / sys-devel/distcc 15 | if [ $? == 0 ]; then 16 | run_merge -C sys-devel/distcc 17 | fi 18 | fi 19 | 20 | if [ -n "${clst_ICECREAM}" ] 21 | then 22 | run_merge -C sys-devel/icecream 23 | fi 24 | -------------------------------------------------------------------------------- /targets/stage4/chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | echo "Bringing system up to date using profile specific use flags" 6 | run_merge -u @system 7 | 8 | echo "Emerging packages using stage4 use flags" 9 | 10 | run_merge "${clst_packages}" 11 | -------------------------------------------------------------------------------- /targets/stage4/controller.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ${clst_shdir}/support/functions.sh 4 | 5 | case $1 in 6 | pre-kmerge) 7 | # Sets up the build environment before any kernels are compiled 8 | exec_in_chroot ${clst_shdir}/support/pre-kmerge.sh 9 | ;; 10 | 11 | kernel) 12 | shift 13 | export kname="$1" 14 | 15 | # If we have our own linuxrc, copy it in 16 | [ -n "${clst_linuxrc}" ] && \ 17 | copy_to_chroot ${clst_linuxrc} /tmp/linuxrc 18 | exec_in_chroot ${clst_shdir}/support/kmerge.sh 19 | delete_from_chroot /tmp/linuxrc 20 | 21 | extract_modules ${clst_chroot_path} ${kname} 22 | ;; 23 | 24 | build_packages) 25 | shift 26 | export clst_packages="$*" 27 | exec_in_chroot ${clst_shdir}/${clst_target}/chroot.sh 28 | ;; 29 | 30 | preclean) 31 | exec_in_chroot ${clst_shdir}/${clst_target}/preclean-chroot.sh 32 | ;; 33 | 34 | rc-update) 35 | exec_in_chroot ${clst_shdir}/support/rc-update.sh 36 | ;; 37 | 38 | fsscript) 39 | exec_in_chroot ${clst_fsscript} 40 | ;; 41 | 42 | livecd-update) 43 | # Now, finalize and tweak the livecd fs (inside of the chroot) 44 | exec_in_chroot ${clst_shdir}/support/livecdfs-update.sh 45 | ;; 46 | 47 | bootloader) 48 | exit 0 49 | ;; 50 | 51 | target_image_setup) 52 | shift 53 | ${clst_shdir}/support/target_image_setup.sh $1 54 | ;; 55 | 56 | unmerge) 57 | shift 58 | export clst_packages="$*" 59 | exec_in_chroot ${clst_shdir}/support/unmerge.sh 60 | ;; 61 | 62 | iso) 63 | shift 64 | ${clst_shdir}/support/create-iso.sh $1 65 | ;; 66 | 67 | clean) 68 | exit 0 69 | ;; 70 | 71 | *) 72 | exit 1 73 | ;; 74 | esac 75 | exit $? 76 | -------------------------------------------------------------------------------- /targets/stage4/preclean-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export RUN_DEFAULT_FUNCS="no" 4 | 5 | source /tmp/chroot-functions.sh 6 | 7 | update_env_settings 8 | show_debug 9 | 10 | cleanup_stages 11 | -------------------------------------------------------------------------------- /targets/support/create-iso.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ${clst_shdir}/support/functions.sh 4 | 5 | ## START RUNSCRIPT 6 | 7 | # Check for our CD ISO creation tools 8 | case ${clst_hostarch} in 9 | alpha) 10 | cdmaker="xorriso" 11 | cdmakerpkg="dev-libs/libisoburn" 12 | ;; 13 | mips) 14 | cdmaker="sgibootcd" 15 | cdmakerpkg="sys-boot/sgibootcd" 16 | ;; 17 | ppc*|powerpc*|sparc*) 18 | cdmaker="grub-mkrescue" 19 | cdmakerpkg="dev-libs/libisoburn and sys-boot/grub:2" 20 | ;; 21 | amd64|arm64|ia64|x86|i?86) 22 | cdmaker="grub-mkrescue" 23 | # grub-mkrescue requires: 24 | # xorriso from libisoburn 25 | # mkisofs from cdrtools 26 | # mformat from mtools 27 | cdmakerpkg="sys-fs/mtools, dev-libs/libisoburn, sys-boot/grub:2, and app-cdr/cdrtools" 28 | ;; 29 | *) 30 | cdmaker="mkisofs" 31 | cdmakerpkg="app-cdr/cdrtools" 32 | ;; 33 | esac 34 | 35 | [ ! -f /usr/bin/${cdmaker} ] \ 36 | && echo && echo && die \ 37 | "!!! /usr/bin/${cdmaker} is not found. Have you merged ${cdmakerpkg}?" \ 38 | && echo && echo 39 | 40 | # If not volume ID is set, make up a sensible default 41 | if [ -z "${clst_iso_volume_id}" ] 42 | then 43 | case ${clst_livecd_type} in 44 | gentoo-*) 45 | case ${clst_hostarch} in 46 | alpha) 47 | clst_iso_volume_id="Gentoo Linux - Alpha" 48 | ;; 49 | amd64) 50 | clst_iso_volume_id="Gentoo Linux - AMD64" 51 | ;; 52 | arm) 53 | clst_iso_volume_id="Gentoo Linux - ARM" 54 | ;; 55 | arm64) 56 | clst_iso_volume_id="Gentoo Linux - ARM64" 57 | ;; 58 | hppa) 59 | clst_iso_volume_id="Gentoo Linux - HPPA" 60 | ;; 61 | ia64) 62 | clst_iso_volume_id="Gentoo Linux - IA64" 63 | ;; 64 | m68k) 65 | clst_iso_volume_id="Gentoo Linux - M68K" 66 | ;; 67 | mips) 68 | clst_iso_volume_id="Gentoo Linux - MIPS" 69 | ;; 70 | ppc*|powerpc*) 71 | clst_iso_volume_id="Gentoo Linux - PowerPC" 72 | ;; 73 | s390) 74 | clst_iso_volume_id="Gentoo Linux - S390" 75 | ;; 76 | sh) 77 | clst_iso_volume_id="Gentoo Linux - SH" 78 | ;; 79 | sparc*) 80 | clst_iso_volume_id="Gentoo Linux - SPARC" 81 | ;; 82 | x86) 83 | clst_iso_volume_id="Gentoo Linux - x86" 84 | ;; 85 | *) 86 | clst_iso_volume_id="Catalyst LiveCD" 87 | ;; 88 | esac 89 | esac 90 | fi 91 | 92 | if [ "${#clst_iso_volume_id}" -gt 32 ]; then 93 | old_clst_iso_volume_id=${clst_iso_volume_id} 94 | clst_iso_volume_id="${clst_iso_volume_id:0:32}" 95 | echo "ISO Volume label is too long, truncating to 32 characters" 1>&2 96 | echo "old: '${old_clst_iso_volume_id}'" 1>&2 97 | echo "new: '${clst_iso_volume_id}'" 1>&2 98 | fi 99 | 100 | # Generate list of checksums that genkernel can use to verify the contents of 101 | # the ISO 102 | isoroot_checksum() { 103 | [ -z "${clst_livecd_verify}" ] && return 104 | 105 | echo ">> Creating checksums for all files included in the ISO" 106 | 107 | pushd "${clst_target_path}" 108 | find -type f -exec b2sum {} + > /tmp/isoroot_b2sums 109 | popd 110 | 111 | mv /tmp/isoroot_b2sums "${clst_target_path}"/ 112 | } 113 | 114 | run_mkisofs() { 115 | isoroot_checksum 116 | 117 | echo "Running \"mkisofs ${@}\"" 118 | mkisofs "${@}" || die "Cannot make ISO image" 119 | } 120 | 121 | # Here we actually create the ISO images for each architecture 122 | case ${clst_hostarch} in 123 | alpha) 124 | isoroot_checksum 125 | 126 | echo ">> xorriso -as genisofs -alpha-boot boot/bootlx -R -l -J -V \"${clst_iso_volume_id}\" -o \"${1}\" \"${clst_target_path}\"" 127 | xorriso -as genisofs -alpha-boot boot/bootlx -R -l -J -V "${clst_iso_volume_id}" -o "${1}" "${clst_target_path}" || die "Cannot make ISO image" 128 | ;; 129 | arm) 130 | ;; 131 | hppa) 132 | echo ">> Running mkisofs to create iso image...." 133 | run_mkisofs -R -l -J -V "${clst_iso_volume_id}" -o "${1}" "${clst_target_path}"/ 134 | pushd "${clst_target_path}/" 135 | palo -f boot/palo.conf -C "${1}" 136 | popd 137 | ;; 138 | mips) 139 | if [[ ${clst_fstype} != squashfs ]]; then 140 | die "SGI LiveCD(s) only support the 'squashfs' fstype!" 141 | fi 142 | 143 | # $clst_target_path/[kernels|arcload] already exists, create loopback and sgibootcd 144 | [ ! -d "${clst_target_path}/loopback" ] && mkdir "${clst_target_path}/loopback" 145 | [ ! -d "${clst_target_path}/sgibootcd" ] && mkdir "${clst_target_path}/sgibootcd" 146 | 147 | # Setup variables 148 | [ -f "${clst_target_path}/livecd" ] && rm -f "${clst_target_path}/livecd" 149 | img="${clst_target_path}/loopback/image.squashfs" 150 | knl="${clst_target_path}/kernels" 151 | arc="${clst_target_path}/arcload" 152 | cfg="${clst_target_path}/sgibootcd/sgibootcd.cfg" 153 | echo "" > "${cfg}" 154 | 155 | # If the image file exists in $clst_target_path, move it to the loopback dir 156 | [ -e "${clst_target_path}/image.squashfs" ] \ 157 | && mv -f "${clst_target_path}/image.squashfs" "${clst_target_path}/loopback" 158 | 159 | # An sgibootcd config is essentially a collection of commandline params 160 | # stored in a text file. We could pass these on the command line, but it's 161 | # far easier to generate a config file and pass it to sgibootcd versus using a 162 | # ton of commandline params. 163 | # 164 | # f= indicates files to go into DVH (disk volume header) in an SGI disklabel 165 | # format: f=@ 166 | # p0= the first partition holds the LiveCD rootfs image 167 | # format: p0= 168 | # p8= the eighth partition is the DVH partition 169 | # p10= the tenth partition is the disk volume partition 170 | # format: p8= is always "#dvh" and p10= is always "#volume" 171 | 172 | # Add the kernels to the sgibootcd config 173 | for x in ${clst_boot_kernel}; do 174 | echo -e "f=${knl}/${x}@${x}" >> ${cfg} 175 | done 176 | 177 | # Next, the bootloader binaries and config 178 | echo -e "f=${arc}/sash64@sash64" >> ${cfg} 179 | echo -e "f=${arc}/sashARCS@sashARCS" >> ${cfg} 180 | echo -e "f=${arc}/arc.cf@arc.cf" >> ${cfg} 181 | 182 | # Next, the Loopback Image 183 | echo -e "p0=${img}" >> ${cfg} 184 | 185 | # Finally, the required SGI Partitions (dvh, volume) 186 | echo -e "p8=#dvh" >> ${cfg} 187 | echo -e "p10=#volume" >> ${cfg} 188 | 189 | # All done; feed the config to sgibootcd and end up with an image 190 | # c= the config file 191 | # o= output image (burnable to CD; readable by fdisk) 192 | /usr/bin/sgibootcd c=${cfg} o=${clst_iso} 193 | ;; 194 | amd64|arm64|ia64|ppc*|powerpc*|sparc*|x86|i?86) 195 | isoroot_checksum 196 | 197 | extra_opts=("-joliet" "-iso-level" "3") 198 | case ${clst_hostarch} in 199 | sparc*) extra_opts+=("--sparc-boot") ;; 200 | esac 201 | 202 | echo ">> Running grub-mkrescue to create iso image...." 203 | grub-mkrescue --mbr-force-bootable -volid "${clst_iso_volume_id}" "${extra_opts[@]}" -o "${1}" "${clst_target_path}" 204 | ;; 205 | esac 206 | exit $? 207 | -------------------------------------------------------------------------------- /targets/support/depclean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | if [ "${clst_livecd_depclean}" = "keepbdeps" ]; then 6 | run_merge --depclean --with-bdeps=y 7 | else 8 | run_merge --depclean --with-bdeps=n 9 | fi 10 | 11 | exit 0 12 | -------------------------------------------------------------------------------- /targets/support/diskimagefs-update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | if [[ $(readlink /etc/portage/make.profile) == *systemd* ]] ; then 6 | 7 | # We are using systemd. 8 | 9 | # Types of bootable disk images planned for (diskimage/type): 10 | # cloud-init - an image that starts cloud-init for configuration and then can be 11 | # used out of the box 12 | # console - an image that has an empty root password and allows passwordless 13 | # login on the console only 14 | # ssh - an image that populates /root/.ssh/authorized_keys and starts dhcp 15 | # as well as sshd; obviously not fit for public distribution 16 | # generic - an image with no means of logging in... needs postprocessing 17 | # no services are started 18 | 19 | configure_dhcp() { 20 | echo "Configuring DHCP on all ethernet devices" 21 | cat > /etc/systemd/network/default.network <<'END' 22 | [Match] 23 | Name=en* 24 | 25 | [Network] 26 | DHCP=yes 27 | END 28 | } 29 | 30 | configure_sshd() { 31 | echo "Configuring sshd" 32 | mkdir -vp /root/.ssh 33 | chown root:root /root/.ssh 34 | echo "${clst_diskimage_sshkey}" > /root/.ssh/authorized_keys 35 | } 36 | 37 | echo "Generating /etc/locale.gen" 38 | cat > /etc/locale.gen < /etc/locale.conf || die "Failed to set locale" 49 | env-update || die "Failed to run env-update" 50 | 51 | echo "Setting keymap" 52 | echo "KEYMAP=us" > /etc/vconsole.conf || die "Failed to set keymap" 53 | 54 | echo "Disk image type is ${clst_diskimage_type}" 55 | case ${clst_diskimage_type} in 56 | generic) 57 | echo "Setting up generic image (warning, not very useful on its own)" 58 | echo "Running systemd-firstboot" 59 | systemd-firstboot --timezone=UTC || die "Failed running systemd-firstboot" 60 | ;; 61 | console) 62 | echo "Setting up console log-in image. Please set the root password ASAP." 63 | echo "Removing root password" 64 | passwd -d root || die "Failed removing root password" 65 | echo "Running systemd-firstboot" 66 | systemd-firstboot --timezone=UTC || die "Failed running systemd-firstboot" 67 | configure_dhcp 68 | ;; 69 | ssh) 70 | echo "Setting up ssh log-in image, using the following key" 71 | echo " ${clst_diskimage_sshkey}" 72 | echo "Running systemd-firstboot" 73 | systemd-firstboot --timezone=UTC || die "Failed running systemd-firstboot" 74 | configure_dhcp 75 | configure_sshd 76 | echo "Adding sshd service" 77 | systemctl enable sshd || die "Failed enabling sshd service" 78 | ;; 79 | cloud-init|cloudinit) 80 | echo "Setting up cloud-init image" 81 | echo "Running systemd-firstboot" 82 | systemd-firstboot --timezone=UTC || die "Failed running systemd-firstboot" 83 | echo "Enabling cloud-init services" 84 | for name in cloud-init-main cloud-init-local cloud-init-network cloud-config cloud-final ; do 85 | systemctl enable ${name}.service || die "Failed enabling ${name}.service" 86 | done 87 | ;; 88 | *) 89 | die "As yet unsupported image type" 90 | ;; 91 | esac 92 | 93 | else 94 | 95 | # We are using OpenRC. 96 | 97 | die "OpenRC is as yet unsupported." 98 | 99 | fi 100 | 101 | # all done 102 | # (we can't install the boot loader here because nothing is mounted) 103 | -------------------------------------------------------------------------------- /targets/support/functions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | copy_to_chroot() { 4 | local src="${1}" 5 | local dst="${clst_chroot_path}/${2:-/tmp}" 6 | cp -pPR "${src}" "${dst}" 7 | } 8 | 9 | delete_from_chroot() { 10 | rm -f "${clst_chroot_path}/${1}" 11 | } 12 | 13 | # Takes the full path to the source file as its argument 14 | # copies the file to the /tmp directory of the chroot 15 | # and executes it. 16 | exec_in_chroot() { 17 | local file_name=$(basename ${1}) 18 | 19 | copy_to_chroot ${1} 20 | copy_to_chroot ${clst_shdir}/support/chroot-functions.sh 21 | 22 | # Ensure the file has the executable bit set 23 | chmod +x ${clst_chroot_path}/tmp/${file_name} 24 | 25 | echo "Running ${file_name} in chroot:" 26 | echo " ${clst_CHROOT} ${clst_chroot_path} /tmp/${file_name}" 27 | ${clst_CHROOT} "${clst_chroot_path}" "/tmp/${file_name}" || exit 1 28 | 29 | delete_from_chroot /tmp/${file_name} 30 | delete_from_chroot /tmp/chroot-functions.sh 31 | } 32 | 33 | die() { 34 | echo "$1" 35 | exit 1 36 | } 37 | 38 | extract_cdtar() { 39 | # Create a filesystem tree for the ISO at 40 | # $clst_target_path. We extract the "cdtar" to this directory, 41 | # which will normally contains a pre-built binary 42 | # boot-loader/filesystem skeleton for the ISO. 43 | tar -I lbzip2 -xpf ${clst_cdtar} -C $1 || die "Couldn't extract cdtar ${cdtar}" 44 | } 45 | 46 | extract_kernels() { 47 | # extract multiple kernels 48 | # $1 = Destination 49 | # ${clst_target_path}/kernel is often a good choice for ${1} 50 | 51 | # Takes the relative desination dir for the kernel as an arguement 52 | # i.e boot 53 | [ -z "$clst_boot_kernel" ] && \ 54 | die "Required key boot/kernel not defined, exiting" 55 | # install the kernels built in kmerge.sh 56 | for x in ${clst_boot_kernel} 57 | do 58 | first=${first:-""} 59 | kbinary="${clst_chroot_path}/tmp/kerncache/${x}-kernel-initrd-${clst_version_stamp}.tar.bz2" 60 | if [ -z "${first}" ] 61 | then 62 | # grab name of first kernel 63 | export first="${x}" 64 | fi 65 | 66 | [ ! -e "${kbinary}" ] && die "Can't find kernel tarball at ${kbinary}" 67 | mkdir -p ${1}/ 68 | tar -I lbzip2 -xf ${kbinary} -C ${1}/ 69 | 70 | # change config name from "config-*" to "gentoo-config", for example 71 | mv ${1}/config-* ${1}/${x}-config 72 | 73 | # change kernel name from "kernel" to "gentoo", for example 74 | if [ -e ${1}/kernel-* ] 75 | then 76 | mv ${1}/kernel-* ${1}/${x} 77 | fi 78 | if [ -e ${1}/kernelz-* ] 79 | then 80 | mv ${1}/kernelz-* ${1}/${x} 81 | fi 82 | if [ -e ${1}/vmlinuz-* ] 83 | then 84 | mv ${1}/vmlinuz-* ${1}/${x} 85 | fi 86 | if [ -e ${1}/vmlinux-* ] 87 | then 88 | mv ${1}/vmlinux-* ${1}/${x} 89 | fi 90 | 91 | # change initrd name from "initrd" to "gentoo.igz", for example 92 | if [ -e ${1}/initrd-* ] 93 | then 94 | mv ${1}/initrd-* ${1}/${x}.igz 95 | fi 96 | if [ -e ${1}/initramfs-* ] 97 | then 98 | mv ${1}/initramfs-* ${1}/${x}.igz 99 | fi 100 | 101 | # rename "System.map" to "System-gentoo.map", for example 102 | if [ -e ${1}/System.map-* ] 103 | then 104 | mv ${1}/System.map-* ${1}/System-${x}.map 105 | fi 106 | done 107 | } 108 | 109 | extract_modules() { 110 | # $1 = Destination 111 | # $2 = kname 112 | kmodules="${clst_chroot_path}/tmp/kerncache/${2}-modules-${clst_version_stamp}.tar.bz2" 113 | 114 | if [ -f "${kmodules}" ] 115 | then 116 | mkdir -p ${1}/ 117 | tar -I lbzip2 -xf ${kmodules} --strip-components 1 -C ${1}/lib lib 118 | else 119 | echo "Can't find kernel modules tarball at ${kmodules}. Skipping...." 120 | fi 121 | } 122 | -------------------------------------------------------------------------------- /targets/support/iso-bootloader-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ${clst_shdir}/support/functions.sh 4 | 5 | # $1 is the destination root 6 | 7 | if [[ -n ${clst_cdtar} ]]; then 8 | extract_cdtar $1 9 | fi 10 | 11 | extract_kernels $1/boot 12 | 13 | cmdline_opts=() 14 | 15 | # Add any additional options 16 | if [ -n "${clst_livecd_bootargs}" ] 17 | then 18 | for x in ${clst_livecd_bootargs} 19 | do 20 | cmdline_opts+=(${x}) 21 | done 22 | fi 23 | 24 | case ${clst_fstype} in 25 | squashfs) 26 | cmdline_opts+=(looptype=squashfs loop=/image.squashfs) 27 | ;; 28 | jffs2) 29 | cmdline_opts+=(looptype=jffs2 loop=/image.jffs2) 30 | ;; 31 | esac 32 | 33 | # Optional memtest setups 34 | memtest_grub() { 35 | if [[ -e $1/memtest64.bios ]]; then 36 | echo 'if [ "x$grub_platform" = xpc ]; then' 37 | echo ' menuentry "Memtest86+ 64bit BIOS" {' 38 | echo ' linux "/memtest64.bios"' 39 | echo ' }' 40 | echo 'fi' 41 | fi 42 | if [[ -e $1/memtest.efi64 ]]; then 43 | echo 'if [ "x$grub_platform" = xefi ]; then' 44 | echo ' menuentry "Memtest86+ 64bit UEFI" {' 45 | echo ' chainloader "/memtest.efi64"' 46 | echo ' }' 47 | echo 'fi' 48 | fi 49 | if [[ -e $1/memtest32.bios ]]; then 50 | echo 'menuentry "Memtest86+ 32bit BIOS" {' 51 | echo ' linux "/memtest32.bios"' 52 | echo '}' 53 | fi 54 | } 55 | 56 | default_append_line=(${cmdline_opts[@]} cdroot) 57 | default_dracut_append_line=(${clst_livecd_bootargs} root=live:CDLABEL=${clst_iso_volume_id} rd.live.dir=/ rd.live.squashimg=image.squashfs cdroot) 58 | 59 | case ${clst_hostarch} in 60 | alpha) 61 | # NO SOFTLEVEL SUPPORT YET 62 | acfg=$1/etc/aboot.conf 63 | bctr=0 64 | # Pass 1 is for non-serial 65 | for x in ${clst_boot_kernel} 66 | do 67 | echo -n "${bctr}:/boot/${x} " >> ${acfg} 68 | echo -n "initrd=/boot/${x}.igz " >> ${acfg} 69 | echo "${cmdline_opts[@]} cdroot" >> ${acfg} 70 | ((bctr=${bctr}+1)) 71 | done 72 | # Pass 2 is for serial 73 | cmdline_opts+=(console=ttyS0) 74 | for x in ${clst_boot_kernel} 75 | do 76 | echo -n "${bctr}:/boot/${x} " >> ${acfg} 77 | echo -n "initrd=/boot/${x}.igz " >> ${acfg} 78 | echo "${cmdline_opts[@]} cdroot" >> ${acfg} 79 | ((bctr=${bctr}+1)) 80 | done 81 | ;; 82 | arm) 83 | # NO SOFTLEVEL SUPPORT YET 84 | ;; 85 | hppa) 86 | # NO SOFTLEVEL SUPPORT YET 87 | mkdir -p $1/boot 88 | 89 | icfg=$1/boot/palo.conf 90 | kmsg=$1/boot/kernels.msg 91 | hmsg=$1/boot/help.msg 92 | # Make sure we strip the extension to the kernel to allow palo to choose 93 | boot_kernel_common_name=${first/%32/} 94 | boot_kernel_common_name=${boot_kernel_common_name/%64/} 95 | 96 | # copy the bootloader for the final image 97 | cp /usr/share/palo/iplboot $1/boot/ 98 | 99 | echo "--commandline=0/${boot_kernel_common_name} initrd=${first}.igz ${default_append_line[@]}" >> ${icfg} 100 | echo "--bootloader=boot/iplboot" >> ${icfg} 101 | echo "--ramdisk=boot/${first}.igz" >> ${icfg} 102 | for x in ${clst_boot_kernel} 103 | do 104 | echo "--recoverykernel=boot/${x}" >> ${icfg} 105 | done 106 | ;; 107 | amd64|arm64|ia64|ppc*|powerpc*|sparc*|x86|i?86) 108 | kern_subdir=/boot 109 | iacfg=$1/boot/grub/grub.cfg 110 | mkdir -p $1/boot/grub 111 | echo 'set default=0' > ${iacfg} 112 | echo 'set gfxpayload=keep' >> ${iacfg} 113 | echo 'set timeout=10' >> ${iacfg} 114 | echo 'insmod all_video' >> ${iacfg} 115 | echo '' >> ${iacfg} 116 | for x in ${clst_boot_kernel} 117 | do 118 | eval "kernel_console=\$clst_boot_kernel_${x}_console" 119 | eval "distkernel=\$clst_boot_kernel_${x}_distkernel" 120 | 121 | echo "menuentry 'Boot LiveCD (kernel: ${x})' --class gnu-linux --class os {" >> ${iacfg} 122 | if [ ${distkernel} = "yes" ] 123 | then 124 | echo " search --no-floppy --set=root -l ${clst_iso_volume_id}" >> ${iacfg} 125 | echo " linux ${kern_subdir}/${x} ${default_dracut_append_line[@]}" >> ${iacfg} 126 | else 127 | echo " linux ${kern_subdir}/${x} ${default_append_line[@]}" >> ${iacfg} 128 | fi 129 | echo " initrd ${kern_subdir}/${x}.igz" >> ${iacfg} 130 | echo "}" >> ${iacfg} 131 | echo "" >> ${iacfg} 132 | echo "menuentry 'Boot LiveCD (kernel: ${x}) (cached)' --class gnu-linux --class os {" >> ${iacfg} 133 | if [ ${distkernel} = "yes" ] 134 | then 135 | echo " search --no-floppy --set=root -l ${clst_iso_volume_id}" >> ${iacfg} 136 | echo " linux ${kern_subdir}/${x} ${default_dracut_append_line[@]} rd.live.ram=1" >> ${iacfg} 137 | else 138 | echo " linux ${kern_subdir}/${x} ${default_append_line[@]} docache" >> ${iacfg} 139 | fi 140 | 141 | echo " initrd ${kern_subdir}/${x}.igz" >> ${iacfg} 142 | echo "}" >> ${iacfg} 143 | if [ -n "${kernel_console}" ] 144 | then 145 | echo "submenu 'Special console options (kernel: ${x})' --class gnu-linux --class os {" >> ${iacfg} 146 | for y in ${kernel_console} 147 | do 148 | echo "menuentry 'Boot LiveCD (kernel: ${x} console=${y})' --class gnu-linux --class os {" >> ${iacfg} 149 | echo " linux ${kern_subdir}/${x} ${default_append_line[@]} console=${y}" >> ${iacfg} 150 | echo " initrd ${kern_subdir}/${x}.igz" >> ${iacfg} 151 | echo "}" >> ${iacfg} 152 | echo "" >> ${iacfg} 153 | done 154 | echo "}" >> ${iacfg} 155 | fi 156 | echo "" >> ${iacfg} 157 | done 158 | memtest_grub $1 >> ${iacfg} 159 | ;; 160 | mips) 161 | # NO SOFTLEVEL SUPPORT YET 162 | 163 | # Mips is an interesting arch -- where most archs will 164 | # use ${1} as the root of the LiveCD, an SGI LiveCD lacks 165 | # such a root. Instead, we will use ${1} as a scratch 166 | # directory to build the components we need for the 167 | # CD image, and then pass these components to the 168 | # `sgibootcd` tool which outputs a final CD image 169 | scratch="${1}" 170 | mkdir -p ${scratch}/{kernels/misc,arcload} 171 | echo "" > ${scratch}/arc.cf 172 | 173 | # Move kernel binaries to ${scratch}/kernels, and 174 | # move everything else to ${scratch}/kernels/misc 175 | for x in ${clst_boot_kernel}; do 176 | [ -e "${1}/boot/${x}" ] && mv ${1}/boot/${x} ${scratch}/kernels 177 | [ -e "${1}/boot/${x}.igz" ] && mv ${1}/boot/${x}.igz ${scratch}/kernels/misc 178 | done 179 | [ -d "${1}/boot" ] && rmdir ${1}/boot 180 | 181 | # Source the arcload source file to generated required sections of arc.cf 182 | source ${clst_shdir}/support/mips-arcload_conf.sh 183 | 184 | # Generate top portions of the config 185 | echo -e "${topofconfig}${serial}${dbg}${cmt1}" >> ${scratch}/arc.cf 186 | 187 | # Next, figure out what kernels were specified in the 188 | # spec file, and generate the appropriate arcload conf 189 | # blocks specific to each system 190 | ip22="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip22" | tr "\n" " ")" 191 | ip27="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip27" | tr "\n" " ")" 192 | ip28="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip28" | tr "\n" " ")" 193 | ip30="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip30" | tr "\n" " ")" 194 | ip32="$(echo ${clst_boot_kernel} | tr " " "\n" | grep "ip32" | tr "\n" " ")" 195 | 196 | if [ -n "${ip22}" ]; then 197 | echo -e "${ip22base}" >> ${scratch}/arc.cf 198 | for x in ${ip22}; do echo -e "${!x}" >> ${scratch}/arc.cf; done 199 | echo -e "${ip22vid}${ip22x}" >> ${scratch}/arc.cf 200 | fi 201 | 202 | [ -n "${ip27}" ] && echo -e "${ip27base}" >> ${scratch}/arc.cf 203 | [ -n "${ip28}" ] && echo -e "${ip28base}" >> ${scratch}/arc.cf 204 | [ -n "${ip30}" ] && echo -e "${ip30base}" >> ${scratch}/arc.cf 205 | 206 | if [ -n "${ip32}" ]; then 207 | echo -e "${ip32base}" >> ${scratch}/arc.cf 208 | for x in ${ip32}; do echo -e "${!x}" >> ${scratch}/arc.cf; done 209 | echo -e "${ip32vid}${ip32x}" >> ${scratch}/arc.cf 210 | fi 211 | 212 | # Finish off the config 213 | echo -e "${cmt2}" >> ${scratch}/arc.cf 214 | 215 | # Move the bootloader binaries & config to their destination 216 | [ -e "${1}/sashARCS" ] && mv ${1}/sashARCS ${scratch}/arcload 217 | [ -e "${1}/sash64" ] && mv ${1}/sash64 ${scratch}/arcload 218 | [ -e "${1}/arc.cf" ] && mv ${1}/arc.cf ${scratch}/arcload 219 | ;; 220 | esac 221 | exit $? 222 | -------------------------------------------------------------------------------- /targets/support/kmerge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | install -d /tmp/kerncache 6 | 7 | distkmerge_get_image_path() { 8 | case ${clst_basearch} in 9 | amd64|x86) 10 | echo arch/x86/boot/bzImage 11 | ;; 12 | arm64) 13 | echo arch/arm64/boot/Image.gz 14 | ;; 15 | arm) 16 | echo arch/arm/boot/zImage 17 | ;; 18 | hppa|ppc|ppc64) 19 | echo ./vmlinux 20 | ;; 21 | riscv) 22 | echo arch/riscv/boot/Image.gz 23 | ;; 24 | *) 25 | die "unsupported ARCH=${clst_basearch}" 26 | ;; 27 | esac 28 | } 29 | 30 | genkernel_compile() { 31 | # default genkernel args 32 | GK_ARGS=( 33 | "${kernel_gk_kernargs[@]}" 34 | --cachedir=/tmp/kerncache/${kname}-genkernel_cache-${clst_version_stamp} 35 | --no-mountboot 36 | --kerneldir=/usr/src/linux 37 | --modulespackage=/tmp/kerncache/${kname}-modules-${clst_version_stamp}.tar.bz2 38 | --minkernpackage=/tmp/kerncache/${kname}-kernel-initrd-${clst_version_stamp}.tar.bz2 all 39 | ) 40 | # extra genkernel options that we have to test for 41 | if [[ -n ${clst_gk_mainargs} ]]; then 42 | GK_ARGS+=(${clst_gk_mainargs}) 43 | fi 44 | if [[ -n ${clst_KERNCACHE} ]]; then 45 | GK_ARGS+=(--kerncache=/tmp/kerncache/${kname}-kerncache-${clst_version_stamp}.tar.bz2) 46 | fi 47 | if [[ -e /var/tmp/${kname}.config ]]; then 48 | GK_ARGS+=(--kernel-config=/var/tmp/${kname}.config) 49 | fi 50 | if [[ -d /tmp/initramfs_overlay/${initramfs_overlay} ]]; then 51 | GK_ARGS+=(--initramfs-overlay=/tmp/initramfs_overlay/${initramfs_overlay}) 52 | fi 53 | if [[ -n ${clst_CCACHE} ]]; then 54 | GK_ARGS+=(--kernel-cc=/usr/lib/ccache/bin/gcc --utils-cc=/usr/lib/ccache/bin/gcc) 55 | fi 56 | if [[ -n ${clst_linuxrc} ]]; then 57 | GK_ARGS+=(--linuxrc=/tmp/linuxrc) 58 | fi 59 | if [[ -n ${clst_busybox_config} ]]; then 60 | GK_ARGS+=(--busybox-config=/tmp/busy-config) 61 | fi 62 | if [[ ${clst_target} == netboot ]]; then 63 | GK_ARGS+=(--netboot) 64 | 65 | if [[ -n ${clst_merge_path} ]]; then 66 | GK_ARGS+=(--initramfs-overlay="${clst_merge_path}") 67 | fi 68 | fi 69 | if [[ -n ${clst_VERBOSE} ]]; then 70 | GK_ARGS+=(--loglevel=2) 71 | fi 72 | 73 | if [[ -n ${clst_VERBOSE} ]]; then 74 | gk_callback_opts=(-vN) 75 | else 76 | gk_callback_opts=(-qN) 77 | fi 78 | if [[ -n ${clst_KERNCACHE} ]]; then 79 | gk_callback_opts+=(-kb) 80 | fi 81 | if [[ -n ${clst_FETCH} ]]; then 82 | gk_callback_opts+=(-f) 83 | fi 84 | 85 | if [[ -n ${kernel_merge} ]]; then 86 | gk_callback=${gk_callback_opts[@]} 87 | genkernel --callback="emerge ${gk_callback} ${kernel_merge}" \ 88 | "${GK_ARGS[@]}" || exit 1 89 | else 90 | genkernel "${GK_ARGS[@]}" || exit 1 91 | fi 92 | } 93 | 94 | [ -n "${clst_ENVSCRIPT}" ] && source /tmp/envscript 95 | 96 | # Set the timezone for the kernel build 97 | rm /etc/localtime 98 | cp -f /usr/share/zoneinfo/UTC /etc/localtime 99 | 100 | eval "initramfs_overlay=\$clst_boot_kernel_${kname}_initramfs_overlay" 101 | eval "kernel_merge=\$clst_boot_kernel_${kname}_packages" 102 | eval "kernel_use=\$clst_boot_kernel_${kname}_use" 103 | eval eval kernel_gk_kernargs=( \$clst_boot_kernel_${kname}_gk_kernargs ) 104 | eval eval kernel_dracut_kernargs=( \$clst_boot_kernel_${kname}_dracut_args ) 105 | eval "ksource=\$clst_boot_kernel_${kname}_sources" 106 | eval "distkernel=\$clst_boot_kernel_${kname}_distkernel" 107 | 108 | if [[ ${distkernel} = "yes" ]] ; then 109 | [[ -z ${ksource} ]] && ksource="sys-kernel/gentoo-kernel" 110 | else 111 | [[ -z ${ksource} ]] && ksource="sys-kernel/gentoo-sources" 112 | fi 113 | 114 | kernel_version=$(portageq best_visible / "${ksource}") 115 | 116 | if [[ -n ${clst_KERNCACHE} ]]; then 117 | mkdir -p "/tmp/kerncache/${kname}" 118 | pushd "/tmp/kerncache/${kname}" >/dev/null 119 | 120 | echo "${kernel_use}" > /tmp/USE 121 | echo "${kernel_version}" > /tmp/VERSION 122 | echo "${clst_kextraversion}" > /tmp/EXTRAVERSION 123 | 124 | if cmp -s {/tmp/,}USE && \ 125 | cmp -s {/tmp/,}VERSION && \ 126 | cmp -s {/tmp/,}EXTRAVERSION && \ 127 | cmp -s /var/tmp/${kname}.config CONFIG; then 128 | cached_kernel_found="true" 129 | fi 130 | 131 | rm -f /tmp/{USE,VERSION,EXTRAVERSION} 132 | popd >/dev/null 133 | fi 134 | 135 | if [[ ! ${cached_kernel_found} ]]; then 136 | if [[ ${distkernel} = "yes" ]] ; then 137 | USE="-initramfs" run_merge --update "${ksource}" 138 | else 139 | USE="symlink" run_merge --update "${ksource}" 140 | fi 141 | fi 142 | 143 | if [[ -n ${clst_KERNCACHE} ]]; then 144 | SOURCESDIR="/tmp/kerncache/${kname}/sources" 145 | if [[ ! ${cached_kernel_found} ]]; then 146 | echo "Moving kernel sources to ${SOURCESDIR} ..." 147 | 148 | rm -rf "${SOURCESDIR}" 149 | mv $(readlink -f /usr/src/linux) "${SOURCESDIR}" 150 | fi 151 | ln -snf "${SOURCESDIR}" /usr/src/linux 152 | fi 153 | 154 | if [[ ${distkernel} = "yes" ]] ; then 155 | # Build external kernel modules 156 | if [[ -n ${kernel_merge} ]]; then 157 | run_merge ${kernel_merge} 158 | fi 159 | 160 | # Kernel already built, let's run dracut to make initramfs 161 | distkernel_source_path=$(equery -Cq f ${ksource} | grep "/usr/src/linux-" -m1) 162 | distkernel_image_path=$(distkmerge_get_image_path) 163 | distkernel_version=${distkernel_source_path##"/usr/src/linux-"} 164 | 165 | DRACUT_ARGS=( 166 | "${kernel_dracut_kernargs[@]}" 167 | --force 168 | --kernel-image="${distkernel_source_path}/${distkernel_image_path}" 169 | --kver="${distkernel_version}" 170 | ) 171 | 172 | dracut "${DRACUT_ARGS[@]}" || exit 1 173 | 174 | # Create minkernel package to mimic genkernel's behaviour 175 | cd /boot 176 | tar jcvf /tmp/kerncache/${kname}-kernel-initrd-${clst_version_stamp}.tar.bz2 System.map* config* initramfs* vmlinuz* vmlinux* 177 | cd / 178 | tar jcvf /tmp/kerncache/${kname}-modules-${clst_version_stamp}.tar.bz2 lib/modules 179 | 180 | else 181 | if [[ -n ${clst_kextraversion} ]]; then 182 | echo "Setting EXTRAVERSION to ${clst_kextraversion}" 183 | 184 | if [[ -e /usr/src/linux/Makefile.bak ]]; then 185 | cp /usr/src/linux/Makefile{.bak,} 186 | else 187 | cp /usr/src/linux/Makefile{,.bak} 188 | fi 189 | sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" \ 190 | /usr/src/linux/Makefile 191 | fi 192 | 193 | genkernel_compile 194 | fi 195 | 196 | # Write out CONFIG, USE, VERSION, and EXTRAVERSION files 197 | if [[ -n ${clst_KERNCACHE} && ! ${cached_kernel_found} ]]; then 198 | pushd "/tmp/kerncache/${kname}" >/dev/null 199 | 200 | cp /var/tmp/${kname}.config CONFIG 201 | echo "${kernel_use}" > USE 202 | echo "${kernel_version}" > VERSION 203 | echo "${clst_kextraversion}" > EXTRAVERSION 204 | 205 | popd >/dev/null 206 | fi 207 | 208 | if [[ ! ${cached_kernel_found} ]]; then 209 | run_merge --deselect "${ksource}" 210 | # This was breaking multi-kernel iso builds, probably not needed 211 | # rm /usr/src/linux 212 | fi 213 | -------------------------------------------------------------------------------- /targets/support/livecdfs-update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | RUN_DEFAULT_FUNCS="no" 4 | 5 | source /tmp/chroot-functions.sh 6 | 7 | # Allow root logins to our CD by default 8 | if [ -e /etc/ssh/sshd_config ] 9 | then 10 | sed -i \ 11 | -e '/^#PermitRootLogin/c# Allow root login with password on livecds.\nPermitRootLogin Yes' \ 12 | /etc/ssh/sshd_config 13 | fi 14 | 15 | # Clean up the time and set to UTC 16 | rm -rf /etc/localtime 17 | cp /usr/share/zoneinfo/UTC /etc/localtime 18 | 19 | # Setup the hostname 20 | echo 'hostname="livecd"' > /etc/conf.d/hostname 21 | echo "127.0.0.1 livecd.gentoo livecd localhost" > /etc/hosts 22 | 23 | # Since we're an official Gentoo release, we do things the official Gentoo way. 24 | # As such, we override livecd/users. 25 | case ${clst_livecd_type} in 26 | gentoo-release-live*) 27 | user_comment="Gentoo default user" 28 | clst_livecd_users="gentoo" 29 | ;; 30 | esac 31 | 32 | # Add any users 33 | if [ -n "${clst_livecd_users}" ] 34 | then 35 | first_user=$(echo ${clst_livecd_users} | cut -d' ' -f1) 36 | default_comment="Default LiveCD User" 37 | [ -z "${user_comment}" ] && user_comment=${default_comment} 38 | 39 | if [ "$(getent group games | cut -d: -f1)" != "games" ] 40 | then 41 | echo "Adding games group" 42 | groupadd -g 35 games 43 | fi 44 | if [ "$(getent group plugdev | cut -d: -f1)" != "plugdev" ] 45 | then 46 | echo "Adding plugdev group" 47 | groupadd plugdev 48 | fi 49 | for x in ${clst_livecd_users} 50 | do 51 | useradd -G users,wheel,audio,plugdev,games,cdrom,disk,floppy,usb \ 52 | -g 100 -c "${user_comment}" -m ${x} 53 | chown -R ${x}:users /home/${x} 54 | done 55 | fi 56 | 57 | # Setup sudoers 58 | if [ -f /etc/sudoers ] 59 | then 60 | sed -i '/NOPASSWD: ALL/ s/^# //' /etc/sudoers 61 | fi 62 | 63 | # Add this for hwsetup/mkx86config 64 | mkdir -p /etc/sysconfig 65 | 66 | cat < /etc/fstab 67 | #################################################### 68 | ## ATTENTION: THIS IS THE FSTAB ON THE LIVECD ## 69 | ## PLEASE EDIT THE FSTAB at /mnt/gentoo/etc/fstab ## 70 | #################################################### 71 | 72 | # fstab tweaks 73 | tmpfs / tmpfs defaults 0 0 74 | EOF 75 | 76 | mv ${clst_make_conf} ${clst_make_conf}.old 77 | cat < ${clst_make_conf} 78 | #################################################### 79 | ## ATTENTION: THIS IS THE MAKE.CONF ON THE LIVECD ## 80 | ## PLEASE EDIT /mnt/gentoo${clst_make_conf} INSTEAD ## 81 | #################################################### 82 | EOF 83 | cat ${clst_make_conf}.old >> ${clst_make_conf} 84 | 85 | # Add some helpful aliases 86 | cat <> /etc/profile 87 | alias cp='cp -i' 88 | alias mv='mv -i' 89 | alias rm='rm -i' 90 | alias ls='ls --color=auto' 91 | alias ll='ls -l' 92 | alias grep='grep --color=auto' 93 | EOF 94 | 95 | # Tweak the MOTD for Gentoo releases 96 | case ${clst_livecd_type} in 97 | gentoo-release-minimal) 98 | cat /etc/generic.motd.txt /etc/minimal.motd.txt > /etc/motd 99 | sed -i 's:^##GREETING:Welcome to the Gentoo Linux Minimal Installation CD!:' /etc/motd 100 | ;; 101 | gentoo-release-live*) 102 | cat /etc/generic.motd.txt /etc/livecd.motd.txt > /etc/motd 103 | sed -i -e 's:^##GREETING:Welcome to the Gentoo Linux LiveCD!:' /etc/motd 104 | ;; 105 | esac 106 | 107 | rm -f /etc/generic.motd.txt /etc/minimal.motd.txt /etc/livecd.motd.txt 108 | 109 | # Post configuration 110 | case ${clst_livecd_type} in 111 | gentoo-release-*) 112 | # Clear out lastlog 113 | rm -f /var/log/lastlog && touch /var/log/lastlog 114 | 115 | cat <<-EOF > /usr/share/applications/gentoo-handbook.desktop 116 | [Desktop Entry] 117 | Encoding=UTF-8 118 | Version=1.0 119 | Type=Link 120 | URL=https://wiki.gentoo.org/wiki/Handbook:Main_Page 121 | Terminal=false 122 | Name=Gentoo Linux Handbook 123 | GenericName=Gentoo Linux Handbook 124 | Comment=This is a link to Gentoo Linux Handbook. 125 | Icon=text-editor 126 | EOF 127 | 128 | # Copy our icons into place and build home directories 129 | if [ -n "${clst_livecd_users}" ] 130 | then 131 | for username in ${clst_livecd_users} 132 | do 133 | mkdir -p /home/${username}/Desktop 134 | # Copy our Handbook icon 135 | [ -e /usr/share/applications/gentoo-handbook.desktop ] && \ 136 | cp -f /usr/share/applications/gentoo-handbook.desktop \ 137 | /home/${username}/Desktop 138 | chown -R ${username}:100 /home/${username} 139 | done 140 | fi 141 | ;; 142 | generic-livecd ) 143 | ;; 144 | esac 145 | 146 | env-update 147 | -------------------------------------------------------------------------------- /targets/support/mips-arcload_conf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | #// Variables holding the data of the arcload config file, arc.cf 5 | #//----------------------------------------------------------------------------- 6 | 7 | topofconfig="# Gentoo/MIPS LiveCD Prototype\n# ARCLoad Configuration\n\ndetect;\n\n\ 8 | # Global options\ncomment\t\t\"Global Options (not bootable):\\\n\\\r\\\n\\\r\";\n\n" 9 | 10 | serial="serial {\n\ 11 | \tbaud=9600 {\n\ 12 | \t\tport1 {\n\ 13 | \t\t\tdescription\t\"Serial Console, Port 1, 9600 Baud\";\n\ 14 | \t\t\timage\t\t\"\";\n\ 15 | \t\t\tappend\t\t\"console=ttyS0,9600\" \"nox\";\n\ 16 | \t\t}\n\n\ 17 | \t\tport2 {\n\ 18 | \t\t\tdescription\t\"Serial Console, Port 2, 9600 Baud\";\n\ 19 | \t\t\timage\t\t\"\";\n\ 20 | \t\t\tappend\t\t\"console=ttyS1,9600\" \"nox\";\n\ 21 | \t\t}\n\ 22 | \t}\n\n\ 23 | \tbaud=38400 {\n\ 24 | \t\tport1 {\n\ 25 | \t\t\tdescription\t\"Serial Console, Port 1, 38400 Baud\";\n\ 26 | \t\t\timage\t\t\"\";\n\ 27 | \t\t\tappend\t\t\"console=ttyS0,38400\" \"nox\";\n\ 28 | \t\t}\n\n\ 29 | \t\tport2 {\n\ 30 | \t\t\tdescription\t\"Serial Console, Port 2, 38400 Baud\";\n\ 31 | \t\t\timage\t\t\"\";\n\ 32 | \t\t\tappend\t\t\"console=ttyS1,38400\" \"nox\";\n\ 33 | \t\t}\n\ 34 | \t}\n\ 35 | }\n\n\n" 36 | 37 | dbg="debug {\n\ 38 | \tdescription\t\"Debug Shell\";\n\ 39 | \timage\t\t\"\";\n\ 40 | \tappend\t\t\"real_root=shell\" \"nox\";\n}\n\n" 41 | 42 | cmt1="comment\t\t\"\\\n\\\n\";\n\ 43 | comment\t\t\"Bootable Images & Options:\\\n\\\r\\\n\\\r\";\n" 44 | 45 | ip22base="# IP22 R4x00 Systems (Indy/Indigo2)\n\ 46 | ip22 {\n\ 47 | \tdescription\t\"SGI Indy/Indigo2\";\n\ 48 | \tappend\t\t\"real_root=/dev/sr0\" \"cdroot=/dev/loop0\" \"looptype=sgimips\" \"nosound\";\n" 49 | 50 | ip22r4k="\tr4000 r4600 r4700 {\n\ 51 | \t\tdescription\t\"\\\tR4x00 CPU\";\n\ 52 | \t\timage system\t\"/ip22r4k\";\n\ 53 | \t}\n" 54 | 55 | ip22r5k="\tr5000 {\n\ 56 | \t\tdescription\t\"\\\tR5000 CPU\";\n\ 57 | \t\timage system\t\"/ip22r5k\";\n\ 58 | \t}\n" 59 | 60 | ip22vid="\tvideo {\n\ 61 | \t\tdescription\t\"\\\tNewport Console\\\n\\\r\";\n\ 62 | \t\tappend\t\t\"console=tty0\" \"ip22\";\n\ 63 | \t}\n" 64 | 65 | ip22x="}\n\n\n" 66 | 67 | ip27base="# IP27 Origin 200/2000\n\ 68 | ip27 {\n\ 69 | \tdescription\t\"SGI Origin 200/2000\\\n\\\r\";\n\ 70 | \timage system\t\"/ip27r10k\";\n\ 71 | \tappend\t\t\"real_root=/dev/sr0\" \"cdroot=/dev/loop0\" \"looptype=sgimips\" \"nox\" \"nosound\";\n\ 72 | }\n\n\n" 73 | 74 | ip28base="# IP28 Indigo2 Impact R10000\n\ 75 | ip28 {\n\ 76 | \tdescription\t\"SGI Indigo2 Impact R10000\\\n\\\r\";\n\ 77 | \timage system\t\"/ip28r10k\";\n\ 78 | \tappend\t\t\"real_root=/dev/sr0\" \"cdroot=/dev/loop0\" \"looptype=sgimips\" \"nosound\" \"ip28\";\n\ 79 | }\n\n\n" 80 | 81 | ip30base="# IP30 Octane\n\ 82 | ip30 {\n\ 83 | \tdescription\t\"SGI Octane\";\n\ 84 | \timage system\t\"/ip30r10k\";\n\ 85 | \tappend\t\t\"real_root=/dev/sr0\" \"cdroot=/dev/loop0\" \"looptype=sgimips\" \"nosound\" \"ip30\";\n\n\ 86 | \tnosmp {\n\ 87 | \t\tdescription\t\"\\\tUniprocessor Mode\";\n\ 88 | \t\tappend\t\t\"nosmp\";\n\ 89 | \t}\n\n\ 90 | \tvideo {\n\ 91 | \t\tdescription\t\"\\\tImpactSR/VPro Console\\\n\\\r\";\n\ 92 | \t\tappend\t\t\"console=tty0\" \"ip30\";\n\ 93 | \t}\n\ 94 | }\n\n\n" 95 | 96 | ip32base="# IP32 O2\n\ 97 | ip32 {\n\ 98 | \tdescription\t\"SGI O2\";\n\ 99 | \tappend\t\t\"real_root=/dev/sr0\" \"cdroot=/dev/loop0\" \"looptype=sgimips\" \"nosound\";\n" 100 | 101 | ip32r5k="\tr5000 {\n\ 102 | \t\tdescription\t\"\\\tR5000 CPU\";\n\ 103 | \t\timage system\t\"/ip32r5k\";\n\ 104 | \t}\n" 105 | 106 | ip32rm5k="\trm5200 {\n\ 107 | \t\tdescription\t\"\\\tRM5200 CPU\";\n\ 108 | \t\timage system\t\"/ip32rm5k\";\n\ 109 | \t}\n" 110 | 111 | ip32rm7k="\trm7000 {\n\ 112 | \t\tdescription\t\"\\\tRM7000 CPU\";\n\ 113 | \t\timage system\t\"/ip32rm7k\";\n\ 114 | \t}\n" 115 | 116 | ip32r10k="\tr10000 r12000 {\n\ 117 | \t\tdescription\t\"\\\tR10000/R12000 CPU\";\n\ 118 | \t\timage system\t\"/ip32r10k\";\n\ 119 | \t}\n" 120 | 121 | ip32vid="\tvideo=640x480 {\n\ 122 | \t\tdescription\t\"\\\tGBEFB Console 640x480 16bpp/75Hz\";\n\ 123 | \t\tappend\t\t\"console=tty0 video=gbefb:640x480-16@75\" \"ip32\";\n\ 124 | \t}\n\n\ 125 | \tvideo=800x600 {\n\ 126 | \t\tdescription\t\"\\\tGBEFB Console 800x600 16bpp/75Hz\";\n\ 127 | \t\tappend\t\t\"console=tty0 video=gbefb:800x600-16@75\" \"ip32\";\n\ 128 | \t}\n\n\ 129 | \tvideo=1024x768 {\n\ 130 | \t\tdescription\t\"\\\tGBEFB Console 1024x768 16bpp/75Hz\";\n\ 131 | \t\tappend\t\t\"console=tty0 video=gbefb:1024x768-16@75\" \"ip32\";\n\ 132 | \t}\n\n\ 133 | \tvideo=1280x1024 {\n\ 134 | \t\tdescription\t\"\\\tGBEFB Console 1280x1024 16bpp/75Hz\\\n\\\r\\\n\\\r\\\n\\\r\";\n\ 135 | \t\tappend\t\t\"console=tty0 video=gbefb:1280x1024-16@75\" \"ip32\";\n\ 136 | \t}\n" 137 | 138 | ip32x="}\n\n\n" 139 | 140 | cmt2="comment\t\t\"To boot an image, set \`OSLoadFilename\` to the to following sequence\";\n\ 141 | comment\t\t\"depending on your desired options (examples):\\\n\\\r\\\n\\\r\";\n\ 142 | comment\t\t\"IP32 R5000 w/ 38400 serial:\\\n\\\r\";\n\ 143 | comment\t\t\"setenv OSLoadFilename ip32(r5000,serial-h)\\\n\\\r\\\n\\\r\";\n\ 144 | comment\t\t\"IP32 RM5200 w/ GBEFB Console @ 800x600:\\\n\\\r\";\n\ 145 | comment\t\t\"setenv OSloadFilename ip32(rm5200,video=800x600)\\\n\\\r\\\n\\\r\";\n\ 146 | comment\t\t\"IP30 w/ no SMP and video:\\\n\\\r\";\n\ 147 | comment\t\t\"setenv OSLoadFilename ip30(nosmp,video)\\\n\\\r\\\n\\\r\\\n\\\r\";\n\ 148 | comment\t\t\"Once \`OSLoadFilename\` is set, execute:\\\n\\\r\\\n\\\r\";\n\ 149 | comment\t\t\"\`sashARCS\` for IP22/IP32\\\n\\\r\\\n\\\r\";\n\ 150 | comment\t\t\"\`sash64\` for IP27/IP28/IP30\\\n\\\r\\\n\\\r\";\n\n" 151 | 152 | #//----------------------------------------------------------------------------- 153 | -------------------------------------------------------------------------------- /targets/support/netboot-final.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ${clst_shdir}/support/functions.sh 4 | 5 | extract_kernels ${clst_target_path}/boot 6 | 7 | # Move kernel binaries to ${clst_target_path}/kernels, and 8 | # move everything else to ${clst_target_path}/kernels/misc 9 | mkdir -p ${clst_target_path}/kernels/misc 10 | 11 | for x in ${clst_boot_kernel}; do 12 | mv ${clst_target_path}/boot/${x} ${clst_target_path}/kernels 13 | mv ${clst_target_path}/boot/${x}.igz ${clst_target_path}/kernels/misc 14 | mv ${clst_target_path}/boot/System-${x}.map ${clst_target_path}/kernels/misc 15 | done 16 | 17 | rm -f ${clst_target_path}/boot/gentoo-config 18 | rmdir ${clst_target_path}/boot 19 | 20 | # Any post-processing necessary for each architecture can be done here. This 21 | # may include things like sparc's elftoaout, x86's PXE boot, etc. 22 | case ${clst_hostarch} in 23 | hppa) 24 | # Only one kernel should be there 25 | kname=${clst_boot_kernel[0]} 26 | rm -f ${clst_target_path}/${kname}-hppa.lif 27 | 28 | palo \ 29 | -k ${clst_target_path}/kernels/${kname} \ 30 | -r ${clst_target_path}/kernels/misc/${kname}.igz \ 31 | -s ${clst_target_path}/${kname}-hppa.lif \ 32 | -f /dev/null \ 33 | -b /usr/share/palo/iplboot \ 34 | -c "0/vmlinux initrd=0/ramdisk" \ 35 | || exit 1 36 | 37 | ;; 38 | sparc*) 39 | if [ "${clst_subarch}" == "sparc" ]; then 40 | piggyback=piggyback 41 | else 42 | piggyback=piggyback64 43 | fi 44 | for x in ${clst_boot_kernel}; do 45 | elftoaout ${clst_target_path}/kernels/${x} -o ${clst_target_path}/${x}-a.out 46 | ${piggyback} ${clst_target_path}/${x}-a.out ${clst_target_path}/kernels/misc/System-${x}.map ${clst_target_path}/kernels/misc/${x}.igz 47 | done 48 | ;; 49 | esac 50 | exit $? 51 | -------------------------------------------------------------------------------- /targets/support/pre-distkmerge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | RUN_DEFAULT_FUNCS="yes" 4 | 5 | source /tmp/chroot-functions.sh 6 | 7 | run_merge --oneshot sys-kernel/dracut 8 | -------------------------------------------------------------------------------- /targets/support/pre-kmerge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | RUN_DEFAULT_FUNCS="yes" 4 | 5 | source /tmp/chroot-functions.sh 6 | 7 | if [[ ${clst_hostarch} == hppa ]]; then 8 | for i in ${clst_boot_kernel}; do 9 | case ${i} in 10 | *32) 11 | let num32++ 12 | ;; 13 | *64) 14 | let num64++ 15 | ;; 16 | *) 17 | die "Kernel names must end with either \"32\" or \"64\"" 18 | ;; 19 | esac 20 | done 21 | [[ $num32 -gt 1 ]] && die "Only one 32-bit kernel can be configured" 22 | [[ $num64 -gt 1 ]] && die "Only one 64-bit kernel can be configured" 23 | fi 24 | 25 | run_merge --oneshot sys-kernel/genkernel 26 | install -d /tmp/kerncache 27 | -------------------------------------------------------------------------------- /targets/support/qcow2-grub-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /tmp/chroot-functions.sh 4 | 5 | echo "Setting up grub for also serial console" 6 | cat >> /etc/default/grub <