2016-02-08 20:10:14 +03:00
# step 4: dive into mkimage
2010-12-03 17:53:02 +03:00
2011-10-06 12:46:31 +04:00
GLOBAL_BUILDDIR ?= $( shell pwd )
2011-11-05 13:03:48 +04:00
CURRENT_LINK := mkimage-profiles
OUT_LINK := out
2011-06-12 19:06:36 +04:00
2011-11-08 02:07:38 +04:00
# there were mkimage fixes induced by mkimage-profile development
2012-12-12 00:00:35 +04:00
# - minimal version is bumped for critical bugfixes/features
# - optimal one relates to the less universally relevant bits
2011-11-08 02:07:38 +04:00
MKI_VER_MINIMAL = 0.1.7
2013-01-21 15:08:35 +04:00
MKI_VER_OPTIMAL = 0.2.6
2011-11-08 02:07:38 +04:00
2011-10-06 12:46:31 +04:00
i n c l u d e d i s t c f g . m k
2010-08-28 20:28:42 +04:00
i n c l u d e f u n c t i o n s . m k
2012-04-23 22:56:35 +04:00
# check the build environment
2012-01-05 00:30:56 +04:00
i f e q ( , $( realpath $ ( MKIMAGE_PREFIX ) /config .mk ) )
$( error please apt -get install mkimage and have a look at QUICKSTART as well )
e n d i f
2012-01-21 23:39:28 +04:00
i n c l u d e $( MKIMAGE_PREFIX ) / c o n f i g . m k
2011-11-08 02:07:38 +04:00
i f e q ( - , $( shell rpmvercmp $ ( MKI_VERSION ) $ ( MKI_VER_MINIMAL ) | tr -d [0-9]) )
$(info error : mkimage -$( MKI_VERSION ) is too old , please upgrade )
$( error mkimage is too old , $ ( MKI_VER_MINIMAL ) is minimal supported version )
e n d i f
i f e q ( - , $( shell rpmvercmp $ ( MKI_VERSION ) $ ( MKI_VER_OPTIMAL ) | tr -d [0-9]) )
$(info warning : mkimage -$( MKI_VERSION ) is suboptimal , consider upgrading )
$( warning consider upgrading mkimage to $ ( MKI_VER_OPTIMAL ) or better )
e n d i f
2013-02-04 19:18:06 +04:00
# glob it just in case
IMAGEDIR := $( wildcard $( IMAGEDIR) )
2012-04-23 22:56:35 +04:00
# additional means to reduce havoc in IMAGEDIR
2013-02-04 19:18:06 +04:00
IMAGE_SORTDIR := $( wildcard $( SORTDIR) )
2012-04-23 22:56:35 +04:00
2017-03-27 18:32:09 +03:00
# use distro version in image name if defined
i f d e f D I S T R O _ V E R S I O N
IMAGE_VERSION := -$( DISTRO_VERSION)
IMAGE_VER_LINK := $( IMAGE_NAME) $( IMAGE_VERSION) -latest-$( ARCH) .$( IMAGE_TYPE)
e n d i f
IMAGE_OUTFILE := \
$( IMAGE_NAME) $( IMAGE_VERSION) -$( STATUS) $( DATE) -$( ARCH) .$( IMAGE_TYPE)
2012-04-23 22:56:35 +04:00
IMAGE_OUTDIR := $( IMAGEDIR) $( IMAGE_SORTDIR:%= /%)
IMAGE_OUTPATH := $( IMAGE_OUTDIR) /$( IMAGE_OUTFILE)
IMAGE_RELPATH := $( IMAGE_SORTDIR:%= %/) $( IMAGE_OUTFILE)
IMAGE_RELDIR := $( IMAGE_OUTDIR:$( GLOBAL_BUILDDIR) /%= %)
2012-06-18 17:16:52 +04:00
IMAGE_LINK := $( IMAGE_NAME) -latest-$( ARCH) .$( IMAGE_TYPE)
2012-04-23 22:56:35 +04:00
IMAGE_LINKPATH := $( IMAGEDIR) /$( IMAGE_LINK)
### multi-pack can be useful (think netinst iso/tree)
2011-10-06 12:46:31 +04:00
MKI_PACK_RESULTS = $( IMAGE_PACKTYPE) :$( IMAGE_OUTFILE)
2010-08-28 20:28:42 +04:00
2015-08-07 12:50:49 +03:00
# these get copied over as is
2010-09-09 13:50:29 +04:00
COPY_TREE = ./files
2010-08-28 20:28:42 +04:00
2011-05-11 23:40:47 +04:00
# outdir shouldn't be wiped clean before use
2011-06-14 18:25:55 +04:00
CLEANUP_OUTDIR ?=
2011-05-11 23:40:47 +04:00
2012-07-09 22:50:57 +04:00
GLOBAL_TARGET := $( ARCH)
2016-07-07 19:35:33 +03:00
GLOBAL_HSH_LANGS := $( INSTALL_LANGS)
2011-11-04 02:14:18 +04:00
GLOBAL_HSH_APT_CONFIG := $( wildcard $( APTCONF) )
2010-09-27 23:02:57 +04:00
2018-02-15 16:57:50 +03:00
# take the latter part for complex-specified subprofiles like stage2@live;
# care to exclude non-directories holding no makefiles like rootfs
SUBDIRS = $( sort $( dir $( wildcard $( addsuffix /Makefile,$( SUBPROFILE_DIRS) ) ) ) )
2011-10-06 12:46:31 +04:00
# the lib/build-*.mk comes from features.in/build-*/lib
2012-10-10 17:18:32 +04:00
i n c l u d e $( sort $ ( wildcard lib /*.mk ) )
2010-09-08 16:47:06 +04:00
i n c l u d e $( MKIMAGE_PREFIX ) / t a r g e t s . m k
2010-08-28 20:28:42 +04:00
2011-10-06 12:46:31 +04:00
# specified only for the final image (target-specific)
2012-04-23 22:56:35 +04:00
pack-image : OUTDIR = $( IMAGE_OUTDIR )
2011-11-09 23:14:22 +04:00
pack-image : imagedir
2011-07-15 01:00:46 +04:00
2012-02-08 00:21:33 +04:00
copy-tree : $( SAVE_PROFILE :%=save -profile )
save-profile :
@mkdir -p files/.disk; \
git archive --prefix= mkimage-profile/ HEAD \
| gzip -9 > files/.disk/profile.tgz
2011-11-09 23:14:22 +04:00
.PHONY : imagedir postprocess debug
2012-07-10 20:08:01 +04:00
prep : imagedir
2011-11-09 23:14:22 +04:00
imagedir :
2012-04-23 22:56:35 +04:00
@mkdir -p " $( IMAGE_OUTDIR) "
2011-05-11 23:40:47 +04:00
2011-12-12 19:34:00 +04:00
postprocess : | $( addprefix postprocess -,$ ( sort $ ( POSTPROCESS_TARGETS ) ) )
2012-04-23 22:56:35 +04:00
@OUTSIZE= "`ls -lh " $( IMAGE_OUTPATH) " | cut -f5 -d' '`" ; \
2017-12-04 19:41:17 +03:00
if [ ! -n " $$ OUTSIZE " ] ; then \
echo " ** error: $( IMAGE_OUTPATH) missing " >& 2; \
exit 1; \
fi ; \
2012-04-23 22:56:35 +04:00
echo " ** image: $( IMAGE_OUTPATH) [ $$ OUTSIZE] " >& 2 && \
echo " IMAGE_OUTPATH = $( IMAGE_OUTPATH) " && \
2012-06-15 20:33:04 +04:00
echo " IMAGE_OUTFILE = $( IMAGE_OUTFILE) " && \
2012-04-23 22:56:35 +04:00
ln -sf " $( IMAGE_RELPATH) " " $( IMAGE_LINKPATH) " && \
ln -sf " $( IMAGE_RELDIR) " " $( OUT_LINK) " && \
ln -sf " $( IMAGE_LINK) " " $( IMAGEDIR) / $( CURRENT_LINK) . $( IMAGE_TYPE) " ; \
2017-03-27 18:32:09 +03:00
if [ -n " $( IMAGE_VER_LINK) " ] ; then \
ln -sf " $( IMAGE_RELPATH) " " $( IMAGEDIR) / $( IMAGE_VER_LINK) " ; \
fi ; \
2011-10-06 12:46:31 +04:00
if [ -n " $( GLOBAL_DEBUG) " ] ; then \
2012-06-15 20:33:04 +04:00
mkdir -p " $( LOGDIR) " ; \
cp -a build.log " $( LOGDIR) / $( IMAGE_OUTFILE) .log " ; \
cp -a distcfg.mk " $( LOGDIR) / $( IMAGE_OUTFILE) .cfg " ; \
2011-10-06 12:46:31 +04:00
fi
2010-09-27 23:02:57 +04:00
2017-08-07 21:49:47 +03:00
debug ::
2011-06-14 18:25:55 +04:00
@echo " TOPDIR= $( TOPDIR) "
2011-12-30 14:46:58 +04:00
@echo " IMAGEDIR= $( IMAGEDIR) "
2011-06-14 18:25:55 +04:00
@echo " ARCH= $( ARCH) "
2012-07-09 22:50:57 +04:00
@echo " GLOBAL_TARGET= $( GLOBAL_TARGET) "
2016-07-07 19:35:33 +03:00
@echo " GLOBAL_HSH_LANGS= $( GLOBAL_HSH_LANGS) "
2011-06-14 18:25:55 +04:00
@echo " GLOBAL_HSH_APT_CONFIG= $( GLOBAL_HSH_APT_CONFIG) "
2012-07-09 22:50:57 +04:00
@echo " GLOBAL_HSH_USE_QEMU= $( GLOBAL_HSH_USE_QEMU) "