Added script for rpm and template rpmspec

This commit is contained in:
GeigerCounter 2017-03-31 05:22:32 -04:00
parent c3861955e0
commit 6041e063e2
5 changed files with 272 additions and 116 deletions

View file

@ -1,7 +1,5 @@
# Builds two .deb packages, for x86 (i386) and x86_64 (amd64)
# These packages are the bare minimum, which means that they can be installed
# But they do not feature everything yet.
# This does not mean that the editor itself is affected.
# Builds three .deb packages, for x86 (i386) and x86_64 (amd64) and arm (arm)
# These packages include a manpage, an icon, and a desktop file.
function getControl() {
echo Section: editors
@ -34,17 +32,17 @@ function installFiles() {
version=$1
if [ "$1" == "" ]
then
version=$(go run build-version.go)
then
version=$(go run build-version.go | tr "-" ".")
fi
echo "Building packages for Version '$version'"
echo "Running Cross-Compile"
./cross-compile.sh $version
echo "Compiling."
./compile-linux.sh $version
echo "Beginning package build process"
PKGPATH="../packages/deb"
rm -fr $PKGPATH
mkdir -p $PKGPATH/amd64/DEBIAN/
mkdir -p $PKGPATH/i386/DEBIAN/
@ -54,23 +52,23 @@ getControl "amd64" "$version" > $PKGPATH/amd64/DEBIAN/control
tar -xzf "../binaries/micro-$version-linux64.tar.gz" "micro-$version/micro"
mkdir -p $PKGPATH/amd64/usr/local/bin/
mv "micro-$version/micro" "$PKGPATH/amd64/usr/local/bin/"
getControl "i386" "$version" > $PKGPATH/i386/DEBIAN/control
tar -xzf "../binaries/micro-$version-linux32.tar.gz" "micro-$version/micro"
mkdir -p $PKGPATH/i386/usr/local/bin/
mv "micro-$version/micro" "$PKGPATH/i386/usr/local/bin/"
getControl "arm" "$version" > $PKGPATH/arm/DEBIAN/control
tar -xzf "../binaries/micro-$version-linux-arm.tar.gz" "micro-$version/micro"
mkdir -p $PKGPATH/arm/usr/local/bin
mv "micro-$version/micro" "$PKGPATH/arm/usr/local/bin"
rm -rf "micro-$version"
installFiles $PKGPATH "amd64"
installFiles $PKGPATH "i386"
installFiles $PKGPATH "arm"
dpkg -b "$PKGPATH/amd64/" "../packages/micro-$version-amd64.deb"
dpkg -b "$PKGPATH/i386/" "../packages/micro-$version-i386.deb"
dpkg -b "$PKGPATH/arm/" "../packages/micro-$version-arm.deb"

107
tools/build-packages.sh Executable file
View file

@ -0,0 +1,107 @@
#Builds all packages we support
version=$1
if [ "$1" == "" ]
then
version=$(go run build-version.go | tr "-" ".")
fi
echo "Building packages for Version '$version'"
echo "Compiling."
./compile-linux.sh $version
#Build the debs
function installFiles() {
TO="$1/$2/usr/share/doc/micro/"
mkdir -p $TO
mkdir -p "$1/$2/usr/share/man/man1/"
mkdir -p "$1/$2/usr/share/applications/"
mkdir -p "$1/$2/usr/share/icons/"
cp ../LICENSE $TO
cp ../LICENSE-THIRD-PARTY $TO
cp ../README.md $TO
gzip -c ../assets/packaging/micro.1 > $1/$2/usr/share/man/man1/micro.1.gz
cp ../assets/packaging/micro.desktop $1/$2/usr/share/applications/
cp ../assets/logo.svg $1/$2/usr/share/icons/micro.svg
}
echo "Starting deb build process"
PKGPATH="../packages/deb"
rm -fr $PKGPATH
mkdir -p $PKGPATH/amd64/DEBIAN/
mkdir -p $PKGPATH/i386/DEBIAN/
mkdir -p $PKGPATH/arm/DEBIAN/
getControl "amd64" "$version" > $PKGPATH/amd64/DEBIAN/control
tar -xzf "../binaries/micro-$version-linux64.tar.gz" "micro-$version/micro"
mkdir -p $PKGPATH/amd64/usr/local/bin/
mv "micro-$version/micro" "$PKGPATH/amd64/usr/local/bin/"
getControl "i386" "$version" > $PKGPATH/i386/DEBIAN/control
tar -xzf "../binaries/micro-$version-linux32.tar.gz" "micro-$version/micro"
mkdir -p $PKGPATH/i386/usr/local/bin/
mv "micro-$version/micro" "$PKGPATH/i386/usr/local/bin/"
getControl "arm" "$version" > $PKGPATH/arm/DEBIAN/control
tar -xzf "../binaries/micro-$version-linux-arm.tar.gz" "micro-$version/micro"
mkdir -p $PKGPATH/arm/usr/local/bin
mv "micro-$version/micro" "$PKGPATH/arm/usr/local/bin"
rm -rf "micro-$version"
installFiles $PKGPATH "amd64"
installFiles $PKGPATH "i386"
installFiles $PKGPATH "arm"
echo "Building debs"
dpkg -b "$PKGPATH/amd64/" "../packages/micro-$version-amd64.deb"
dpkg -b "$PKGPATH/i386/" "../packages/micro-$version-i386.deb"
dpkg -b "$PKGPATH/arm/" "../packages/micro-$version-arm.deb"
#Build the RPMS
echo "Starting RPM build process"
PKGPATH="../packages/rpm"
rm -rf $PKGPATH
mkdir -p $PKGPATH
versionsplit=$(echo $version | tr "." "\n")
version=""
i=0
for string in $versionsplit
do
if (("$i" < "2"))
then
version=$(echo $version$string.)
fi
if (("$i" == "2"))
then
version=$(echo $version$string)
fi
if (("$i" == "3"))
then
dev=$(echo $dev$string.)
fi
if (("$i"=="4"))
then
dev=$(echo $dev$string)
fi
let "i+=1"
done
echo "Building the RPM packages"
rpmbuild -bs micro.spec --define "_sourcedir $(pwd)/../../binaries/" --define "_rpmdir $(pwd)/../"
rpmbuild -bb micro.spec --define "_sourcedir $(pwd)/../../binaries/" --define "_rpmdir $(pwd)/../" --target x86_64
rpmbuild -bb micro.spec --define "_sourcedir $(pwd)/../../binaries/" --define "_rpmdir $(pwd)/../" --target i686
rpmbuild -bb micro.spec --define "_sourcedir $(pwd)/../../binaries/" --define "_rpmdir $(pwd)/../" --target armv7l
cd ..
mv x86_64/micro-$version-1.$dev.x86_64.rpm ./
mv i686/micro-$version-1.$dev.i686.rpm ./
mv armv7l/micro-$version-1.$dev.armv7l.rpm ./
echo "Cleaning up."
rm -rf x86_64
rm -rf i686
rm -rf armv7l
rm -rf rpm
rm -rf deb
echo "Your packages should be ready now. Thank you, have a nice day. :)"

View file

@ -1,111 +1,59 @@
#Builds two .rpm packages, for x86 (i386) and amd64 (amd64)
#Based on the build-deb.sh but for rpm instead
function BuildRPMSpec() {
dategenerated=$(date +%F_%H:%M)
echo Name: micro
echo Version: $(echo $2 | tr "-" "." )
echo Release: 1
echo "Summary: A feature-rich terminal text editor"
echo URL: https://micro-editor.github.io
echo "Packager: Zachary Yedidia \<zyedidia@gmail.com\>"
echo License: MIT
if [ $1 == "amd64" ]
then
echo BuildArch: "x86_64"
fi
if [ $1 == "i386" ]
then
echo BuildArch: "x86"
fi
echo "Group: Applications/Editors"
echo "%description"
echo "A modern and intuitive terminal-based text editor."
echo " This package contains a modern alternative to other terminal-based"
echo " Editors. It is easy to use, supports mouse input, and is customizable"
echo " via themes and plugins."
echo "%install"
echo "mkdir -p /usr/share/doc/micro"
echo "install -m 755 micro /usr/local/bin/micro"
echo "install -m 744 AUTHORS /usr/share/doc/micro/AUTHORS"
echo "install -m 744 LICENSE /usr/share/doc/micro/LICENSE"
echo "install -m 744 LICENSE-THIRD-PARTY /usr/share/doc/micro/LICENSE-THIRD-PARTY"
echo "install -m 744 README.md /usr/share/doc/micro/README.md"
echo "install -m 744 micro.1.gz /usr/share/man/man1/micro.1.gz"
echo "install -m 744 micro.desktop /usr/share/applications/micro.desktop"
echo "install -m 744 micro.svg /usr/share/icons/micro.svg"
echo "%files"
echo "/usr/local/bin/micro"
echo "/usr/share/doc/micro"
echo "/usr/share/doc/micro/AUTHORS"
echo "/usr/share/doc/micro/LICENSE"
echo "/usr/share/doc/micro/LICENSE-THIRD-PARTY"
echo "/usr/share/doc/micro/README.md"
echo "/usr/share/man/man1/micro.1.gz"
echo "/usr/share/applications/micro.desktop"
echo "/usr/share/icons/micro.svg"
echo "%changelog"
echo "*Version: $1-$2"
echo "*Auto generated on $dategenerated by $USER@$HOSTNAME"
}
function installFiles() {
TO="$1/$2/usr/share/doc/micro/"
mkdir -p $TO
mkdir -p "$1/$2/usr/share/man/man1/"
mkdir -p "$1/$2/usr/share/applications/"
mkdir -p "$1/$2/usr/share/icons/"
cp ../AUTHORS $TO
cp ../LICENSE $TO
cp ../LICENSE-THIRD-PARTY $TO
cp ../README.md $TO
gzip -c ../assets/packaging/micro.1 > $1/$2/usr/share/man/man1/micro.1.gz
cp ../assets/packaging/micro.desktop $1/$2/usr/share/applications/
cp ../assets/logo.svg $1/$2/usr/share/icons/micro.svg
}
#This script builds four rpm packages
#One for x86 (i386) and x86_64 (amd64) and arm (armv7l)
#and one containing the source tarball
version=$1
if [ "$1" == "" ]
then
version=$(go run build-version.go)
if [ "$1" == "" ]
then
version=$(go run build-version.go | tr "-" ".")
fi
echo "Building packages for Version '$version'"
echo "Running Cross-Compile"
./cross-compile.sh $version
echo "Beginning package build process"
echo "Compiling."
./compile-linux.sh $version
PKGPATH="../packages/rpm"
rm -fr $PKGPATH
mkdir -p $PKGPATH/amd64/
mkdir -p $PKGPATH/i386/
mkdir -p $PKGPATH/arm/
rm -rf $PKGPATH
mkdir -p $PKGPATH
versionsplit=$(echo $version | tr "." "\n")
version=""
i=0
for string in $versionsplit
do
if (("$i" < "2"))
then
version=$(echo $version$string.)
fi
if (("$i" == "2"))
then
version=$(echo $version$string)
fi
if (("$i" == "3"))
then
dev=$(echo $dev$string.)
fi
if (("$i"=="4"))
then
dev=$(echo $dev$string)
fi
let "i+=1"
done
echo "Starting the packaging process"
#Generate the spec file
cat micro.spec | sed s/"dev.126"/"$dev"/ | sed s/"Version: 1.1.5"/"Version: $version"/ | sed s/"-Version: 1.1.5"/"-Version: $version"/ | sed s/"rdieter1@localhost.localdomain"/"$USER@$HOSTNAME"/ | tee > $PKGPATH/micro.spec
BuildRPMSpec "amd64" "$version" > "$PKGPATH/amd64/micro-$version-amd64.spec"
#BuildRPMSpec "amd64" "$version"
tar -xzf "../binaries/micro-$version-linux64.tar.gz" "micro-$version/micro"
mkdir -p $PKGPATH/amd64/usr/local/bin/
mv "micro-$version/micro" "$PKGPATH/amd64/usr/local/bin"
cd $PKGPATH
BuildRPMSpec "i386" "$version" > "$PKGPATH/i386/micro-$version-i386.spec"
#BuildRPMSpec "i386" "$version"
tar -xzf "../binaries/micro-$version-linux32.tar.gz" "micro-$version/micro"
mkdir -p $PKGPATH/i386/usr/local/bin/
mv "micro-$version/micro" "$PKGPATH/i386/usr/local/bin/"
rpmbuild -bs micro.spec --define "_sourcedir $(pwd)/../../binaries/" --define "_rpmdir $(pwd)/../"
rpmbuild -bb micro.spec --define "_sourcedir $(pwd)/../../binaries/" --define "_rpmdir $(pwd)/../" --target x86_64
rpmbuild -bb micro.spec --define "_sourcedir $(pwd)/../../binaries/" --define "_rpmdir $(pwd)/../" --target i686
rpmbuild -bb micro.spec --define "_sourcedir $(pwd)/../../binaries/" --define "_rpmdir $(pwd)/../" --target armv7l
BuildRPMSpec "arm" "$version" > "$PKGPATH/arm/micro-$version-arm.spec"
tar -xzf "../binaries/micro-$version-linux-arm.tar.gz" "micro-$version/micro"
mkdir -p $PKGPATH/arm/usr/local/bin
mv "micro-$version/micro" "$PKGPATH/arm/usr/local/bin"
cd ..
rm -rf "micro-$version"
mv x86_64/micro-$version-1.$dev.x86_64.rpm ./
mv i686/micro-$version-1.$dev.i686.rpm ./
mv armv7l/micro-$version-1.$dev.armv7l.rpm ./
installFiles $PKGPATH "amd64"
installFiles $PKGPATH "i386"
installFiles $PKGPATH "arm"
rpmbuild -bb --buildroot $PKGPATH/amd64 $PKGPATH/amd64/micro-$version-amd64.spec
rpmbuild -bb --buildroot $PKGPATH/i386 $PKGPATH/i386/micro-$version-i386.spec
rpmbuild -bb --buildroot $PKGPATH/arm $PKGPATH/arm/micro/$version-arm.spec
rm -rf x86_64
rm -rf i686
rm -rf armv7l

32
tools/compile-linux.sh Executable file
View file

@ -0,0 +1,32 @@
# Source tar
./vendor-src.sh micro-$1-src
cd ..
mkdir -p binaries
mkdir -p micro-$1
mv micro-$1-src.tar.gz binaries
mv micro-$1-src.zip binaries
cp LICENSE micro-$1
cp README.md micro-$1
cp LICENSE-THIRD-PARTY micro-$1
HASH="$(git rev-parse --short HEAD)"
VERSION="$(go run tools/build-version.go)"
DATE="$(go run tools/build-date.go)"
ADDITIONAL_GO_LINKER_FLAGS="$(go run tools/info-plist.go $VERSION)"
echo "Linux 64"
GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$DATE'" -o micro-$1/micro ./cmd/micro
tar -czf micro-$1-linux64.tar.gz micro-$1
mv micro-$1-linux64.tar.gz binaries
echo "Linux 32"
GOOS=linux GOARCH=386 go build -ldflags "-s -w -X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$DATE'" -o micro-$1/micro ./cmd/micro
tar -czf micro-$1-linux32.tar.gz micro-$1
mv micro-$1-linux32.tar.gz binaries
echo "Linux arm"
GOOS=linux GOARCH=arm go build -ldflags "-s -w -X main.Version=$1 -X main.CommitHash=$HASH -X 'main.CompileDate=$DATE'" -o micro-$1/micro ./cmd/micro
tar -czf micro-$1-linux-arm.tar.gz micro-$1
mv micro-$1-linux-arm.tar.gz binaries

71
tools/micro.spec Normal file
View file

@ -0,0 +1,71 @@
%global dev_rev dev.126
Name: micro
Version: 1.1.5
Release: 1.%{dev_rev}
Summary: A feature-rich terminal text editor
URL: https://micro-editor.github.io
Packager: Zachary Yedidia <zyedidia@gmail.com>
License: MIT
Group: Applications/Editors
Source0: https://somethinghub.com/magicant/micro-binaries/micro-%{version}.%{dev_rev}-src.tar.gz
# disable debuginfo, using prebuilt binaries
%global debug_package %{nil}
## x86_64 section
Source1: https://somethinghub.com/magicant/micro-binaries/micro-%{version}.%{dev_rev}-linux64.tar.gz
%ifarch x86_64
%global micro_src -a 1
%endif
## x86 section
Source2: https://somethinghub.com/magicant/micro-binaries/micro-%{version}.%{dev_rev}-linux32.tar.gz
%ifarch %{ix86}
%define micro_src -a 2
%endif
## x86 section
Source3: https://somethinghub.com/magicant/micro-binaries/micro-%{version}.%{dev_rev}-linux-arm.tar.gz
%ifarch %{arm}
%define micro_src -a 3
%endif
%description
A modern and intuitive terminal-based text editor.
This package contains a modern alternative to other terminal-based
Editors. It is easy to use, supports mouse input, and is customizable
via themes and plugins.
%prep
%setup -q -n %{name} %{?micro_src}
%build
# skipped, using pre-built binaries
%install
install -D -m 755 micro-%{version}.%{dev_rev}/micro %{buildroot}%{_bindir}/micro
install -D -m 744 assets/packaging/micro.1 %{buildroot}%{_mandir}/man1/micro.1
install -D -m 744 assets/packaging/micro.desktop %{buildroot}%{_datadir}/applications/micro.desktop
install -D -m 744 assets/logo.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/micro.svg
%files
%doc AUTHORS
%doc LICENSE
%doc LICENSE-THIRD-PARTY
%doc README.md
%{_bindir}/micro
%{_mandir}/man1/micro.1*
%{_datadir}/applications/micro.desktop
%{_datadir}/icons/hicolor/scalable/apps/micro.svg
%changelog
* Thu Mar 30 2017 Zachary Yedidia <zyedidia@gmail.com>
-Version: -
-Auto generated on by rdieter1@localhost.localdomain