1281760Ssjg# $Id: manifest.mk,v 1.2 2014/10/31 18:06:17 sjg Exp $ 2281760Ssjg# 3281760Ssjg# @(#) Copyright (c) 2014, Simon J. Gerraty 4281760Ssjg# 5281760Ssjg# This file is provided in the hope that it will 6281760Ssjg# be of use. There is absolutely NO WARRANTY. 7281760Ssjg# Permission to copy, redistribute or otherwise 8281760Ssjg# use this file is hereby granted provided that 9281760Ssjg# the above copyright notice and this notice are 10281760Ssjg# left intact. 11281760Ssjg# 12281760Ssjg# Please send copies of changes and bug-fixes to: 13281760Ssjg# sjg@crufty.net 14281760Ssjg# 15281760Ssjg 16281760Ssjg# generate mtree style manifest supported by makefs in FreeBSD 17281760Ssjg 18281760Ssjg# input looks like 19281760Ssjg# MANIFEST= my.mtree 20281760Ssjg# for each MANIFEST we have a list of dirs 21281760Ssjg# ${MANIFEST}.DIRS += bin sbin usr/bin ... 22281760Ssjg# for each dir we have a ${MANIFEST}.SRCS.$dir 23281760Ssjg# that provides the absolute path to the contents 24281760Ssjg# ${MANIFEST}.SRCS.bin += ${OBJTOP}/bin/sh/sh 25281760Ssjg# ${MANIFEST}.SYMLINKS is a list of src target pairs 26281760Ssjg# for each file/dir there are a number of attributes 27281760Ssjg# UID GID MODE FLAGS 28281760Ssjg# which can be set per dir, per file or we use defaults 29281760Ssjg# eg. 30281760Ssjg# MODE.sbin = 550 31281760Ssjg# MODE.usr/sbin = 550 32281760Ssjg# MODE.dirs = 555 33281760Ssjg# means that sbin and usr/sbin get 550 all other dirs get 555 34281760Ssjg# MODE.usr/bin/passwd = 4555 35281760Ssjg# MODE.usr/bin.files = 555 36281760Ssjg# MODE.usr/sbin.files = 500 37281760Ssjg# means passwd gets 4555 other files in usr/bin get 555 and 38281760Ssjg# files in usr/sbin get 500 39281760Ssjg# STORE defaults to basename of src and target directory 40281760Ssjg# but we can use 41281760Ssjg# ${MANIFEST}.SRCS.sbin += ${OBJTOP}/bin/sh-static/sh-static 42281760Ssjg# STORE.sbin/sh-static = sbin/sh 43281760Ssjg# 44281760Ssjg# the above is a little overkill but means we can easily adapt to 45281760Ssjg# different formats 46281760Ssjg 47281760SsjgUID.dirs ?= 0 48281760SsjgGID.dirs ?= 0 49281760SsjgMODE.dirs ?= 775 50281760SsjgFLAGS.dirs ?= 51281760Ssjg 52281760SsjgUID.files ?= 0 53281760SsjgGID.files ?= 0 54281760SsjgMODE.files ?= 555 55281760Ssjg 56281760Ssjg# a is attribute name d is dirname 57281760SsjgM_DIR_ATTR = L:@a@$${$$a.$$d:U$${$$a.dirs}}@ 58281760Ssjg# as above and s is set to the name we store f as 59281760SsjgM_FILE_ATTR = L:@a@$${$$a.$$s:U$${$$a.$$d.files:U$${$$a.files}}}@ 60281760Ssjg 61281760Ssjg# this produces the body of the manifest 62281760Ssjg# there should typically be a header prefixed 63281760Ssjg_GEN_MTREE_MANIFEST_USE: .USE 64281760Ssjg @(${${.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}}';@} \ 65281760Ssjg ${${.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}}';@}@} \ 66281760Ssjg set ${${.TARGET}.SYMLINKS}; while test $$# -ge 2; do echo "$$2 type=link link=$$1"; shift 2; done) > ${.TARGET} 67