Added hdparm with support for /dev/disk/by-id

This commit is contained in:
layman 2016-05-28 00:09:16 +02:00
parent f3db41bd31
commit cfea545183
6 changed files with 185 additions and 0 deletions

6
sys-apps/hdparm/Manifest Normal file
View File

@ -0,0 +1,6 @@
AUX hdparm-9.48-sysmacros.patch 474 SHA256 6e75ceceac0065586af5982822d3c54fbd189dbd929102d40ac3fbf372fc1698 SHA512 cd12a544f6149076c48657f572d71dbc400fa80fa26e6604325d3812159f2a3cd3ab79d8f248b64aac3db7c9913c6f406e427cab62103c927274ff6439a4151a WHIRLPOOL 453542b64f9c64dce17824a46d4d81468b79f7252eb8dc502578264cc3735d15c08ee69a61e98be5e451f4477e05c4fdf70248ec2267d4d177295e9f515ce65c
AUX hdparm-conf.d.3 872 SHA256 37c95ff723fa578e9039613d09dbf790d99113a318c065422986c744519214e9 SHA512 968c6b9d26a71bf724728c259d35a499a644496875eac255dcac3cb4a7e5cadb677a4f6e5e0f8bbd7e1826b6fb77cb39af15b11d1e59b3e9daf9ba442b9e6f02 WHIRLPOOL 110d330860c4f5e3b1626b85ab369a02e5c092acf656edc845a2f311b5349644317ec2021063a0fb977d3b9851e0bb9c54fd66e814a080d6af3aa0f05fbd658b
AUX hdparm-init-9 1753 SHA256 8ed1f82087a22cab4c94d498054a208fc01f0156fc0c1701ce3ac2cf5e48bc91 SHA512 c2cb54c271eee8311cf9cccf27a22bd51227f9148efbe35e43192ad154e5c5f4358eed56e7d9159790abc6fc98ae89bd6d44c8edcd30d796b3cd4dea7f23f17f WHIRLPOOL 9aef4a277c9faa36793829c3f9a4e7cd2cdd70cdd48d61a09ce671660f799c5167f2caebd4bb3abe0947b824f329cd6ee237f2c25c1b0e4647ca48cd208015e0
DIST hdparm-9.48.tar.gz 130277 SHA256 ce97b4a71cb04146f54cf6f69787e7f97ddfda9836dc803b459d3b3df3a4fbee SHA512 5b8908a762d892c403406da4798202bed95f035396e3c49f04da910fa53a6b442a7d7c9cb1e5d786d7c8c5a1b681c8d1db10f1bd8dad09600a6f3811fbf8afb7 WHIRLPOOL 4f17e6622a9c6516834b0487c0d73ba7aaaffcd5381cbcf03c01fa936924975c3fb7190052c4d1bba7a0b53a53fc9b910fe4c71440f4a556d533d43ecd474516
EBUILD hdparm-9.48-r1.ebuild 1063 SHA256 7e5ffebc9255afec667778f1e5596553da72c1be2532de217990dea84f7e92fa SHA512 cff8cd7024c94f483b59038f79101d83d08b5173d5d1bbd4211112925a5dcf929015c081094764b44d0e6f418bbc30d0051c43152543e32a617402e95fd09b88 WHIRLPOOL 0c1716cb2c5bbf8d32d7a2a9058881c60f236ce6481736099aac4ad612da747785dcf03335e577b1135773ee6c19ddda0e8dcc5eeabc8b7ac7ef3db28475d41c
MISC metadata.xml 326 SHA256 7be17151b3f5f5c65b8edad44e9c49ac62d306f856a257b67e0f01a1d6b1796d SHA512 39219fcef0756910c51e804cf94170408208840e7b88d99b4583f8fcfb02e1664358f9d4bf4c3f1a1a619b6a87852bc4831c93f10215500842023132a85c2287 WHIRLPOOL 0c72b42d0ce47a7985115e1f65cd3a25bee06d41807b746e32966d69de586d4a84e22ffba08d1fbe0f0526d80074d8433813652e4512cadee0bbc847dac19e1b

View File

@ -0,0 +1,23 @@
https://bugs.gentoo.org/580052
https://sourceforge.net/p/hdparm/patches/44/
--- a/geom.c
+++ b/geom.c
@@ -15,6 +15,7 @@
#include <errno.h>
#include <dirent.h>
#include <sys/stat.h>
+#include <sys/sysmacros.h>
#include <sys/ioctl.h>
#include <linux/types.h>
#include <linux/fs.h>
--- a/sysfs.c
+++ b/sysfs.c
@@ -15,6 +15,7 @@
#include <dirent.h>
#include <limits.h>
#include <sys/stat.h>
+#include <sys/sysmacros.h>
#include <linux/types.h>
#include "hdparm.h"

View File

@ -0,0 +1,26 @@
# /etc/conf.d/hdparm: config file for /etc/init.d/hdparm
#
# Note that options such as -y which force *immediate* power saving options
# should generally not be placed here. The hdparm init.d script may run at
# anytime with respect to other init.d scripts that do system wide drive
# scans (like the hald script), so they will merely get spun right back up.
# If you wish to use these options, please use the local.start init.d script
# instead so that you're guaranteed that it will run last.
#
# You can either set hdparm arguments for each drive using hdX_args,
# discX_args, cdromX_args and genericX_args, e.g.
#
# hda_args="-d1 -X66"
# disc1_args="-d1"
# cdrom0_args="-d1"
# or you can set options for all PATA drives
pata_all_args="-d1"
# or you can set options for all SATA drives
sata_all_args=""
# or, you can set hdparm options for all drives
all_args=""

View File

@ -0,0 +1,77 @@
#!/sbin/openrc-run
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
depend() {
before bootmisc
}
do_hdparm() {
local e=
eval e=\$${extra_args}
[ -z "${args}${all_args}${e}" ] && return 0
if [ -n "${args:=${all_args} ${e}}" ] ; then
local orgdevice=$(readlink -f "${device}")
if [ -b "${orgdevice}" ] ; then
ebegin "Running hdparm on ${device}"
hdparm ${args} "${device}" > /dev/null
eend $?
fi
fi
}
scan_nondevfs() {
# non-devfs compatible system
local device
for device in /dev/hd* /dev/sd* /dev/cdrom* ; do
[ -e "${device}" ] || continue
case "${device}" in
*[0-9]) continue ;;
/dev/hd*) extra_args="pata_all_args" ;;
/dev/sd*) extra_args="sata_all_args" ;;
*) extra_args="_no_xtra_args" ;;
esac
# check that the block device really exists by
# opening it for reading
local errmsg= status= nomed=1
errmsg=$(export LC_ALL=C ; : 2>&1 <"${device}")
status=$?
case ${errmsg} in
*": No medium found") nomed=0;;
esac
args=""
if [ -b "${device}" ] && [ "${status}" = "0" -o "${nomed}" = "0" ] ; then
local conf_var="${device##*/}_args"
eval args=\$${conf_var}
fi
# allows a disk to be configured using its id (override above)
# we replace all dashes by underscores
for alias in /dev/disk/by-id/* ; do
if [ "${alias}" -ef "${device}" ] ; then
eval args_tmp=\$"$(basename "${alias}" | sed 's/-/_/g')"_args
if [ -n "${args_tmp}" ]; then
args="${args_tmp}"
fi
break
fi
done
if [ -n "$args" ]; then
do_hdparm
fi;
done
}
start() {
if get_bootparam "nohdparm" ; then
ewarn "Skipping hdparm init as requested in kernel cmdline"
return 0
fi
scan_nondevfs
}

View File

@ -0,0 +1,42 @@
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
EAPI="4"
inherit toolchain-funcs flag-o-matic eutils
DESCRIPTION="Utility to change hard drive performance parameters"
HOMEPAGE="http://sourceforge.net/projects/hdparm/"
SRC_URI="mirror://sourceforge/hdparm/${P}.tar.gz"
LICENSE="BSD GPL-2" # GPL-2 only
SLOT="0"
KEYWORDS="alpha amd64 arm ~arm64 hppa ~ia64 ~m68k ~mips ~ppc ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~arm-linux ~x86-linux"
IUSE="static"
src_prepare() {
epatch "${FILESDIR}"/${P}-sysmacros.patch #580052
use static && append-ldflags -static
sed -i \
-e "/^CFLAGS/ s:-O2:${CFLAGS}:" \
-e "/^LDFLAGS/ s:-s:${LDFLAGS}:" \
Makefile || die "sed"
}
src_compile() {
emake STRIP=: CC="$(tc-getCC)"
}
src_install() {
into /
dosbin hdparm contrib/idectl
newinitd "${FILESDIR}"/hdparm-init-9 hdparm
newconfd "${FILESDIR}"/hdparm-conf.d.3 hdparm
doman hdparm.8
dodoc hdparm.lsm Changelog README.acoustic hdparm-sysconfig
docinto wiper
dodoc wiper/{README.txt,wiper.sh}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="project">
<email>base-system@gentoo.org</email>
<name>Gentoo Base System</name>
</maintainer>
<upstream>
<remote-id type="sourceforge">hdparm</remote-id>
</upstream>
</pkgmetadata>