summaryrefslogtreecommitdiff
path: root/pkgthing
diff options
context:
space:
mode:
Diffstat (limited to 'pkgthing')
-rw-r--r--pkgthing/Version1
-rw-r--r--pkgthing/find58
-rw-r--r--pkgthing/init48
-rw-r--r--pkgthing/pget.sh53
-rwxr-xr-xpkgthing/pkgthing14
-rw-r--r--pkgthing/pkgthing.mk41
-rw-r--r--pkgthing/search19
7 files changed, 226 insertions, 8 deletions
diff --git a/pkgthing/Version b/pkgthing/Version
new file mode 100644
index 0000000..81a5eb1
--- /dev/null
+++ b/pkgthing/Version
@@ -0,0 +1 @@
+2.9.0 (beta)
diff --git a/pkgthing/find b/pkgthing/find
new file mode 100644
index 0000000..4b33612
--- /dev/null
+++ b/pkgthing/find
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+# option handling
+case "$1" in
+ -v|-q) volume=$1; prog=$2;;
+ *) prog="$1";;
+esac
+
+# core
+error() {
+ echo "$0:$@"
+ exit 1
+}
+
+checkList() {
+ prog=$1
+ src=$2
+ file=$3
+ sed -n "s/^\($prog\) \.* \(.*\)/\1\t\2/p" "$src/$file" | \
+ while read line; do
+ _prg=`echo "$line" | cut -f 1`
+ _pkg=`echo "$line" | cut -f 2`
+ echo "\`$_prg' is in the $src package \`$_pkg'"
+ if [ "$volume" == '-v' ]; then
+ pkgthing search "$_pkg" "$src" | sed 's/^\(.\)/ \1/g'
+ fi
+ done
+}
+
+useVar() {
+ var=$1
+ val=$2
+ case "$var" in
+ \$name) _name="$val";;
+ \$union) :;;
+ \$progs)
+ checkList "$prog" "$_name" "$val"
+ :;;
+ esac
+}
+
+# parse files
+for lst in *.lst; do
+ _name='oops'
+ while read line; do
+ if [ -n "$line" ]; then
+ case "$line" in
+ \#*) :;; # comment, do nothing
+ \$*) # setting a variable
+ var=${line%%=*}
+ val=${line#$var=}
+ useVar "$var" "$val"
+ :;;
+ *) :;; # setting a source
+ esac
+ fi
+ done < "$lst"
+done
diff --git a/pkgthing/init b/pkgthing/init
new file mode 100644
index 0000000..4f5f784
--- /dev/null
+++ b/pkgthing/init
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+lst=$1
+
+error() {
+ echo "$0:$@"
+ exit 1
+}
+
+useVar() {
+ var=$1
+ val=$2
+ case "$var" in
+ \$name) _name="$val";;
+ \$union) echo 'union feature not yet implemented';;
+ esac
+}
+
+setsrc() {
+ mount_point=$1
+ dev=$2
+ case "$dev" in
+ file://*) ln -s "${dev#file://}" "$mount_point";;
+ ftp://*) ln -s "/$dev" "$mount_point";;
+ *) error "I don't know which protocol to use for \`$dev'.";;
+ esac
+}
+
+# parse files
+_name='oops'
+while read line; do
+ if [ -n "$line" ]; then
+ case "$line" in
+ \#*) :;; # comment, do nothing
+ \$*) # setting a variable
+ var=${line%%=*}
+ val=${line#$var=}
+ useVar "$var" "$val"
+ :;;
+ *) # setting a source
+ grp=`echo "$line" | cut -f 1`
+ src=`echo "$line" | cut -f 2`
+ mkdir -p "$_name"
+ setsrc "$_name/$grp" "$src"
+ :;;
+ esac
+ fi
+done < "$lst"
diff --git a/pkgthing/pget.sh b/pkgthing/pget.sh
index c0c12fe..d68cad0 100644
--- a/pkgthing/pget.sh
+++ b/pkgthing/pget.sh
@@ -1,10 +1,47 @@
-#!/bin/sh
-name='pget'
-ver='1.9.1'
+#!/bin/bash
-src=/var/srcdir
-cd $src; if [ $? -ne 0 ]; then exit 1; fi
-out="`echo "$1" | sed 's@^.*://@@'`"
-curl $@ -L -C - --create-dirs -o "$out"
-ptranslate "$out"
+useVar() {
+ var=$1
+ val=$2
+ case "$var" in
+ \$name) _name="$val";;
+ \$union) echo 'union feature not yet implemented';;
+ esac
+}
+setsrc() {
+ mount_point=$1
+ dev=$2
+ case "$dev" in
+ file://) ln -s "${dev#file://}" "$mount_point";;
+ ftp://) ln -s "/$dev" "$mount_point";;
+ *)
+ echo "I don't know which protocol to use fo \`$dev'.";
+ exit 1;;
+ esac
+}
+
+# parse files
+for lst in *.lst; do
+ echo 'loading `'$lst\''...'
+ _name='oops'
+ while read line; do
+ if [ -n "$line" ]; then
+ case "$line" in
+ \#*) :;; #comment, do nothing
+ \$*) #setting a variable
+ var=${line%%=*}
+ val=${line#$var}
+ useVar "$var" "$val"
+ :;;
+ *) #setting a source
+ grp=`echo "$line" | cut -f 1`
+ src=`echo "$line" | cut -f 2`
+ mkdir -p "$_name/$grp"
+ setsrc "$_name/$grp" "$src"
+ :;;
+ esac
+ echo $var == $val
+ fi
+ done < "$lst"
+done
diff --git a/pkgthing/pkgthing b/pkgthing/pkgthing
new file mode 100755
index 0000000..9439461
--- /dev/null
+++ b/pkgthing/pkgthing
@@ -0,0 +1,14 @@
+#!/bin/sh
+name='pkgthing'
+export datadir=/usr/src/local/pkgthing
+
+srcdir=/usr/src
+
+case "$1" in
+ find) shift; bash $datadir/find $@;;
+ search) shift; bash $datadir/search $@;;
+
+ -v|-V|--version) make -C "$srcdir" version;;
+ -h|-H|--help) make -C "$srcdir" help;;
+ *) make -C "$srcdir" $1;;
+esac
diff --git a/pkgthing/pkgthing.mk b/pkgthing/pkgthing.mk
new file mode 100644
index 0000000..29322b6
--- /dev/null
+++ b/pkgthing/pkgthing.mk
@@ -0,0 +1,41 @@
+#!/usr/bin/make -f
+name = pkgthing
+ver = 2.9.0
+
+usage = Usage: make [-C /usr/src] TARGET
+email = LukeShu@sbcglobal.net
+
+datadir = /usr/src/local/pkgthing
+
+.PHONY: shorthelp help version
+shorthelp:
+ # $(name): please specify an action
+ # $(usage)
+ #
+ # Try `make -C /usr/src help' for more options
+
+help:
+ # $(name) $(ver), package thing(y) - THing Is Not GNU (yet?)
+ # $(usage)
+ #
+ # ...
+ #
+ # Mail bug reports and suggestions to <$(email)>
+
+version:
+ # $(name) $(ver)
+ #
+ # Copyright (C) 2009 Luke Shumaker, Inc.
+ # Licence GPLv2+: GNU GPL version 2 or later
+ # <http://www.gnu.org/licenses/gpl.html>.
+ # This is free software: you are free to change and redistribute it.
+ # There is NO WARRANTY, to the extent permitted by law.
+ #
+ # Originally written by Luke Shumaker <$(email)>
+
+#.PHONY: init $(addprefix init-,$(shell echo *.lst))
+init: $(addprefix init-,$(shell echo *.lst))
+
+init-%: %
+ # loading `$<'...
+ bash $(datadir)/init "$<"
diff --git a/pkgthing/search b/pkgthing/search
new file mode 100644
index 0000000..a9aade0
--- /dev/null
+++ b/pkgthing/search
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+pkg=$1
+src=${2-*}
+
+printname() {
+ name=$1
+ echo -n "$name"
+ if [ -L "${name%/}" ]; then
+ echo -n ' -> '
+ printname `readlink "${name%/}"`
+ else
+ echo '' # or, rather: putchar('\n');
+ fi
+}
+
+for i in $src/*/"$pkg/" $src/*/"$pkg.README"; do
+ if [ -e "$i" ]; then printname "$i"; fi
+done