aboutsummaryrefslogtreecommitdiff
path: root/repos/gentemplate.sh
diff options
context:
space:
mode:
authoremmett1 <emmett1.2miligrams@protonmail.com>2024-05-24 12:22:12 +0800
committeremmett1 <emmett1.2miligrams@protonmail.com>2024-05-24 12:22:12 +0800
commit46ca440e9d6cc606d9c3233021e32d24b25172cf (patch)
treeeeb573e47ac56498fbf74bda6d22fac47038ecab /repos/gentemplate.sh
parent8c2e7bb570c11a51fdcecf7302af4058757d862c (diff)
downloadalicelinux-46ca440e9d6cc606d9c3233021e32d24b25172cf.tar.gz
alicelinux-46ca440e9d6cc606d9c3233021e32d24b25172cf.zip
added repos
Diffstat (limited to 'repos/gentemplate.sh')
-rwxr-xr-xrepos/gentemplate.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/repos/gentemplate.sh b/repos/gentemplate.sh
new file mode 100755
index 00000000..9232caff
--- /dev/null
+++ b/repos/gentemplate.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+[ "$1" ] || exit 1
+
+#if [ ! -f REPO ]; then
+ #echo "you not inside repo's directory"
+ #exit 1
+#fi
+
+url=$1
+
+name=$(echo $1 | rev | cut -d / -f1 | cut -d - -f2- | rev | tr '[:upper:]' '[:lower:]')
+version=$(echo $1 | rev | cut -d / -f1 | cut -d - -f1 | rev | sed 's/\.tar.*//' | sed 's/^v//')
+
+case $url in
+ *.pythonhosted.*) name="python-$name";;
+ */pypi.org/*) name="python-$name";;
+ *.metacpan.*|*.cpan.*) name="perl-$name";;
+ */refs/tags/*) # github tags tarball
+ gh=${1%/archive*} # project url
+ name=${gh##*/} # project name
+ verstar=${1##*/} # version with tar suffix
+ vers=${verstar%.tar.*} # version without tar suffix
+ version=${vers#v} # final version without 'v' prefix
+ url=$gh/archive/$vers/$name-$verstar;;
+ *) name=$name;;
+esac
+
+if [ "$2" ]; then
+ name=$2
+fi
+
+[ -d $name ] && {
+ grep ^version= $name/info
+ echo "port for $name exist"
+ exit 1
+}
+url=$(echo $url | sed "s,$name,\${name},g;s,$version,\${version},g" )
+
+case $version in
+ *.*.*) v=${version%.*}
+ url=$(echo $url | sed "s,$v,\${version%\.\*},g" )
+esac
+
+mkdir -p $name
+
+echo "name=$name
+version=$version
+release=1
+source=\"$url\"" > $name/info
+
+cat $name/info