diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9953e6e --- /dev/null +++ b/Makefile @@ -0,0 +1,75 @@ +# Makefile for git-redate + +# Package name +PACKAGE_NAME := git-redate + +# Package version +PACKAGE_VERSION := 1.0.2 + +# Author +AUTHOR := Potato Labs + +# Build directory +BUILD_DIR := build + +# Source directory +SOURCE_DIR := . + +# Install directory +INSTALL_DIR := /usr/local/bin + +# Build artifacts +DEB_PACKAGE := $(PACKAGE_NAME)_$(PACKAGE_VERSION)_all.deb +RPM_PACKAGE := $(PACKAGE_NAME)-$(PACKAGE_VERSION).noarch.rpm + +.PHONY: all clean package install uninstall + +all: package + +package: + # Detect system type + @if [ -x $$(command -v dpkg) ]; then \ + echo "Building DEB package..."; \ + mkdir -p $(BUILD_DIR)/deb/DEBIAN; \ + echo "Package: $(PACKAGE_NAME)" > $(BUILD_DIR)/deb/DEBIAN/control; \ + echo "Version: $(PACKAGE_VERSION)" >> $(BUILD_DIR)/deb/DEBIAN/control; \ + echo "Architecture: all" >> $(BUILD_DIR)/deb/DEBIAN/control; \ + echo "Maintainer: $(AUTHOR)" >> $(BUILD_DIR)/deb/DEBIAN/control; \ + echo "Depends: bash, git" >> $(BUILD_DIR)/deb/DEBIAN/control; \ + echo "Description: Change the dates of several git commits with a single command." >> $(BUILD_DIR)/deb/DEBIAN/control; \ + mkdir -p $(BUILD_DIR)/deb/usr/bin; \ + cp $(SOURCE_DIR)/$(PACKAGE_NAME) $(BUILD_DIR)/deb/usr/bin; \ + chmod +x $(BUILD_DIR)/deb/usr/bin/$(PACKAGE_NAME); \ + dpkg-deb --build $(BUILD_DIR)/deb $(BUILD_DIR)/$(DEB_PACKAGE); \ + elif [ -x $$(command -v rpm) ]; then \ + echo "Building RPM package..."; \ + mkdir -p $(BUILD_DIR)/rpm/usr/bin; \ + cp $(SOURCE_DIR)/$(PACKAGE_NAME) $(BUILD_DIR)/rpm/usr/bin; \ + chmod +x $(BUILD_DIR)/rpm/usr/bin/$(PACKAGE_NAME); \ + fpm -s dir -t rpm \ + -n $(PACKAGE_NAME) \ + -v $(PACKAGE_VERSION) \ + --iteration 1 \ + --maintainer "$(AUTHOR)" \ + --depends bash \ + --depends git \ + --description "Change the dates of several git commits with a single command." \ + -C $(BUILD_DIR)/rpm \ + usr; \ + else \ + echo "Unsupported system type!"; \ + exit 1; \ + fi + +install: + # Install the script + cp $(SOURCE_DIR)/$(PACKAGE_NAME) $(INSTALL_DIR)/$(PACKAGE_NAME) + chmod +x $(INSTALL_DIR)/$(PACKAGE_NAME) + +uninstall: + # Uninstall the script + rm -f $(INSTALL_DIR)/$(PACKAGE_NAME) + +clean: + # Clean build artifacts + rm -rf $(BUILD_DIR) diff --git a/README.md b/README.md index 034b2bc..012b7ed 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,11 @@ Change the dates of several git commits with a single command. For homebrew users, you need to run `brew tap PotatoLabs/homebrew-git-redate` and then `brew install git-redate`. -If you're not using homebrew, you can clone this repo and move the `git-redate` file into any folders in your $PATH. Restart your terminal afterwards and you're good to go! +You can also create debian/rpm packages for installing by cloning this repo and running `make package` in the project directory. + +The `make install` command can be used to directly install the script in the current system and `make uninstall` can be used to reverse the install operation. + +If you want to do it manually you can move the `git-redate` file into any folders in your $PATH. Restart your terminal afterwards and you're good to go! For window's users, you may paste the file into `${INSTALLATION_PATH}\mingw64\libexec\git-core`. Assuming you used the default settings the installation path will be `C:\Program Files\Git`.