Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 299637 Details for
Bug 399875
ebuild for *all* brother linux drivers (lpr/cupswrapper)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
generateBrotherEbuilds.py
generateebuilds.py (text/plain), 6.15 KB, created by
Fabian Henze
on 2012-01-23 19:31:13 UTC
(
hide
)
Description:
generateBrotherEbuilds.py
Filename:
MIME Type:
Creator:
Fabian Henze
Created:
2012-01-23 19:31:13 UTC
Size:
6.15 KB
patch
obsolete
>#!/usr/bin/env python3 ># -*- coding: utf-8 -*- > ># Generates gentoo ebuilds for brother printer drivers. ># Copyright (c) 2012 Fabian Henze > ># use the following command to generate a (hopefully valid) input file: ># curl "http://welcome.solutions.brother.com/bsc/public_s/id/linux/en/download_prn.html" | tr "\\r\\n" " " | sed "s_ *_ _g" | sed "s_dlfile=_\n_g" | sed s_\&.*__ | tail -n +2 | grep \.deb\$ | cut -b 42- > brother_distfilelist.txt > >import sys >import re >import argparse > >__author__ = "Fabian Henze" >__license__ = "GPLv2" > >def main(): > parser = argparse.ArgumentParser(description="Generates gentoo ebuilds for brother printer drivers.") > exclusiveGroup = parser.add_mutually_exclusive_group(required=True) > > parser.add_argument("-i", "--input", nargs=1, type=argparse.FileType('r'), required=True, > help="input file name") > parser.add_argument("-o", "--output", nargs=1, default=[sys.stdout], type=argparse.FileType('w'), > help="output (ebuild) file name") > > exclusiveGroup.add_argument("-l", "--lpr", dest="createLpr", action="store_true", > help="Generate a brother-lpr-driver ebuild") > exclusiveGroup.add_argument("-c", "--cupswrapper", dest="createLpr", action="store_false", > help="Generate a brother-cupswrapper ebuild") > > args = parser.parse_args() > > regex = re.compile(r"(br)?([a-zA-Z0-9]*)lpr-([0-9].[0-9].[0-9]-[0-9])\.i386\.deb") > distfileList = [] > > while True: > lpr = args.input[0].readline().strip() > wrapper = args.input[0].readline().strip() > > if len(lpr) == 0 and len(wrapper) == 0: > break # EOF > > ignore, lprName, lprVersion = re.match(regex, lpr).groups() > distfileList.append([lprName, lpr, wrapper]) > writeEbuild(distfileList, args.createLpr, args.output[0]) > > >def writeEbuild(distfileList, createLpr, output): > print(ebuild_header, file=output) > > for i in distfileList: > if createLpr: > print("\t[{0}]=\"{1}\"".format(i[0], i[1]), file=output) > else: > print("\t[{0}]=\"{1}\"".format(i[0], i[2]), file=output) > > print(ebuild_middle, end='', file=output) > > for i in distfileList: > print(i[0], end=' ', file=output) > > if createLpr: > print(ebuild_footer_lpr, file=output) > else: > print(ebuild_footer_cupswrapper, file=output) > > > > > > > >ebuild_header = \ >"""# Copyright 1999-2012 Gentoo Foundation ># Distributed under the terms of the GNU General Public License v2 ># $Header: $ > >EAPI=4 > >declare -A mapping >mapping=(""" > >ebuild_middle = ")\n\nIUSE_BROTHER_DEVICES=\"" > >ebuild_footer_lpr = \ >"""\" > >IUSE="" >SRC_URI="" > >for device in ${IUSE_BROTHER_DEVICES}; do > IUSE="${IUSE} brother_devices_${device}" > SRC_URI="${SRC_URI} brother_devices_${device}? ( http://www.brother.com/pub/bsc/linux/dlf/${mapping[${device}]} )" >done > >DESCRIPTION="Brother printer driver" >HOMEPAGE="http://welcome.solutions.brother.com/bsc/public_s/id/linux/en/download_prn.html" > >LICENSE="Brother" >SLOT="0" >KEYWORDS="~x86 ~amd64" >RESTRICT="fetch strip" > >DEPEND="" >RDEPEND="${DEPEND}" > >S="$WORKDIR" > >pkg_nofetch() { > for device in ${IUSE_BROTHER_DEVICES}; do > if use brother_devices_${device} ]; then > einfo "Please download '${mapping[${device}]}' from:" > einfo " http://www.brother.com/cgi-bin/agreement/agreement.cgi?dlfile=http://www.brother.com/pub/bsc/linux/dlf/${mapping[${device}]}&lang=English_gpl" > fi > done > einfo "Select 'I Accept' and move the file(s) to ${DISTDIR}." >} > >src_unpack() { > for archive in ${A}; do > unpack "${archive}" > unpack ./data.tar.gz > rm -f control.tar.gz data.tar.gz debian-binary *.deb *.rpm > done >} > >src_compile() { > # Don't overwrite the users configuration file. > for file in ./opt/brother/Printers/*/inf/br*rc ; do > if [ -e /"${file}" ]; then > echo "Preserving config-file: ${file/\./}" > mv "${file}" "${file}.dist" > cp /"${file}" "${file}" > fi > done >} > >src_install() { > cp -r * "$D/" >}""" > >ebuild_footer_cupswrapper = \ >"""\" > >IUSE="" >SRC_URI="" > >for device in ${IUSE_BROTHER_DEVICES}; do > IUSE="${IUSE} brother_devices_${device}" > SRC_URI="${SRC_URI} brother_devices_${device}? ( http://www.brother.com/pub/bsc/linux/dlf/${mapping[${device}]} )" >done > >DESCRIPTION="Brother printer driver cups wrapper" >HOMEPAGE="http://welcome.solutions.brother.com/bsc/public_s/id/linux/en/download_prn.html" > >LICENSE="Brother" >SLOT="0" >KEYWORDS="~x86 ~amd64" > >RESTRICT="fetch strip" > >DEPEND="" >RDEPEND="${DEPEND}" > >S="$WORKDIR" > >pkg_nofetch() { > for device in ${IUSE_BROTHER_DEVICES}; do > if use brother_devices_${device} ]; then > einfo "Please download '${mapping[${device}]}' from:" > einfo " http://www.brother.com/cgi-bin/agreement/agreement.cgi?dlfile=http://www.brother.com/pub/bsc/linux/dlf/${mapping[${device}]}&lang=English_gpl" > fi > done > einfo "Select 'I Accept' and move the file(s) to ${DISTDIR}." >} > >src_unpack() { > for archive in ${A}; do > unpack "${archive}" > unpack ./data.tar.gz > rm -f control.tar.gz data.tar.gz debian-binary *.deb *.rpm > done >} > >src_compile() { > for file in ./opt/brother/Printers/*/cupswrapper/cupswrapper* ./usr/local/Brother/Printer/*/cupswrapper/cupswrapper* ; do > [ -e "$file" ] && sed -i s_/usr/lib/cups/filter_/usr/libexec/cups/filter_g "$file" > done >} > >src_install() { > cp -r * "$D/" >} > >pkg_postinst() { > einfo "Depending on your printer model, you may need to run some of the following" > einfo "scripts as root:" > einfo "# ${ROOT}opt/brother/Printers/YOUR_PRINTER/cupswrapper/cupswrapperYOUR_PRINTER" > einfo "# ${ROOT}usr/local/Brother/Printer/YOUR_PRINTER/cupswrapper/cupswrapperSetup_YOUR_PRINTER" > einfo "# ${ROOT}usr/local/Brother/cupswrapper/cupswrapperYOUR_PRINTER-version" >}""" > > > > >if __name__ == '__main__': > main()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 399875
:
299633
|
299635
| 299637