From 5c6a51b437f7aa5395a3bb68df28a0728d8dd1ee Mon Sep 17 00:00:00 2001 From: Drtan Samos Date: Sun, 21 Apr 2013 12:03:36 +0200 Subject: Ability to uninstall when installing from sources. --- Makefile | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 275ec9f..e4f0b04 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ V=6 -INSTALL_FILES=$(wildcard parabolaiso/initcpio/install/*) -HOOKS_FILES=$(wildcard parabolaiso/initcpio/hooks/*) -SCRIPT_FILES=$(wildcard parabolaiso/initcpio/script/*) +INSTALL_SRC_DIR=parabolaiso/initcpio/install +HOOKS_SRC_DIR=parabolaiso/initcpio/hooks +SCRIPT_SRC_DIR=parabolaiso/initcpio/script INSTALL_DIR=$(DESTDIR)/usr/lib/initcpio/install HOOKS_DIR=$(DESTDIR)/usr/lib/initcpio/hooks @@ -13,7 +13,7 @@ DOC_FILES=$(wildcard docs/*) DOC_DIR=$(DESTDIR)/usr/share/doc/parabolaiso -all: +all: install dist install: install-program install-initcpio install-examples install-doc @@ -22,9 +22,9 @@ install-program: install-initcpio: install -d $(SCRIPT_DIR) $(HOOKS_DIR) $(INSTALL_DIR) - install -m 755 -t $(SCRIPT_DIR) $(SCRIPT_FILES) - install -m 644 -t $(HOOKS_DIR) $(HOOKS_FILES) - install -m 644 -t $(INSTALL_DIR) $(INSTALL_FILES) + install -m 755 -t $(SCRIPT_DIR) $(wildcard $(SCRIPT_SRC_DIR)/*) + install -m 644 -t $(HOOKS_DIR) $(wildcard $(HOOKS_SRC_DIR)/*) + install -m 644 -t $(INSTALL_DIR) $(wildcard $(INSTALL_SRC_DIR)/*) install-examples: install -d -m 755 $(DESTDIR)/usr/share/parabolaiso/ @@ -34,8 +34,25 @@ install-doc: install -d $(DOC_DIR) install -m 644 -t $(DOC_DIR) $(DOC_FILES) +uninstall: uninstall-program uninstall-initcpio uninstall-examples uninstall-doc + +uninstall-program: + rm $(DESTDIR)/usr/sbin/mkparabolaiso + +uninstall-initcpio: + @$(foreach file,$(wildcard $(SCRIPT_SRC_DIR)/*),rm -r $(subst $(SCRIPT_SRC_DIR),$(SCRIPT_DIR),$(file));) + @$(foreach file,$(wildcard $(HOOKS_SRC_DIR)/*),rm -r $(subst $(HOOKS_SRC_DIR),$(HOOKS_DIR),$(file));) + @$(foreach file,$(wildcard $(INSTALL_SRC_DIR)/*),rm -r $(subst $(INSTALL_SRC_DIR),$(INSTALL_DIR),$(file));) + +uninstall-examples: + rm -rfd $(DESTDIR)/usr/share/parabolaiso/configs + rm -d $(DESTDIR)/usr/share/parabolaiso + +uninstall-doc: + rm -rf $(DOC_DIR) + dist: git archive --format=tar --prefix=parabolaiso-$(V)/ v$(V) | gzip -9 > parabolaiso-$(V).tar.gz gpg --detach-sign --use-agent parabolaiso-$(V).tar.gz -.PHONY: install install-program install-initcpio install-examples install-doc dist +.PHONY: install install-program install-initcpio install-examples install-doc dist uninstall uninstall-program uninstall-initcpio uninstall-examples uninstall-doc -- cgit v1.2.3-54-g00ecf From 654d8bba202b0a1827a652d5f2c9979f0814ad6a Mon Sep 17 00:00:00 2001 From: Drtan Samos Date: Sun, 21 Apr 2013 15:58:33 +0200 Subject: Prevents errors when file paths contain spaces. --- Makefile | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index e4f0b04..cb5f9e4 100644 --- a/Makefile +++ b/Makefile @@ -7,9 +7,6 @@ SCRIPT_SRC_DIR=parabolaiso/initcpio/script INSTALL_DIR=$(DESTDIR)/usr/lib/initcpio/install HOOKS_DIR=$(DESTDIR)/usr/lib/initcpio/hooks SCRIPT_DIR=$(DESTDIR)/usr/lib/initcpio - -DOC_FILES=$(wildcard docs/*) - DOC_DIR=$(DESTDIR)/usr/share/doc/parabolaiso @@ -18,38 +15,38 @@ all: install dist install: install-program install-initcpio install-examples install-doc install-program: - install -D -m 755 parabolaiso/mkparabolaiso $(DESTDIR)/usr/sbin/mkparabolaiso + install -D -m 755 parabolaiso/mkparabolaiso "$(DESTDIR)/usr/sbin/mkparabolaiso" install-initcpio: - install -d $(SCRIPT_DIR) $(HOOKS_DIR) $(INSTALL_DIR) - install -m 755 -t $(SCRIPT_DIR) $(wildcard $(SCRIPT_SRC_DIR)/*) - install -m 644 -t $(HOOKS_DIR) $(wildcard $(HOOKS_SRC_DIR)/*) - install -m 644 -t $(INSTALL_DIR) $(wildcard $(INSTALL_SRC_DIR)/*) + install -d "$(SCRIPT_DIR)" "$(HOOKS_DIR)" "$(INSTALL_DIR)" + install -m 755 -t "$(SCRIPT_DIR)" $(wildcard $(SCRIPT_SRC_DIR)/*) + install -m 644 -t "$(HOOKS_DIR)" $(wildcard $(HOOKS_SRC_DIR)/*) + install -m 644 -t "$(INSTALL_DIR)" $(wildcard $(INSTALL_SRC_DIR)/*) install-examples: - install -d -m 755 $(DESTDIR)/usr/share/parabolaiso/ - cp -a --no-preserve=ownership configs $(DESTDIR)/usr/share/parabolaiso/ + install -d -m 755 "$(DESTDIR)/usr/share/parabolaiso/" + cp -a --no-preserve=ownership configs "$(DESTDIR)/usr/share/parabolaiso/" install-doc: - install -d $(DOC_DIR) - install -m 644 -t $(DOC_DIR) $(DOC_FILES) + install -d "$(DOC_DIR)" + install -m 644 -t "$(DOC_DIR)" $(wildcard docs/*) uninstall: uninstall-program uninstall-initcpio uninstall-examples uninstall-doc uninstall-program: - rm $(DESTDIR)/usr/sbin/mkparabolaiso + rm "$(DESTDIR)/usr/sbin/mkparabolaiso" uninstall-initcpio: - @$(foreach file,$(wildcard $(SCRIPT_SRC_DIR)/*),rm -r $(subst $(SCRIPT_SRC_DIR),$(SCRIPT_DIR),$(file));) - @$(foreach file,$(wildcard $(HOOKS_SRC_DIR)/*),rm -r $(subst $(HOOKS_SRC_DIR),$(HOOKS_DIR),$(file));) - @$(foreach file,$(wildcard $(INSTALL_SRC_DIR)/*),rm -r $(subst $(INSTALL_SRC_DIR),$(INSTALL_DIR),$(file));) + $(foreach file,$(wildcard $(SCRIPT_SRC_DIR)/*),rm -r "$(subst $(SCRIPT_SRC_DIR),$(SCRIPT_DIR),$(file))";) + $(foreach file,$(wildcard $(HOOKS_SRC_DIR)/*),rm -r "$(subst $(HOOKS_SRC_DIR),$(HOOKS_DIR),$(file))";) + $(foreach file,$(wildcard $(INSTALL_SRC_DIR)/*),rm -r "$(subst $(INSTALL_SRC_DIR),$(INSTALL_DIR),$(file))";) uninstall-examples: - rm -rfd $(DESTDIR)/usr/share/parabolaiso/configs - rm -d $(DESTDIR)/usr/share/parabolaiso + rm -rfd "$(DESTDIR)/usr/share/parabolaiso/configs" + rm -d "$(DESTDIR)/usr/share/parabolaiso" uninstall-doc: - rm -rf $(DOC_DIR) + rm -rf "$(DOC_DIR)" dist: git archive --format=tar --prefix=parabolaiso-$(V)/ v$(V) | gzip -9 > parabolaiso-$(V).tar.gz -- cgit v1.2.3-54-g00ecf From 14a433fea892b3d771e9cfcaed6919939e4f39a8 Mon Sep 17 00:00:00 2001 From: Esteban Carnevale Date: Mon, 2 Sep 2013 20:03:36 -0300 Subject: Modify Makefile to deploy all profile branches using script "expand". --- Makefile | 12 +++-- expand | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 188 insertions(+), 5 deletions(-) create mode 100755 expand (limited to 'Makefile') diff --git a/Makefile b/Makefile index cb5f9e4..397ec3c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -V=6 +V=2013.08.12 INSTALL_SRC_DIR=parabolaiso/initcpio/install HOOKS_SRC_DIR=parabolaiso/initcpio/hooks @@ -15,7 +15,7 @@ all: install dist install: install-program install-initcpio install-examples install-doc install-program: - install -D -m 755 parabolaiso/mkparabolaiso "$(DESTDIR)/usr/sbin/mkparabolaiso" + install -D -m 755 parabolaiso/mkparabolaiso "$(DESTDIR)/usr/bin/mkparabolaiso" install-initcpio: install -d "$(SCRIPT_DIR)" "$(HOOKS_DIR)" "$(INSTALL_DIR)" @@ -49,7 +49,9 @@ uninstall-doc: rm -rf "$(DOC_DIR)" dist: - git archive --format=tar --prefix=parabolaiso-$(V)/ v$(V) | gzip -9 > parabolaiso-$(V).tar.gz - gpg --detach-sign --use-agent parabolaiso-$(V).tar.gz + ./expand $(V) dist -.PHONY: install install-program install-initcpio install-examples install-doc dist uninstall uninstall-program uninstall-initcpio uninstall-examples uninstall-doc +dist-branches: + ./expand $(V) dist-branches + +.PHONY: install install-program install-initcpio install-examples install-doc dist dist-branches uninstall uninstall-program uninstall-initcpio uninstall-examples uninstall-doc diff --git a/expand b/expand new file mode 100755 index 0000000..5234379 --- /dev/null +++ b/expand @@ -0,0 +1,181 @@ +#!/bin/bash + +set -e + +version="$1" + +type="$2" + +### CONFIGURATION OPTIONS + +# Profiles to package in addition to the profile releng for the make target "dist-branches" +branches_dist_branches=(baseline gnome toolkit) + +# Profiles to package in addition to the profile releng for the make target "dist" +branches_dist=(baseline) + +### END OF CONFIGURATION OPTIONS + +error() { + echo "${@}. Stop." >&2 + exit 1 +} + +dist_branches() { + branches="${branches_dist_branches}" + # Refs to package (the branches) + refs="${branches[@]}" + # Ref of the releng profile to package + releng="master" + # Release branch. This branch only has commits to prepare the package. + release_branch="release-branches" + # Release ref. It is a branch for dist_branches. The package is created from this ref. + release="${release_branch}" + # Refs that should exist for the make target dist-branches. This branches will be packaged. + allrefs=( ${releng} ${branches[@]} ) +} + +dist() { + branches="${branches_dist}" + # Refs to package (branch names appending the date, like "baseline/2013.08.12") + refs="${branches_dist[@]/%//${version}}" + # Ref of the releng profile to package + releng="master/${version}" + # Release branch. This branch only has commits to prepare the package. + release_branch="release" + # Release ref. Tag of commit in release_branch. The package is created from this ref. + release="release/${version}" + # These refs should exist to package for the make target dist. + allrefs=( ${releng} ${refs[@]} ) +} + +expand() { + ref="$1" + dir="$2" + + GIT_INDEX_FILE="${index}" git read-tree --empty + GIT_INDEX_FILE="${index}".release git read-tree --empty + + # Find the current head of ${ref} + head="$(git show-ref --hash "refs/${ref_type}/${ref}")" + # Find the current head of the release branch. + head_release="$(git show-ref --hash refs/heads/"${release_branch}")" + if [[ $dir == releng ]] ; then + # Read the tree of "$ref" with profile path rename into an index file. + git ls-tree -z -r "${head}" | sed -z "s|configs/profile|configs/${dir}|" | GIT_INDEX_FILE="${index}" git update-index -z --index-info + # Remove the master branch from the release index, that is, leave everything from configs/ excluding configs/releng + git ls-tree -z -r "${head_release}" | grep -zZP 'configs/(?!releng)' | GIT_INDEX_FILE="${index}".release git update-index -z --index-info + # This combines the two indexes (obtained in the last two commands). + GIT_INDEX_FILE="${index}".release git ls-files -z -s | GIT_INDEX_FILE="${index}" git update-index -z --add --index-info + else + # Read only paths configs/profile of "$ref" with profile path rename into an index file. + git ls-tree -z -r "${head}" -- configs/profile | sed -z "s|configs/profile|configs/${dir}|" | GIT_INDEX_FILE="${index}" git update-index -z --index-info + # Remove configs/${dir} from the release index. + git ls-tree -z -r "${head_release}" | grep -zZv configs/"${dir}" | GIT_INDEX_FILE="${index}".release git update-index -z --index-info + # This combines the two indexes (obtained in the last two commands). + GIT_INDEX_FILE="${index}".release git ls-files -z -s | GIT_INDEX_FILE="${index}" git update-index -z --add --index-info + fi + # Write the index file into the repo as a tree. + tree="$(GIT_INDEX_FILE="${index}" git write-tree)" + # Write a commit to the repo. + commit="$(echo "Update profile ${dir}" | git commit-tree "$tree" -p "${head_release}")" + # Update the head of the repository to be the new commit. + git update-ref refs/heads/"${release_branch}" "$commit" "${head_release}" +} + +expand_empty() { + ref="${releng}" + dir="releng" + + GIT_INDEX_FILE="${index}" git read-tree --empty + + # Find the current head of ${ref} + head="$(git show-ref --hash "refs/${ref_type}/${ref}")" + # Read the tree of "$ref" with profile path rename into an index file. + git ls-tree -z -r "${head}" | sed -z "s|configs/profile|configs/${dir}|" | GIT_INDEX_FILE="${index}" git update-index -z --index-info + # Write the index file into the repo as a tree. + tree="$(GIT_INDEX_FILE="${index}" git write-tree)" + # Write a commit to the repo. + commit="$(echo "Update profile ${dir}" | git commit-tree "$tree")" + # Update the head of the repository to be the new commit. + git update-ref refs/heads/"${release_branch}" "$commit" 0000000000000000000000000000000000000000 +} + +ref_test() { + es=0 + git show-ref --quiet "$1" || es=$? + + if [[ $es == 1 ]] ; then + error "$2" + elif [[ $es > 1 ]] ; then + error "$3" + fi +} + +ref_test_negative() { + es=0 + git show-ref --quiet "$1" || es=$? + + if [[ $es == 0 ]] ; then + error "$2" + elif [[ $es > 1 ]] ; then + error "$3" + fi +} + +release_prepare() { + ref_test_negative "refs/tags/${release}" "Release tag ${release} can not be created because it already exists" "Error testing the release tag" +} + +show_ref() { + for ref in ${allrefs[@]} ; do + ref_test "refs/${ref_type}/${ref}" "Git reference refs/${ref_type}/${ref} should exist" "Error testing git reference refs/${ref_type}/${ref}" + done +} + +archive_ref() { + git archive --format=tar.gz --prefix=parabolaiso-"${version}"/ "refs/${ref_type}/${release}" > parabolaiso-"${version}".tar.gz +} + +archive() { + git tag -s -m "tag ${release}" "${release}" "${release_branch}" + archive_ref + gpg --detach-sign --use-agent parabolaiso-"${version}".tar.gz +} + +dist_expand() { + index="$(mktemp)" + + es=0 + git show-ref --quiet "refs/heads/${release_branch}" || es=$? + + if [[ $es == 0 ]] ; then + expand "${releng}" releng + elif [[ $es == 1 ]] ; then + expand_empty + echo "Release branch created." + elif [[$es > 1 ]] ; then + error "Error testing the release branch" + fi + + for i in ${!branches[@]} ; do + expand ${refs[$i]} ${branches[$i]} + done +} + +if [[ ${type} == dist ]] ; then + ref_type="tags" + dist + release_prepare + show_ref + dist_expand + archive +elif [[ ${type} == dist-branches ]] ; then + ref_type="heads" + dist_branches + show_ref + dist_expand + archive_ref +else + error "Second argument is not correct" +fi -- cgit v1.2.3-54-g00ecf From e9a0f37965a538881d08d205ff4a2b46597e0d47 Mon Sep 17 00:00:00 2001 From: Esteban Carnevale Date: Mon, 2 Sep 2013 20:03:38 -0300 Subject: Replace sbin with bin in Makefile. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 397ec3c..222f39a 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ install-doc: uninstall: uninstall-program uninstall-initcpio uninstall-examples uninstall-doc uninstall-program: - rm "$(DESTDIR)/usr/sbin/mkparabolaiso" + rm "$(DESTDIR)/usr/bin/mkparabolaiso" uninstall-initcpio: $(foreach file,$(wildcard $(SCRIPT_SRC_DIR)/*),rm -r "$(subst $(SCRIPT_SRC_DIR),$(SCRIPT_DIR),$(file))";) -- cgit v1.2.3-54-g00ecf