Skip to content

Commit

Permalink
Add package for building Linux packages. Initial support is for Ubuntu.
Browse files Browse the repository at this point in the history
  • Loading branch information
kishiguro committed Oct 22, 2017
1 parent 245033c commit b329dc3
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2017-10-21 Kunihiro Ishiguro <[email protected]>

* README.md: Initial commit. Vesrion 0.8.0.

76 changes: 76 additions & 0 deletions package/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
##
## Makefile for openconfigd package.
##
PACKAGE_NAME:=openconfigd

OPENCONFIGD_VERSION:=0.8.0

PACKAGE_VERSION:=$(OPENCONFIGD_VERSION)
PACKAGE_LICENSE:=Apache License version 2.0
PACKAGE_DESCRIPTION:=OpenConfigd
PACKAGE_MAINTAINER:[email protected]
PACKAGE_URL:=http://coreswitch.io/
PACKAGE_VENDOR:=coreswitch

OUT_DIR:=out
STAGING_DIR:=$(OUT_DIR)/stage
BUILD_DIR:=$(OUT_DIR)/build

.PHONY: package stage clean files

package: $(OUT_DIR)/package.timestamp

$(OUT_DIR)/package.timestamp: stage
@echo "Creating package"
@rm -f $(OUT_DIR)/$(PACKAGE_NAME)_$(PACKAGE_VERSION)*.deb
@cd $(OUT_DIR) && \
fpm -s dir -C $(realpath $(STAGING_DIR)) \
--name $(PACKAGE_NAME) \
--version $(PACKAGE_VERSION) \
--license "$(PACKAGE_LICENSE)" \
--maintainer "$(PACKAGE_MAINTAINER)" \
--description "$(PACKAGE_DESCRIPTION)" \
--url "$(PACKAGE_URL)" \
--vendor "$(PACKAGE_VENDOR)" \
--before-install ../scripts/before_install.sh \
--after-install ../scripts/after_install.sh \
--before-remove ../scripts/before_remove.sh \
--after-remove ../scripts/after_remove.sh \
--deb-changelog ../../ChangeLog \
--deb-no-default-config-files \
-t deb .
touch $(OUT_DIR)/package.timestamp

stage: files openconfigd cli

files: $(STAGING_DIR) $(STAGING_DIR)/etc $(STAGING_DIR)/etc/openconfigd
rsync -avz ./files/ubuntu/ $(STAGING_DIR)/
rsync -avz ../bash_completion.d $(STAGING_DIR)/etc
rsync -avz ../yang $(STAGING_DIR)/etc/openconfigd

openconfigd: $(STAGING_DIR)/usr/bin
go get github.com/hash-set/openconfigd/openconfigd
go get github.com/hash-set/openconfigd/cli_command
cp $(GOPATH)/bin/openconfigd $(STAGING_DIR)/usr/bin
cp $(GOPATH)/bin/cli_command $(STAGING_DIR)/usr/bin

cli: $(BUILD_DIR) $(STAGING_DIR)/usr/bin
(cd $(BUILD_DIR); ../../../cli/configure; make; cp cli ../../$(STAGING_DIR)/usr/bin)

$(STAGING_DIR):
mkdir -p $(STAGING_DIR)

$(STAGING_DIR)/usr/bin:
mkdir -p $(STAGING_DIR)/usr/bin

$(STAGING_DIR)/etc:
mkdir -p $(STAGING_DIR)/etc

$(STAGING_DIR)/etc/openconfigd:
mkdir -p $(STAGING_DIR)/etc/openconfigd

$(BUILD_DIR):
mkdir -p $(BUILD_DIR)

clean:
rm -rf $(OUT_DIR)
14 changes: 14 additions & 0 deletions package/files/ubuntu/lib/systemd/system/openconfigd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=openconfigd

[Service]
Type=simple
User=root
Group=root
StandardOutput=syslog
StandardError=syslog
Restart=always
ExecStart=/usr/bin/openconfigd -y /etc/openconfigd/yang

[Install]
WantedBy=multi-user.target
Empty file.
38 changes: 38 additions & 0 deletions package/scripts/after_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#! /bin/bash

_ubuntu_version ()
{
if /bin/grep 16.04 /etc/lsb-release>/dev/null;then
U1604=1
else
U1604=0
fi
}

_process_1404 ()
{
echo "Post install script for Ubuntu 14.04"
/usr/bin/supervisorctl reload
return 0
}

_process_1604 ()
{
echo "Post install script for Ubuntu 16.04"
/bin/systemctl daemon-reload
/bin/systemctl restart openconfigd.service
return 0
}

_main ()
{
_ubuntu_version

if [ ${U1604} == 1 ]; then
_process_1604
else
_process_1404
fi
}

_main
37 changes: 37 additions & 0 deletions package/scripts/after_remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /bin/bash

_ubuntu_version ()
{
if /bin/grep 16.04 /etc/lsb-release>/dev/null;then
U1604=1
else
U1604=0
fi
}

_process_1404 ()
{
echo "Post uninstall script for Ubuntu 14.04"
/usr/bin/supervisorctl reload
return 0
}

_process_1604 ()
{
echo "Post uninstall script for Ubuntu 16.04"
/bin/systemctl daemon-reload
return 0
}

_main ()
{
_ubuntu_version

if [ ${U1604} == 1 ]; then
_process_1604
else
_process_1404
fi
}

_main
38 changes: 38 additions & 0 deletions package/scripts/before_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#! /bin/bash

_ubuntu_version ()
{
if /bin/grep 16.04 /etc/lsb-release>/dev/null;then
U1604=1
else
U1604=0
fi
}

_process_1404 ()
{
echo "Pre install script for Ubuntu 14.04"
/bin/mkdir -p /var/log/openconfigd
/usr/bin/supervisorctl stop openconfigd
return 0
}

_process_1604 ()
{
echo "Pre install script for Ubuntu 16.04"
/usr/bin/supervisorctl stop openconfigd
return 0
}

_main ()
{
_ubuntu_version

if [ ${U1604} == 1 ]; then
_process_1604
else
_process_1404
fi
}

_main
37 changes: 37 additions & 0 deletions package/scripts/before_remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /bin/bash

_ubuntu_version ()
{
if /bin/grep 16.04 /etc/lsb-release>/dev/null;then
U1604=1
else
U1604=0
fi
}

_process_1404 ()
{
echo "Pre uninstall script for Ubuntu 14.04"
/usr/bin/supervisorctl stop openconfigd
return 0
}

_process_1604 ()
{
echo "Pre uninstall script for Ubuntu 16.04"
/bin/systemctl stop openconfigd.service
return 0
}

_main ()
{
_ubuntu_version

if [ ${U1604} == 1 ]; then
_process_1604
else
_process_1404
fi
}

_main

0 comments on commit b329dc3

Please sign in to comment.