summaryrefslogtreecommitdiffstats
path: root/build/install/uninstall.sh
blob: a9e74bc390eeada815372b9aa369bfd57a5c3188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash -e
##############################################################################
# Copyright (c) 2015 Ericsson AB and others.
# stefan.k.berg@ericsson.com
# jonas.bjurel@ericsson.com
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################


my_exit() {
    cd /tmp
    if [ -d "$MOUNT" ]; then
        fusermount -u $MOUNT
        rmdir $MOUNT
    fi
}
trap my_exit EXIT

echo "Live uninstall is currently disabled as it is not tested"
exit 1

TOP=`pwd`
MOUNT=`mktemp -d /tmp/XXXXXXX`
ssh-copy-id root@10.20.0.2
sshfs root@10.20.0.2:/ $MOUNT

DEST=$MOUNT
REPO=$DEST/var/www/nailgun/ubuntu/fuelweb/x86_64

cd $REPO
if [ ! -f  $REPO/dists/trusty/main/binary-amd64/Packages.backup ]; then
    echo "Error - didn't find backup file for Packages!"
    exit 1
fi

if [ ! -f  $REPO/dists/trusty/main/binary-amd64/Packages.gz.backup ]; then
    echo "Error - didn't find backup file for Packages.gz!"
    exit 1
fi

if [ ! -f  $REPO/dists/trusty/Release.backup ]; then
    echo "Error - didn't find backup file for Release!"
    exit 1
fi

if [ ! -f $DEST/etc/puppet/manifests/site.pp.backup ]; then
    echo "Error - didn't find backup file for site.pp!"
    exit 1
fi

echo "Removing Debian packages:"
cd $TOP/release/pool/main
for deb in *.deb
do
    echo "   $deb"
    rm -Rf $REPO/pool/main/$deb
done
cd $REPO

echo "Removing Puppet modules:"
cd $TOP/puppet/modules
for dir in *
do
    echo "   $dir"
    rm -Rf $DEST/etc/puppet/modules/$dir
done
cd $REPO

echo "Restoring backups of datafiles"

rm -f $REPO/dists/trusty/main/binary-amd64/Packages $REPO/dists/trusty/main/binary-amd64/Packages.gz
rm -f $REPO/dists/trusty/Release $DEST/etc/puppet/manifests/site.pp
mv $REPO/dists/trusty/main/binary-amd64/Packages.backup $REPO/dists/trusty/main/binary-amd64/Packages
mv $REPO/dists/trusty/main/binary-amd64/Packages.gz.backup $REPO/dists/trusty/main/binary-amd64/Packages.gz
mv $REPO/dists/trusty/Release.backup $REPO/dists/trusty/Release
mv $DEST/etc/puppet/manifests/site.pp.backup $DEST/etc/puppet/manifests/site.pp
s="cp"> else \ git submodule update --init 2>/dev/null; \ fi @rm -f $@ @git submodule -q foreach '${REPOINFO} . >> ${FREPODIR}/$@' # Generate patches from submodules .PHONY: patches-export patches-export: sub @git submodule -q foreach ' \ SUB_DIR=${F_PATCH_DIR}/$$name; \ git tag | awk "!/root/ && /${F_OPNFV_TAG}-fuel/" | while read F_TAG; do \ SUB_FEATURE=`dirname $${F_TAG#${F_OPNFV_TAG}-fuel/}`; \ echo "`tput setaf 2`-- exporting $$name ($$F_TAG)`tput sgr0`"; \ mkdir -p $$SUB_DIR/$${SUB_FEATURE} && \ git format-patch --no-signature --ignore-space-at-eol \ -o $$SUB_DIR/$$SUB_FEATURE -N $$F_TAG-root..$$F_TAG; \ sed -i -e "1{/From: /!d}" -e "s/[[:space:]]*$$//" \ $$SUB_DIR/$$SUB_FEATURE/*.patch; \ done' # Apply patches from patch/* to respective submodules # We rely on `make sub` and/or `make clean` to checkout correct base .PHONY: patches-import patches-import: sub .cachepatched .cachepatched: ${FPATCHES} @$(MAKE) clean @git submodule -q foreach ' \ SUB_DIR=${F_PATCH_DIR}/$$name; mkdir -p $$SUB_DIR && \ git tag ${F_OPNFV_TAG}-root && \ git checkout -q -b opnfv-fuel && \ find $$SUB_DIR -type d | sort | while read p_dir; do \ SUB_PATCHES=$$(ls $$p_dir/*.patch 2>/dev/null); \ if [ -n "$$SUB_PATCHES" ]; then \ SUB_FEATURE=$${p_dir#$$SUB_DIR}; \ SUB_TAG=${F_OPNFV_TAG}-fuel$$SUB_FEATURE/patch; \ echo "`tput setaf 2`-- patching $$name ($$SUB_TAG)`tput sgr0`";\ git tag $$SUB_TAG-root && \ git am -3 --whitespace=nowarn --patch-format=mbox \ --committer-date-is-author-date $$SUB_PATCHES && \ git tag $$SUB_TAG || exit 1; \ fi \ done && \ git tag ${F_OPNFV_TAG}' @touch $@ # Clean any changes made to submodules, checkout upstream Fuel root commit .PHONY: clean clean: @cd ${F_GIT_ROOT} && git submodule -q foreach ' \ git am -q --abort > /dev/null 2>&1; \ git checkout -q -f ${F_OPNFV_TAG}-root > /dev/null 2>&1; \ git branch -q -D opnfv-fuel > /dev/null 2>&1; \ git tag | grep ${F_OPNFV_TAG} | xargs git tag -d > /dev/null 2>&1; \ git reset -q --hard HEAD; \ git clean -xdff' @rm -f .cachepatched .PHONY: deepclean deepclean: clean clean-cache @git submodule deinit -f . @rm -f .cache* .PHONY: release release: sub # Store artifact in cache straight away if caching is enabled # (no .cacheid will be present unless this is a cached build) test -f .cacheid && $(MAKE) -f Makefile put-cache || exit 0 # NOTE: Patches are not included in cache $(MAKE) -f Makefile patches-import ############################################################################## # Cache operations - only used when building through ci/build.sh ############################################################################## # NOTE: Current method of collecting submodule refs requires submodules to be # NOT initialized <OR> NO patches applied. # NOTE: Querying `git submodule status` from parent will show the patched tree. # Create a unique hash to be used for getting and putting cache, based on: # - git submodule SHAs, collected with `git submodule status` # - The contents of this Makefile .cacheid: @$(MAKE) clean sha1sum Makefile > .cachedata git submodule status | cut -c2-41 >> .cachedata cat .cachedata | $(CACHETOOL) getid > .cacheid # Clean local data related to caching - called prior to ordinary build .PHONY: clean-cache clean-cache: clean rm -f .cachedata .cacheid # Try to download cache - called prior to ordinary build .PHONY: get-cache get-cache: .cacheid @if $(CACHETOOL) check $(shell cat .cacheid); then \ $(MAKE) clean && \ $(CACHETOOL) get $(shell cat .cacheid) | \ tar xf - -C ${F_GIT_DIR}; \ else \ echo "No cache item found for $(shell cat .cacheid)" ;\ exit 0;\ fi # Store cache if not already stored - called after ordinary build .PHONY: put-cache put-cache: .cacheid @if ! $(CACHETOOL) check $(shell cat .cacheid); then \ $(MAKE) clean && \ tar cf - -C ${F_GIT_DIR} modules | \ $(CACHETOOL) put $(shell cat .cacheid); \ fi