>From ac5dbb4bba5b802be4a8df4d7f7c3202fe51259b Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Thu, 22 Jan 2015 18:27:07 +0300 Subject: [PATCH] pkg.in/lists: archdep suffices for pkglists This is an initial implementation of architecture dependent contents handling for package lists more or less in the vein of mkimage-profiles-desktop's one *but* using suffix part to filter words in or out *not* prefix part to replace it with a comment marker (thus filtering out lines). The syntax should be pretty obvious: a b@i586 c@x86_64 will get "a b" given ARCH=i586 and "a c" given ARCH=x86_64; please see doc/archdep.txt for a more elaborate description and a conversion script. --- doc/archdep.txt | 46 +++++++++++++++++++++++++++++++++++++++++++ doc/mkimage-profiles.asciidoc | 2 ++ lib/profile.mk | 1 + pkg.in/lists/Makefile | 11 ++++++++++- 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 doc/archdep.txt diff --git a/doc/archdep.txt b/doc/archdep.txt new file mode 100644 index 0000000..25927ce --- /dev/null +++ b/doc/archdep.txt @@ -0,0 +1,46 @@ +== Архитектурно-зависимые фрагменты == + +=== Makefile === + +Достаточно воспользоваться ifeq/ifneq, сравнивая $(ARCH) с нужным: + + ifeq (x86_64,$(ARCH)) + EFI_LISTS := $(call tags,base efi) + endif + +При необходимости сравнить со списком ("любой x86") можно сделать так: + + ifeq (,$(filter-out i586 x86_64,$(ARCH))) + use/x11/xorg: use/x11 use/x11/intel use/firmware + else + use/x11/xorg: use/x11 + endif + +В рецептах (shell-часть Makefile) используйте $(ARCH) или $$ARCH. + +=== скрипты === + +В скриптовых хуках ({image-,}scripts.d/*) проверяйте $GLOBAL_ARCH. + +=== списки пакетов === + +Бывает так, что в списке пакетов есть смысл упоминать какой-либо из них +только для определённой архитектуры (например, wine или steam); в таких +случаях можно воспользоваться механизмом подстановки, который пословно +обрабатывает списки и в случае наличия суффикса @ARCH оставляет только +слова, в которых этот суффикс соответствует заданной архитектуре сборки. + +Например, для Simply Linux в mkimage-profiles-desktop есть строчки: + +@I586_ONLY@haspd +@X86_64_ONLY@i586-haspd + +В случае mkimage-profiles они должны выглядеть так: + +haspd@i586 +i586-haspd@x86_64 + +Для преобразования можно воспользоваться следующей командой: + +sed -r -e 's/@I586_ONLY@([^\t ]+)/\1@i586/g' \ + -e 's/@X86_64_ONLY@([^\t ]+)/\1@x86_64/g' diff --git a/doc/mkimage-profiles.asciidoc b/doc/mkimage-profiles.asciidoc index 8feb97d..a280122 100644 --- a/doc/mkimage-profiles.asciidoc +++ b/doc/mkimage-profiles.asciidoc @@ -42,6 +42,8 @@ include::features.txt[] include::pkglists.txt[] +include::archdep.txt[] + = Каталоги = include::../conf.d/README[] diff --git a/lib/profile.mk b/lib/profile.mk index 762f8be..05a2352 100644 --- a/lib/profile.mk +++ b/lib/profile.mk @@ -98,6 +98,7 @@ profile/bare: profile/init ifeq (,$(REPO:altlinux%=)) @$(call set,IMAGE_INIT_LIST,+branding-$$(BRANDING)-release) endif + @$(call xport,ARCH) @mp-commit "$(BUILDDIR)" "image configuration defaults set" # put the derived SUBPROFILE_DIRS here to get it logged in clear text by the way diff --git a/pkg.in/lists/Makefile b/pkg.in/lists/Makefile index 485d3d0..1759e9c 100644 --- a/pkg.in/lists/Makefile +++ b/pkg.in/lists/Makefile @@ -18,7 +18,7 @@ include $(BUILDDIR)/distcfg.mk SUFFIX := pkg/lists TARGET := $(BUILDDIR)/$(SUFFIX) -all: $(TARGET) $(GLOBAL_DEBUG) $(DOTBASE) copy-lists copy-groups +all: | $(TARGET) $(GLOBAL_DEBUG) $(DOTBASE) copy-lists copy-groups grep-archdep @mp-commit "$(TARGET)" "requested $(SUFFIX) copied over" # env | sort -u | grep _LISTS | xargs -r cp -t @@ -33,6 +33,15 @@ copy-groups: cp -at $(TARGET) -- $(THE_GROUPS) $(MAIN_GROUPS); \ fi +grep-archdep: a = $(ARCH) +grep-archdep: s = [:space:] +grep-archdep: + # xargs -L 1024 -n 1024 ? -- breaks -I + @find $(TARGET) -type f \ + | xargs -I '__' sh -c '\ + sed -rni "s/\\<([^@ ]*)\\>|\\<([^@ ]*)@$a\\>/\\1\\2/pg" __; \ + sed -i -r "s/\\<([^@ ]*)@[^@ ]+\\> *//g" __' + # do beforehand as foreach gets expanded before recipe execution $(TARGET): @mkdir -p $(TARGET) -- 2.1.4