WIP: Rewrite bpm utils in go #1
3
Makefile
3
Makefile
@ -27,7 +27,8 @@ install: build config/
|
||||
# Install binaries
|
||||
install -Dm755 build/bpm-* -t $(DESTDIR)$(BINDIR)/
|
||||
# Install config files
|
||||
install -Dm644 config/* -t $(DESTDIR)$(SYSCONFDIR)/bpm-utils/
|
||||
install -dm755 $(DESTDIR)$(SYSCONFDIR)/bpm-utils/
|
||||
cp -r config/* -t $(DESTDIR)$(SYSCONFDIR)/bpm-utils/
|
||||
|
||||
clean:
|
||||
rm -r build/
|
||||
|
42
config/templates/cmake
Normal file
42
config/templates/cmake
Normal file
@ -0,0 +1,42 @@
|
||||
# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package
|
||||
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
|
||||
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
|
||||
|
||||
DOWNLOAD="https://wwww.my-url.com/file.tar.gz"
|
||||
FILENAME="${DOWNLOAD##*/}"
|
||||
|
||||
# The prepare function is executed in the root of the temp directory
|
||||
# This function is used for downloading files and putting them into the correct location
|
||||
prepare() {
|
||||
wget "$DOWNLOAD"
|
||||
tar -xvf "$FILENAME" --strip-components=1 -C "$BPM_SOURCE"
|
||||
}
|
||||
|
||||
# The build function is executed in the source directory
|
||||
# This function is used to compile the source code
|
||||
build() {
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
|
||||
make
|
||||
}
|
||||
|
||||
# The check function is executed in the source directory
|
||||
# This function is used to run tests to verify the package has been compiled correctly
|
||||
check() {
|
||||
cd build
|
||||
|
||||
make test
|
||||
}
|
||||
|
||||
# The package function is executed in the source directory
|
||||
# This function is used to move the compiled files into the output directory
|
||||
package() {
|
||||
cd build
|
||||
|
||||
make DESTDIR="$BPM_OUTPUT" install
|
||||
|
||||
# Install package license
|
||||
install -Dm644 "$BPM_SOURCE"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/$NAME/LICENSE
|
||||
}
|
@ -29,4 +29,7 @@ check() {
|
||||
# This function is used to move the compiled files into the output directory
|
||||
package() {
|
||||
make DESTDIR="$BPM_OUTPUT" install
|
||||
|
||||
# Install package license
|
||||
install -Dm644 "$BPM_SOURCE"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/$NAME/LICENSE
|
||||
}
|
34
config/templates/gnu-make
Normal file
34
config/templates/gnu-make
Normal file
@ -0,0 +1,34 @@
|
||||
# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package
|
||||
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
|
||||
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
|
||||
|
||||
DOWNLOAD="https://wwww.my-url.com/file.tar.gz"
|
||||
FILENAME="${DOWNLOAD##*/}"
|
||||
|
||||
# The prepare function is executed in the root of the temp directory
|
||||
# This function is used for downloading files and putting them into the correct location
|
||||
prepare() {
|
||||
wget "$DOWNLOAD"
|
||||
tar -xvf "$FILENAME" --strip-components=1 -C "$BPM_SOURCE"
|
||||
}
|
||||
|
||||
# The build function is executed in the source directory
|
||||
# This function is used to compile the source code
|
||||
build() {
|
||||
make PREFIX=/usr
|
||||
}
|
||||
|
||||
# The check function is executed in the source directory
|
||||
# This function is used to run tests to verify the package has been compiled correctly
|
||||
check() {
|
||||
make check
|
||||
}
|
||||
|
||||
# The package function is executed in the source directory
|
||||
# This function is used to move the compiled files into the output directory
|
||||
package() {
|
||||
make DESTDIR="$BPM_OUTPUT" PREFIX=/usr install
|
||||
|
||||
# Install package license
|
||||
install -Dm644 "$BPM_SOURCE"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/$NAME/LICENSE
|
||||
}
|
42
config/templates/meson
Normal file
42
config/templates/meson
Normal file
@ -0,0 +1,42 @@
|
||||
# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package
|
||||
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
|
||||
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
|
||||
|
||||
DOWNLOAD="https://wwww.my-url.com/file.tar.gz"
|
||||
FILENAME="${DOWNLOAD##*/}"
|
||||
|
||||
# The prepare function is executed in the root of the temp directory
|
||||
# This function is used for downloading files and putting them into the correct location
|
||||
prepare() {
|
||||
wget "$DOWNLOAD"
|
||||
tar -xvf "$FILENAME" --strip-components=1 -C "$BPM_SOURCE"
|
||||
}
|
||||
|
||||
# The build function is executed in the source directory
|
||||
# This function is used to compile the source code
|
||||
build() {
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
meson setup --prefix=/usr ..
|
||||
meson compile
|
||||
}
|
||||
|
||||
# The check function is executed in the source directory
|
||||
# This function is used to run tests to verify the package has been compiled correctly
|
||||
check() {
|
||||
cd build
|
||||
|
||||
meson test
|
||||
}
|
||||
|
||||
# The package function is executed in the source directory
|
||||
# This function is used to move the compiled files into the output directory
|
||||
package() {
|
||||
cd build
|
||||
|
||||
meson install --destdir="$BPM_OUTPUT"
|
||||
|
||||
# Install package license
|
||||
install -Dm644 "$BPM_SOURCE"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/$NAME/LICENSE
|
||||
}
|
34
config/templates/python-module
Normal file
34
config/templates/python-module
Normal file
@ -0,0 +1,34 @@
|
||||
# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package
|
||||
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
|
||||
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
|
||||
|
||||
DOWNLOAD="https://wwww.my-url.com/file.tar.gz"
|
||||
FILENAME="${DOWNLOAD##*/}"
|
||||
|
||||
# The prepare function is executed in the root of the temp directory
|
||||
# This function is used for downloading files and putting them into the correct location
|
||||
prepare() {
|
||||
wget "$DOWNLOAD"
|
||||
tar -xvf "$FILENAME" --strip-components=1 -C "$BPM_SOURCE"
|
||||
}
|
||||
|
||||
# The build function is executed in the source directory
|
||||
# This function is used to compile the source code
|
||||
build() {
|
||||
python3 -m build --wheel --no-isolation .
|
||||
}
|
||||
|
||||
# The check function is executed in the source directory
|
||||
# This function is used to run tests to verify the package has been compiled correctly
|
||||
check() {
|
||||
# Python module testing command varies from module to module
|
||||
}
|
||||
|
||||
# The package function is executed in the source directory
|
||||
# This function is used to move the compiled files into the output directory
|
||||
package() {
|
||||
python3 -m installer --destdir="$BPM_OUTPUT" dist/*.whl
|
||||
|
||||
# Install package license
|
||||
install -Dm644 "$BPM_SOURCE"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/$NAME/LICENSE
|
||||
}
|
@ -18,7 +18,7 @@ var description = flag.String("d", "Default Package Description", "Set the descr
|
||||
var version = flag.String("v", "1.0", "Set the package version (Defaults to \"1.0\")")
|
||||
var url = flag.String("u", "", "Set the package URL (Optional)")
|
||||
var license = flag.String("l", "", "Set the package licenses (Optional)")
|
||||
var template = flag.String("t", "source.default", "Set the package template (Defaults to \"source.default\")")
|
||||
var template = flag.String("t", "gnu-configure", "Set the package template (Defaults to \"gnu-configure\")")
|
||||
var git = flag.Bool("g", true, "Create git repository (Defaults to true)")
|
||||
|
||||
func main() {
|
||||
@ -67,7 +67,7 @@ func help() {
|
||||
fmt.Println(" -v=<version> | Set the package version (Defaults to \"1.0\")")
|
||||
fmt.Println(" -u=<url> | Set the package URL (Optional)")
|
||||
fmt.Println(" -l=<licenses> | Set the package licenses (Optional)")
|
||||
fmt.Println(" -t=<template file> | Use a template file (Defaults to source.default)")
|
||||
fmt.Println(" -t=<template file> | Use a template file (Defaults to gnu-configure)")
|
||||
fmt.Println(" -g=<true/false> | Create git repository (Defaults to true)")
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ func runChecks() {
|
||||
log.Fatalf("No package name was specified!")
|
||||
}
|
||||
|
||||
if stat, err := os.Stat(path.Join("/etc/bpm-utils/", *template)); err != nil || stat.IsDir() {
|
||||
if stat, err := os.Stat(path.Join("/etc/bpm-utils/templates/", *template)); err != nil || stat.IsDir() {
|
||||
log.Fatalf("%s is not a valid template file!", *template)
|
||||
}
|
||||
}
|
||||
@ -145,7 +145,7 @@ func createDirectory() {
|
||||
}
|
||||
|
||||
// Copy source template file
|
||||
input, err := os.ReadFile(path.Join("/etc/bpm-utils/", *template))
|
||||
input, err := os.ReadFile(path.Join("/etc/bpm-utils/templates", *template))
|
||||
if err != nil {
|
||||
log.Fatalf("Error: could not read template file: %s", err)
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user