blob: 99a3303b65edf20d12807a858dc62d96ad76d715 (
plain)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=5
inherit base eutils bash-completion-r1 git-2 linux-info systemd
DESCRIPTION="Power-Management made easy, designed for Thinkpads."
HOMEPAGE="http://linrunner.de/en/tlp/tlp.html"
EGIT_REPO_URI='git://github.com/linrunner/TLP.git'
EGIT_BRANCH='master'
EGIT_COMMIT="${PV}"
SRC_URI="http://git.erdmann.es/trac/dywi_tlp-gentoo-additions/downloads/tlp-gentoo-additions-0.4.tar.bz2"
RESTRICT="mirror"
LICENSE="GPL-2+ tpacpi-bundled? ( GPL-3 )"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE="tlp_suggests rdw laptop-mode-tools +tpacpi-bundled +pm-utils"
_PKG_TPACPI='>app-laptop/tpacpi-bat-1.0'
_PKG_TPSMAPI='app-laptop/tp_smapi'
_PKG_ACPICALL='sys-power/acpi_call'
_OPTIONAL_DEPEND='
sys-apps/smartmontools
sys-apps/ethtool
sys-apps/lsb-release
'
DEPEND=""
RDEPEND="${DEPEND-}
sys-apps/hdparm
pm-utils? ( sys-power/pm-utils )
!pm-utils? ( sys-apps/systemd )
sys-power/acpid
virtual/udev
dev-lang/perl
sys-apps/usbutils
sys-apps/pciutils
|| ( net-wireless/iw net-wireless/wireless-tools )
net-wireless/rfkill
rdw? ( net-misc/networkmanager )
tlp_suggests? ( ${_OPTIONAL_DEPEND} )
!laptop-mode-tools? ( !app-laptop/laptop-mode-tools )
"
# pm hooks to disable defined by upstream
#
# hooks that have a different name in gentoo:
# * <none>
#
CONFLICTING_PM_POWERHOOKS_UPSTREAM="95hdparm-apm disable_wol hal-cd-polling
intel-audio-powersave harddrive laptop-mode journal-commit pci_devices
pcie_aspm readahead sata_alpm sched-powersave usb_bluetooth wireless
xfs_buffer"
CONFLICTING_PM_POWERHOOKS="${CONFLICTING_PM_POWERHOOKS_UPSTREAM}"
CONFIG_CHECK='~DMIID ~ACPI_PROC_EVENT ~POWER_SUPPLY ~ACPI_AC'
ERROR_DMIID='DMIID is required by tlp-stat and tpacpi-bat'
ERROR_ACPI_PROC_EVENT='ACPI_PROC_EVENT is required by thinkpad-radiosw'
src_unpack() {
git-r3_src_unpack
base_src_unpack
}
src_prepare() {
local sed_expr
PATCHES=(
"${WORKDIR}/gentoo/"{49tlp,Makefile}.patch
)
cat "${WORKDIR}/gentoo/default.append" >> "${S}/default" || die
sed_expr='s@^(\s*TLP_ENABLE=)[01]$@\10@'
sed -r -e "${sed_expr}" -i "${S}/default" || die "sed failed (TLP_ENABLE=0)"
base_src_prepare
if ! use pm-utils; then
sed -r -e '/install.*(PLIB|PMETC)/d' -i "${S}/Makefile" || die "sed Makefile"
fi
# # edit version
# sed_expr="s@^(readonly TLPVER=[\"]?)(0[.]4)([\"]?)\s*\$@\1${PVR}\3@"
# sed -r -e "${sed_expr}" -i "${S}/tlp-functions" || die "sed tlp-functions"
chmod u+x "${WORKDIR}/gentoo/tlp_configure.sh" && \
ln -fs "${WORKDIR}/gentoo/tlp_configure.sh" "${S}/configure" || \
die "cannot setup configure script!"
}
src_configure() {
# econf is not supported and TLP is noarch, use ./configure directly
./configure --quiet --src="${S}" \
--target=gentoo $(use_with tpacpi-bundled) || die "configure failed ($?)"
}
src_compile() { return 0; }
src_install() {
# TLP_NO_TPACPI: do not install the bundled tpacpi-bat file
# TLP expects to find tpacpi-bat at /usr/sbin/tpacpi-bat
# LIBDIR: use proper libary dir names instead of relying on a
# lib->lib64 symlink on amd64 systems
emake DESTDIR="${ED}" LIBDIR=$(get_libdir) \
CONFFILE="${ED}etc/conf.d/${PN}" \
$(usex tpacpi-bundled "" TLP_NO_TPACPI=1) \
install-tlp $(usex rdw install-rdw "")
## init/service file(s)
newinitd "${WORKDIR}/gentoo/${PN}-init.openrc" "${PN}"
systemd_dounit "${PN}"{,-sleep}.service
## bashcomp
newbashcomp "${PN}.bash_completion" "${PN}"
## man, doc
doman man/?*.?*
dodoc README*
}
pkg_postrm() {
## Re-enable conflicting pm-utils hooks
local \
TLP_NOP="${EROOT%/}/usr/$(get_libdir)/${PN}-pm/${PN}-nop" \
POWER_D="${EROOT%/}/etc/pm/power.d" \
hook hook_name
einfo "Re-enabling power hooks in ${POWER_D} that link to ${TLP_NOP}"
for hook_name in ${CONFLICTING_PM_POWERHOOKS?}; do
hook="${POWER_D}/${hook_name}"
if \
[[ ( -L "${hook}" ) && ( "$(readlink "${hook}")" == "${TLP_NOP}" ) ]]
then
rm "${hook}" || die "cannot reenable hook ${hook_name}."
fi
done
}
pkg_postinst() {
## Disable conflicting pm-utils hooks
# always disable hooks even if USE=-pm-utils
# Otherwise a blocker on sys-power/pm-utils would be necessary
#
local \
TLP_NOP="${EROOT%/}/usr/$(get_libdir)/${PN}-pm/${PN}-nop" \
POWER_D="${EROOT%/}/etc/pm/power.d" \
iter
einfo "Disabling conflicting power hooks in ${POWER_D}"
[[ -e "${POWER_D}" ]] || mkdir -p "${POWER_D}" || \
die "cannot create '${POWER_D}'."
for iter in ${CONFLICTING_PM_POWERHOOKS?}; do
if [[ ! -e "${POWER_D}/${iter}" ]]; then
ln -s -- "${TLP_NOP}" "${POWER_D}/${iter}" || \
die "cannot disable power.d hook ${iter}."
fi
done
## postinst messages
elog "${PN^^} is disabled by default."
elog "You have to enable ${PN^^} by setting ${PN^^}_ENABLE=1 in /etc/conf.d/${PN}."
ewarn "Using ${PN^^} with systemd is unsupported."
elog "systemd users should enable ${PN^^} by running"
for iter in "${PN}"{,-sleep}.service; do
elog "- systemctl enable ${iter}"
done
elog "Others (openrc et al.) should add /etc/init.d/${PN} to their favorite runlevel."
elog "You must restart acpid after upgrading ${PN}."
local a
_check_installed() { has_version "${1}" && a=" (already installed)" || a=; }
if ! use tlp_suggests; then
local p
elog "In order to get full functionality, the following packages should be installed:"
for p in ${_OPTIONAL_DEPEND?}; do
_check_installed "${p}"
elog "- ${p}${a}"
done
fi
elog "For battery charge threshold control,"
elog "one or more of the following packages are required:"
_check_installed "${_PKG_TPSMAPI?}"
elog "- ${_PKG_TPSMAPI?} - for Thinkpads up to Core 2 (and Sandy Bridge partially)${a}"
if use tpacpi-bundled; then
_check_installed "${_PKG_ACPICALL?}"
elog "- ${_PKG_ACPICALL?} - kernel module for Sandy Bridge Thinkpads (this includes Ivy Bridge/Haswell/... ones as well)${a}"
else
_check_installed "${_PKG_TPACPI?}"
elog "- ${_PKG_TPACPI?} - for Sandy Bridge Thinkpads (this includes Ivy Bridge/Haswell/... ones as well)${a}"
fi
if use laptop-mode-tools; then
ewarn "Reminder: don't run laptop-mode-tools and ${PN} at the same time."
fi
if ! use tpacpi-bundled; then
ewarn "USE=-tpacpi-bundled: do not report bugs about tpacpi-bat upstream."
fi
}
|