init
authorVincent Dahmen <wahrwolf@wolfpit.net>
Wed, 12 Feb 2020 21:59:29 +0000 (22:59 +0100)
committerVincent Dahmen <wahrwolf@wolfpit.net>
Wed, 12 Feb 2020 21:59:29 +0000 (22:59 +0100)
12 files changed:
Makefile [new file with mode: 0644]
build.sh [new file with mode: 0755]
scripts/Makefile [new file with mode: 0644]
scripts/build.sh [new file with mode: 0755]
scripts/create-package [new file with mode: 0755]
scripts/gen-package [new file with mode: 0644]
scripts/npm-scripts [new file with mode: 0644]
templates/PKGBUILD.proto [new file with mode: 0644]
templates/mermaid-cli-0.2.4.tgz [new file with mode: 0644]
templates/nodejs-npm.proto [new file with mode: 0644]
templates/python-pip.proto [new file with mode: 0644]
templates/python2-pip.proto [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..a094556
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,25 @@
+export BUILD_ARGS = -cun #--skippgpcheck
+export BUILD_SCRIPT = /usr/bin/extra-x86_64-build
+export AUR_URL = https://aur.archlinux.org
+export DB_PATH = packages/wolfaur.db.tar.gz
+export DB_NAME = wolfaur.db.tar.gz
+export DESTDIR = packages
+export SRCDIR = build
+
+PACKAGES = $(wildcard build/*)
+
+.PHONY: $(PACKAGES)
+
+packages/%: build/% 
+       git -C $< pull 
+       /bin/bash -c "./build.sh $(notdir $<)"
+
+build/%: build/%/.git 
+       git -C $(dir $<) pull 
+
+build/%/.git:
+       git clone "$(AUR_URL)/$(patsubst build/%/.git,%,$@)" "$(dir $@)"
+
+
+update: $(foreach repo,$(PACKAGES),$(patsubst build/%,packages/%,$(repo)))
+
diff --git a/build.sh b/build.sh
new file mode 100755 (executable)
index 0000000..ca4f735
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+pkgdir=${DESTDIR:-packages}
+srcdir=${SRCDIR:-build}
+
+echo "Packaging $1 in $srcdir to $pkgdir"
+
+if [ -e "$srcdir/$1/.skip" ]
+then                                                   \
+       echo Found "$1/.skip"
+       echo Skipping package "$1"
+       exit 0
+else 
+       echo Building package "$1"
+       (cd "$srcdir/$1" && $BUILD_SCRIPT -- $BUILD_ARGS)
+       rm -f "$srcdir/$1/*.log"
+fi 
+packagename=$(cd "$srcdir/$1" && makepkg --packagelist)
+if [ -e "$packagename" ]
+then
+       echo "Adding $(basename $packagename) to $DB_PATH"
+       cp "$packagename" "$pkgdir/"
+       cd $pkgdir
+       repo-add -R "$DB_NAME" $(basename "$packagename")
+       repose -fz "$DB_NAME"  "$1"
+fi
diff --git a/scripts/Makefile b/scripts/Makefile
new file mode 100644 (file)
index 0000000..02d55bc
--- /dev/null
@@ -0,0 +1,19 @@
+export BUILD_ARGS = -cun
+export BUILD_SCRIPT = /usr/bin/extra-x86_64-build
+export AUR_URL = https://aur.archlinux.org
+export DB_PATH = packages/wolfaur.db.tar.gz
+export DB_NAME = wolfaur.db.tar.gz
+export DESTDIR = packages
+export SRCDIR = build
+
+
+packages/%: build/% 
+       /bin/bash -c "./build.sh $(notdir $<)"
+
+build/nodejs-%:  
+
+build/%:  
+       if [ ! -d "$@/.git" ] ; then git clone $(AUR_URL)/$(patsubst build/%,%,$@) $@ ; fi
+       cd $@ && git pull 
+
+update: $(foreach repo,$(wildcard build/*),$(patsubst build/%,packages/%,$(repo)))
diff --git a/scripts/build.sh b/scripts/build.sh
new file mode 100755 (executable)
index 0000000..d07e231
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+pkgdir=${DESTDIR:-packages}
+srcdir=${SRCDIR:-build}
+
+echo "Packaging $1 in $srcdir to $pkgdir"
+
+if [ -e "$srcdir/$1/.skip" ]
+then                                                   \
+       echo Found "$1/.skip"
+       echo Skipping package "$1"
+else 
+       echo Building package "$1"
+       (cd "$srcdir/$1" && $BUILD_SCRIPT -- $BUILD_ARGS)
+       rm -f "$srcdir/$1/*.log"
+fi 
+packagename=$(cd "$srcdir/$1" && makepkg --packagelist)
+echo "Adding $(basename $packagename) to $DB_PATH"
+cp "$packagename" "$pkgdir/"
+cd $pkgdir
+repo-add -R "$DB_NAME" $(basename "$packagename")
+repose -fz "$DB_NAME"  "$1"
diff --git a/scripts/create-package b/scripts/create-package
new file mode 100755 (executable)
index 0000000..64098c5
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+source gen-package
+
+
+pkgname=${1}
+tool=${2}
+
+destdir=${3:-${aur_packages}/${pkgname}}
+
+init_local_repo $pkgname
+cd $destdir
+
+case $tool in
+npm)
+gen_npm_pkgbuild $pkgname "${destdir}/PKGBUILD"
+;;
+*)
+echo "$tool module still in development"
+;;
+esac
+
+git add PKGBUILD
+git commit -m "$pkgname: adds autogenerated PKGBUILD"
+git push --set-upstream master origin
+
+
diff --git a/scripts/gen-package b/scripts/gen-package
new file mode 100644 (file)
index 0000000..f37e2be
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/bash
+# load local git support
+source /usr/local/lib/wolfgit/repos.sh
+
+source ./npm-scripts
+
+function init_local_repo(){
+       local pkgname=${1}
+       local prefix=${2:-aur}
+       local destdir=${3:-${aur_packages}/${pkgname}}
+       local origin_name=${prefix}/${pkgname}
+
+       local repo_url=$(create_repo "${origin_name}")
+
+       git clone -- "$repo_url" $destdir
+}
+
+function create_package(){
+       local pkgname=${1}
+       local tool=${2}
+
+       local destdir=${3:-${aur_packages}/${pkgname}}
+
+       init_local_repo $pkgname
+       cd $destdir
+
+       case $tool in
+               npm)
+                       destdir="${aur_packages}/nodejs-${pkgname}"
+                       gen_npm_pkgbuild $pkgname "${destdir}/PKGBUILD"
+                       ;;
+               *)
+                       echo "$tool module still in development"
+                       ;;
+       esac
+
+       git add PKGBUILD
+       git commit -m "$pkgname: adds autogenerated PKGBUILD"
+       git push --set-upstream master origin
+}
+
+
+
diff --git a/scripts/npm-scripts b/scripts/npm-scripts
new file mode 100644 (file)
index 0000000..3ca7421
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/bash
+aur_packages=/srv/aur/build
+aur_templates=/srv/aur/templates
+
+function npm_deps_to_array(){
+       local pkgname=${1}
+       npm  --json view "$pkgname" dependencies        |
+               jq --raw-output --compact-output        \
+               'keys'                                  |
+               sed     --expression 's/,/ /g'          \
+                       --expression 's/\[//'           \
+                       --expression 's/\]//'
+}
+
+function prefix_package_names(){
+       local packages="${1}"
+
+       for pkg in $packages; do
+               echo -n "nodejs-$pkg"
+       done
+       }
+
+function fill_npm_template(){
+       local pkgname=${1}
+       local template=${2:-"${aur_templates}/nodejs-npm.proto"}
+
+       # ENVs for template
+       export  PKGNAME=$pkgname
+       export  VERSION=$(npm view "$pkgname" dist-tags.latest)
+       export  DESCRIPTION=$(npm view "$pkgname" description)
+       export  AUTHOR=$(npm view "$pkgname" author)
+       export  URL=$(npm view "$pkgname" homepage)
+       export  LICENSE=$(npm view "$pkgname" license)
+       export  DEPENDENCIES="$(npm_deps_to_array "$pkgname")"
+       export  SHASUM=$(npm view "$pkgname" dist.shasum)
+       export  SOURCE="$(npm view "$pkgname" dist.tarball)"
+
+       envsubst '${PKGNAME},${VERSION},${DESCRIPTION},${AUTHOR},${URL},${LICENSE},${DEPENDENCIES},${SHASUM},${SOURCE}' <"$template"
+}
+
+function gen_npm_pkgbuild(){
+       local pkgname=${1}
+       local destfile=${2:-PKGBUILD}
+
+       fill_npm_template "$pkgname" > "$destfile"
+}
diff --git a/templates/PKGBUILD.proto b/templates/PKGBUILD.proto
new file mode 100644 (file)
index 0000000..a2c600d
--- /dev/null
@@ -0,0 +1,52 @@
+# This is an example PKGBUILD file. Use this as a start to creating your own,
+# and remove these comments. For more information, see 'man PKGBUILD'.
+# NOTE: Please fill out the license field for your package! If it is unknown,
+# then please put 'unknown'.
+
+# Maintainer: Your Name <youremail@domain.com>
+pkgname=NAME
+pkgver=VERSION
+pkgrel=1
+epoch=
+pkgdesc=""
+arch=()
+url=""
+license=('GPL')
+groups=()
+depends=()
+makedepends=()
+checkdepends=()
+optdepends=()
+provides=()
+conflicts=()
+replaces=()
+backup=()
+options=()
+install=
+changelog=
+source=("$pkgname-$pkgver.tar.gz"
+        "$pkgname-$pkgver.patch")
+noextract=()
+md5sums=()
+validpgpkeys=()
+
+prepare() {
+       cd "$pkgname-$pkgver"
+       patch -p1 -i "$srcdir/$pkgname-$pkgver.patch"
+}
+
+build() {
+       cd "$pkgname-$pkgver"
+       ./configure --prefix=/usr
+       make
+}
+
+check() {
+       cd "$pkgname-$pkgver"
+       make -k check
+}
+
+package() {
+       cd "$pkgname-$pkgver"
+       make DESTDIR="$pkgdir/" install
+}
diff --git a/templates/mermaid-cli-0.2.4.tgz b/templates/mermaid-cli-0.2.4.tgz
new file mode 100644 (file)
index 0000000..ae9ef1e
Binary files /dev/null and b/templates/mermaid-cli-0.2.4.tgz differ
diff --git a/templates/nodejs-npm.proto b/templates/nodejs-npm.proto
new file mode 100644 (file)
index 0000000..3a5b4c2
--- /dev/null
@@ -0,0 +1,24 @@
+# This is an auto generated PKGBUILD for packages installed via npm
+# Packager: wahrwolf <wahrwolf [├Ąt] wolfpit.net >
+# Author: ${AUTHOR}
+
+pkgname=${PKGNAME}
+pkgver=${VERSION}
+pkgrel=1
+epoch=
+pkgdesc="${DESCRIPTION}"
+arch=(any)
+url="${URL}"
+license=(${LICENSE})
+depends=(${DEPENDENCIES})
+makedepends=('nodejs', 'npm')
+#source=("http://registry.npmjs.org/$_pkgname/-/_$pkgname-$pkgver.tgz")
+source=("${SOURCE}")
+noextract=(_$pkgname-$pkgver.tgz)
+md5sums=()
+sha1sums=(${SHASUM})
+
+package() {
+       install -Dm 755 "$pkgdir/usr/lib/node_modules"
+       npm install --global --prefix "$pkgdir/usr" $_pkgname@pkgver
+}
diff --git a/templates/python-pip.proto b/templates/python-pip.proto
new file mode 100644 (file)
index 0000000..a2c600d
--- /dev/null
@@ -0,0 +1,52 @@
+# This is an example PKGBUILD file. Use this as a start to creating your own,
+# and remove these comments. For more information, see 'man PKGBUILD'.
+# NOTE: Please fill out the license field for your package! If it is unknown,
+# then please put 'unknown'.
+
+# Maintainer: Your Name <youremail@domain.com>
+pkgname=NAME
+pkgver=VERSION
+pkgrel=1
+epoch=
+pkgdesc=""
+arch=()
+url=""
+license=('GPL')
+groups=()
+depends=()
+makedepends=()
+checkdepends=()
+optdepends=()
+provides=()
+conflicts=()
+replaces=()
+backup=()
+options=()
+install=
+changelog=
+source=("$pkgname-$pkgver.tar.gz"
+        "$pkgname-$pkgver.patch")
+noextract=()
+md5sums=()
+validpgpkeys=()
+
+prepare() {
+       cd "$pkgname-$pkgver"
+       patch -p1 -i "$srcdir/$pkgname-$pkgver.patch"
+}
+
+build() {
+       cd "$pkgname-$pkgver"
+       ./configure --prefix=/usr
+       make
+}
+
+check() {
+       cd "$pkgname-$pkgver"
+       make -k check
+}
+
+package() {
+       cd "$pkgname-$pkgver"
+       make DESTDIR="$pkgdir/" install
+}
diff --git a/templates/python2-pip.proto b/templates/python2-pip.proto
new file mode 100644 (file)
index 0000000..a2c600d
--- /dev/null
@@ -0,0 +1,52 @@
+# This is an example PKGBUILD file. Use this as a start to creating your own,
+# and remove these comments. For more information, see 'man PKGBUILD'.
+# NOTE: Please fill out the license field for your package! If it is unknown,
+# then please put 'unknown'.
+
+# Maintainer: Your Name <youremail@domain.com>
+pkgname=NAME
+pkgver=VERSION
+pkgrel=1
+epoch=
+pkgdesc=""
+arch=()
+url=""
+license=('GPL')
+groups=()
+depends=()
+makedepends=()
+checkdepends=()
+optdepends=()
+provides=()
+conflicts=()
+replaces=()
+backup=()
+options=()
+install=
+changelog=
+source=("$pkgname-$pkgver.tar.gz"
+        "$pkgname-$pkgver.patch")
+noextract=()
+md5sums=()
+validpgpkeys=()
+
+prepare() {
+       cd "$pkgname-$pkgver"
+       patch -p1 -i "$srcdir/$pkgname-$pkgver.patch"
+}
+
+build() {
+       cd "$pkgname-$pkgver"
+       ./configure --prefix=/usr
+       make
+}
+
+check() {
+       cd "$pkgname-$pkgver"
+       make -k check
+}
+
+package() {
+       cd "$pkgname-$pkgver"
+       make DESTDIR="$pkgdir/" install
+}