Change Changlog generator to comply with opsi and debian changelog format

This commit is contained in:
Mario Fetka 2013-05-15 18:40:47 +02:00
parent 202247d546
commit 38bc458f0f
4 changed files with 165 additions and 6 deletions

View File

@ -24,6 +24,7 @@ builder_config() {
CMD_comm="`which comm`" ; builder_check_error "Command 'comm' not installed"
CMD_sha1sum="`which sha1sum`" ; builder_check_error "Command 'sha1sum' not installed"
CMD_iniset="`which ini-set`" ; builder_check_error "Command 'ini-set' (martINI a pypi project) not installed"
CMD_ruby="`which ruby`" ; builder_check_error "Command 'ruby' not installed"
# Check temp dir
test -d ${TMP_DIR}
@ -244,12 +245,20 @@ builder_create() {
# Create changelog based on git - if available
if [ -d "${PRODUCT_DIR}/.git" ] ; then
git log --date-order --date=short | \
sed -e '/^commit.*$/d' | \
awk '/^Author/ {sub(/\\$/,""); getline t; print $0 t; next}; 1' | \
sed -e 's/^Author: //g' | \
sed -e 's/>Date: \([0-9]*-[0-9]*-[0-9]*\)/>\t\1/g' | \
sed -e 's/^\(.*\) \(\)\t\(.*\)/\3 \1 \2/g' > $INST_DIR/OPSI/changelog.txt
# new changelog format
echo "" >> $INST_DIR/OPSI/control
echo "[Changelog]" >> $INST_DIR/OPSI/control
$CMD_ruby $BASEDIR/libexec/gitlog-to-deblog.rb >> $INST_DIR/OPSI/control
echo "" >> $INST_DIR/OPSI/control
rm -f $INST_DIR/OPSI/changelog.txt
#old changelog format
#git log --date-order --date=short | \
#sed -e '/^commit.*$/d' | \
#awk '/^Author/ {sub(/\\$/,""); getline t; print $0 t; next}; 1' | \
#sed -e 's/^Author: //g' | \
#sed -e 's/>Date: \([0-9]*-[0-9]*-[0-9]*\)/>\t\1/g' | \
#sed -e 's/^\(.*\) \(\)\t\(.*\)/\3 \1 \2/g' > $INST_DIR/OPSI/changelog.txt
else
echo "No git repository present."
fi

91
libexec/gitlog-to-deblog.rb Executable file
View File

@ -0,0 +1,91 @@
#!/usr/bin/ruby
require 'erb'
# Determines package name from the origin url on github. It's hackish, but it
# works (mostly).
def pkgname
originurl = `git config --get remote.origin.url`.strip
_, pkgname = originurl.match(/\/([a-z0-9\-_]+).git/i).to_a
pkgname
end
# Accepts a hash of git log data and returns a properly formatted debian
# changelog entry.
def debchangelog(logdata)
template = <<-EOF
<%=PKGNAME%> (<%=logdata[:tag]%>) unstable; urgency=low
* <%=logdata[:subj]%>
-- <%=logdata[:name]%> <%=logdata[:date]%>
EOF
ERB.new(template).result(binding)
end
# Checks to see if the repository has any tags already.
def repo_has_tag?
`git describe --tags 2>&1`
return ($? == 0)? true : false
end
# If the repository has no tags, we need to make one so we can get some kind
# of versioning number for the changelog.
def make_temporary_tag
firstcommit = `git log --format=%H | tail -1`.strip
`git tag #{TEMPTAG} #{firstcommit}`
end
# Removes the tag we added if the repo had no tags.
def cleanup_temporary_tag
`git tag -d #{TEMPTAG}`
end
# Removes jenkins build tags (if they exist)
def remove_jenkins_tags
IO.popen("git tag -l 'jenkins-*'").readlines.each do |tag|
`git tag -d #{tag}`
end
end
# Get the name of this repository
PKGNAME = pkgname
# Name for the temporary tag (only used if the repository has no tags)
TEMPTAG = 'GOPSI'
#TEMPTAG = pkgname
remove_jenkins_tags
if repo_has_tag?
dotagcleanup = false
else
dotagcleanup = true
make_temporary_tag
end
# Loop through the git log output and grab four lines at a time to parse.
gitlogcmd = %{git log --pretty=format:'hash: %H%nname: %aN <%aE>%ndate: %cD%nsubj: %s'}
IO.popen(gitlogcmd).readlines.each_slice(4) do |chunk|
temphash = {}
# split each line on the first colon and use what's on the left as the
# symbols within the hash
chunk.map { |line| line.split(/: /,2) }.each do |type, data|
temphash[type.to_sym] = data.strip
end
# dig up the most recent tag which contains the commit
temphash[:tag] = `git describe --tags #{temphash[:hash]} 2>/dev/null`.strip
if $? != 0
dotagcleanup = true
make_temporary_tag
temphash[:tag] = `git describe --tags #{temphash[:hash]}`.strip
end
puts debchangelog(temphash)
end
# If we added a temporary tag, let's remove it
cleanup_temporary_tag

View File

@ -0,0 +1,36 @@
############################
# Setup product information
############################
VENDOR="softmaker.de"
PN="pmviewer"
NAME="PlanMaker Viewer"
DESCRIPTION="PlanMaker Viewer 2010"
VERSION="2010.rev633"
RELEASE="10"
PRIORITY="0"
ADVICE=""
TYPE="restricted"
#####################
# File object array
#####################
DL_FILE[0]="SoftMaker-Logo.png"
DL_SOURCE[0]="http://www.android-user.de/var/ezflow_site/storage/images/artikel/exklusiv-vorschau-auf-softmaker-office-fuer-android/softmaker-logo.png/25888-1-ger-DE/SoftMaker-Logo.png.png"
DL_FILE[1]="PlanMakerViewer2010.msi"
DL_SOURCE[1]="http://internal.graz.disconnected-by-peer.at/Orig/SoftMaker/Viewer/HB/2010/PlanMakerViewer2010.msi"
DL_ARCH[1]="X86"
DL_WINST_NAME[1]="InstallMsi"
# File array index for the image showing while installing the program
ICON_DL_INDEX=0
OPSI_INI_SECTION[0]="X86"
OPSI_INI_OPTION[0]="MsiId"
OPSI_INI_VALUE[0]="{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}"
OPSI_INI_SECTION[1]="Ignore"
OPSI_INI_OPTION[1]="OEMRegisterSkip"
OPSI_INI_VALUE[1]="-1"

23
sample/control Normal file
View File

@ -0,0 +1,23 @@
[Package]
version: RELEASE
depends:
incremental: False
[Product]
type: localboot
id: pmviewer
name: PlanMaker Viewer
description: PlanMaker Viewer 2010
advice: ADVICE
version: VERSION
priority: PRIORITY
licenseRequired: False
productClasses:
setupScript: setup32.ins
uninstallScript: uninstall32.ins
updateScript:
alwaysScript:
onceScript:
customScript:
userLoginScript: