aboutsummaryrefslogtreecommitdiff
path: root/contrib/cpt-new
blob: a78fb4666f16c42de1f91750e7b331a14c07be21 (plain)
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
#!/bin/sh -e
# Create a boilerplate CPT package

## SYNOPSIS:
## .Nm
## .Op Ar package-name
## .Op Ar version
## .Op Ar source
## DESCRIPTION:
## .Nm
## creates an empty CPT package with the given arguments.
## .Ar package-name
## is the only mandatory argument.
## see: cpt-checksum.1

out() { printf '%s\n' "$@" ;}
die() { printf '\033[1;31m!> \033[m%s\n' "$@" >&2 ; exit 1 ;}

case "$1" in ''|--help|-h) out "usage: ${0##*/} [pkg] [version] [source]"; exit 0; esac

[ -d "$1" ] && die "Package '$1' already exists."

# Create the directory
mkdir -p "$1"

# Create the build file
printf '%s\n' "#!/bin/sh -e" > "$1/build" ; chmod +x "$1/build"

# Create the version file
printf '%s\n' "$2 1" > "$1/version"

# Create the sources file
printf '%s\n' "$3" > "$1/sources"

out "Package '${1##*/}' created to '$PWD/$1'" >&2