-all:
- ./build-package
+VERSION = 1.1.2
+BUILDVERSION = 1
+ARCHITECTURE = amd64
+PACKAGENAME = scantopdf-$(VERSION)-$(BUILDVERSION)-$(ARCHITECTURE)
+
+all: test package
+
+test:
+ ./tests/scanbasic.bats
+
+build: build/$(PACKAGENAME)/usr/local/bin/scantopdf \
+ build/$(PACKAGENAME)/usr/local/bin/scantopdfgray \
+ build/$(PACKAGENAME)/usr/local/bin/scantopdfbw \
+
+build/$(PACKAGENAME)/usr/local/bin/scantopdf:
+ mkdir -p build
+ mkdir -p build/$(PACKAGENAME)/usr/local/bin
+ cat src/scantopdf \
+ | sed "/@scanbasic.sh@/r src/scanbasic.sh" \
+ | sed "/@scanbasic.sh@/d" \
+ | sed "s/@VERSION@/$(VERSION)/" \
+ > build/$(PACKAGENAME)/usr/local/bin/scantopdf
+ chmod 755 build/$(PACKAGENAME)/usr/local/bin/scantopdf
+
+build/$(PACKAGENAME)/usr/local/bin/scantopdfgray:
+ mkdir -p build
+ mkdir -p build/$(PACKAGENAME)/usr/local/bin
+ cat src/scantopdfgray \
+ | sed "/@scanbasic.sh@/r src/scanbasic.sh" \
+ | sed "/@scanbasic.sh@/d" \
+ | sed "s/@VERSION@/$(VERSION)/" \
+ > build/$(PACKAGENAME)/usr/local/bin/scantopdfgray
+ chmod 755 build/$(PACKAGENAME)/usr/local/bin/scantopdfgray
+
+build/$(PACKAGENAME)/usr/local/bin/scantopdfbw:
+ mkdir -p build
+ mkdir -p build/$(PACKAGENAME)/usr/local/bin
+ cat src/scantopdfgray \
+ | sed "/@scanbasic.sh@/r src/scanbasic.sh" \
+ | sed "/@scanbasic.sh@/d" \
+ | sed "s/@VERSION@/$(VERSION)/" \
+ > build/$(PACKAGENAME)/usr/local/bin/scantopdfbw
+ chmod 755 build/$(PACKAGENAME)/usr/local/bin/scantopdfbw
+
+build/$(PACKAGENAME)/usr/local/share/scantopdf/cutpage.html:
+ mkdir -p build/$(PACKAGENAME)/usr/local/share/scantopdf
+ cp src/cutpage.html build/$(PACKAGENAME)/usr/local/share/scantopdf/cutpage.html
+
+build/$(PACKAGENAME)/DEBIAN/control:
+ mkdir -p build/$(PACKAGENAME)/DEBIAN
+ cat src/control \
+ | sed "s/@VERSION@/$(VERSION)/" \
+ > build/$(PACKAGENAME)/DEBIAN/control
+
+build/$(PACKAGENAME).deb: build \
+ build/$(PACKAGENAME)/usr/local/share/scantopdf/cutpage.html \
+ build/$(PACKAGENAME)/DEBIAN/control
+ cd build && dpkg-deb --build --root-owner-group $(PACKAGENAME)
+
+package: build/$(PACKAGENAME).deb
clean:
rm -rf build
\ No newline at end of file
+++ /dev/null
-#!/bin/bash
-
-errlog()
-{
- local lastexit=$?
- local msg="$1"
-
- echo "â ERROR: $msg"
- echo "đ EXIT $lastexit"
- return $lastexit
-}
-
-build_package()
-{
- local VERSION="1.1.2"
- local BUILDVERSION="1"
- local ARCHITECTURE="amd64"
- local PACKAGENAME="scantopdf-$VERSION-$BUILDVERSION-$ARCHITECTURE"
- local EXECUTABLES="scantopdf \
- scantopdfgray \
- scantopdfbw"
-
- echo "âšī¸ INFO: build package $PACKAGENAME"
-
- mkdir -p build
- mkdir -p build/$PACKAGENAME/usr/local/bin
-
- local executable=
- local buildpath=
- for executable in $EXECUTABLES; do
- buildpath="build/$PACKAGENAME/usr/local/bin/$executable"
- cat src/$executable \
- | sed "/@scanbasic.sh@/r src/scanbasic.sh" \
- | sed "/@scanbasic.sh@/d" \
- | sed "s/@VERSION@/$VERSION/" \
- > $buildpath
- chmod 755 $buildpath
- done
-
- mkdir -p build/$PACKAGENAME/usr/local/share/scantopdf
- cp src/cutpage.html build/$PACKAGENAME/usr/local/share/scantopdf/cutpage.html
-
- mkdir -p build/$PACKAGENAME/DEBIAN
- cat src/control \
- | sed "s/\$VERSION/$VERSION/" \
- > build/$PACKAGENAME/DEBIAN/control
-
- cd build
- dpkg-deb --build --root-owner-group $PACKAGENAME
-}
-
-run_tests()
-{
- echo "âšī¸ INFO: run tests"
- ./tests/scanbasic.bats
-}
-
-main()
-{
- echo "â START: build-package"
-
- [ -n "$SKIP_TESTS" ] \
- || run_tests \
- || errlog "tests failed" \
- || return $?
- build_package
-
- echo "â
SUCCESS: build-package"
-}
-
-main