{"id":173,"date":"2014-03-28T08:24:24","date_gmt":"2014-03-28T08:24:24","guid":{"rendered":"http:\/\/thomas.goirand.fr\/blog\/?p=173"},"modified":"2014-03-28T08:31:19","modified_gmt":"2014-03-28T08:31:19","slug":"automatic-backport-script","status":"publish","type":"post","link":"http:\/\/thomas.goirand.fr\/blog\/?p=173","title":{"rendered":"Automatic backport script"},"content":{"rendered":"<p>Since I have to do a lot of backports for the OpenStack packages in Debian Wheezy, I got tired of doing them by hand. Therefore, I have created a script to automate the task. I&#8217;m not particularly proud (or ashamed) of that script, but I just want to share it. Probably some fellow readers will happily provide me with enhancements and ideas.<\/p>\n<p>Note that the use of mk-build-deps implies that the &#8220;equivs&#8221; package has to be installed. What I do is run this &#8220;build-backport&#8221; script within a cowbuilder, to make sure I always have a clean backport environment.<\/p>\n<pre class=\"brush:shell\">#!\/bin\/sh\r\n\r\nset -e\r\nset -x\r\n\r\nPKG_NAME=${1}\r\nBPO_DISTRO=wheezy-backports\r\nBPO_POSTFIX=bpo70+1\r\nREPO_ROOT=\/home\/ftp\r\nREPO_DEST=icehouse-backports\r\n\r\nif [ `whoami` = \"jenkins\" ] ; then\r\n        BUILD_ROOT=\/var\/lib\/jenkins\/jobs\/openstack-pkg-tools\/builds\/${BUILD_NUMBER}\r\nelse\r\n        BUILD_ROOT=~\/sources\r\nfi\r\n\r\n# Get info from packages.debian.org\r\nPKG_INFO_FILE=`mktemp -t pkg_info_file.XXXXXX`\r\nwget --no-check-certificate -O ${PKG_INFO_FILE} http:\/\/packages.debian.org\/sid\/${PKG_NAME}\r\nDEB_VERSION=`rmadison ${PKG_NAME} | grep sid | awk '{print $3}'`\r\nUPSTREAM_VERSION=`echo ${DEB_VERSION} | cut -d'-' -f1  | cut -d\":\" -f2`\r\nDSC_URL=`cat ${PKG_INFO_FILE} | grep dsc | cut -d'\"' -f2`\r\nrm ${PKG_INFO_FILE}\r\n\r\n# Prepare build folder and go in it\r\nMY_CWD=`pwd`\r\nrm -rf ${BUILD_ROOT}\/$PKG_NAME\r\nmkdir -p ${BUILD_ROOT}\/$PKG_NAME\r\ncd ${BUILD_ROOT}\/$PKG_NAME\r\n\r\n# Download the .dsc and extract it\r\ndget -d -u ${DSC_URL}\r\nPKG_SRC_NAME=`ls *.dsc | cut -d_ -f1`\r\nPKG_NAME_FIRST_CHAR=`echo ${PKG_SRC_NAME} | awk '{print substr($0,1,1)}'`\r\ndpkg-source -x *.dsc\r\n\r\necho \"Now running mk-build-deps -i ${PKG_SRC_NAME}-${UPSTREAM_VERSION}\/debian\/control\"\r\nmk-build-deps -i ${PKG_SRC_NAME}-${UPSTREAM_VERSION}\/debian\/control\r\n\r\n# Build the package as backport using cowbuilder\r\ncd ${PKG_SRC_NAME}-${UPSTREAM_VERSION}\r\ndch --bpo -m \"Backported for ${BPO_DISTRO}.\"\r\ndpkg-buildpackage\r\ncd ..  \r\nPKG_FINAL_DEST=${REPO_ROOT}\/debian\/pool\/${REPO_DEST}\/main\/${PKG_NAME_FIRST_CHAR}\/${PKG_SRC_NAME}\r\nssh archive.gplhost.com \"mkdir -p ${PKG_FINAL_DEST}\"\r\nscp *.orig.tar.* *${DEB_VERSION}~${BPO_POSTFIX}* archive.gplhost.com:${PKG_FINAL_DEST}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Since I have to do a lot of backports for the OpenStack packages in Debian Wheezy, I got tired of doing them by hand. Therefore, I have created a script to automate the task. I&#8217;m not particularly proud (or ashamed) of that script, but I just want to share it. Probably some fellow readers will [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=\/wp\/v2\/posts\/173"}],"collection":[{"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=173"}],"version-history":[{"count":3,"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=\/wp\/v2\/posts\/173\/revisions"}],"predecessor-version":[{"id":176,"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=\/wp\/v2\/posts\/173\/revisions\/176"}],"wp:attachment":[{"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=173"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/thomas.goirand.fr\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}