Skip to content

Commit

Permalink
Added uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
dutor committed Dec 16, 2019
1 parent 2b4bb24 commit 47e8f80
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 4 deletions.
18 changes: 15 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
cmake_minimum_required(VERSION 3.0)
project("nebula-gears" CXX ASM)


set(CMAKE_CXX_STANDARD 14)

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY lib)
Expand Down Expand Up @@ -37,14 +36,27 @@ configure_file(
@ONLY
)

set(stage_dir "${CMAKE_BINARY_DIR}/stage")
set(stage_install_prefix "${stage_dir}/${CMAKE_INSTALL_PREFIX}")
set(share_dir "share/nebula-gears")
set(installed_files_file "installed_files")

add_custom_target(
package
COMMAND
make -s install DESTDIR=${CMAKE_BINARY_DIR}/stage
make -s install DESTDIR=${stage_dir}
COMMAND
mkdir -p ${stage_install_prefix}/${share_dir}
COMMAND
find ${stage_install_prefix} -type f -fprint ${stage_install_prefix}/${share_dir}/${installed_files_file}
COMMAND
find ${stage_install_prefix} -type f -fprint ${stage_install_prefix}/${share_dir}/${installed_files_file}
COMMAND
sed -i "s#${stage_install_prefix}/##" ${stage_install_prefix}/${share_dir}/${installed_files_file}
COMMAND
cp -f ${CMAKE_BINARY_DIR}/${package_name}-meta.sh ${package_name}.sh
COMMAND
tar -cJf - -C ${CMAKE_BINARY_DIR}/stage/${CMAKE_INSTALL_PREFIX} . >> ${CMAKE_BINARY_DIR}/${package_name}.sh
tar -cJf - -C ${stage_install_prefix} . >> ${CMAKE_BINARY_DIR}/${package_name}.sh
COMMAND
chmod +x ${CMAKE_BINARY_DIR}/${package_name}.sh
)
3 changes: 2 additions & 1 deletion aux/self-extractable.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ hash xz &>/dev/null || { echo "xz: command not found"; exit 1; }
hash lsb_release &>/dev/null || { echo "lsb_release: command not found"; exit 1; }

mkdir -p $prefix

[[ -w $prefix ]] || { echo "$prefix: No permission to write"; exit 1; }

archive_offset=$(awk '/^__start_of_archive__$/{print NR+1; exit 0;}' $0)
tail -n+$archive_offset $0 | tar --numeric-owner -xJf - -C $prefix
tail -n+$archive_offset $0 | tar --no-same-owner --numeric-owner -xJf - -C $prefix

echo "@package_name@ has been installed to $prefix"

Expand Down
2 changes: 2 additions & 0 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ install(
distro-name
distro-fullname
distro-version
nebula-gears-uninstall
nebula-gears-show-files
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
Expand Down
18 changes: 18 additions & 0 deletions scripts/nebula-gears-show-files
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /usr/bin/env bash

set -e
set -o pipefail

this_dir=$(dirname $(readlink -f $0))

bin_dir_name=$(basename $this_dir)
[[ $bin_dir_name = bin ]] || exit 1

install_prefix=$(dirname $this_dir)
share_dir=$install_prefix/share/nebula-gears
installed_files_file=$share_dir/installed_files

for file in $(cat $installed_files_file)
do
echo $install_prefix/$file
done
21 changes: 21 additions & 0 deletions scripts/nebula-gears-uninstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#! /usr/bin/env bash

set -e
set -o pipefail

this_dir=$(dirname $(readlink -f $0))

bin_dir_name=$(basename $this_dir)
[[ $bin_dir_name = bin ]] || exit 1

install_prefix=$(dirname $this_dir)
share_dir=$install_prefix/share/nebula-gears
installed_files_file=$share_dir/installed_files

for file in $(cat $installed_files_file)
do
echo "Removing $install_prefix/$file"
rm -f $install_prefix/$file
done

echo "Done"

0 comments on commit 47e8f80

Please sign in to comment.