aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/hdparm/hdparm_9.39.bb
blob: d8342ccd4fa3133e7cb76680e412c98ce7bce71a (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
DESCRIPTION = "hdparm is a Linux shell utility for viewing \
and manipulating various IDE drive and driver parameters."
SECTION = "console/utils"
LICENSE = "BSD"
LICENSE_wiper = "GPLv2"
LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=910a8a42c962d238619c75fdb78bdb24 \
                    file://debian/copyright;md5=a82d7ba3ade9e8ec902749db98c592f3 \
                    file://wiper/GPLv2.txt;md5=fcb02dc552a041dee27e4b85c7396067 \
                    file://wiper/wiper.sh;beginline=7;endline=31;md5=b7bc642addc152ea307505bf1a296f09"

PACKAGES += "wiper"

FILES_wiper = "${bindir}/wiper.sh"
FILES_${PN} = "${base_sbindir} ${mandir}"

RDEPENDS_wiper = "bash gawk stat"

SRC_URI = "${SOURCEFORGE_MIRROR}/hdparm/hdparm-${PV}.tar.gz "

SRC_URI[md5sum] = "2bc17b72403885d4faf959682944243b"
SRC_URI[sha256sum] = "72d550af4526aa96f0841c79321a0ee39d636cbaf1f294e52193e90c054b3cea"

do_install () {
	install -d ${D}/${base_sbindir} ${D}/${mandir}/man8 ${D}/${bindir}
	oe_runmake 'DESTDIR=${D}' 'sbindir=${base_sbindir}' install
	mv ${D}${base_sbindir}/hdparm ${D}${base_sbindir}/hdparm.${PN}
	cp ${S}/wiper/wiper.sh ${D}/${bindir}
}

pkg_postinst_${PN} () {
	update-alternatives --install ${base_sbindir}/hdparm hdparm hdparm.${PN} 100
}

pkg_prerm_${PN} () {
	update-alternatives --remove hdparm hdparm.${PN}
}
th(sys.argv[0]))) lib_path = os.path.abspath(scripts_path + '/../lib') sys.path = sys.path + [lib_path] import scriptpath # For importing the following modules bitbakepath = scriptpath.add_bitbake_lib_path() if not bitbakepath: sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n") sys.exit(1) import bb.cooker import bb.providers import bb.tinfoil def get_fnlist(bbhandler, pkg_pn, preferred): ''' Get all recipe file names ''' if preferred: (latest_versions, preferred_versions) = bb.providers.findProviders(bbhandler.config_data, bbhandler.cooker.recipecaches[''], pkg_pn) fn_list = [] for pn in sorted(pkg_pn): if preferred: fn_list.append(preferred_versions[pn][1]) else: fn_list.extend(pkg_pn[pn]) return fn_list def get_recipesdata(bbhandler, preferred): ''' Get data of all available recipes which have PACKAGECONFIG flags ''' pkg_pn = bbhandler.cooker.recipecaches[''].pkg_pn data_dict = {} for fn in get_fnlist(bbhandler, pkg_pn, preferred): data = bbhandler.parse_recipe_file(fn) flags = data.getVarFlags("PACKAGECONFIG") flags.pop('doc', None) if flags: data_dict[fn] = data return data_dict def collect_pkgs(data_dict): ''' Collect available pkgs in which have PACKAGECONFIG flags ''' # pkg_dict = {'pkg1': ['flag1', 'flag2',...]} pkg_dict = {} for fn in data_dict: pkgconfigflags = data_dict[fn].getVarFlags("PACKAGECONFIG") pkgconfigflags.pop('doc', None) pkgname = data_dict[fn].getVar("P", True) pkg_dict[pkgname] = sorted(pkgconfigflags.keys()) return pkg_dict def collect_flags(pkg_dict): ''' Collect available PACKAGECONFIG flags and all affected pkgs ''' # flag_dict = {'flag': ['pkg1', 'pkg2',...]} flag_dict = {} for pkgname, flaglist in pkg_dict.items(): for flag in flaglist: if flag in flag_dict: flag_dict[flag].append(pkgname) else: flag_dict[flag] = [pkgname] return flag_dict def display_pkgs(pkg_dict): ''' Display available pkgs which have PACKAGECONFIG flags ''' pkgname_len = len("RECIPE NAME") + 1 for pkgname in pkg_dict: if pkgname_len < len(pkgname): pkgname_len = len(pkgname) pkgname_len += 1 header = '%-*s%s' % (pkgname_len, str("RECIPE NAME"), str("PACKAGECONFIG FLAGS")) print(header) print(str("").ljust(len(header), '=')) for pkgname in sorted(pkg_dict): print('%-*s%s' % (pkgname_len, pkgname, ' '.join(pkg_dict[pkgname]))) def display_flags(flag_dict): ''' Display available PACKAGECONFIG flags and all affected pkgs ''' flag_len = len("PACKAGECONFIG FLAG") + 5 header = '%-*s%s' % (flag_len, str("PACKAGECONFIG FLAG"), str("RECIPE NAMES")) print(header) print(str("").ljust(len(header), '=')) for flag in sorted(flag_dict): print('%-*s%s' % (flag_len, flag, ' '.join(sorted(flag_dict[flag])))) def display_all(data_dict): ''' Display all pkgs and PACKAGECONFIG information ''' print(str("").ljust(50, '=')) for fn in data_dict: print('%s' % data_dict[fn].getVar("P", True)) print(fn) packageconfig = data_dict[fn].getVar("PACKAGECONFIG", True) or '' if packageconfig.strip() == '': packageconfig = 'None' print('PACKAGECONFIG %s' % packageconfig) for flag,flag_val in data_dict[fn].getVarFlags("PACKAGECONFIG").items(): if flag == "doc": continue print('PACKAGECONFIG[%s] %s' % (flag, flag_val)) print('') def main(): pkg_dict = {} flag_dict = {} # Collect and validate input parser = optparse.OptionParser( description = "Lists recipes and PACKAGECONFIG flags. Without -a or -f, recipes and their available PACKAGECONFIG flags are listed.", usage = """ %prog [options]""") parser.add_option("-f", "--flags", help = "list available PACKAGECONFIG flags and affected recipes", action="store_const", dest="listtype", const="flags", default="recipes") parser.add_option("-a", "--all", help = "list all recipes and PACKAGECONFIG information", action="store_const", dest="listtype", const="all") parser.add_option("-p", "--preferred-only", help = "where multiple recipe versions are available, list only the preferred version", action="store_true", dest="preferred", default=False) options, args = parser.parse_args(sys.argv) with bb.tinfoil.Tinfoil() as bbhandler: bbhandler.prepare() print("Gathering recipe data...") data_dict = get_recipesdata(bbhandler, options.preferred) if options.listtype == 'flags': pkg_dict = collect_pkgs(data_dict) flag_dict = collect_flags(pkg_dict) display_flags(flag_dict) elif options.listtype == 'recipes': pkg_dict = collect_pkgs(data_dict) display_pkgs(pkg_dict) elif options.listtype == 'all': display_all(data_dict) if __name__ == "__main__": main()