Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ELOG and Ebuild Phase Hook

ELOG and Ebuild Phase Hook

ELOG と Ebuild Phase Hook について調べた

Yasuhiro Asaka

May 11, 2014
Tweet

More Decks by Yasuhiro Asaka

Other Decks in Programming

Transcript

  1. Introduction ELOG Ebuild Phase Hook emerge ͷϩάͱ௨஌ ELOG ͱ Ebuild

    Phase Hook ʹ͍ͭͯௐ΂ͨ Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 2014-05-11 Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  2. Introduction ELOG Ebuild Phase Hook 1 Introduction 2 ELOG 3

    Ebuild Phase Hook Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  3. Introduction ELOG Ebuild Phase Hook ࣗݾ঺հ Yasuhiro Asaka ϓϩάϥϚ (ϑϦʔϥϯε)

    Gentoo, Funtoo StumpWM, Xterm Dvorak, Vim Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  4. Introduction ELOG Ebuild Phase Hook ໨తɺௐ΂ͨ͜ͱ emerge ͷϩάΛऔΓ͍ͨɺ׬ྃΛ஌Γ͍ͨ ELOG ͰϞδϡʔϧΛ࢖͏

    ELOG ͰΧελϜίϚϯυͰΛ࢖͏ emerge ͷϑΣʔζͷܦաΛ஌Γ͍ͨ Ebuild Phase Hook Λ࢖͏ Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  5. Introduction ELOG Ebuild Phase Hook ಺༰ ELOG ͷϩΪϯάػೳ ELOG ͬͯͲΜͳͷ͔

    ϞδϡʔϧΛ࢖͏ ΧελϜίϚϯυ Λ࢖͏ Ebuild Phase Hook Ebuild Phase Hook ͬͯͲ Μͳͷ͔ ύοέʔδຖʹ༻ҙͯ͠ ࢖͏ /etc/portage/bashrc ʹ͓͍ ͯ࢖͏ Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  6. Introduction ELOG Ebuild Phase Hook ಺༰ ELOG ͷϩΪϯάػೳ ELOG ͬͯͲΜͳͷ͔

    ϞδϡʔϧΛ࢖͏ ΧελϜίϚϯυ Λ࢖͏ Ebuild Phase Hook Ebuild Phase Hook ͬͯͲ Μͳͷ͔ ύοέʔδຖʹ༻ҙͯ͠ ࢖͏ /etc/portage/bashrc ʹ͓͍ ͯ࢖͏ Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  7. Introduction ELOG Ebuild Phase Hook ELOG ͬͯͲΜͳͷ͔ Portage-2.0.* Ͱ͸ enotice

    ͱ͍͏ ebuild ͕͋ͬͨ ELOG ʹͳͬͯ Portage ʹ૊Έࠐ·Εͨ (enotice ͱඇޓ׵) อଘ͞Εͨϩά͸ eread Ͱ֬ೝͰ͖Δ ઃఆʹ࢖͏ม਺ (make.conf) PORTAGE_ELOG_CLASSES ELOG ର৅Λࢦఆ͢Δ (info, warn, error ͳͲ) PORTAGE_ELOG_SYSTEM ϞδϡʔϧΛࢦఆ͢Δ (ۭͩͱ ELOG ͸ disabled) PORTAGE_ELOG_COMMAND $PACKAGE ($PF, $PN-$PVR) ͱ $LOGFILE (ύε) ͷ 2 ͭͷ஋Λ౉ͤΔ (ਖ਼نදݱ) Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  8. Introduction ELOG Ebuild Phase Hook ELOG ͬͯͲΜͳͷ͔ ઃఆྫ e.g. GentWoo

    PORTAGE_ELOG_CLASSES="log warn error qa" PORTAGE_ELOG_SYSTEM="custom:* echo save" PORTAGE_ELOG_COMMAND="/usr/bin/gentwoo ’${PACKAGE}’ ’${LOGFILE}’" Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  9. Introduction ELOG Ebuild Phase Hook ϞδϡʔϧΛ࢖͏ Ұ౓ʹෳ਺ͷϞδϡʔϧΛ࢖͏͜ͱ͕Ͱ͖Δ ίϩϯͰ۠੾ͬͯɺPORTAGE_ELOG_CLASSES Λ্ॻ͖Ͱ͖Δ "echo

    save:log mail:*" ίʔυ͸ /usr/lib/portage/pym/portage/elog/ ʹ͋Δ (Python) ඪ४Ͱ༻ҙ͞Ε͍ͯΔ echo, save, custom, syslog, mail, mail_summary, save, save_summary PORTAGE_ELOG_COMMAND Λ࢖͏ʹ͸ custom Λࢦఆ͢Δ Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  10. Introduction ELOG Ebuild Phase Hook ϞδϡʔϧΛ࢖͏ Email Ϟδϡʔϧ PORTAGE_ELOG_SYSTEM ʹ

    mail ·ͨ͸ mail_summary ϞδϡʔϧΛ௥Ճͯ͠࢖͏ mail_summary ͸ emerge ͕ऴྃ͢Δͱ ͢΂ͯͷϝοηʔδΛ 1 ௨ʹ·ͱΊͯૹΔ ${ACTION} (merge, unmerge) ͸ mail ͰͷΈ࢖͑Δ PORTAGE_ELOG_MAILURI /usr/share/portage/config/make.conf.example ࢀর PORTAGE_ELOG_MAILFROM "portageexample.org" PORTAGE_ELOG_MAILSUBJECT "[portage] euild log for ${ACTION} ${PACKAGE} on ${HOST}" Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  11. Introduction ELOG Ebuild Phase Hook email Ϟδϡʔϧͷ஫ҙɺ·ͱΊ SystemExit ͳͲͰதࢭͯ͠΋ૹΒΕΔ (੒൱ʹΑΒͳ͍)

    ೝূͳͲͰࣦഊ͢Δͱྫ֎ͷϝοηʔδΛग़ͯ͘͠ΕΔ !!! An error occured while trying to send logmail: ... Sure you configured PORTAGE_LOG_MAILURI correctly? Python (socket.getfqdn()) Ͱɺ/etc/hosts ΛͪΌΜͱಡΊΔ͔ ֬ೝ͓ͯ͘͠ (${HOST}) portage 2.1.1 ͔Β ΞυϨεͷ user ෦෼ʹ΋ ͕࢖͑Δ (gmail ͩͱ, [email protected]@gmail.com:100587) port ͸ SMTP ೝূΛ࢖͏৔߹͸ 465 ΍ 587 ͡Όͳͯ͘ɺ 100465 ͱ͔ 100587 ʹ͢Δ Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  12. Introduction ELOG Ebuild Phase Hook ϞδϡʔϧΛ࢖͏ ϩά (௨஌) ྫ: Email

    Ϟδϡʔϧ INFO: setup Package: app-editors/vim-7.4.273 Repository: gentoo Maintainer: [email protected] USE: X acl amd64 cscope elibc_glibc kernel_linux lua ... \ racket userland_GNU FEATURES: preserve-libs sandbox INFO: prepare Applying vim-patches-7.4.273.patch ... INFO: postinst Updating documentation tags in /usr/share/vim/vim74 Calling eselect vi update... Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  13. Introduction ELOG Ebuild Phase Hook jabber Ϟδϡʔϧ http://projects.usrportage.de/index.fcgi/ portage-mod-jabber/wiki %

    epkginfo portage-mod_jabber * app-portage/portage-mod_jabber [gentoo] Maintainer: [email protected] Upstream: None specified Homepage: http://usrportage.de/ Location: /usr/portage/app-portage/portage-mod_jabber Keywords: 0.0.3:0: Keywords: 0.0.5.1:0: ~amd64 ~arm ~x86 License: GPL-2 # configuration (make.conf) PORTAGE_ELOG_SYSTEM="jabber" PORTAGE_ELOG_JABBERFROM="sender:[email protected][/resource]" PORTAGE_ELOG_JABBERTO="[email protected] [email protected] [email protected]" Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  14. Introduction ELOG Ebuild Phase Hook ϞδϡʔϧΛ࢖͏ ΧελϜίϚϯυͰ௨஌͢Δ root ϢʔβͷϓϩηεʹͳΔ X-Session

    ʹ઀ଓ͢Δ޻෉͕ඞཁ DISPLAY ":0.0" XAUTHORITY "/home/user/.Xauthority" (X-session ͷΫοΩʔ) #!/bin/sh if [ $# -lt 1 ]; then echo "Usage: ‘basename $0‘ command" >&2 exit 2 fi su -c "exec env DISPLAY=’$DISPLAY’ XAUTHORITY=’$XAUTHORITY’ ’$SHELL’ -c ’$*’" Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  15. Introduction ELOG Ebuild Phase Hook σϞ Stumpish ͷྫ https://gist.github.com/grauwoelfchen/4f64480526d8aa1b15b4 https://gist.github.com/grauwoelfchen/3d64c13cf473667123d6

    # xroot-stumpish ’package name’ ’log file name’ +--------------------+ | package name | | log file name | +--------------------+ Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  16. Introduction ELOG Ebuild Phase Hook Ebuild Phase Hook ͱ͸ Ebuild

    ͷ֤ஈ֊ͷલޙ (pre, post) ͰධՁ͞ΕΕΔ Bash εΫϦϓτ Ebuild Λ௚઀ॻ͖׵͑ͨΓͤͣʹ֤ Phase Ͱ؀ڥม਺ͳͲΛ ্ॻ͖ͨ͠ΓͰ͖Δ ΧςΰϦ΍ SLOT ΛߜͬͯධՁ͞ΕΔΑ͏ʹ΋Ͱ͖Δ Ebuild Ͱ࢖ΘΕΔม਺ͷ΄͔ϔϧύʔؔ਺ (einfo ͳͲ) ΋࢖͑Δ Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  17. Introduction ELOG Ebuild Phase Hook bashrc ͷ৔ॴͱॱং ධՁ͞ΕΔॱং (্͔Β) $PN

    Package name $P Package name and version $PF Full-Package name (${PN}-${PVR}) 1 /etc/portage/bashrc 2 /etc/portage/env/${CATEGORY}/${PN} 3 /etc/portage/env/${CATEGORY}/${PN}:${SLOT} 4 /etc/portage/env/${CATEGORY}/${P} 5 /etc/portage/env/${CATEGORY}/${PF} Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  18. Introduction ELOG Ebuild Phase Hook Ebuild Phase Hook ͷྫ ML

    (gentoo-portage-dev) ʹ͋ͬͨྫ $ cat /etc/portage/env/sys-libs/glibc pre_pkg_setup() { local x for x in installsources splitdebug ; do if ! has $x $FEATURES ; then elog "bashrc is adding $x to FEATURES for $PN" FEATURES="$FEATURES $x" fi done ... } Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  19. Introduction ELOG Ebuild Phase Hook Ebuild Phase Hook ͷྫ άϩʔόϧͰϑοΫ͢Δྫ

    $ cat /etc/portage/bashrc if [ "${EBUILD_PHASE}" == "postinst" ]; then einfo "postinst" ... elif [ "${EBUILD_PHASE}" == "postrm" ]; then einfo "postrm" ... fi ... Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  20. Introduction ELOG Ebuild Phase Hook Ebuild Phase ͷҰཡ 1 pretend

    2 clean 3 setup 4 unpack 5 prepare 6 configure 7 compile 8 test 9 install 10 ? 11 preinst 12 ? 13 prerm 14 postrm 15 cleanrm 16 postinst 17 ? 18 clean Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  21. Introduction ELOG Ebuild Phase Hook Ebuild Phase Hook ͷ஫ҙɺ·ͱΊ ಉظత

    ʹݺ͹ΕΔ (sleep ͢Δͱ emerge ͱ·ͬͪΌ͏) ର৅ͷ Phase ͕ఆٛ͞Ε͍ͯͳ͍৔߹΋͋Δ (ebuild ʹΑΔ) ${EBUILD_PHASE} ͕ۭจࣈྻͰݺ͹ΕΔ͕࣌͋Δ ? ຊདྷ͸ Ebuild Λ௚઀ϋοΫͤͣʹɺ؀ڥม਺΍ઃఆͳͲΛ ߦ͏΋ͷ Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  22. Introduction ELOG Ebuild Phase Hook ࢀߟϦϯΫ Portage Documentation http://dev.gentoo.org/~zmedico/portage/doc/ Ebuild

    Phase Hook http://dev.gentoo.org/~zmedico/portage/doc/ch01s02.html Ebuild Phases http://dev.gentoo.org/~zmedico/portage/doc/ch06.html#package-ebuild-phases Helper Functions http://dev.gentoo.org/~zmedico/portage/doc/ch06s02.html Ebuild Writing http://devmanual.gentoo.org/ebuild-writing/index.html EAPI http://devmanual.gentoo.org/ebuild-writing/eapi/ Variables http://devmanual.gentoo.org/ebuild-writing/variables/ Working with Portage > Files and Directories http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=3&chap=1 Gentoo Wiki - Project:Portage http://wiki.gentoo.org/wiki/Project:Portage Portage log http://wiki.gentoo.org/wiki/Portage_log mod_jabber for Portage http://projects.usrportage.de/index.fcgi/portage-mod-jabber/wiki Remote X Apps mini-HOWTO http://zweije.home.xs4all.nl/xauth.html#toc7 7. X Applications from Another User-id http://zweije.home.xs4all.nl/xauth-7.html Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌
  23. Introduction ELOG Ebuild Phase Hook ͓ΘΓ ͋Γ͕ͱ͏͍͟͝·ͨ͠ Gentoo Security Team

    ͷํ࡞੒ͷ LaTeX ςʔϚΛ ࢖Θͤͯ΋Β͍·ͨ͠ http://a3li.li/2014/04/gentoo-latex-beamer-theme/ Yasuhiro Asaka @grauwoelfchen Gentoo ษڧձ #2 emerge ͷϩάͱ௨஌