{"id":1144,"date":"2012-06-28T11:52:31","date_gmt":"2012-06-28T11:52:31","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=1144"},"modified":"2012-07-02T13:39:55","modified_gmt":"2012-07-02T13:39:55","slug":"making-reposado-client-aware","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=1144","title":{"rendered":"Making Reposado Client aware"},"content":{"rendered":"<p>Apple&#8217;s Software Update service has the ability to offer the &#8220;correct&#8221; catalog to a client that requests simply &#8220;index.sucatalog&#8221;. This ability was first added with OS X Server 10.6.6, and involved the use of Apache&#8217;s mod_rewrite.<\/p>\n<p>This feature is handy, as it greatly simplifies client configuration. You no longer need to take client OS version into consideration when setting the CatalogURL for the client.<\/p>\n<p>Lion Server&#8217;s Software Update service has a similar capability, but this is done via a CGI instead.<\/p>\n<p>Since Reposado doesn&#8217;t handle the web-serving part of offering Apple software updates, Reposado itself cannot provide a similar feature: instead you must configure your web server to do URL rewrites, or write your own CGI to provide this functionality.<\/p>\n<p>mod_rewrite example<br \/>\n___________________<\/p>\n<p>If you are using Apache2 as your webserver, you may be able to configure mod_rewrite to return the &#8220;correct&#8221; OS-specific sucatalog:<\/p>\n<p>Here is an example .htaccess file you could place at the root of your Reposado repo:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">RewriteEngine On<br \/>\nOptions FollowSymLinks<br \/>\nRewriteBase \/<br \/>\nRewriteCond %{HTTP_USER_AGENT} Darwin\/8<br \/>\nRewriteRule ^index(.*)\\.sucatalog$ content\/catalogs\/index$1.sucatalog [L]<br \/>\nRewriteCond %{HTTP_USER_AGENT} Darwin\/9<br \/>\nRewriteRule ^index(.*)\\.sucatalog$ content\/catalogs\/others\/index-leopard.merged-1$1.sucatalog [L]<br \/>\nRewriteCond %{HTTP_USER_AGENT} Darwin\/10<br \/>\nRewriteRule ^index(.*)\\.sucatalog$ content\/catalogs\/others\/index-leopard-snowleopard.merged-1$1.sucatalog [L]<br \/>\nRewriteCond %{HTTP_USER_AGENT} Darwin\/11<br \/>\nRewriteRule ^index(.*)\\.sucatalog$ content\/catalogs\/others\/index-lion-snowleopard-leopard.merged-1$1.sucatalog [L]<br \/>\nRewriteCond %{HTTP_USER_AGENT} Darwin\/12<br \/>\nRewriteRule ^index(.*)\\.sucatalog$ content\/catalogs\/others\/index-mountainlion-lion-snowleopard-leopard.merged-1$1.sucatalog [L]<\/div><\/div>\n<p>(This requires Apache2 to be configured to actually pay attention to mod_rewite rules in .htaccess files. See your Apache and mod_rewrite documentation for details.)<\/p>\n<p>(Note that the format for these rules is specific for use in an .htaccess file. The rules would need to be changed if in the main Apache config file.)<\/p>\n<p>(Other web servers such as Nginx support URL rewriting; the specifics are slightly different, but the general concepts are similar.)<\/p>\n<h2>Testing<\/h2>\n<p>The current version of Reposado can help you test your URL rewrites. When catalogs are written out to disk, a key named &#8220;_CatalogName&#8221; is added to the catalog with the base filename of the catalog. This allows you to verify that the catalog being returned is the one you expect.<\/p>\n<p>For example, I want to test that I&#8217;m getting the Lion catalog:<\/p>\n<p>% curl &#8211;user-agent &#8220;Darwin\/11.4.0&#8221; http:\/\/su.example.com\/index_testing.sucatalog &gt; \/tmp\/testing<br \/>\n% Total % Received % Xferd Average Speed Time Time Time Current<br \/>\nDload Upload Total Spent Left Speed<br \/>\n100 1024k 100 1024k 0 0 25.1M 0 &#8211;:&#8211;:&#8211; &#8211;:&#8211;:&#8211; &#8211;:&#8211;:&#8211; 32.2M<\/p>\n<p>% tail -5 \/tmp\/testing<\/p>\n<p>_CatalogName<br \/>\nindex-lion-snowleopard-leopard.merged-1_testing.sucatalog<br \/>\nThe _CatalogName is &#8220;index-lion-snowleopard-leopard.merged-1_testing.sucatalog&#8221;, which is what I expect.<\/p>\n<p>I can repeat the test for Snow Leopard, this time against the &#8220;release&#8221; branch:<\/p>\n<p>% curl &#8211;user-agent &#8220;Darwin\/10.8.0&#8221; http:\/\/su.example.com\/index_release.sucatalog &gt; \/tmp\/release<br \/>\n% Total % Received % Xferd Average Speed Time Time Time Current<br \/>\nDload Upload Total Spent Left Speed<br \/>\n100 912k 100 912k 0 0 29.7M 0 &#8211;:&#8211;:&#8211; &#8211;:&#8211;:&#8211; &#8211;:&#8211;:&#8211; 31.8M<\/p>\n<p>% tail -5 \/tmp\/release<\/p>\n<p>_CatalogName<br \/>\nindex-leopard-snowleopard.merged-1_release.sucatalog<\/p>\n<h2>Conclusion<\/h2>\n<p>Adding URL rewriting to your Reposado web server configuration makes client configuration much simpler, as you no longer have to worry about which OS the client is running.<\/p>\n<h2>NOTE<\/h2>\n<p>As the URL is being rewritten on the fly, if you goto the url in a browser you will get a 404 error.<\/p>\n<p>I have added the following to the .htaccess file so that I can at least see a catalog in Safari to verify the server is running.<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">RewriteCond %{HTTP_USER_AGENT} Safari\/*<br \/>\nRewriteRule ^index(.*)\\.sucatalog$ content\/catalogs\/others\/index-mountainlion-lion-snowleopard-leopard.merged-1$1.sucatalog [L]<\/div><\/div>\n<p><a href='https:\/\/blog.designed79.co.uk\/wp-content\/uploads\/2012\/06\/htaccess.zip'>htaccess<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apple&#8217;s Software Update service has the ability to offer the &#8220;correct&#8221; catalog to a client that requests simply &#8220;index.sucatalog&#8221;. This ability was [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1144","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1144"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1144\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}