/usr/bin/casparize is in caspar 20170830-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | #!/bin/bash
# This file is maintained at http://git.mdcc.cx/caspar
# casparize - create Makefile-populated directories
# Copyright (C) 2009 Jeroen Hoppenbrouwers <hoppie@hoppie.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Creates a directory in working directory named like the last path
# element of the parameter, and creates a Makefile in the new directory
# containing standard caspar(7) setup that refers to the parameter path.
# If relevant, also copies the original config file into the new dir.
# Is reasonably picky about path names, tries to avoid common errors.
#
# V1.3 2009-07-25
# Abort on first error.
set -e
if [ -z "$1" ]; then
echo "Usage:"
echo " casparize /path/to/config/dir"
echo " Creates dir in working directory and"
echo " sets up caspar(7) Makefile in it."
echo " casparize /path/to/config/dir/file"
echo " Creates dir in working directory and"
echo " sets up caspar(7) Makefile in it,"
echo " then copies the config file into it."
echo ""
echo "Typical example:"
echo " \$ cd <svn>/etc"
echo " \$ casparize /etc/postfix/main.cf"
echo ""
echo "Will never overwrite anything that already exists."
exit 1
fi
# Complain if config path is not absolute.
if [ "${1:0:1}" != "/" ]; then
echo "ERROR: config path must be absolute".
exit 1
fi
# If given config path is a file, split it off and continue with just the
# config directory (until at the end where the file comes in).
if [ -d "$1" ]; then
# Target is a directory; just continue.
conffile=""
confdir=$1
else
# Target is a file; split off.
conffile=`basename $1`
confdir=`dirname $1`
fi
# Two options are covered:
# 1. New directory required, create in working directory.
# 2. New dir and file required, create dir in working directory and file
# in the newly created directory.
# What is NOT covered is "create file in working directory" because we
# assume that it is rare to not have the working directory set up with a
# Makefile. But it could be done.
# Complain if working directory basename is not equal to one-but-last
# element of the given config directory path. This catches most "oops"
# cases.
here=`pwd`
here=`basename $here`
target=`dirname $confdir`
target=`basename $target`
if [ "$here" != "$target" ]; then
echo "ERROR: Check config directory versus working directory."
exit 1
fi
# Find the include/install.mk file by looking up the tree from working dir.
scandir=`pwd`
uplevels=""
until [ -a "${uplevels}include/install.mk" ]; do
scandir=`dirname $scandir`
if [ "$scandir" = "/" ]; then
echo "ERROR: could not find include/install.mk anywhere up the path."
exit 1
fi
uplevels+="../"
done
# Directory to be created in working directory.
base=`basename $confdir`
# If the directory to be created already exists, don't complain.
# It may be that caspar(1) is used to create the Makefile only.
mkdir -pv $base
if [ -e "${base}/Makefile" ]; then
# Complain if the Makefile already exists.
echo "WARNING: $base/Makefile already exists; not overwriting."
else
# Create the Makefile.
echo "csp_DIR = $confdir" > ${base}/Makefile
echo "include ${uplevels}../include/install.mk" >> ${base}/Makefile
echo "casparize: created file \`$base/Makefile'"
fi
# If required, create the configuration file as well (copy over).
if [ -n "${conffile}" ]; then
if [ -e "${base}/${conffile}" ]; then
echo "WARNING: ${base}/${conffile} already exists; not overwriting."
else
cp ${confdir}/${conffile} $base
echo "casparize: created file \`${base}/${conffile}'"
fi
fi
exit 0
|