-
Notifications
You must be signed in to change notification settings - Fork 0
/
architect-package
executable file
·91 lines (70 loc) · 2.45 KB
/
architect-package
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh
# Try to get this to get run by makepkg at the end
# Uncomment ONE (and only one) of these to match your target system
PKGTYPE="deb"
#PKGTYPE="tar" # Pick this for Slackware
#PKGTYPE="solaris"
PKGEXT=$PKGTYPE # TODO - make this work for "tar" and "solaris" (only works for deb/rpm at the moment)
echo "Architect v. 0.8.2, 2015-02-16"
echo "By Viktor Nova"
echo
ls -l --color=auto
echo "\nCurrent directory is: `pwd`"
ls -l --color=auto pkg/
echo
read -p "What is the package name? (${PWD##*/})" PKGNAME
if [ -z "$PKGNAME" ]; then
PKGNAME=${PWD##*/}
fi
read -p "What is the version? " PKGVERSION
echo
echo "0: System default"
echo "1: All (noarch)"
echo "2: i386"
echo "3: i686"
echo "4: x86_64"
echo "5: Other (specify) \n"
read -p "What is the architecture? (0) " n
case $n in
0) ARCHITECTURE="native";;
1) ARCHITECTURE="all";;
2) ARCHITECTURE="i386";;
3) ARCHITECTURE="i686";;
4) ARCHITECTURE="x86_64";;
5) read -p "Enter your target package architecture: " ARCHITECTURE;;
*) echo "Invalid choice. Building default system native package"
ARCHITECTURE="native";;
esac
if [ -d "pkg/$PKGNAME" ]; then
pushd pkg/$PKGNAME
echo "Stripping pacman metadata from package directory (TODO: use this to generate native dependencies!)"
rm -f .MTREE .PKGINFO
echo "Stripping binaries"
find . | xargs file | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded
ls -l --color=auto
echo "Creating $ARCHITECTURE package with FPM"
fpm -s dir -t $PKGTYPE -n $PKGNAME -v $PKGVERSION -p $PKGNAME-VERSION_ARCH.$PKGEXT -a $ARCHITECTURE -C pkg/$PKGNAME/ . && \
echo -e "Righteous dude, your package has been created.\n" && \
echo "Listing packages in current directory: \n" \
ls --color=auto *.$PKGTYPE \
exit 0
echo "there mighta been a problem with FPM"
exit 1
fi
echo "Error, dude. The directory pkg/$PKGNAME don't exist yo."
exit 1
#cd pkg/$PKGNAME && \
#rm -f .MTREE .PKGINFO && \
#fpm -s dir -t deb -n $PKGNAME -v $VERSION . && \
#cd ../..
#echo -e "Righteous, $PKGTYPE package has been created.\n" && \
#ls --color *.deb
# ----------------------------------
# FPM takes the argument "--depends DEPENDENCY", and it can be declared multiple times
#
# Arch's makepkg generates a .PKGINFO file that has lines like this:
# depend = pcre
# depend = libgl
# ..etc, so it would be easy to use awk to parse that into a legitimate argument to do it
# THIS DOESN'T WORK YET BUT HERE'S THE SYNTAX
# fpm -t deb -s dir -n $PKGNAME -v $VERSION $DIR