{"id":568,"date":"2013-03-27T22:29:15","date_gmt":"2013-03-27T21:29:15","guid":{"rendered":"http:\/\/www.jbahillo.com\/?p=568"},"modified":"2013-07-29T12:38:47","modified_gmt":"2013-07-29T11:38:47","slug":"updating-packages-from-a-folder","status":"publish","type":"post","link":"https:\/\/www.jbahillo.com\/?p=568","title":{"rendered":"Updating packages from a folder"},"content":{"rendered":"<p>Today I had to update a set of installed packages from a folder, but in that folder there were some deb packages that were not installed and that I did not want to install, so I thought of doing a script that check if that package were installed and if so, update them with the deb file.<\/p>\n<p>Of course, the main issue here is that the deb package name is not the name of the package once installed (the deb is , say samba_1.2.3..deb while the package name would be just samba), so parsing basenames (and taking out the version numbers which where preceded by a _) was the clue here:<\/p>\n<pre class=\"brush: bash; auto-links: true; collapse: false; gutter: true; first-line: 1; highlight: []; html-script: false; light: false; pad-line-numbers: true; toolbar: true; wrap-lines: true\">\r\n#!\/bin\/bash\r\n# END\r\nfor e in $(ls -F | grep -v [\/,*]) \r\ndo\r\n#we&#039;ll store in $filename the dpkg package name.\r\nfilename=$(echo $e | cut -d_ -f1)\r\ndpkg -l | grep $filename &gt; \/dev\/null\r\n\r\n\tif [ $? == 0 ] ; then\r\n\r\n\t\tsudo dpkg -i $e\r\n\telse \r\n\t\techo $filename &quot;is not installed, ignored&quot;\r\n\tfi\r\ndone\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Today I had to update a set of installed packages from a folder, but in that folder there were some deb packages that were not installed and that I did not want to install, so I thought of doing a&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/www.jbahillo.com\/?p=568\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"ep_exclude_from_search":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[10,96],"tags":[72,106,107,73],"class_list":["post-568","post","type-post","status-publish","format-standard","hentry","category-gnulinux","category-zentyal","tag-bash","tag-deb","tag-reinstall","tag-script"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p74T96-9a","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=\/wp\/v2\/posts\/568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=568"}],"version-history":[{"count":10,"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=\/wp\/v2\/posts\/568\/revisions"}],"predecessor-version":[{"id":693,"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=\/wp\/v2\/posts\/568\/revisions\/693"}],"wp:attachment":[{"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jbahillo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}