1# $Id: manifest.mk,v 1.5 2025/08/09 22:42:24 sjg Exp $ 2# 3# @(#) Copyright (c) 2014, Simon J. Gerraty 4# 5# SPDX-License-Identifier: BSD-2-Clause 6# 7# Please send copies of changes and bug-fixes to: 8# sjg@crufty.net 9# 10 11# generate mtree style manifest supported by makefs in FreeBSD 12 13# input looks like 14# MANIFEST= my.mtree 15# for each MANIFEST we have a list of dirs 16# ${MANIFEST}.DIRS += bin sbin usr/bin ... 17# for each dir we have a ${MANIFEST}.SRCS.$dir 18# that provides the absolute path to the contents 19# ${MANIFEST}.SRCS.bin += ${OBJTOP}/bin/sh/sh 20# ${MANIFEST}.SYMLINKS is a list of src target pairs 21# for each file/dir there are a number of attributes 22# UID GID MODE FLAGS 23# which can be set per dir, per file or we use defaults 24# eg. 25# MODE.sbin = 550 26# MODE.usr/sbin = 550 27# MODE.dirs = 555 28# means that sbin and usr/sbin get 550 all other dirs get 555 29# MODE.usr/bin/passwd = 4555 30# MODE.usr/bin.files = 555 31# MODE.usr/sbin.files = 500 32# means passwd gets 4555 other files in usr/bin get 555 and 33# files in usr/sbin get 500 34# STORE defaults to basename of src and target directory 35# but we can use 36# ${MANIFEST}.SRCS.sbin += ${OBJTOP}/bin/sh-static/sh-static 37# STORE.sbin/sh-static = sbin/sh 38# 39# the above is a little overkill but means we can easily adapt to 40# different formats 41 42UID.dirs ?= 0 43GID.dirs ?= 0 44MODE.dirs ?= 775 45FLAGS.dirs ?= 46 47UID.files ?= 0 48GID.files ?= 0 49MODE.files ?= 555 50 51# a is attribute name d is dirname 52M_DIR_ATTR = L:@a@$${$$a.$$d:U$${$$a.dirs}}@ 53# as above and s is set to the name we store f as 54M_FILE_ATTR = L:@a@$${$$a.$$s:U$${$$a.$$d.files:U$${$$a.files}}}@ 55 56# this produces the body of the manifest 57# there should typically be a header prefixed 58_GEN_MTREE_MANIFEST_USE: .USE 59 @(${${.TARGET}.DIRS:O:u:@d@echo '$d type=dir uid=${UID:${M_DIR_ATTR}} gid=${GID:${M_DIR_ATTR}} mode=${MODE:${M_DIR_ATTR}} ${FLAGS:${M_DIR_ATTR}}';@} \ 60 ${${.TARGET}.DIRS:O:u:@d@${${.TARGET}.SRCS.$d:O:u:@f@echo '${s::=${STORE.$d/${f:T}:U$d/${f:T}}}$s contents="$f" type=file uid=${UID:${M_FILE_ATTR}} gid=${GID:${M_FILE_ATTR}} mode=${MODE:${M_FILE_ATTR}} ${FLAGS:${M_FILE_ATTR}}';@}@} \ 61 set ${${.TARGET}.SYMLINKS}; while test $$# -ge 2; do echo "$$2 type=link link=$$1"; shift 2; done) > ${.TARGET} 62