diff --git a/conf.d/live.mk b/conf.d/live.mk index 91394fa5..284b06c3 100644 --- a/conf.d/live.mk +++ b/conf.d/live.mk @@ -1,8 +1,19 @@ # live images ifeq (distro,$(IMAGE_CLASS)) -distro/live: distro/.base use/live use/syslinux/ui-menu +distro/live: distro/.base use/live/base distro/rescue: distro/.base use/rescue use/syslinux/ui-menu distro/dos: distro/.init use/dos use/syslinux/ui-menu +distro/live-builder: distro/.base sub/main \ + use/live/base use/dev/mkimage + @$(call add,LIVE_LISTS,$(call tags,base && (server || builder))) + @$(call add,LIVE_PACKAGES,livecd-tmpfs livecd-online-repo) + @$(call add,LIVE_PACKAGES,apt-repo zsh) + @$(call add,MAIN_PACKAGES,rpm-build basesystem) + @$(call add,MAIN_PACKAGES,fakeroot sisyphus_check) + @$(call add,MAIN_PACKAGES,syslinux pciids memtest86+ mkisofs) + @$(call add,MAIN_PACKAGES,file make-initrd make-initrd-propagator) + @$(call add,MAIN_PACKAGES,livecd-tmpfs livecd-online-repo) + endif diff --git a/features.in/build-distro/lib/build-distro.mk b/features.in/build-distro/lib/build-distro.mk index 50b665d7..2cca06b7 100644 --- a/features.in/build-distro/lib/build-distro.mk +++ b/features.in/build-distro/lib/build-distro.mk @@ -40,7 +40,7 @@ dot-disk: @echo "$(ARCH)" >files/.disk/arch @echo "$(DATE)" >files/.disk/date @if type -t git >&/dev/null; then \ - ( cd $(TOPDIR) && \ - git show-ref --head -ds -- HEAD ) \ + ( cd $(TOPDIR) && test -d .git && \ + git show-ref --head -ds -- HEAD ||:) \ >files/.disk/commit 2>/dev/null; \ fi diff --git a/features.in/dev/README b/features.in/dev/README new file mode 100644 index 00000000..1bcbdcde --- /dev/null +++ b/features.in/dev/README @@ -0,0 +1,5 @@ +Эта фича служит для создания образов, предназначающихся для разработки. +В первую очередь обеспечивается развёртывание hasher и mkimage. + +Реализована поддержка LiveCD, возможно приспособление для образов +сборочных VM/VE. diff --git a/features.in/dev/config.mk b/features.in/dev/config.mk new file mode 100644 index 00000000..6a154f7b --- /dev/null +++ b/features.in/dev/config.mk @@ -0,0 +1,7 @@ +use/dev: + @$(call add,FEATURES,dev) + @$(call add,COMMON_PACKAGES,git-core hasher gear) + +use/dev/mkimage: use/dev + @$(call add,COMMON_PACKAGES,mkimage) + @$(call add,LIVE_PACKAGES,shadow-change) diff --git a/features.in/dev/live/image-scripts.d/40-hasher b/features.in/dev/live/image-scripts.d/40-hasher new file mode 100755 index 00000000..f77cb507 --- /dev/null +++ b/features.in/dev/live/image-scripts.d/40-hasher @@ -0,0 +1,44 @@ +#!/bin/sh -efu +# configure hasher (implies that 30-users has been run already) + +# predefined passwordless livecd user +USER="altlinux" +if ! id "$USER" >&/dev/null; then + echo "No such user '$USER'" >&2 + exit +fi + +# ~ +HOME="/home/$USER" +install -dm750 -o "$USER" -g "$USER" "$HOME" + +# we honestly don't know much more +if type -t git >&/dev/null; then + su - -c "git config --global user.email $USER@localhost" "$USER" + su - -c "git config --global user.name 'live builder'" "$USER" +fi + +# developer should feel comfortable, eh? ;-) +ZSHELL="/bin/zsh" +if [ -x "$ZSHELL" ]; then + chsh -s "$ZSHELL" "$USER" + install -m755 -o "$USER" -g "$USER" /dev/null "$HOME/.zshrc" + echo "mkdir -p \"\$TMP/hasher\"" >> "$HOME/.zshrc" +fi + +# $TMP +TMP="/tmp/.private/$USER" +control pam_mktemp enabled +subst '/^%_tmppath.*tmp$/d' "$HOME/.rpmmacros" +echo "%_tmppath $TMP" >> "$HOME/.rpmmacros" + +# ~/hasher +WORKDIR="$TMP/hasher" +ln -s "$TMP/hasher" "$HOME/hasher" + +# online repo needs network not isolation +echo "export share_network=1" >> /etc/profile.d/hasher.sh +chmod +x /etc/profile.d/hasher.sh + +# requisite +hasher-useradd "$USER" diff --git a/features.in/dev/live/image-scripts.d/50-etcnet-dhcp b/features.in/dev/live/image-scripts.d/50-etcnet-dhcp new file mode 100755 index 00000000..d8e7f53e --- /dev/null +++ b/features.in/dev/live/image-scripts.d/50-etcnet-dhcp @@ -0,0 +1,7 @@ +#!/bin/sh -efu +# attempt to autoconfigure ethernet + +mkdir -p /etc/net/ifaces/eth0 && { + echo TYPE=eth + echo BOOTPROTO=dhcp +} > /etc/net/ifaces/eth0/options ||: diff --git a/features.in/dev/live/image-scripts.d/80-cdrom-repo b/features.in/dev/live/image-scripts.d/80-cdrom-repo new file mode 100755 index 00000000..3b6ba7b0 --- /dev/null +++ b/features.in/dev/live/image-scripts.d/80-cdrom-repo @@ -0,0 +1,9 @@ +#!/bin/sh -efu +# configure local image repository provided by sub/main + +# TODO: some integration with sub/main to ensure that it is there + +{ + echo "# for real stuff you'll need full repo, see apt-repo" + echo "rpm file:/image ALTLinux main" +} > /etc/apt/sources.list.d/cdrom.list diff --git a/features.in/live/config.mk b/features.in/live/config.mk index d00cfef4..3bf5016f 100644 --- a/features.in/live/config.mk +++ b/features.in/live/config.mk @@ -1,3 +1,9 @@ use/live: use/stage2 sub/stage2/live @$(call add,FEATURES,live) - @$(call add,LIVE_LISTS,$(call tags,(base || desktop) && (live || network || icewm))) + +use/live/base: use/live use/syslinux/ui-menu + @$(call add,LIVE_LISTS,$(call tags,base && (live || network))) + +use/live/icewm: use/live/base + @$(call add,LIVE_LISTS,\ + $(call tags,(base || desktop) && (live || network || icewm))) diff --git a/features.in/live/live/image-scripts.d/30-users b/features.in/live/live/image-scripts.d/30-users index f593b77b..f78631bf 100755 --- a/features.in/live/live/image-scripts.d/30-users +++ b/features.in/live/live/image-scripts.d/30-users @@ -23,8 +23,7 @@ add_user() fi done - /usr/sbin/useradd -p "" -G "$groups" "$1" ||: - chown -R "$1:auth" "/etc/tcb/$1" + useradd -p "" -G "$groups" "$1" ||: chown -R "$1:$1" /home/$1 if [ -n "$GLOBAL_CRYPT_HOMES" ]; then @@ -39,13 +38,14 @@ add_user() else verbose "Can't find writable $sudoers file." fi + + echo "Hello friend, say \`$1' to log in at \\l" >> /etc/issue } verbose "has started" verbose "Clear password for root account" -/usr/sbin/usermod -p "" root -chown -R root.auth /etc/tcb/root +usermod -p "" root add_user altlinux diff --git a/image.in/Makefile b/image.in/Makefile index 91b542fc..c05be3e5 100644 --- a/image.in/Makefile +++ b/image.in/Makefile @@ -41,7 +41,7 @@ postprocess: echo "** image: $(IMAGE_OUTFILE)" && \ ln -sf "$(IMAGE_OUTFILE)" "$(IMAGEDIR)/$(IMAGE_FILE)" && \ ln -sf "$(IMAGE_FILE)" "$(IMAGEDIR)/$(LINKPREFIX).$(IMAGE_TYPE)"; \ - ln -sf "$$OUTPATH" "$(IMAGE_FILE)"; \ + ln -sf "$${OUTPATH#`pwd`/}" "$(IMAGE_FILE)"; \ if [ -n "$(GLOBAL_DEBUG)" ]; then \ cp -a build.log "$$OUTPATH.log"; \ cp -a distcfg.mk "$$OUTPATH.cfg"; \ diff --git a/lib/clean.mk b/lib/clean.mk index 1fe05760..ba3d8b50 100644 --- a/lib/clean.mk +++ b/lib/clean.mk @@ -15,7 +15,7 @@ endif # ordinary clean: destroys workdirs but not the corresponding results clean: @echo '** cleaning up $(WARNING)' - @find -name '*~' -delete >&/dev/null + @find -name '*~' -delete >&/dev/null ||: @if [ -L build -a -d build/ ]; then \ $(MAKE) -C build $@ GLOBAL_BUILDDIR=$(shell readlink build) $(LOG) ||:; \ fi @@ -28,6 +28,6 @@ distclean: clean rm -rf build/.git; \ $(MAKE) -C build $@ GLOBAL_BUILDDIR=$(shell readlink build) $(LOG) || \ rm -rf build/; \ - rm -r $(shell readlink build); \ + rm -rf $(shell readlink build); \ fi - @rm -f build + @rm -f build ||: diff --git a/lib/profile.mk b/lib/profile.mk index 09c40437..28d5765b 100644 --- a/lib/profile.mk +++ b/lib/profile.mk @@ -11,7 +11,7 @@ SYMLINK = build ifndef BUILDDIR BUILDDIR := $(shell [ -s "$(SYMLINK)" ] \ && realpath "$(SYMLINK)" \ - || bin/mktmpdir mkimage-profiles.build) + || bin/mktmpdir mkimage-profiles) endif # even smart caching only hurts when every build goes from scratch @@ -26,36 +26,43 @@ RC := $(HOME)/.mkimage/profiles.mk # holds a postprocessor; shell test executes in particular situation # NB: not exported, for toplevel use only -SHORTEN = $(shell [ "$(DEBUG)" != 2 -a -s "$(SYMLINK)" ] \ - && echo "| sed 's,$(BUILDDIR),$(SYMLINK),'") +SHORTEN = $(shell \ + if [ -s "$(SYMLINK)" ]; then \ + echo "| sed 's,$(BUILDDIR),$(SYMLINK),'"; \ + else \ + echo "| sed 's,$(TMP),\$$TMP,'"; \ + fi;) # step 1: initialize the off-tree mkimage profile (BUILDDIR) profile/init: distclean @echo -n "** initializing BUILDDIR: " @rsync -qaH --delete image.in/ "$(BUILDDIR)"/ + @mkdir "$(BUILDDIR)"/.mki # mkimage toplevel marker @$(call put,ifndef DISTCFG_MK) @$(call put,DISTCFG_MK = 1) - @{ \ - git show-ref --head -d -s -- HEAD && \ - git status -s && \ - echo; \ - } $(LOG) - @mkdir "$(BUILDDIR)"/.mki # mkimage toplevel marker - @if type -t git >&/dev/null && cd $(BUILDDIR); then \ - git init -q && \ - git add . && \ - git commit -qam 'derivative profile initialized'; \ + @if type -t git >&/dev/null; then \ + if [ -d .git ]; then \ + git show-ref --head -d -s -- HEAD && \ + git status -s && \ + echo; \ + fi $(LOG); \ + if cd $(BUILDDIR); then \ + git init -q && \ + git add . && \ + git commit -qam 'derivative profile initialized'; \ + fi; \ fi - @rm -f "$(SYMLINK)" && \ - if [ -w . ]; then \ - ln -sf "$(BUILDDIR)" "$(SYMLINK)" && \ - echo "$(SYMLINK)/"; \ - else \ - echo "$(BUILDDIR)/"; \ - fi + @if [ -w . ]; then \ + rm -f "$(SYMLINK)" && \ + ln -sf "$(BUILDDIR)" "$(SYMLINK)" && \ + echo "$(SYMLINK)/"; \ + else \ + echo "$(BUILDDIR)/" $(SHORTEN); \ + fi $(SHORTEN) profile/bare: profile/init - @echo "** preparing distro configuration$${DEBUG:+: see $(CONFIG)}" $(SHORTEN) + @echo "** preparing distro config$${DEBUG:+: see $(CONFIG)}" \ + $(SHORTEN) @$(call try,MKIMAGE_PREFIX,/usr/share/mkimage) @$(call try,GLOBAL_VERBOSE,) @$(call try,IMAGEDIR,$(IMAGEDIR)) diff --git a/pkg.in/lists/tagged/base+builder b/pkg.in/lists/tagged/base+builder new file mode 100644 index 00000000..0f89c718 --- /dev/null +++ b/pkg.in/lists/tagged/base+builder @@ -0,0 +1,3 @@ +rpm-build +mkimage +git-core diff --git a/pkg.in/lists/tagged/base+live b/pkg.in/lists/tagged/base+live index 05a0f170..04f79000 100644 --- a/pkg.in/lists/tagged/base+live +++ b/pkg.in/lists/tagged/base+live @@ -1,4 +1,5 @@ wget +rsync apt vim-console mc diff --git a/sub.in/stage2/README b/sub.in/stage2/README index 9cc36be8..b0db8d27 100644 --- a/sub.in/stage2/README +++ b/sub.in/stage2/README @@ -4,3 +4,5 @@ Результат -- соответственно названный файл со squashfs, подлежащий копированию в итоговый образ. + +NB: смонтированный образ доступен в такой системе как /image/.