{"id":23,"date":"2016-08-09T21:05:58","date_gmt":"2016-08-10T01:05:58","guid":{"rendered":"https:\/\/fs.wp.odu.edu\/sobrien\/?p=23"},"modified":"2016-08-23T11:01:39","modified_gmt":"2016-08-23T15:01:39","slug":"keeping-macports-up-to-date","status":"publish","type":"post","link":"https:\/\/fs.wp.odu.edu\/sobrien\/2016\/08\/09\/keeping-macports-up-to-date\/","title":{"rendered":"portsUpdate: Keeping MacPorts Up to Date"},"content":{"rendered":"<p>Mmmmmk, so apparently <code>cron<\/code> is going the way of the dodo on OS X\/Darwin. Best practice is to move your cron jobs to <code>launchd<\/code>. Here&#8217;s the <a href=\"https:\/\/developer.apple.com\/library\/prerelease\/content\/documentation\/MacOSX\/Conceptual\/BPSystemStartup\/Chapters\/ScheduledJobs.html#\/\/apple_ref\/doc\/uid\/10000172i-CH1-SW2\" target=\"_blank\">Apple kb info for timed jobs using <code>launchd<\/code><\/a> (which includes the notice of deprecation) and <a href=\"http:\/\/alvinalexander.com\/mac-os-x\/mac-osx-startup-crontab-launchd-jobs\" target=\"_blank\">here&#8217;s a great tutorial on using <code>launchd<\/code><\/a>.<\/p>\n<p>My goal was to automagically keep MacPorts up-to-date, ala Ubuntu&#8217;s unattended upgrades.\u00a0Because I&#8217;m old, I put <code>port selfupdate<\/code>, <code>port upgrade outdated<\/code> &amp; <code>port uninstall inactive<\/code> in root&#8217;s crontab, but then today I was reading more and decided that I really ought to do it the Mac way since it&#8217;ll be upgrade proof.<\/p>\n<p><strong>Introducing portsUpdate<\/strong>! You can <a href=\"https:\/\/github.com\/seannyob\/portsUpdate\" target=\"_blank\">download the portsUpdate via git<\/a>.<br \/>\nportsUpdate is copyleft.<\/p>\n<p><strong>Note: portsUpdate works with OS X 10.11 El Capitan.<\/strong> I am not going to test it with older Mac versions, although if your system runs launchd, you could try it. YMMV, I&#8217;m not responsible if you break your system in any case.<\/p>\n<p>portsUpdate is a launchd xml file that runs a bash script once daily to update MacPorts, an associated launchd xml to ensure that the path is correct, and <a href=\"http:\/\/www.ccpo.odu.edu\/~sean\/InstallMacPortsUpdater\">an associated installer<\/a>.<\/p>\n<p><strong>TL;DR<\/strong><\/p>\n<p>If you trust me (don&#8217;t, why would you), you can just download the installer, open Terminal.app, &amp;&#8230;<br \/>\n<code>$ cd yourDownloadsDirectory<br \/>\n$ chmod +x <a href=\"http:\/\/www.ccpo.odu.edu\/~sean\/InstallMacPortsUpdater\">InstallMacPortsUpdater<\/a><br \/>\n$ sudo .\/InstallMacPortsUpdater<\/code><br \/>\n&amp; have a coffee. Your MacPorts will update every morning at 3:30 a.m. &amp; your old packages will be removed every Sunday to keep your system running lean.<\/p>\n<p>If you want to know how to use it and want to read the scripts (or even improve upon them!) please read on along&#8230;<\/p>\n<p>In particular, note the <a href=\"https:\/\/developer.apple.com\/library\/prerelease\/content\/documentation\/MacOSX\/Conceptual\/BPSystemStartup\/Chapters\/ScheduledJobs.html#\/\/apple_ref\/doc\/uid\/10000172i-CH1-SW2\">policy<\/a> on timed <code>launchd<\/code> jobs and the computer state: if your machine is asleep, it&#8217;ll run when it wakes, if it&#8217;s off, it&#8217;ll run the next time it&#8217;s scheduled.<\/p>\n<p>I tend to enable Power Nap, especially on fixed workstations:<\/p>\n<p>System Preferences &gt; Engery Saver &gt; Enable Power Nap<\/p>\n<p><a href=\"https:\/\/fs.wp.odu.edu\/sobrien\/wp-content\/uploads\/sites\/1816\/2016\/08\/Screen-Shot-2016-08-09-at-12.43.45-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-24\" src=\"https:\/\/fs.wp.odu.edu\/sobrien\/wp-content\/uploads\/sites\/1816\/2016\/08\/Screen-Shot-2016-08-09-at-12.43.45-PM.png\" alt=\"Screen Shot 2016-08-09 at 12.43.45 PM\" width=\"397\" height=\"285\" srcset=\"https:\/\/fs.wp.odu.edu\/sobrien\/wp-content\/uploads\/sites\/1816\/2016\/08\/Screen-Shot-2016-08-09-at-12.43.45-PM.png 1560w, https:\/\/fs.wp.odu.edu\/sobrien\/wp-content\/uploads\/sites\/1816\/2016\/08\/Screen-Shot-2016-08-09-at-12.43.45-PM-300x215.png 300w, https:\/\/fs.wp.odu.edu\/sobrien\/wp-content\/uploads\/sites\/1816\/2016\/08\/Screen-Shot-2016-08-09-at-12.43.45-PM-1024x734.png 1024w\" sizes=\"(max-width: 397px) 100vw, 397px\" \/><\/a><\/p>\n<p>So if you want to inspect it before you install, just:<\/p>\n<p><code>$ git clone https:\/\/github.com\/seannyob\/portsUpdate<br \/>\n$ cd portsUpdate<\/code><\/p>\n<p>Note that there are four files:<br \/>\n<code>setenv.PATH.plist<br \/>\ncom.seannyob.portsUpdate.plist<br \/>\nportsUpdate<br \/>\nInstall<\/code><\/p>\n<p>And then to install you would just set <code>Install<\/code> executable if it isn&#8217;t, then run it with <code>sudo<\/code>.<\/p>\n<p>So. <code>setenv.PATH.plist<\/code> resolves an issue with <code>launchd<\/code> which is that scripts\/applications\/programs in <code>\/opt\/local\/bin<\/code> are not in <code>launchd<\/code>&#8216;s path.<br \/>\n<code>com.seannyob.portsUpdate.plist<\/code> tells launchd where portsUpdate is located &amp; when to run it.<br \/>\n<code>portsUpdate<\/code> is a bash script that runs updates, upgrades &amp; cleanup of your MacPorts package database, ensuring that you are always up to date on features &amp; any security &amp;\/or bug fixes of your critical unixy apps.<br \/>\n<code>Install<\/code> is the same as <code>InstallMacPortsUpdater<\/code> above. It is a bash script that checks to make sure you&#8217;ve installed MacPorts, then git, then gits the package, then installs the three other aforementioned files in their appropriate places in the file system, then loads them into <code>launchd<\/code> using <code>launchctl<\/code>.<\/p>\n<p>Note in particular that if you wanted to modify the time &amp;\/or frequency of updates\/upgrades, you could do so in <code>com.seannyob.portsUpdate.plist<\/code> and the frequency of uninstall inactive is set for Sundays in <code>portsUpdate<\/code>.<\/p>\n<p>Feel free to peruse them and use or modify them to your liking. If you have comments &amp;\/or suggestions, please let me know!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mmmmmk, so apparently cron is going the way of the dodo on OS X\/Darwin. Best practice is to move your cron jobs to launchd. Here&#8217;s the Apple kb info for timed jobs using launchd (which includes the notice of deprecation) and here&#8217;s a great tutorial on using launchd. My goal was to automagically keep MacPorts [&hellip;]<\/p>\n","protected":false},"author":3412,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","wds_primary_category":0},"categories":[4,2,3],"tags":[],"_links":{"self":[{"href":"https:\/\/fs.wp.odu.edu\/sobrien\/wp-json\/wp\/v2\/posts\/23"}],"collection":[{"href":"https:\/\/fs.wp.odu.edu\/sobrien\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fs.wp.odu.edu\/sobrien\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fs.wp.odu.edu\/sobrien\/wp-json\/wp\/v2\/users\/3412"}],"replies":[{"embeddable":true,"href":"https:\/\/fs.wp.odu.edu\/sobrien\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":5,"href":"https:\/\/fs.wp.odu.edu\/sobrien\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":100,"href":"https:\/\/fs.wp.odu.edu\/sobrien\/wp-json\/wp\/v2\/posts\/23\/revisions\/100"}],"wp:attachment":[{"href":"https:\/\/fs.wp.odu.edu\/sobrien\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fs.wp.odu.edu\/sobrien\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fs.wp.odu.edu\/sobrien\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}