alicelinux

A lightweight musl + clang/llvm + libressl + busybox distro
git clone https://codeberg.org/emmett1/alicelinux
Log | Files | Refs | README | LICENSE

gentemplate.sh (1203B)


      1 #!/bin/sh
      2 
      3 [ "$1" ] || exit 1
      4 
      5 #if [ ! -f REPO ]; then
      6 	#echo "you not inside repo's directory"
      7 	#exit 1
      8 #fi
      9 
     10 url=$1
     11 
     12 name=$(echo $1 | rev | cut -d / -f1 | cut -d - -f2- | rev | tr '[:upper:]' '[:lower:]')
     13 version=$(echo $1 | rev | cut -d / -f1 | cut -d - -f1 | rev | sed 's/\.tar.*//' | sed 's/^v//')
     14 
     15 case $url in
     16 	*.pythonhosted.*) name="python-$name";;
     17 	*/pypi.org/*) name="python-$name";;
     18 	*.metacpan.*|*.cpan.*) name="perl-$name";;
     19 	*/refs/tags/*)                 # github tags tarball
     20 			gh=${1%/archive*}      # project url
     21 			name=${gh##*/}         # project name
     22 			verstar=${1##*/}       # version with tar suffix
     23 			vers=${verstar%.tar.*} # version without tar suffix
     24 			version=${vers#v}      # final version without 'v' prefix
     25 			url=$gh/archive/$vers/$name-$verstar;;
     26 	*) name=$name;;
     27 esac
     28 
     29 if [ "$2" ]; then
     30 	name=$2
     31 fi
     32 
     33 [ -d $name ] && {
     34 	grep ^version= $name/abuild
     35 	echo "port for $name exist"
     36 	exit 1
     37 }
     38 url=$(echo $url | sed "s,$name,\${name},g;s,$version,\${version},g" )
     39 
     40 case $version in
     41 	*.*.*) v=${version%.*}
     42 		url=$(echo $url | sed "s,$v,\${version%\.\*},g" )
     43 esac
     44 
     45 mkdir -p $name
     46 
     47 echo "name=$name
     48 version=$version
     49 release=1
     50 source=\"$url\"" > $name/abuild
     51 
     52 cat $name/abuild