1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
TAR="$1"
RETURNTARNAME="$2"
#VERSION+"$3"
. $(dirname $0)/common.sh
alpkg=$(basename $TAR)
VERSION="$(echo "$alpkg" | grep -o -P '[-_.][0-9][0-9]*([.]*[0-9])*' | head -n1 | sed -e 's|^[-_.]||')" #"
[ -n "$VERSION" ] && PRODUCT="$(echo "$alpkg" | sed -e "s|[-_.]$VERSION.*||")" || fatal "Can't get version from $TAR. We have almost no chance it will supported in alien."
# set version as all between name and extension
#local woext="$(echo "alpkg" | sed -e 's|\.tar.*||')"
#if [ "$woext" != "$alpkg" ] ; then
# VERSION="$(echo "$woext" " | sed -e "s|^$PKGNAME[-_.]||")"
#fi
pkgtype="$(erc type $alpkg)"
PKGNAME=$PRODUCT-$VERSION.$pkgtype
if [ "$pkgtype" = "tar" ] || [ "$pkgtype" = "tar.gz" ] || [ "$pkgtype" = "tgz" ] ; then
# just rename supported formats
if [ "$alpkg" != "$PKGNAME" ] ; then
mv $alpkg $PKGNAME
fi
else
# converts directly unsupported formats
PKGNAME=$PRODUCT-$VERSION.tar
erc repack $alpkg $PKGNAME || fatal
fi
#if [ "$alpkg" != "$newalpkg" ] ; then
# rm -f $verbose $alpkg
# alpkg=$newalpkg
# fi
# TODO: how to add to tarball?
cat <<EOF >$PKGNAME.eepm.yaml
name: $PRODUCT
version: $VERSION
upstream_file: $alpkg
EOF
return_tar $PKGNAME