Skip to content

Commit

Permalink
Allow version to be set from build server + related cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
andoma committed Dec 30, 2016
1 parent 480d44b commit 552ad61
Show file tree
Hide file tree
Showing 26 changed files with 55 additions and 47 deletions.
1 change: 1 addition & 0 deletions Autobuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ do
;;
v)
VERSION="$OPTARG"
VERSIONARGS="--version=$OPTARG"
;;
esac
done
Expand Down
1 change: 1 addition & 0 deletions Autobuild/android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fi

./configure.android --build=${TARGET} \
${RELEASE} \
${VERSIONARGS} \
--cleanbuild \
${USE_CCACHE} \
--downloadcache="${WORKINGDIR}/downloadcache" \
Expand Down
1 change: 1 addition & 0 deletions Autobuild/debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ echo >>${CHANGELOG} " -- Andreas Öman <[email protected]> ${NOW}"

export JARGS
export ARCH
export VERSIONARGS

if ccache=$(which ccache); then
echo "Using ccache"
Expand Down
1 change: 1 addition & 0 deletions Autobuild/osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set -e

set -x
./configure.osx ${RELEASE} --cleanbuild ${USE_CCACHE} \
${VERSIONARGS} \
--downloadcache="${WORKINGDIR}/downloadcache"

set +x
Expand Down
1 change: 1 addition & 0 deletions Autobuild/ps3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fi

./configure.ps3 --build=${TARGET} \
${RELEASE} \
${VERSIONARGS} \
--cleanbuild \
${USE_CCACHE} \
--downloadcache="${WORKINGDIR}/downloadcache"
Expand Down
1 change: 1 addition & 0 deletions Autobuild/rpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ set -x
./configure.rpi --build=${TARGET} \
--toolchain="${TOOLCHAIN}/host/usr/bin/arm-buildroot-linux-gnueabihf-" \
--sysroot="${TOOLCHAIN}/host/usr/arm-buildroot-linux-gnueabihf/sysroot" \
${VERSIONARGS} \
${RELEASE} \
--cleanbuild \
${USE_CCACHE} \
Expand Down
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export DH_VERBOSE=1
dh $@

override_dh_auto_configure:
dh_auto_configure -- --release ${USE_CCACHE} ${ARCH}
dh_auto_configure -- --release ${USE_CCACHE} ${ARCH} ${VERSIONARGS}

override_dh_installdocs:
@echo No documentation
Expand Down
17 changes: 8 additions & 9 deletions ios/Movian/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

@import MediaPlayer;

const char *htsversion;
const char *htsversion_full;
const char *appversion;

uint32_t
parse_version_int(const char *str)
Expand All @@ -31,17 +30,17 @@
int minor = 0;
int commit = 0;
sscanf(str, "%d.%d.%d", &major, &minor, &commit);

return
major * 10000000 +
minor * 100000 +
commit;
major * 10000000 +
minor * 100000 +
commit;
}

uint32_t
app_get_version_int(void)
{
return parse_version_int(htsversion);
return parse_version_int(appversion);
}


Expand Down Expand Up @@ -224,8 +223,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
NSString* version = [infoDict objectForKey:@"CFBundleShortVersionString"];
htsversion_full = htsversion = strdup([version UTF8String]);
appversion = strdup([version UTF8String]);

gconf.concurrency = (int)[[NSProcessInfo processInfo] activeProcessorCount];

#ifdef TARGET_OS_TV
Expand Down
7 changes: 3 additions & 4 deletions src/api/httpcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ hc_root_old(http_connection_t *hc)
"<html><body>"
"<h2>%s</h2><p>Version %s"
, gconf.system_name,
htsversion_full);
appversion);

htsbuf_qprintf(&out,
"<form name=\"input\" method=\"get\">"
Expand Down Expand Up @@ -343,13 +343,12 @@ hc_diagnostics(http_connection_t *hc, const char *remain, void *opaque,
{
htsbuf_queue_t out;
htsbuf_queue_init(&out, 0);
extern const char *htsversion_full;

htsbuf_qprintf(&out,
htsbuf_qprintf(&out,
"<html><body>"
"<strong>%s</strong> Version %s<br><br>"
, gconf.system_name,
htsversion_full);
appversion);

diag_html(hc, &out);

Expand Down
2 changes: 1 addition & 1 deletion src/arch/linux/linux_trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ linux_trap_init(void)
self[r] = 0;

snprintf(line1, sizeof(line1),
"PRG: "APPNAMEUSER" (%s) EXE: %s, CWD: %s ", htsversion_full,
"PRG: "APPNAMEUSER" (%s) EXE: %s, CWD: %s ", appversion,
self, getcwd(path, sizeof(path)));

dl_iterate_phdr(callback, NULL);
Expand Down
2 changes: 1 addition & 1 deletion src/backend/bittorrent/peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,7 @@ peer_send_extension_handshake(peer_t *p)
htsmsg_add_u32(m, "ut_metadata", EXTENSION_MSGID_METADATA);
htsmsg_add_msg(handshake, "m", m);

snprintf(version, sizeof(version), APPNAMEUSER" %s", htsversion);
snprintf(version, sizeof(version), APPNAMEUSER" %s", appversion);
htsmsg_add_str(handshake, "v", version);
peer_send_extension_msg(p, handshake, EXTENSION_MSGID_HANDSHAKE);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ecmascript/ecmascript.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ es_create_env(es_context_t *ec, const char *loaddir, const char *storage)
duk_push_int(ctx, app_get_version_int());
duk_put_prop_string(ctx, obj_idx, "currentVersionInt");

duk_push_string(ctx, htsversion);
duk_push_string(ctx, appversion);
duk_put_prop_string(ctx, obj_idx, "currentVersionString");

duk_push_string(ctx, gconf.device_id);
Expand Down
2 changes: 1 addition & 1 deletion src/fileaccess/fa_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ http_headers_init(struct http_header_list *l, const http_file_t *hf)
http_header_add(l, "Connection",
hf->hf_want_close ? "close" : "keep-alive", 0);
snprintf(str, sizeof(str), APPNAMEUSER" %s %s",
arch_get_system_type(), htsversion);
arch_get_system_type(), appversion);
http_header_add(l, "User-Agent", str, 0);
}

Expand Down
8 changes: 3 additions & 5 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,10 @@ static void
init_global_info(void)
{
prop_t *s = prop_create(prop_get_global(), "app");
extern const char *htsversion;
extern const char *htsversion_full;

prop_set(s, "name", PROP_SET_STRING, APPNAMEUSER);
prop_set(s, "version", PROP_SET_STRING, htsversion);
prop_set(s, "fullversion", PROP_SET_STRING, htsversion_full);
prop_set(s, "version", PROP_SET_STRING, appversion);
prop_set(s, "fullversion", PROP_SET_STRING, appversion);
prop_set(s, "copyright", PROP_SET_STRING, "© 2006 - 2016 Lonelycoder AB");
}

Expand Down Expand Up @@ -538,7 +536,7 @@ parse_opts(int argc, char **argv)
" URL is any URL-type supported, "
"e.g., \"file:///...\"\n"
"\n",
htsversion_full,
appversion,
argv0,
gconf.cache_path,
gconf.persistent_path);
Expand Down
3 changes: 1 addition & 2 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,7 @@ typedef struct gconf {
extern gconf_t gconf;

/* From version.c */
extern const char *htsversion;
extern const char *htsversion_full;
extern const char *appversion;

typedef struct inithelper {
LIST_ENTRY(inithelper) link;
Expand Down
4 changes: 2 additions & 2 deletions src/networking/ftp_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ static int
cmd_SYST(ftp_connection_t *fc, char *args)
{
ftp_write(fc, 215, "UNIX Type: L8 Version: %s %s",
htsversion, arch_get_system_type());
appversion, arch_get_system_type());
return 0;
}

Expand Down Expand Up @@ -868,7 +868,7 @@ ftp_session(void *aux)
net_fmt_host(buf, sizeof(buf), &fc->fc_local_addr);

ftp_write(fc, 220, "%s FTP server (%s Version %s) ready.",
buf, gconf.system_name, htsversion);
buf, gconf.system_name, appversion);

while(1) {
if(tcp_read_line(fc->fc_tc, buf, sizeof(buf)))
Expand Down
2 changes: 1 addition & 1 deletion src/networking/http_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ http_send_header(http_connection_t *hc, int rc, const char *content,
rc, http_rc2str(rc));

htsbuf_qprintf(&hdrs, "Server: "APPNAMEUSER" %s\r\n",
htsversion_full);
appversion);

htsbuf_qprintf(&hdrs, "Date: %s\r\n", http_asctime(t, date, sizeof(date)));

Expand Down
2 changes: 1 addition & 1 deletion src/networking/ssdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ ssdp_send(asyncio_fd_t *af, const net_addr_t *myaddr, const net_addr_t *dst,
dst ? "HTTP/1.1 200 OK" : "NOTIFY * HTTP/1.1",
ssdp_uuid, usn_postfix ?: "",
incl_host ? "HOST: 239.255.255.250:1900\r\n" : "",
htsversion, htsversion,
appversion, appversion,
*date ? "DATE: " : "", date, *date ? "\r\n" : "",
dst ? "EXT:\r\n" : "",
myaddr->na_addr[0],
Expand Down
3 changes: 1 addition & 2 deletions src/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,10 @@ trace_init(void)
log_root = prop_create(prop_get_global(), "logbuffer");
hts_mutex_init(&trace_mutex);
trace_initialized = 1;
extern const char *htsversion_full;

TRACE(TRACE_INFO, "SYSTEM",
APPNAMEUSER" %s starting. %d CPU cores. Systemtype:%s OS:%s",
htsversion_full, gconf.concurrency,
appversion, gconf.concurrency,
arch_get_system_type(),
gconf.os_info[0] ? gconf.os_info : "<unknown>");
}
8 changes: 4 additions & 4 deletions src/ui/gu/gu_menubar.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ m_about(GtkWidget *menu_item, gpointer callback_data)
gu_window_t *gw = callback_data;

gtk_show_about_dialog(GTK_WINDOW(gw->gw_window),
"program-name", "HTS Showtime",
"version", htsversion,
"website", "http://www.lonelycoder.com/hts",
"copyright", "2006 - 2009 Andreas Öman, et al.",
"program-name", APPNAMEUSER,
"version", appversion,
"website", "https://movian.tv/",
"copyright", "Lonelycoder AB",
NULL);
}

Expand Down
2 changes: 1 addition & 1 deletion src/upnp/upnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ send_dev_description(http_connection_t *hc, const char *remain, void *opaque,
"<presentationURL>/</presentationURL>"
"<serviceList>",
gconf.system_name,
htsversion_full,
appversion,
upnp_uuid);


Expand Down
3 changes: 1 addition & 2 deletions src/usage.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ try_send(void *aux)
htsmsg_add_u32(m, "begin_session", 1);

htsmsg_t *metrics = htsmsg_create_map();
extern const char *htsversion_full;

htsmsg_add_str(metrics, "_os", arch_get_system_type());

Expand All @@ -135,7 +134,7 @@ try_send(void *aux)
else
htsmsg_add_str(metrics, "_carrier", "none");

htsmsg_add_str(metrics, "_app_version", htsversion_full);
htsmsg_add_str(metrics, "_app_version", appversion);
htsmsg_add_str(metrics, "_locale", gconf.lang);

htsmsg_add_msg(m, "metrics", metrics);
Expand Down
13 changes: 8 additions & 5 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
#include "buildversion.h"
#include "config.h"

const char *htsversion=BUILD_VERSION;
const char *htsversion_full=BUILD_VERSION;
#ifdef VERSIONOVERRIDE
const char *appversion=VERSIONOVERRIDE;
#else
const char *appversion=BUILD_VERSION;
#endif

#include "main.h"
#include <stdio.h>
Expand All @@ -35,14 +38,14 @@ parse_version_int(const char *str)
sscanf(str, "%d.%d.%d", &major, &minor, &commit);

return
major * 10000000 +
major * 10000000 +
minor * 100000 +
commit;
}

uint32_t
app_get_version_int(void)
app_get_version_int(void)
{
return parse_version_int(BUILD_VERSION);
return parse_version_int(appversion);
}

10 changes: 10 additions & 0 deletions support/configure.inc
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ common_help(){
echo "Standard options:"
echo " --help Print this message"
echo " --build=BUILD Build in build.BUILD [build.$BUILD]"
echo " --version=VERSION Override version from git-describe"
echo " --release Stage for release"
echo " --cleanbuild Erase builddir before configuring"
echo " --ccache Enable use of ccache"
Expand All @@ -240,6 +241,8 @@ common_opt(){

--build=*) BUILD="$2"
;;
--version=*) VERSIONOVERRIDE="$2"
;;
--extra-cflags=*) EXTRA_CFLAGS="$2"
;;
--extra-ldflags=*) EXTRA_LDFLAGS="$2"
Expand Down Expand Up @@ -353,6 +356,13 @@ EOF
#define SHOWTIME_DEFAULT_LOGTARGET "${DEFAULT_LOGTARGET}"
EOF

#
# Version override
#
if [ -n "$VERSIONOVERRIDE" ]; then
echo >>${CONFIG_H} "#define VERSIONOVERRIDE \"${VERSIONOVERRIDE}\""
fi

#
# sanitize
#
Expand Down
2 changes: 0 additions & 2 deletions support/getver.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/sh

set -e

revision=`cd "$1" && git describe --dirty --abbrev=5 2>/dev/null | sed -e 's/-/./g'`

if ! test $revision; then
Expand Down
2 changes: 0 additions & 2 deletions support/version.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/sh

set -e

revision=`$1/support/getver.sh`

NEW_REVISION="#define BUILD_VERSION \"$revision\""
Expand Down

0 comments on commit 552ad61

Please sign in to comment.