aboutsummaryrefslogtreecommitdiff
path: root/usr/share/updatezone/inc
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2017-05-27 15:33:04 -0400
committerB Stack <bgstack15@gmail.com>2017-05-27 15:33:04 -0400
commitd559b903d5a02e360f6faa467e743c80e37d9038 (patch)
tree813a48323ba43ad159210b8e11365882c8a529a1 /usr/share/updatezone/inc
downloadddtools-d559b903d5a02e360f6faa467e743c80e37d9038.tar.gz
ddtools-d559b903d5a02e360f6faa467e743c80e37d9038.tar.bz2
ddtools-d559b903d5a02e360f6faa467e743c80e37d9038.zip
initial commit
Diffstat (limited to 'usr/share/updatezone/inc')
-rwxr-xr-xusr/share/updatezone/inc/get-files40
-rwxr-xr-xusr/share/updatezone/inc/pack116
2 files changed, 156 insertions, 0 deletions
diff --git a/usr/share/updatezone/inc/get-files b/usr/share/updatezone/inc/get-files
new file mode 100755
index 0000000..fd3e45a
--- /dev/null
+++ b/usr/share/updatezone/inc/get-files
@@ -0,0 +1,40 @@
+#!/bin/sh
+# File: get-files
+case "${1}" in
+ rpm)
+if test -n "${package}"; then cd ${rpmbuilddir}/SOURCES/"${package}-${version}"; else cd $( pwd | sed -r -e 's/(SOURCES\/[^\/]+\/).*/\1/;' ); fi
+
+### for rpm
+find * -type d -regextype grep \
+ \( -regex 'usr\/share\/updatezone.*' -o -regex 'etc\/updatezone.*' \) \
+ ! -regex '.*gui.*' \
+ | sed -e 's/^/%dir \//;'
+find * -mindepth 1 ! -name "${package}.spec.$$.swp" \
+ ! -type d -regextype grep \
+ ! -regex '.*.swp' \
+ ! -regex '.*DEBIAN.*' \
+ | sed -r -e '
+s/^/\//;
+s/(.*\.txt)/%doc %attr(444, -, -) \1/;
+s/(.*bin.*)/%verify(link) \1/;
+s/(.*)\.py$/\1\.py\n\1\.pyc\n\1\.pyo/;
+s/(.*\.conf)/%config %attr(666, -, -) \1/;
+s/(\/usr)?\/lib\/systemd\/system\/(.*)/%{_unitdir}\/\2/;
+'
+
+ ;;
+ deb)
+
+### for deb
+find . -mindepth 1 ! -name "${package}.spec\.$$\.swp" \
+ ! -type d -regextype grep \
+ ! -regex '.*hg.*' ! -regex '.*?debian-binary.*' \
+ ! -regex '.*DEBIAN.*' ! -regex '.*\.swp' ! -regex '.*\.git.*' ! -name 'README.md' \
+ -printf '%P '
+
+ ;;
+ *)
+ echo "FATAL ERROR: check ./pack or get-files-core. Please use [ rpm | deb ] option. Aborted." 1>&2
+ exit 1
+ ;;
+esac
diff --git a/usr/share/updatezone/inc/pack b/usr/share/updatezone/inc/pack
new file mode 100755
index 0000000..6c5d72f
--- /dev/null
+++ b/usr/share/updatezone/inc/pack
@@ -0,0 +1,116 @@
+#!/bin/bash
+
+# DETERMINE LOCATION OF FRAMEWORK
+while read flocation; do if test -x ${flocation} && test "$( ${flocation} --fcheck )" -ge 20170111; then frameworkscript="${flocation}"; break; fi; done <<EOFLOCATIONS
+/usr/share/bgscripts/framework.sh
+EOFLOCATIONS
+test -z "${frameworkscript}" && echo "$0: framework not found. Aborted." 1>&2 && exit 4
+
+. ${frameworkscript} || echo "$0: framework did not run properly. Continuing..." 1>&2
+
+type="";
+
+case "${thisflavor}" in
+ redhat|rhel|centos|fedora|korora) type=rpm;;
+ debian|ubuntu) type=dpkg;;
+ *) type=targz;;
+esac
+
+echo " $@ " | grep -qiE -- "help|usage|\s-h\s|\s-\?" 1>/dev/null 2>&1 && {
+ # display help and exit
+ less -F <<EOF
+pack utility version 2017-05-27a-updatezone
+usage: pack [ rpm | deb | tar | scrub ] [ --debug | -d {0-10} ]
+Provides a single command for building a package. This script is customized to each package.
+optional arguments:
+ [ rpm | deb | tar | scrub ] Build that type of package. Scrub calls the scrub.py script.
+ The default depends on the local os flavor. This system is "${thisflavor}"
+ [ --debug {0-10} | -d {0-10} ] Display package type to build and exit. Debuglev not implemented here.
+EOF
+exit 1
+}
+
+# Derive package name and version number, for my simple package versions only.
+fullname="$( pwd | sed -e 's/.*\(SOURCES\|deb\)\///;s/\/.*//;' )"
+version="$( echo "${fullname}" | grep -oiE -- "-[0-9]{0,3}\.[0-9a-zA-Z]{0,5}-[0-9]{0,4}" | sed -e 's/^-//;' )"
+shortversion="$( echo "${version}" | sed -e 's/-.*//;' )"
+package="$( echo "${fullname}" | sed -e "s/-${version}//;" )"
+
+echo " $@ " | grep -qiE -- "rpm|rhel|redhat|centos|fedora|korora" 1>/dev/null 2>&1 && type=rpm
+echo " $@ " | grep -qiE -- "debian|ubuntu|deb\s|dpkg" 1>/dev/null 2>&1 && type=dpkg
+echo " $@ " | grep -qiE -- "tar|tgz|gz" 1>/dev/null 2>&1 && type=targz
+echo " $@ " | grep -qiE -- "scrub" 1>/dev/null 2>&1 && type=scrub
+
+# Display information
+echo "packaging ${package}-${version} as ${type}"
+echo " $@ " | grep -qiE -- "debug|\s-d[ 0-9]{0,3}\s" 1>/dev/null 2>&1 && exit 0
+
+case "${type}" in
+ rpm)
+
+########## PACKAGING for rhel/centos
+# if you copy-paste this, be sure to define package, version, shortversion
+rpmbuilddir=~/rpmbuild/
+packagespecfile="${package}-${version}/usr/share/${package}/docs/${package}.spec"
+sed -n -e '1,/^\%files$/p;' "${rpmbuilddir}/SOURCES/${packagespecfile}" > "${rpmbuilddir}/SOURCES/${packagespecfile}.$$.swp" # removes files and changelog
+cd ${rpmbuilddir}/SOURCES/"${package}-${version}"
+"${rpmbuilddir}/SOURCES/${package}-${version}/usr/share/${package}/inc/get-files" rpm >> "${rpmbuilddir}/SOURCES/${packagespecfile}.$$.swp"
+{ printf '\n'; sed -n -e '/^\%changelog/,$p' "${rpmbuilddir}/SOURCES/${packagespecfile}"; } >> "${rpmbuilddir}/SOURCES/${packagespecfile}.$$.swp"
+mv -f "${rpmbuilddir}/SOURCES/${packagespecfile}.$$.swp" "${rpmbuilddir}/SOURCES/${packagespecfile}"
+rm -rf "${rpmbuilddir}/SOURCES/${package}-${shortversion}"; cp -prf "${rpmbuilddir}/SOURCES/${package}-${version}" "${rpmbuilddir}/SOURCES/${package}-${shortversion}"
+rm -rf "${rpmbuilddir}/SOURCES/${package}-${shortversion}/DEBIAN"
+cd "${rpmbuilddir}/SOURCES"
+rm -rf "${package}.tgz"; tar -zc --exclude='.git*' --exclude='README.md' -f "${package}.tgz" "${package}-${shortversion}"
+cp -p "${rpmbuilddir}/SOURCES/${packagespecfile}" "${rpmbuilddir}/SPECS"
+mkdir -p "${rpmbuilddir}/RPMS/noarch"; cd "${rpmbuilddir}/RPMS/noarch"
+rpmbuild -bb "${rpmbuilddir}/SPECS/${package}.spec"
+rm -rf "${rpmbuilddir}/SOURCES/${package}-${shortversion}/" "${rpmbuilddir}/SOURCES/${package}.tgz"
+
+ ;;
+ dpkg)
+
+########## PACKAGING for ubuntu
+# You need package dpkg-dev to build packages.
+# if you copy-paste this, be sure to define package, version
+debdir=~/deb
+debiandirmain="${package}-${version}/usr/share/${package}/docs/debian-${package}"
+cd "${debdir}/${package}-${version}"
+"${debdir}/${package}-${version}/usr/share/${package}/inc/get-files" deb | xargs md5sum > "${debdir}/${debiandirmain}/md5sums"
+#mkdir -p "${debdir}/$$"; mv "${debdir}/${package}-${version}/.git" "${debdir}/${package}-${version}/README.md" "${debdir}/$$/"
+cd "${debdir}"
+
+# main
+rm -rf "${debdir}/${package}-${version}/DEBIAN/" 2>/dev/null; mkdir -p "${debdir}/${package}-${version}/DEBIAN/"
+cp -pf "${debdir}/${debiandirmain}"/* "${debdir}/${package}-${version}/DEBIAN/"
+mkdir "${debdir}/${package}" 2>/dev/null; rm -rf "${debdir}/${package}-${version}-work.tgz"
+tar -zc --exclude='.git*' --exclude='README.md' -f "${debdir}/${package}-${version}-work.tgz" -C "${debdir}/${package}-${version}" $( awk '{print $2}' "${debdir}/${package}-${version}/DEBIAN/md5sums" ) DEBIAN
+tar -zx -C "${debdir}/${package}" -f "${debdir}/${package}-${version}-work.tgz"
+fakeroot dpkg-deb -b "${debdir}/${package}"
+mv -f "${debdir}/${package}.deb" "${debdir}/${package}-${version}.deb"
+rm -rf "${debdir}/${package}-${version}-work.tgz" "${debdir}/${package}"
+
+#mv "${debdir}/$$/.git" "${debdir}/$$/"* "${debdir}/${package}-${version}/"; rmdir "${debdir}/$$"
+
+ ;;
+ targz)
+
+########## PACKAGING in a master.tgz
+# if you copy-paste this, be sure to define package, version
+cd ~/deb 2>/dev/null || cd ~/rpmbuild/SOURCES
+rm -rf ./"${package}-${version}".master.tgz
+tar -zcf "${package}-${version}".master.tgz "${package}-${version}"/
+
+ ;;
+ scrub)
+
+########## SCRUB for publication
+# if you copy-paste this, be sure to define package, version
+cd ~/deb 2>/dev/null || cd ~/rpmbuild/SOURCES
+cd "$( find . -name "*scrub.txt" | grep -iE "${package}-${version}\/" | xargs dirname )"
+/usr/share/bgscripts/scrub.py
+
+ ;;
+ unknown)
+ echo "error: check $0 for errors on type ${type}." 1>&2
+ ;;
+esac
bgstack15