forked from nefelim4ag/systemd-swap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.sh
executable file
·53 lines (49 loc) · 1.62 KB
/
package.sh
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
45
46
47
48
49
50
51
52
53
#!/bin/bash -e
################################################################################
# echo wrappers
INFO(){ echo -n "INFO: "; echo "$@" ;}
WARN(){ echo -n "WARN: "; echo "$@" ;}
ERRO(){ echo -n "ERRO: "; echo -n "$@" ; echo " Abort!"; exit 1;}
debian_package(){
cd "$(dirname $0)"
VERSION=$(git tag | tail -n 1)
[ -z "$VERSION" ] && ERRO "Can't get git tag, VERSION are empty!"
DEB_NAME=systemd-swap_${VERSION}_any
mkdir -p $DEB_NAME
make install PREFIX=$DEB_NAME/
mkdir -p $DEB_NAME/DEBIAN
chmod 755 $DEB_NAME/DEBIAN
{
echo "Package: systemd-swap"
echo "Version: $VERSION"
echo "Section: custom"
echo "Priority: optional"
echo "Architecture: all"
echo "Depends: util-linux"
echo "Essential: no"
echo "Installed-Size: 16"
echo "Maintainer: [email protected]"
echo "Description: Script for creating hybrid swap space from zram swaps, swap files and swap partitions."
} > $DEB_NAME/DEBIAN/control
dpkg-deb --build $DEB_NAME
}
archlinux_package(){
INFO "Use pacman -S systemd-swap"
}
fedora_package(){
cd "$(dirname $0)"
FEDORA_VERSION=$1
VERSION=$(git tag | tail -n 1)
[ -z "$VERSION" ] && ERRO "Can't get git tag, VERSION are empty!"
[ -z "$FEDORA_VERSION" ] && ERRO "Please specify fedora version e.g.: $0 fedora f28"
fedpkg --release $FEDORA_VERSION local
mv noarch/*.rpm ./
rmdir noarch
rm *.src.rpm
}
case $1 in
debian) debian_package ;;
archlinux) archlinux_package ;;
fedora) fedora_package $2 ;;
*) echo "$0 <debian|archlinux|fedora [version]>" ;;
esac