summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile56
-rwxr-xr-xbin/genpkg55
2 files changed, 70 insertions, 41 deletions
diff --git a/Makefile b/Makefile
index c6ea6b5..04de5e9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,41 +1,15 @@
-TWEAKS = $(PWD)/tweaks
-PKGS = $(PWD)/pkg
-BIN = $(PWD)/bin
-PKGVAR = $(PWD)/var
-
-.PHONY: prepare package tweakmeta PKGBUILD
-
-PKGBUILD: $(PKGS)/$(PKG)/PKGBUILD
-
-$(PKGS)/$(PKG)/PKGBUILD: tweakmeta
- @cd '$(PKGS)/$(PKG)'; \
- TDIR='$(BIN)/templ' $(BIN)/makepkgbuild
- @echo 'Built pkg/$(PKG)/PKGBUILD.'
-
-tweakmeta: $(PKGS)/$(PKG)/PKGMETA
- @if [ -r '$(TWEAKS)/$(PKG)' ]; \
- then \
- cd '$(PKGS)/$(PKG)'; \
- $(BIN)/tweakmeta >PKGMETA.new <'$(TWEAKS)/$(PKG)'; \
- mv PKGMETA PKGMETA.old; \
- mv PKGMETA.new PKGMETA; \
- echo 'Tweaked PKGMETA with tweaks/$(PKG).'; \
- fi
-
-$(PKGS)/$(PKG)/PKGMETA: prepare
- @[ -d '$(PKGS)/$(PKG)' ] || mkdir '$(PKGS)/$(PKG)'
- @cd '$(PKGS)/$(PKG)'; \
- PATH="$$PATH:$(BIN)" METABIN="$(BIN)/metas" \
- PKGVAR="$(PKGVAR)" \
- $(BIN)/makepkgmeta $(PKG) >PKGMETA
- @echo 'Created pkg/$(PKG)/PKGMETA.'
-
-prepare:
- @case '$(PKG)' in \
- '') echo 'error: Specify the package name in the PKG variable.' 1>&2 ;\
- false ;; \
- esac
- @[ -d '$(PKGVAR)' ] || mkdir '$(PKGVAR)'
-
-package: $(PKGS)/$(PKG)/PKGBUILD
- cd "$(PKGS)/$(PKG)"; makepkg --clean
+usage:
+ @echo 'Run "make install" to install into your home directory.'
+ @echo 'Run "make install_tweaks" to install tweak files, too.'
+
+install:
+ mkdir -p $$HOME/bin
+ install -m 755 bin/makepkgbuild bin/makepkgmeta bin/genpkg \
+ bin/tweakmeta $$HOME/bin
+ mkdir -p $$HOME/lib/genpkg/
+ cp -R lib/* $$HOME/lib/genpkg/
+ mkdir -p $$HOME/pkg/dest
+
+install_tweaks:
+ -mkdir $$HOME/pkg
+ cp -R tweaks $$HOME/pkg/
diff --git a/bin/genpkg b/bin/genpkg
new file mode 100755
index 0000000..b475ac2
--- /dev/null
+++ b/bin/genpkg
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+prog=genpkg
+
+libd=~/lib/genpkg
+tweakd=~/pkg/tweaks
+pkgd=~/pkg/dest
+vard=~/var
+
+if [ $# -lt 1 ]
+then
+ echo "usage: $prog [package name]" 1>&2
+ exit 1
+fi
+
+if ! [ -d "$tweakd" ]
+then
+ echo "$prog: bad package tweaks dir: $tweakd" 1>&2
+ exit 2
+fi
+
+if ! [ -d "$pkgd" ]
+then
+ echo "$prog: bad package dest dir: $pkgd" 1>&2
+ exit 2
+fi
+
+if ! [ -d "$vard" ]
+then
+ echo "$prog: bad package var dir: $vard" 1>&2
+ exit 2
+fi
+
+cwd=$(pwd)
+set -e
+
+for pkg
+do
+ [ -d "$pkgd/$pkg" ] || mkdir "$pkgd/$pkg"
+ cd "$pkgd/$pkg"
+
+ METABIN=$libd/metas PKGVAR=$vard makepkgmeta "$pkg" >PKGMETA
+ echo "Generated $pkgd/$pkg/PKGMETA"
+
+ twk=$libd/tweakd/$pkg
+ if [ -f "$twk" -a -r "$twk" ]
+ then
+ tweakmeta >PKGMETA.new <$twk
+ mv PKGMETA.new PKGMETA
+ echo "Tweaked PKGMETA with $tweakd/$pkg."
+ fi
+
+ TDIR=$libd/templ makepkgbuild
+ echo "Generated $pkgd/$pkg/PKGBUILD"
+done