5 Commits
4 changed files with 75 additions and 30 deletions
+5 -3
View File
@@ -21,7 +21,7 @@ Creating a package for BPM with these utilities is simple
2) Run the following command (You can run the comamnd with no arguments to see available options)
```
bpm-setup -D my_bpm_package -t <binary/source>
bpm-setup -D my_package -t <binary/source>
```
3) This will create a directory named 'my_bpm_package' under the current directory with all the required files for the chosen package type
4) You are able to edit the pkg.info descriptor file inside the newly created directory to your liking. Here's an example of what a descriptor file could look like
@@ -29,12 +29,14 @@ bpm-setup -D my_bpm_package -t <binary/source>
name: my_package
description: My package's description
version: 1.0
revision: 2 (Optional)
architecture: x86_64
url: https://www.my-website.com/ (Optional)
license: MyLicense (Optional)
type: <binary/source>
depends: dependency1,dependency2 (Optional)
make_depends: make_depend1,make_depend2 (Optional)
depends: ["dependency1","dependency2"] (Optional)
optional_depends: ["optional_depend1","optional_depend2"]
make_depends: ["make_depend1","make_depend2"] (Optional)
```
### Binary Packages
3) If you are making a binary package, copy all your binaries along with the directories they reside in (i.e files/usr/bin/my_binary)
+41 -1
View File
@@ -6,11 +6,12 @@ fi
echo "$ARCH"
while getopts "ksa:" o; do
while getopts "ksfa:" o; do
case "${o}" in
a) ARCH="$OPTARG";;
k) KEEP=true;;
s) SKIPCHECK=true;;
f) FORCE=true;;
*) exit 1;;
esac
done
@@ -61,6 +62,44 @@ function ReadPkgInfo() {
}
ReadPkgInfo
if [ -z "$FORCE" ] && command -v bpm &> /dev/null && [ -n "$PKGINFO[depends]" ]; then
MISSING=()
for depend in $(echo "${PKGINFO[depends]}" | tr -d '[]' | tr ',' '\n' ); do
if ! bpm info "$depend" &> /dev/null; then
MISSING+=("$depend")
fi
done
if [ "${#MISSING[@]}" -ne 0 ]; then
echo "The following dependencies could not be resolved: ${MISSING[@]}"
EXIT=true
fi
elif ! command -v bpm &> /dev/null; then
echo "BPM not in PATH. Skipping dependency resolution"
elif [ -n "$FORCE" ]; then
echo "Force compilation enabled. Skipping dependency resolution"
fi
if [ -z "$FORCE" ] && command -v bpm &> /dev/null && [ -n "$PKGINFO[make_depends]" ]; then
MISSING=()
for depend in $(echo "${PKGINFO[make_depends]}" | tr -d '[]' | tr ',' '\n' ); do
if ! bpm info "$depend" &> /dev/null; then
MISSING+=("$depend")
fi
done
if [ "${#MISSING[@]}" -ne 0 ]; then
echo "The following make dependencies could not be resolved: ${MISSING[@]}"
EXIT=true
fi
elif ! command -v bpm &> /dev/null; then
echo "BPM not in PATH. Skipping make dependency resolution"
elif [ -n "$FORCE" ]; then
echo "Force compilation enabled. Skipping make dependency resolution"
fi
if [ -n "$EXIT" ]; then
exit 1
fi
# Creating temporary compilation directory structure
TEMPDIR="/var/tmp/bpm_source_${PKGINFO[name]}"
if [ -d "$TEMPDIR" ] && [ -z "$KEEP" ]; then
@@ -68,6 +107,7 @@ if [ -d "$TEMPDIR" ] && [ -z "$KEEP" ]; then
fi
mkdir -p "$TEMPDIR"
mkdir -p "$TEMPDIR"/source
[ -d "$TEMPDIR"/output ] && rm -rf "$TEMPDIR"/output
mkdir -p "$TEMPDIR"/output
tar -xf "$PACKAGE" -C "$TEMPDIR" source.sh
if tar -xf "$PACKAGE" -C "$TEMPDIR" source-files &> /dev/null; then
+25 -25
View File
@@ -1,27 +1,33 @@
#!/bin/bash
if [ $# -eq 0 ]
then
echo "No output package name given!"
exit 1
fi
if [ -f .compilation-options ]; then
source ./.compilation-options
fi
while getopts "cska:" flag; do
while getopts "cskfa:" flag; do
case "$flag" in
c) CONVERT=true;;
k) KEEP=true;;
s) SKIPCHECK=true;;
f) FORCE=true;;
a) ARCH="${OPTARG}";;
*) exit 1;;
esac
done
output="${@:$OPTIND:1}"
if [ -f pkg.info ]; then
echo "pkg.info file found"
else
echo "pkg.info file not found in $PWD"
exit 1
fi
if [[ ! "$output" =~ ^[a-z.A-Z0-9_-]{1,}$ ]]; then
output="${@:$OPTIND:1}"
if [ -z "$output" ]; then
pkgname=$(grep "^name: " pkg.info)
output=$(echo "$pkgname" | cut -d' ' -f2)"-src.bpm"
fi
if [ -z "$output" ] || [[ ! "$output" =~ ^[a-z.A-Z0-9_-]{1,}$ ]]; then
echo "Invalid output name! The name must only contain letters, numbers, hyphens or underscores!"
exit 1
fi
@@ -55,10 +61,14 @@ else
echo "post_install.sh file found"
toCompress+=("post_install.sh")
fi
if [ -f pre_remove.sh ]; then
echo "pre_remove.sh file found"
toCompress+=("pre_remove.sh")
fi
if [ -f post_remove.sh ]; then
echo "post_remove.sh file found"
toCompress+=("post_remove.sh")
fi
echo "post_remove.sh file found"
toCompress+=("post_remove.sh")
fi
if [ -d source-files ]; then
if [ ! -z "$(ls -A source-files)" ]; then
echo "source-files/ directory found"
@@ -71,13 +81,6 @@ else
fi
fi
if [ -f pkg.info ]; then
echo "pkg.info file found"
else
echo "pkg.info file not found in $PWD"
exit 1
fi
for pkginfo in ./pkg.inf*; do
pkginfo=$(basename "$pkginfo")
echo "${pkginfo} file found"
@@ -89,11 +92,8 @@ tar -c --owner=0 --group=0 --no-same-owner -zf "$output" "${toCompress[@]}"
if [ ! -z "$CONVERT" ] && "$CONVERT" && [[ "$type" == "source" ]]; then
args=()
if ! [ -z "$KEEP" ]; then
args+=("-a" "$ARCH")
fi
if ! [ -z "$SKIPCHECK" ]; then
args+=("-s")
fi
bpm-convert "${args[@]}" -a "$ARCH" "$output"
[ -n "$KEEP" ] && args+=("-k")
[ -n "$SKIPCHECK" ] && args+=("-s")
[ -n "$FORCE" ] && args+=("-f")
bpm-convert "${args[@]}" -a "$ARCH" "$output"
fi
+4 -1
View File
@@ -19,7 +19,6 @@ if [ $# -eq 0 ]; then
exit
fi
NAME="package-name"
DESCRIPTION="Default package description"
VERSION="1.0"
#URL="https://my.project.url/ (Optional)"
@@ -79,6 +78,10 @@ if [ -z "${DIRECTORY}" ]; then
exit 1
fi
if [ -z "${NAME}" ]; then
NAME="${DIRECTORY}"
fi
if [[ ! "${DIRECTORY}" == "/"* ]]; then
DIRECTORY="${PWD}/${DIRECTORY}"
fi