summary refs log tree commit diff
path: root/xnew
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2014-12-10 18:32:45 +0100
committerChristian Neukirchen <chneukirchen@gmail.com>2014-12-10 18:32:45 +0100
commit289ec939c2028add7d99eb0d069a860df105f8bd (patch)
tree464b6788a2db70cd9fd268b4403cb7b30bfb3dc7 /xnew
parent4478129b85f9833de69aac3415978f4f5a14ae17 (diff)
downloadxtools-289ec939c2028add7d99eb0d069a860df105f8bd.tar.gz
xtools-289ec939c2028add7d99eb0d069a860df105f8bd.tar.xz
xtools-289ec939c2028add7d99eb0d069a860df105f8bd.zip
xnew: guess fields when passing a URL.
Diffstat (limited to 'xnew')
-rwxr-xr-xxnew30
1 files changed, 27 insertions, 3 deletions
diff --git a/xnew b/xnew
index 188c326..05fabb1 100755
--- a/xnew
+++ b/xnew
@@ -5,12 +5,36 @@ PKG=${1?no package name given}
 srcdir=$(xdistdir)/srcpkgs
 shift
 
+homepage=
+version=
+distfiles=
+case "$PKG" in
+*://*)
+	# guesstimate defaults
+	homepage=${PKG%/*}/
+	PKG=${PKG##*/}
+	ext=${PKG##*-}
+	again=true
+	while $again; do
+		again=false
+		case "$ext" in
+		[0-9]*)
+			version=$version${ext%%.*}.
+			ext=${ext#*.}
+			again=true
+		esac
+	done
+	version=${version%.}
+	PKG=${PKG%-*}
+	distfiles="$homepage/\${pkgname}-\${version}.$ext"
+esac
+
 mkdir $srcdir/$PKG
 
 cat >$srcdir/$PKG/template <<EOF
 # Template file for '$PKG'
 pkgname=$PKG
-version=
+version=$version
 revision=1
 #wrksrc=
 #create_wrksrc=yes
@@ -27,8 +51,8 @@ depends=""
 short_desc=""
 maintainer="$(git config user.name) <$(git config user.email)>"
 license="GPL-3"
-homepage=""
-distfiles=""
+homepage="$homepage"
+distfiles="$distfiles"
 checksum=badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadb
 EOF