-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathPKGBUILD_examples.txt
128 lines (75 loc) · 2.86 KB
/
PKGBUILD_examples.txt
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
## Examples for reuse in pkgbuilds
# Fix pkgver with forbidden simbols
_pkgver=3.2.01-1
pkgver=${_pkgver//-/.}
# All architectures
arch=(x86_64 i686 i486 pentium4 arm armv6h armv7h aarch64)
# Common cd
cd "${srcdir}/${pkgname}-${pkgver}"
cd "${srcdir}/${pkgname}-${pkgver}/build"
cd "${srcdir}/${pkgname%-git}"
cd "${srcdir}/${pkgname%-git}/build"
pkgver() {
}
# Using the most recent annotated tag reachable from the last commit:
git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
# Using the most recent un-annotated tag reachable from the last commit:
git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
# cutting off 'v' prefix that presents in the git tag
git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
# cutting off 'foo-' prefix that presents in the git tag
git describe --long --tags | sed 's/^foo-//;s/\([^-]*-g\)/r\1/;s/-/./g'
# Git without tags
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
# Both methods can also be combined, to support repositories that start without a tag but get tagged later on (uses a bashism):
( set -o pipefail
git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
)
# Bazaar
printf "r%s" "$(bzr revno)"
# Mercurial
printf "r%s.%s" "$(hg identify -n)" "$(hg identify -i)"
# Subversion
printf "r%s" "$(svnversion | tr -d 'A-z')"
# Git fixed commit from Arch pkgbuilds
git describe --tags | sed 's/^v//;s/-/+/g'
# Exclude a tag (i.e. continuous, nightly) with
--exclude continuous
--exclude nightly
# Git submodules configuration
git submodule init
git config submodule.PATH/NAME.url "${srcdir}/NAME"
git submodule update
# Extract .deb to pkgdir
bsdtar -xf ${srcdir}/data.tar.xz -C ${pkgdir}/
# Build with Cmake
[[ -d build ]] || mkdir build
cmake .. -Wno-dev \
-DCMAKE_BUILD_TYPE=None \
-DCMAKE_INSTALL_PREFIX=/usr
make
make DESTDIR="${pkgdir}" install
# Build with Qmake
qmake-qt5 .pro
make
make install INSTALL_ROOT="${pkgdir}/"
# Build with autotools
autoreconf -f -i
./configure --prefix=usr
make
make DESTDIR="${pkgdir}" install
# Export a different compiler
export CC=/usr/bin/clang CXX=/usr/bin/clang++
export CC=/usr/bin/gcc-11 CXX=/usr/bin/g++-11
export CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10
export CC=/usr/bin/gcc-9 CXX=/usr/bin/g++-9
export CC=/usr/bin/gcc-8 CXX=/usr/bin/g++-8
package() {
install -D LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
install -D README.MD -t "${pkgdir}/usr/share/doc/${pkgname}"
install -D doc/man/*.1 -t "${pkgdir}"/usr/share/man/man1/
ln -s /opt/${pkgname}/${pkgname} ${pkgdir}/usr/bin/${pkgname}
}
# Python version variable
_pyver=$(python -c "from sys import version_info; print(\"%d.%d\" % (version_info[0],version_info[1]))")