diff --git a/.mki/topdir b/.mki/topdir deleted file mode 100644 index 670d3332..00000000 --- a/.mki/topdir +++ /dev/null @@ -1 +0,0 @@ -this directory marks profile topdir, see mkimage README diff --git a/Makefile b/Makefile index 2d14f8e6..95ad9317 100644 --- a/Makefile +++ b/Makefile @@ -5,3 +5,14 @@ include clean.mk include distro.mk +include iso.mk + +# we can't use implicit rules for top-level targets, only for prereqs +CONFIGS=$(shell sed -n 's,^distro/\([^:]\+\):.*$$,\1,p' distro.mk) +DISTROS=$(addsuffix .iso,$(CONFIGS)) + +all: + @echo '** available distribution targets:' + @echo $(DISTROS) | fmt -sw65 | column -t + +$(DISTROS): %.iso: | prep distro/% iso diff --git a/README b/README new file mode 100644 index 00000000..159faa0b --- /dev/null +++ b/README @@ -0,0 +1,12 @@ +Объекты: +- дистрибутивы: distro.mk, могут основываться один на другом; + желательно избегать множественного наследования, используя + вместо него блоки use-* +- блоки функциональности use-*: не являются самостоятельными + (не путать с дистрибутивами), но законченными +- субпрофили: + + install2: инсталятор + + main: пакетная база к инсталяции (обязательная и дополнительная) + + ... +- списки пакетов: большая человеческая просьба по возможности + избегать дублирования diff --git a/bin/mktmpdir b/bin/mktmpdir new file mode 100755 index 00000000..0ed4b454 --- /dev/null +++ b/bin/mktmpdir @@ -0,0 +1,29 @@ +#!/bin/sh +# analyze free space, preferring tmpfs over really many gigaz + +# hope there aren't spaces in RM's $HOME are they? +DIRS="$TMP $TMPDIR $HOME/hasher /tmp /var/tmp" +MINSIZE=1048576 # face control criterion + +# pick existing, writeable, >1Gb free space dirs +# rank them wrt type: tmpfs > realfs > rootfs +choose_tmpdir() { + for i in $DIRS; do + [ -d "$i" -a -w "$i" ] || continue + echo -n "$i " + df -Tl "$i" | tail -1 + done \ + | sort -unk6 \ + | while read dir dev fstype size used free percent mnt; do + [ "$free" -gt "$MINSIZE" ] || continue + [ "$fstype" = "tmpfs" ] && { echo "2 $dir $free"; continue; } + [ "$mnt" = "/" ] && { echo "0 $dir $free"; continue; } + echo "1 $dir $free" + done \ + | sort -n \ + | tail -1 \ + | cut -f2 -d' ' +} + +DIR="`choose_tmpdir`" +mktemp -d "${1:-tmpdir}.XXXXXXXXXX" --tmpdir="${DIR:-..}" diff --git a/clean.mk b/clean.mk index 9d8199c6..d21630c6 100644 --- a/clean.mk +++ b/clean.mk @@ -1,3 +1,20 @@ -clean distclean: - @find -type f -name .config -delete 2>/dev/null ||: - make -C image $@ +clean: + @echo '** cleaning up...' + @[ -d build/ ] && \ + make -C build $@ GLOBAL_BUILDDIR=$(shell readlink build) \ + ||: + +distclean: clean + @[ -d build/ ] && \ + make -C build $@ GLOBAL_BUILDDIR=$(shell readlink build) && \ + rm -r $(shell readlink build) && \ + rm .config.mk build \ + ||: + +# it can be symlinked if r/w (see configure); +# if not, then should come from environment +#BUILDDIR ?= $(shell realpath build) +BUILDDIR ?= $(shell realpath build) + +prep: + @echo BUILDDIR: $(BUILDDIR) diff --git a/configure b/configure new file mode 100755 index 00000000..1ac21d02 --- /dev/null +++ b/configure @@ -0,0 +1,30 @@ +#!/bin/sh +# this is a chinese configure script: +# it would take any parameters, +# nod the head intelligently, +# and hide 'em beneath the clothes +# (until time comes) + +PARAMS="$@" +# TODO: grep/validate? + +# create suitable temporary directory for this build, then +# copy profiles there to configure a copy, not master tree +# keeping profile itself completely readonly would be nice + +export BUILDDIR="$(bin/mktmpdir mkimage-profiles.build)" +ls -ld $BUILDDIR + +#find image.in -type f -print0 | xargs -r0 cp -at "$BUILDDIR"/ -- +rsync -qa --delete image.in/ "$BUILDDIR"/ +cp -a pkg "$BUILDDIR"/ +#rm -f "$BUILDDIR"/.config.mk +touch "$BUILDDIR"/.config.mk +mkdir "$BUILDDIR"/.mki +rm -f build +[ -w . ] \ +&& ln -sf "$BUILDDIR" build \ +|| echo "profile directory readonly: skipping symlinks, env only" + +# remember all those --with-*? we'll pass them downstream, honestly +echo "$PARAMS" > "$BUILDDIR"/.with diff --git a/distro.mk b/distro.mk index 3d602ea1..112d1df0 100644 --- a/distro.mk +++ b/distro.mk @@ -1,16 +1,39 @@ +### build up distribution's configuration +CONFIG = $(BUILDDIR)/.config.mk + +# ACHTUNG: don"t use ANY quotes ('/") for put() arguments! +# shell will get confused by ' or args get spammed with " +put = $(and $(1),$(put_body)) +define put_body +@printf '%s\n' '$(1)# $@' >> "$(CONFIG)"; +endef + +# request particular image subprofile inclusion sub/%: - echo SUBDIRS+=$(@:sub/%=%) >> .config + $(call put,SUBPROFILES+=$(@:sub/%=%)) init: - :> .config + @echo "** starting distro configuration build process" + :> $(CONFIG) + $(call put,KFLAVOUR=std-def) + $(call put,IMAGE_INIT_LIST=+branding-$$(BRANDING)-release) + $(call put,STAGE1_PACKAGES=kernel-image-$$(KFLAVOUR)) -distro/bare: init sub/install2 - echo BASE_LISTS='base kernel' >> .config +# NB: our */* are phony targets really, just for namespace +distro/installer: init sub/install2 + @#$(call put,BRANDING=altlinux-sisyphus) ### + $(call put,BASE_LISTS=base kernel) + $(call put,INSTALL2_PACKAGES=kernel-image-$$(KFLAVOUR)) -distro/server-base: distro/bare sub/main - echo BASE_LISTS+='server-base kernel-server' >> .config - @#echo DISTRO_TRACE+=$@ >> .config +distro/server-base: distro/installer sub/main use/memtest86 + $(call put,BRANDING=altlinux-backup-server) ### + $(call put,BASE_LISTS+=server-base kernel-server) -distro/server-light: distro/server-base sub/disk - echo BASE_LISTS+='kernel-wifi' >> .config - @#echo DISTRO_TRACE+=$@ >> .config +distro/server-light: distro/server-base + $(call put,KFLAVOUR=ovz-smp) + $(call put,BRANDING=sisyphus-server-light) + $(call put,DISK_LISTS+=kernel-wifi) + +use/memtest86: + $(call put,COMMON_PACKAGES+=memtest86+) + @# configure syslinux/isolinux as well diff --git a/image.in/Makefile b/image.in/Makefile new file mode 100644 index 00000000..4091dd5e --- /dev/null +++ b/image.in/Makefile @@ -0,0 +1,49 @@ +include globals.mk +include functions.mk +include $(MKIMAGE_PREFIX)/config.mk +include $(GLOBAL_BUILDDIR)/.config.mk + +SUBDIRS = $(SUBPROFILES) + +# we usually need a bootloader (until stage1 is separate), +# and "main" subprofile needs genbasedir +CHROOT_PACKAGES = syslinux apt-utils $(STAGE1_PACKAGES) + +### +MKI_PACK_RESULTS = boot:mkimage-profiles.iso +COPY_TREE = ./isodata +BOOT_TYPE = isolinux + +### +PROPAGATOR_VERSION = mkimage-profiles 2.0 +PROPAGATOR_MAR_MODULES = ./modules +PROPAGATOR_INITFS = ./initfs + +include /usr/share/mkimage/targets.mk + +all: prep copy-tree copy-subdirs run-scripts pack-image + +prep: initfs disk-info metadata + @echo "TOPDIR=$(TOPDIR)" + +initfs: + echo "file /.VERSION @TMPDIR@/.VERSION 0644 0 0" >initfs + ### FIXME: broken test, we already do branding + [ -z "$(BRANDING)" ] || \ + echo "file /bootsplash /bootsplash/bootsplash 0644 0 0" >>initfs + +disk-info: + mkdir -p isodata/.disk + echo "$(PROPAGATOR_VERSION)" >isodata/.disk/info ### +$(ARCH) + (cd $(TOPDIR); git show-ref --head --dereference -s -- HEAD 2>/dev/null) >isodata/.disk/commit + [ -s isodata/.disk/commit ] || rm isodata/.disk/commit + +# see also alterator-pkg (backend3/pkg-install) +# FIXME: groups unmerged +metadata: + mkdir -p isodata/Metadata + rm -f isodata/Metadata/pkg-groups.tar + tar -cvf isodata/Metadata/pkg-groups.tar \ + -C $(PKGDIR) \ + $(shell echo $(call list,.base) $(call list,base) | sed 's,$(PKGDIR)/*,,g') + diff --git a/configure.ac b/image.in/configure.ac similarity index 60% rename from configure.ac rename to image.in/configure.ac index f13f4712..4101d7c3 100644 --- a/configure.ac +++ b/image.in/configure.ac @@ -16,44 +16,24 @@ AC_ARG_WITH(aptconf, APTCONF=/etc/apt/apt.conf ]) -AC_ARG_WITH(distro, - AC_HELP_STRING([--with-distro=distro], - [base distro, e.g '--with-distro=desktop' (implies branding/docs)]), - [ - if test -n "$with_distro" ; then - # conditional distro config file inclusion? - DISTRO="$with_distro" - case "$DISTRO" in - desktop*) - LABEL="Desktop" - ;; - server-light) - # TODO: docs, kernel... - LABEL="Server" - ;; - # TODO: default case - esac - # FIXME: branding - fi - AC_MSG_RESULT([** distro: $DISTRO]) - ]) - AC_ARG_WITH(mkimage, AC_HELP_STRING([--with-mkimage=dir], [custom mkimage prefix, e.g '--with-mkimage=/home/me/mkimage']), [ AC_MSG_CHECKING([mkimage]) if test -d "$with_mkimage/usr/share/mkimage"; then - MKI_PREFIX="$with_mkimage" + MKIMAGE_PREFIX="$with_mkimage" AC_MSG_RESULT([** $with_mkimage/usr/share/mkimage exists]) fi ], [ - MKI_PREFIX='' + MKIMAGE_PREFIX='' ]) +# with-kernel: provide two separate desktop/server default substs? + AC_SUBST(APTCONF) -AC_SUBST(MKI_PREFIX) +AC_SUBST(MKIMAGE_PREFIX) AC_SUBST(DISTRO) AC_SUBST(LABEL) diff --git a/image.in/functions.mk b/image.in/functions.mk new file mode 100644 index 00000000..ceafcb96 --- /dev/null +++ b/image.in/functions.mk @@ -0,0 +1,5 @@ +PKGDIR=$(TOPDIR)/pkg + +# prefix pkglist name with its directory to form a path +list = $(1:%=$(PKGDIR)/lists/%) + diff --git a/image.in/globals.mk.in b/image.in/globals.mk.in new file mode 100644 index 00000000..ea4f569c --- /dev/null +++ b/image.in/globals.mk.in @@ -0,0 +1,4 @@ +export +MKIMAGE_PREFIX=@MKIMAGE_PREFIX@ +GLOBAL_HSH_APT_CONFIG=@APTCONF@ +GLOBAL_VERBOSE=0 diff --git a/image.in/install2/Makefile b/image.in/install2/Makefile new file mode 100644 index 00000000..3634f651 --- /dev/null +++ b/image.in/install2/Makefile @@ -0,0 +1,17 @@ +default: all + +include $(GLOBAL_BUILDDIR)/globals.mk +include $(GLOBAL_BUILDDIR)/functions.mk +include $(MKIMAGE_PREFIX)/config.mk +include $(GLOBAL_BUILDDIR)/.config.mk + +IMAGE_PACKAGES = kernel-image-std-def \ + installer-distro-server-light-stage2 \ + ./packages \ + $(INSTALL2_PACKAGES) + +MKI_PACK_RESULTS = squash:altinst + +include $(MKIMAGE_PREFIX)/targets.mk + +all: build-image run-image-scripts pack-image diff --git a/image/stage2/image-scripts.d/50udev b/image.in/install2/image-scripts.d/50udev similarity index 100% rename from image/stage2/image-scripts.d/50udev rename to image.in/install2/image-scripts.d/50udev diff --git a/image/stage2/image-scripts.d/85cleanup-cjk b/image.in/install2/image-scripts.d/85cleanup-cjk similarity index 100% rename from image/stage2/image-scripts.d/85cleanup-cjk rename to image.in/install2/image-scripts.d/85cleanup-cjk diff --git a/image/stage2/image-scripts.d/90cleanup b/image.in/install2/image-scripts.d/90cleanup similarity index 100% rename from image/stage2/image-scripts.d/90cleanup rename to image.in/install2/image-scripts.d/90cleanup diff --git a/image/stage2/image-scripts.d/98system b/image.in/install2/image-scripts.d/98system similarity index 100% rename from image/stage2/image-scripts.d/98system rename to image.in/install2/image-scripts.d/98system diff --git a/image/stage2/image-scripts.d/99cleanupdb b/image.in/install2/image-scripts.d/99cleanupdb similarity index 100% rename from image/stage2/image-scripts.d/99cleanupdb rename to image.in/install2/image-scripts.d/99cleanupdb diff --git a/image.in/install2/packages b/image.in/install2/packages new file mode 100644 index 00000000..56ae0e50 --- /dev/null +++ b/image.in/install2/packages @@ -0,0 +1,3 @@ +udev +e2fsprogs +glibc-nss diff --git a/image/isodata/syslinux/isolinux.cfg b/image.in/isodata/syslinux/isolinux.cfg similarity index 94% rename from image/isodata/syslinux/isolinux.cfg rename to image.in/isodata/syslinux/isolinux.cfg index 7b323b4a..45a5ea13 100644 --- a/image/isodata/syslinux/isolinux.cfg +++ b/image.in/isodata/syslinux/isolinux.cfg @@ -10,7 +10,7 @@ implicit 1 # localboot 0x80 label linux kernel alt0/vmlinuz - append initrd=alt0/full.cz changedisk vga=0x314 quiet=1 showopts automatic=metod:cdrom + append initrd=alt0/full.cz changedisk vga=0x314 quiet=1 showopts automatic=method:cdrom label noapic kernel alt0/vmlinuz append initrd=alt0/full.cz changedisk vga=0x314 showopts nolapic noapic acpi=off diff --git a/image.in/main/Makefile b/image.in/main/Makefile new file mode 100644 index 00000000..50479aa1 --- /dev/null +++ b/image.in/main/Makefile @@ -0,0 +1,27 @@ +### installation package base (requisite + optional) + +default: all + +include $(GLOBAL_BUILDDIR)/globals.mk +include $(GLOBAL_BUILDDIR)/functions.mk +include $(MKIMAGE_PREFIX)/config.mk +include $(GLOBAL_BUILDDIR)/.config.mk + +CHROOT_PACKAGES = apt-utils rsync +PACKAGES_EXPAND_METHOD=regexp + +IMAGE_PACKAGES = $(call list,.base) \ + $(MAIN_PACKAGES) \ + $(call list,$(BASE_LISTS)) \ + $(call list,$(DISK_LISTS)) + +MKI_DESTDIR = ALTLinux/RPMS.main +MKI_PACK_RESULTS = data + +include $(MKIMAGE_PREFIX)/targets.mk + +# TODO: pkg groups +all: debug copy-packages pack-image + +debug: + @echo "IMAGE_PACKAGES: $(IMAGE_PACKAGES)" diff --git a/image/modules b/image.in/modules similarity index 100% rename from image/modules rename to image.in/modules diff --git a/image.in/scripts.d/01-genbasedir b/image.in/scripts.d/01-genbasedir new file mode 100755 index 00000000..61390769 --- /dev/null +++ b/image.in/scripts.d/01-genbasedir @@ -0,0 +1,50 @@ +#!/bin/sh + +verbose() +{ + [ -z "$GLOBAL_VERBOSE" ] || + echo >&2 "HOOK: 01-genbasedir: $*" +} + +verbose started + +[ -d "$WORKDIR/ALTLinux" ] || exit 0 +cd "$WORKDIR/ALTLinux" + +set -- contrib-main addon-main ltsp-main +for pair; do + slave=${pair%-*} + master=${pair#*-} + verbose "slave=$slave master=$master" + + [ -d "RPMS.$master" ] || continue + find "RPMS.$master" -mindepth 1 -maxdepth 1 -type f -name '*.rpm' -printf "RPMS.$slave/%f\\0" | + xargs -r0 rm -fv -- +done + +#We always put RPMS.addon on separate disk +if [ -d RPMS.addon ] ; then + rm -fr RPMS.main + INFO_LABEL="Addon" +fi + +comps="$(find -mindepth 1 -maxdepth 1 -type d -name 'RPMS.*' -printf '%f\n' | + sed 's/^RPMS\.//')" + +verbose "comps=$comps" + +genbasedir \ + --topdir="$WORKDIR" \ + --architecture="$INFO_ARCH" \ + --no-oldhashfile \ + --partial \ + --bz2only \ + --create \ + --notautomatic=false \ + ${INFO_NAME:+--archive="$INFO_NAME"} \ + ${INFO_VERSION:+--version="$INFO_VERSION"} \ + ${INFO_ORIGIN:+--origin="$INFO_ORIGIN"} \ + ${INFO_LABEL:+--label="$INFO_LABEL"} \ + ALTLinux $comps + +verbose finished diff --git a/image/Makefile b/image/Makefile deleted file mode 100644 index 3fda9b7e..00000000 --- a/image/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -include /usr/share/mkimage/config.mk - -SUBDIRS = stage2 -CHROOT_PACKAGES = kernel-image-un-def apt-utils - -MKI_PACK_RESULTS = boot:mkimage-profiles.iso -COPY_TREE = ./isodata -BOOT_TYPE = isolinux - -PROPAGATOR_VERSION = mkimage-profiles 2.0 -PROPAGATOR_MAR_MODULES = ./modules -PROPAGATOR_INITFS = ./initfs - -include /usr/share/mkimage/targets.mk - -all: initfs copy-tree copy-subdirs run-scripts pack-image - -initfs: - echo "file /.VERSION @TMPDIR@/.VERSION 0644 0 0" > initfs - #[ -z "$(BRANDING)" ] || \ - # echo "file /bootsplash /bootsplash/bootsplash 0644 0 0" >> initfs diff --git a/image/functions.mk b/image/functions.mk deleted file mode 100644 index 6de55477..00000000 --- a/image/functions.mk +++ /dev/null @@ -1,3 +0,0 @@ -# prefix pkglist name with its directory to form a path -#list = $(1:%=$(GLOBAL_PKGDIR)/lists/%) -list = $(1:%=pkg/lists/%) diff --git a/image/initfs b/image/initfs deleted file mode 100644 index 59905b86..00000000 --- a/image/initfs +++ /dev/null @@ -1 +0,0 @@ -file /.VERSION @TMPDIR@/.VERSION 0644 0 0 diff --git a/image/stage1/Makefile b/image/stage1/Makefile deleted file mode 100644 index 49dd356c..00000000 --- a/image/stage1/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -include /usr/share/mkimage/config.mk - -GLOBAL_VERBOSE=1 - -#CHROOT_PACKAGES=kernel-image-un-def -CHROOT_PACKAGES = kernel-image-un-def apt-utils - -#SUBDIR = /boot -MKI_IMAGESUBDIR = /boot -MKI_PACK_RESULTS = data - -PROPAGATOR_VERSION = mkimage-profiles 2.0 -PROPAGATOR_MAR_MODULES = ./modules -PROPAGATOR_INITFS = ./initfs - -include /usr/share/mkimage/targets.mk - -#all: build-propagator pack-image -all: build-propagator diff --git a/image/stage2/Makefile b/image/stage2/Makefile deleted file mode 100644 index 6866d3ae..00000000 --- a/image/stage2/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -CONFIGDIR = /usr/share/mkimage - -include $(CONFIGDIR)/config.mk - -IMAGE_PACKAGES = kernel-image-un-def \ - udev \ - e2fsprogs \ - glibc-nss \ - installer-distro-server-light-stage2 - -MKI_PACK_RESULTS = squash:altinst -#MKI_PACK_RESULTS = squash:live - -include $(CONFIGDIR)/targets.mk - -all: build-image run-image-scripts pack-image diff --git a/iso.mk b/iso.mk index 73658cac..30a93113 100644 --- a/iso.mk +++ b/iso.mk @@ -1,4 +1,5 @@ -cd: - # setup GLOBAL_BOOT_TYPE, etc - make -C image - # check iso size +iso: + @echo "** starting image build process" + @### setup GLOBAL_BOOT_TYPE, etc + i586 make -C $(BUILDDIR) GLOBAL_BUILDDIR=$(BUILDDIR) + @# check iso size diff --git a/pkg/lists/.base b/pkg/lists/.base new file mode 100644 index 00000000..61931362 --- /dev/null +++ b/pkg/lists/.base @@ -0,0 +1,11 @@ +basesystem +kernel-image-std-def + +interactivesystem +apt-conf-sisyphus +apt + +alterator-lilo +alterator-root +alterator-users +alterator-net-eth diff --git a/pkg/lists/base b/pkg/lists/base new file mode 100644 index 00000000..3d1f4098 --- /dev/null +++ b/pkg/lists/base @@ -0,0 +1,5 @@ +interactivesystem +apt-conf-sisyphus +apt +alterator-lilo + diff --git a/pkg/lists/kernel b/pkg/lists/kernel new file mode 100644 index 00000000..92da8943 --- /dev/null +++ b/pkg/lists/kernel @@ -0,0 +1 @@ +kernel-image-std-def diff --git a/pkg/lists/kernel-server b/pkg/lists/kernel-server new file mode 100644 index 00000000..af09a290 --- /dev/null +++ b/pkg/lists/kernel-server @@ -0,0 +1 @@ +kernel-modules-igb-std-def diff --git a/pkg/lists/kernel-wifi b/pkg/lists/kernel-wifi new file mode 100644 index 00000000..99f6fefb --- /dev/null +++ b/pkg/lists/kernel-wifi @@ -0,0 +1 @@ +firmware-rt73 diff --git a/pkg/lists/server-base b/pkg/lists/server-base new file mode 100644 index 00000000..e54553e3 --- /dev/null +++ b/pkg/lists/server-base @@ -0,0 +1,8 @@ +interactivesystem +vim-console + +sfdisk +mdadm + +openssh-server +acpid