Skip to content

Commit

Permalink
Merge "Install files to correct location for RPM" into stable/juno
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomoe Sugihara authored and gerritforge-ltd committed Dec 3, 2014
2 parents be7dbfe + f1d7a62 commit 79209c9
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,29 +129,24 @@ EOF
CFG=setup.cfg
CFG_BAK=setup.cfg.$version_tag

function setup_cfg() {
if [ -f $CFG ]; then
echo "Backing up $CFG as $CFG_BAK"
cp $CFG $CFG_BAK
function create_cfg() {
if [ -z "$1" ]; then
echo "error: install location was not supplied"
exit -1
fi

# Need to do this to have the files be installed in the right location
cat > $CFG << EOF
# This is an auto-generated file from package.sh
[install]
install-lib=/usr/lib/python2.7/dist-packages
install-lib=$1
install-scripts=/usr/bin
EOF
}

function cleanup_cfg() {
if [ -f $CFG_BAK ]; then
echo "Restoring $CFG_BAK as $CFG"
mv $CFG_BAK $CFG
fi
}

function package_rpm() {
create_cfg /usr/lib/python2.7/site-packages

local args=$(cat << EOF
--epoch 1
--version $rpm_version
Expand All @@ -163,6 +158,8 @@ EOF
}

function package_deb() {
create_cfg /usr/lib/python2.7/dist-packages

local args=$(cat << EOF
--deb-priority 'optional' \
--version $deb_version \
Expand All @@ -175,7 +172,18 @@ EOF

# Main
set +e
setup_cfg

# Back up the config if exists
if [ -f $CFG ]; then
echo "Backing up $CFG as $CFG_BAK"
cp $CFG $CFG_BAK
fi

package_rpm
package_deb
cleanup_cfg

# Restore the backed up config file
if [ -f $CFG_BAK ]; then
echo "Restoring $CFG_BAK as $CFG"
mv $CFG_BAK $CFG
fi

0 comments on commit 79209c9

Please sign in to comment.