Russ Allbery: Review: Two Serpents Rise
| Series: | Craft #2 |
| Publisher: | Tor |
| Copyright: | October 2013 |
| ISBN: | 1-4668-0204-9 |
| Format: | Mobi |
| Pages: | 350 |
| Series: | Craft #2 |
| Publisher: | Tor |
| Copyright: | October 2013 |
| ISBN: | 1-4668-0204-9 |
| Format: | Mobi |
| Pages: | 350 |
DRM leasing part deux (kernel side)
I've stabilized the kernel lease implementation so that leases now
work reliably, and don't require a reboot before running the demo app
a second time. Here's whats changed:
People that know me know that I do whatever I can in order to avoid watching videos online if there's any other way to get to the content. It may be that I'm too old-fashioned, or that I have low attention and prefer to use a media where I can quickly scroll up and down a paragraph, or that I feel the time between bits of content is just a useless transition or whatever...
But I bit. And I loved it.
A couple of days ago, OS News featured a post titled From the AT&T Archives: The UNIX Operating System. It links to a couple of videos in AT&T's Youtube channel.
I watched
Here is my monthly update covering what I have been doing in the free software world (previous month):
diffoscope is our in-depth and content-aware diff utility that can locate and diagnose reproducibility issues.
strip-nondeterminism is our tool to remove specific non-deterministic results from a completed build.
buildinfo.debian.net is my experiment into how to process, store and distribute .buildinfo files after the Debian archive software has processed them.
Pillow fight
For some time I struggled how to tell this short story so it started with
some trolls (clever, but still despiteful, or maybe just with too much energy)
who made a pillow with a picture of the initial systemd author, Lennart Poettering,
and put it on the sofas of the CCC Hamburg hackerspace
Which I perceived as clever trolling, as it really was a harmless pillow, which one could
use to innocently punch Lennart in the face, or rather not, as denial of this was easy
and included, eg of course this pillow was also suitable for hugging!
For some time, I didn't know how to react. Some clever person just turned the
pillow cover upsidedown, so at least we had a white pillow instead. But still,
I wanted a better reaction
And then I met Lennart at devconf.cz in Brno and realized, that I would meet
him again the following weekend in Brussels so on Saturday morning of FOSDEM 2017
I embarrassed Lennart (and myself) a little, but it was very much worth it! And so he signed it:
To put this into perspective or why I think the original pillow was a bad idea:
some people hate systemd, fine (though I do think systemd is a fine piece of
software, but you can surely disagree about this), just, please keep in mind:
"hate/fight the game, not the players".
As I have previously blogged, I recently managed to resurrect my old Drupal site that ran in the Amazon AWS cloud, and get it working again on a new host. I have just written up a summary of how I battled through the process, which can be found here.
Unfortunately, I took a long time to write it up. So it is not as detailed as I originally intended. But if like me you run a Drupal site, or you did and it is also broken, then feel free to follow the link for a read. It may at least give some ideas to follow up. I made heavy use of DrupalVM. If you are just starting out with a Drupal website, and you have more than FTP access to your hosting, I recommend using DrupalVM (which is built with Vagrant & Ansible) for local development and testing.
Welcome to the second post in rambling random R recommendation series, or R4 for short.
Two days ago I posted the initial (actual) post. It provided context for why we need package registration entries (tl;dr: because R CMD check now tests for it, and because it The Right Thing to do, see documentation in the posts). I also showed how generating such a file src/init.c was essentially free as all it took was single call to a new helper function added to R-devel by Brian Ripley and Kurt Hornik.
Now, to actually use R-devel you obviously need to have it accessible. There are a myriad of ways to achieve that: just compile it locally as I have done for years, use a Docker image as I showed in the post -- or be creative with eg Travis or win-builder both of which give you access to R-devel if you're clever about it.
But as no good deed goes unpunished, I was of course told off today for showing a Docker example as Docker was not "Easy". I think the formal answer to that is baloney. But we leave that aside, and promise to discuss setting up Docker at another time.
R is after all ... just R. So below please find a script you can save as, say, ~/bin/pnrrs.r. And calling it---even with R-release---will generate the same code snippet as I showed via Docker. Call it a one-off backport of the new helper function -- with a half-life of a few weeks at best as we will have R 3.4.0 as default in just a few weeks. The script will then reduce to just the final line as the code will be present with R 3.4.0.
#!/usr/bin/r
library(tools)
.find_calls_in_package_code <- tools:::.find_calls_in_package_code
.read_description <- tools:::.read_description
## all what follows is from R-devel aka R 3.4.0 to be
package_ff_call_db <- function(dir)
## A few packages such as CDM use base::.Call
ff_call_names <- c(".C", ".Call", ".Fortran", ".External",
"base::.C", "base::.Call",
"base::.Fortran", "base::.External")
predicate <- function(e)
(length(e) > 1L) &&
!is.na(match(deparse(e[[1L]]), ff_call_names))
calls <- .find_calls_in_package_code(dir,
predicate = predicate,
recursive = TRUE)
calls <- unlist(Filter(length, calls))
if(!length(calls)) return(NULL)
attr(calls, "dir") <- dir
calls
native_routine_registration_db_from_ff_call_db <- function(calls, dir = NULL, character_only = TRUE)
if(!length(calls)) return(NULL)
ff_call_names <- c(".C", ".Call", ".Fortran", ".External")
ff_call_args <- lapply(ff_call_names,
function(e) args(get(e, baseenv())))
names(ff_call_args) <- ff_call_names
ff_call_args_names <-
lapply(lapply(ff_call_args,
function(e) names(formals(e))), setdiff,
"...")
if(is.null(dir))
dir <- attr(calls, "dir")
package <- # drop name
as.vector(.read_description(file.path(dir, "DESCRIPTION"))["Package"])
symbols <- character()
nrdb <-
lapply(calls,
function(e)
if (startsWith(deparse(e[[1L]]), "base::"))
e[[1L]] <- e[[1L]][3L]
## First figure out whether ff calls had '...'.
pos <- which(unlist(Map(identical,
lapply(e, as.character),
"...")))
## Then match the call with '...' dropped.
## Note that only .NAME could be given by name or
## positionally (the other ff interface named
## arguments come after '...').
if(length(pos)) e <- e[-pos]
## drop calls with only ...
if(length(e) < 2L) return(NULL)
cname <- as.character(e[[1L]])
## The help says
##
## '.NAME' is always matched to the first argument
## supplied (which should not be named).
##
## But some people do (Geneland ...).
nm <- names(e); nm[2L] <- ""; names(e) <- nm
e <- match.call(ff_call_args[[cname]], e)
## Only keep ff calls where .NAME is character
## or (optionally) a name.
s <- e[[".NAME"]]
if(is.name(s))
s <- deparse(s)[1L]
if(character_only)
symbols <<- c(symbols, s)
return(NULL)
else if(is.character(s))
s <- s[1L]
else ## expressions
symbols <<- c(symbols, deparse(s))
return(NULL)
## Drop the ones where PACKAGE gives a different
## package. Ignore those which are not char strings.
if(!is.null(p <- e[["PACKAGE"]]) &&
is.character(p) && !identical(p, package))
return(NULL)
n <- if(length(pos))
## Cannot determine the number of args: use
## -1 which might be ok for .External().
-1L
else
sum(is.na(match(names(e),
ff_call_args_names[[cname]]))) - 1L
## Could perhaps also record whether 's' was a symbol
## or a character string ...
cbind(cname, s, n)
)
nrdb <- do.call(rbind, nrdb)
nrdb <- as.data.frame(unique(nrdb), stringsAsFactors = FALSE)
if(NROW(nrdb) == 0L length(nrdb) != 3L)
stop("no native symbols were extracted")
nrdb[, 3L] <- as.numeric(nrdb[, 3L])
nrdb <- nrdb[order(nrdb[, 1L], nrdb[, 2L], nrdb[, 3L]), ]
nms <- nrdb[, "s"]
dups <- unique(nms[duplicated(nms)])
## Now get the namespace info for the package.
info <- parseNamespaceFile(basename(dir), dirname(dir))
## Could have ff calls with symbols imported from other packages:
## try dropping these eventually.
imports <- info$imports
imports <- imports[lengths(imports) == 2L]
imports <- unlist(lapply(imports, [[ , 2L))
info <- info$nativeRoutines[[package]]
## Adjust native routine names for explicit remapping or
## namespace .fixes.
if(length(symnames <- info$symbolNames))
ind <- match(nrdb[, 2L], names(symnames), nomatch = 0L)
nrdb[ind > 0L, 2L] <- symnames[ind]
else if(!character_only &&
any((fixes <- info$registrationFixes) != ""))
## There are packages which have not used the fixes, e.g. utf8latex
## fixes[1L] is a prefix, fixes[2L] is an undocumented suffix
nrdb[, 2L] <- sub(paste0("^", fixes[1L]), "", nrdb[, 2L])
if(nzchar(fixes[2L]))
nrdb[, 2L] <- sub(paste0(fixes[2L]), "$", "", nrdb[, 2L])
## See above.
if(any(ind <- !is.na(match(nrdb[, 2L], imports))))
nrdb <- nrdb[!ind, , drop = FALSE]
## Fortran entry points are mapped to l/case
dotF <- nrdb$cname == ".Fortran"
nrdb[dotF, "s"] <- tolower(nrdb[dotF, "s"])
attr(nrdb, "package") <- package
attr(nrdb, "duplicates") <- dups
attr(nrdb, "symbols") <- unique(symbols)
nrdb
format_native_routine_registration_db_for_skeleton <- function(nrdb, align = TRUE, include_declarations = FALSE)
if(!length(nrdb))
return(character())
fmt1 <- function(x, n)
c(if(align)
paste(format(sprintf(" \"%s\",", x[, 1L])),
format(sprintf(if(n == "Fortran")
"(DL_FUNC) &F77_NAME(%s),"
else
"(DL_FUNC) &%s,",
x[, 1L])),
format(sprintf("%d ,", x[, 2L]),
justify = "right"))
else
sprintf(if(n == "Fortran")
" \"%s\", (DL_FUNC) &F77_NAME(%s), %d ,"
else
" \"%s\", (DL_FUNC) &%s, %d ,",
x[, 1L],
x[, 1L],
x[, 2L])
,
" NULL, NULL, 0 ")
package <- attr(nrdb, "package")
dups <- attr(nrdb, "duplicates")
symbols <- attr(nrdb, "symbols")
nrdb <- split(nrdb[, -1L, drop = FALSE],
factor(nrdb[, 1L],
levels =
c(".C", ".Call", ".Fortran", ".External")))
has <- vapply(nrdb, NROW, 0L) > 0L
nms <- names(nrdb)
entries <- substring(nms, 2L)
blocks <- Map(function(x, n)
c(sprintf("static const R_%sMethodDef %sEntries[] = ",
n, n),
fmt1(x, n),
" ;",
"")
,
nrdb[has],
entries[has])
decls <- c(
"/* FIXME: ",
" Add declarations for the native routines registered below.",
"*/")
if(include_declarations)
decls <- c(
"/* FIXME: ",
" Check these declarations against the C/Fortran source code.",
"*/",
if(NROW(y <- nrdb$.C))
args <- sapply(y$n, function(n) if(n >= 0)
paste(rep("void *", n), collapse=", ")
else "/* FIXME */")
c("", "/* .C calls */",
paste0("extern void ", y$s, "(", args, ");"))
,
if(NROW(y <- nrdb$.Call))
args <- sapply(y$n, function(n) if(n >= 0)
paste(rep("SEXP", n), collapse=", ")
else "/* FIXME */")
c("", "/* .Call calls */",
paste0("extern SEXP ", y$s, "(", args, ");"))
,
if(NROW(y <- nrdb$.Fortran))
args <- sapply(y$n, function(n) if(n >= 0)
paste(rep("void *", n), collapse=", ")
else "/* FIXME */")
c("", "/* .Fortran calls */",
paste0("extern void F77_NAME(", y$s, ")(", args, ");"))
,
if(NROW(y <- nrdb$.External))
c("", "/* .External calls */",
paste0("extern SEXP ", y$s, "(SEXP);"))
)
headers <- if(NROW(nrdb$.Call) NROW(nrdb$.External))
c("#include <R.h>", "#include <Rinternals.h>")
else if(NROW(nrdb$.Fortran)) "#include <R_ext/RS.h>"
else character()
c(headers,
"#include <stdlib.h> // for NULL",
"#include <R_ext/Rdynload.h>",
"",
if(length(symbols))
c("/*",
" The following symbols/expresssions for .NAME have been omitted",
"", strwrap(symbols, indent = 4, exdent = 4), "",
" Most likely possible values need to be added below.",
"*/", "")
,
if(length(dups))
c("/*",
" The following name(s) appear with different usages",
" e.g., with different numbers of arguments:",
"", strwrap(dups, indent = 4, exdent = 4), "",
" This needs to be resolved in the tables and any declarations.",
"*/", "")
,
decls,
"",
unlist(blocks, use.names = FALSE),
## We cannot use names with '.' in: WRE mentions replacing with "_"
sprintf("void R_init_%s(DllInfo *dll)",
gsub(".", "_", package, fixed = TRUE)),
" ",
sprintf(" R_registerRoutines(dll, %s);",
paste0(ifelse(has,
paste0(entries, "Entries"),
"NULL"),
collapse = ", ")),
" R_useDynamicSymbols(dll, FALSE);",
" ")
package_native_routine_registration_db <- function(dir, character_only = TRUE)
calls <- package_ff_call_db(dir)
native_routine_registration_db_from_ff_call_db(calls, dir, character_only)
package_native_routine_registration_db <- function(dir, character_only = TRUE)
calls <- package_ff_call_db(dir)
native_routine_registration_db_from_ff_call_db(calls, dir, character_only)
package_native_routine_registration_skeleton <- function(dir, con = stdout(), align = TRUE,
character_only = TRUE, include_declarations = TRUE)
nrdb <- package_native_routine_registration_db(dir, character_only)
writeLines(format_native_routine_registration_db_for_skeleton(nrdb,
align, include_declarations),
con)
package_native_routine_registration_skeleton(".") ## when R 3.4.0 is out you only need this line/usr/bin/r as I happen to like littler a lot, but you can use Rscript the same way.
Easy enough now?
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
Few months ago, I've written about getting coverage information from many platforms into one report. That approach worked, but I've always felt guilty for pushing almost thousand of files to Codecov.
This week I finally found time to revisit this and make it work better and faster. Actually just uploading these files took about 30 minutes. Together with slow tests execution (which took about 30 minutes as well), we were reaching AppVeyor build time limits and builds did timeout quite often, what is not really nice result.
I've started with rewriting the wrapper used to execute OpenCppCoverage. I've originally used Python for that, which is nice, but I thought the overhead must be noticeable. As it is not possible to execute Python script directly from CTest, it was wrapped in simple bat file, adding another overhead. Reimplementing this in C showed that there is indeed overhead, but this is not going to save more time than few minutes.
Next obvious step was to look at uploading coverage files as this is really something what should be fast and not take such enormous time. When writing the original post, I've already tried to merge coverage data using OpenCppCoverage, but that showed to be too slow to make it actually work (the testsuite didn't complete in given 60 minutes).
I was also looking at existing solutions to merge Cobertura XML files, but I've found nothing working reasonably fast. The problem is that all of these always merge two files at one step, making merging thousand files really slow job as you're constantly generating, parsing and processing the resulting xml file for 1000 times. Also these solutions are probably more generic that what I needed.
In the end these files are just simple XML and merging them should not be hard. I was able to quickly write Python script to merge them. It does not support all of the Cobertura attributes, it just merges line based coverage (as this is the only thing which OpenCppCoverage generates), but works pretty fast and reliable.
Overall the build time went down from 60 minutes to 35 minutes and I don't see much space to improve besides improving OpenCppCoverage speed, what is really out of scope for me. Actually older version (0.9.5.3) performs way faster than current one (0.9.6), which is 2-3 times slower.
Filed under: Debian English Gammu 0 comments

Demonstration of a Lapdance Wikipedia
Illustration of an open jeep, sadly its a military one wikipedia
Welcome to the first actual post in the R4 series, following the short announcement earlier this week.
R CMD check in r-devel (which by next month will become R 3.4.0). A NOTE will be issued now, this will presumably turn into a WARNING at some point. Writing R Extensions has an updated introduction) of the topic.
Package registration has long been available, and applies to all native (i.e. "compiled") function via the .C(), .Call(), .Fortran() or .External() interfaces. If you use any of those -- and .Call() may be the only truly relevant one here -- then is of interest to you.
Brian Ripley and Kurt Hornik also added a new helper function: tools::package_native_routine_registration_skeleton(). It parses the R code of your package and collects all native function entrypoints in order to autogenerate the registration. It is available in R-devel now, will be in R 3.4.0 and makes adding such registration truly trivial.
But as of today, it requires that you have R-devel. Once R 3.4.0 is out, you can call the helper directly.
As for R-devel, there have always been at least two ways to use it: build it locally (which we may cover in another R4 installment), or using Docker. Here will focus on the latter by relying on the Rocker project by Carl and myself.
docker and e.g. bring in the 'daily r-devel' image drd from our Rocker project via
~$ docker pull rocker/drd~/git/rcpptoml(master)$ docker run --rm -ti -v $(pwd):/mnt rocker/drd \ ## line break
RD --slave -e 'tools::package_native_routine_registration_skeleton("/mnt")'
#include <R.h>
#include <Rinternals.h>
#include <stdlib.h> // for NULL
#include <R_ext/Rdynload.h>
/* FIXME:
Check these declarations against the C/Fortran source code.
*/
/* .Call calls */
extern SEXP RcppTOML_tomlparseImpl(SEXP, SEXP, SEXP);
static const R_CallMethodDef CallEntries[] =
"RcppTOML_tomlparseImpl", (DL_FUNC) &RcppTOML_tomlparseImpl, 3 ,
NULL, NULL, 0
;
void R_init_RcppTOML(DllInfo *dll)
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
edd@max:~/git/rcpptoml(master)$ docker command invocation above through its components:
docker run is the basic call to a container--rm -ti does subsequent cleanup (--rm) and gives a terminal (-t) that is interactive (-i)-v $(pwd):/mnt uses the -v a:b options to make local directory a available as b in the container; here $(pwd) calls print working directory to get the local directory which is now mapped to /mnt in the containerrocker/drd invokes the 'drd' container of the Rocker projectRD is a shorthand to the R-devel binary inside the container, and the main reason we use this container-e 'tools::package_native_routine_registration_skeleton("/mnt") calls the helper function of R (currently in R-devel only, so we use RD) to compute a possible init.c file based on the current directory -- which is /mnt inside the containersrc/init.c
We simply copy the output to a file src/init.c; I often fold one opening brace one line up.
useDynLib("RcppTOML") to useDynLib("RcppTOML", .registration=TRUE). Adjust accordingly for other package names.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
All this racism, it's just not cricket. Or is it? One of the most remarkable cricketers to play for England in recent times, Kevin Pietersen, dubbed "the most complete batsman in cricket" by The Times and "England's greatest modern batsman" by the Guardian, was born in South Africa. In the five years he was contracted to the Hampshire county team, he only played one match, because he was too busy representing England abroad. His highest position was nothing less than becoming England's team captain.
Are the British superior to every other European citizen?
One of the implications of the rhetoric coming out of London these days is that the British are superior to their neighbours, entitled to have their cake and eat it too, making foreigners queue up at Paris' Gare du Nord to board the Eurostar while British travelers should be able to walk or drive into European countries unchallenged.
This superiority complex is not uniquely British, you can observe similar delusions are rampant in many of the places where I've lived, including Australia, Switzerland and France. America's Donald Trump has taken this style of politics to a new level.
Look in the mirror Theresa May: after British 10-year old schoolboys Robert Thompson and Jon Venables abducted, tortured, murdered and mutilated 2 year old James Bulger in 1993, why not have all British schoolchildren fingerprinted and added to the police DNA database? Why should "security" only apply based on the country where people are born, their religion or skin colour?
In fact, after Brexit, people like Venables and Thompson will remain in Britain while a Dutch woman, educated at Cambridge and with two British children will not. If that isn't racism, what is?
Running foreigner's off the roads
Theresa May has only been Prime Minister for less than a year but she has a history of bullying and abusing foreigners in her previous role in the Home Office. One example of this was a policy of removing driving licenses from foreigners, which has caused administrative chaos and even taken away the licenses of many people who technically should not have been subject to these regulations anyway.
Shouldn't the DVLA (Britain's office for driving licenses) simply focus on the competence of somebody to drive a vehicle? Bringing all these other factors into licensing creates a hostile environment full of mistakes and inconvenience at best and opportunities for low-level officials to engage in arbitrary acts of racism and discrimination.
Of course, when you are taking your country on the road to nowhere, who needs a driving license anyway?
What does "maximum control" over other human beings mean to you?
The new British PM has said she wants "maximum control" over immigrants. What exactly does "maximum control" mean? Donald Trump appears to be promising "maximum control" over Muslims, Hitler sought "maximum control" over the Jews, hasn't the whole point of the EU been to avoid similar situations from ever arising again?
This talk of "maximum control" in British politics has grown like a weed out of the UKIP. One of their senior figures has been linked to kidnappings and extortion, which reveals a lot about the character of the people who want to devise and administer these policies. Similar people in Australia aspire to jobs in the immigration department where they can extort money out of people for getting them pushed up the queue. It is no surprise that the first member of Australia's parliament ever sent to jail was put there for obtaining bribes and sexual favours from immigrants. When Nigel Farage talks about copying the Australian immigration system, he is talking about creating jobs like these for his mates.
Even if "maximum control" is important, who really believes that a bunch of bullies in Westminster should have the power to exercise that control? Is May saying that British bosses are no longer competent to make their own decisions about who to employ or that British citizens are not reliable enough to make their own decisions about who they marry and they need a helping hand from paper-pushers in the immigration department?
Echoes of the Third Reich
Most people associate acts of mass murder with the Germans who lived in the time of Adolf Hitler. These are the stories told over and and over again in movies, books and the press.
Look more closely, however, and it appears that the vast majority of Germans were not in immediate contact with the gas chambers. Even Gobels' secretary writes that she was completely oblivious to it all. Many people were simply small cogs in a big bad machine. The clues were there, but many of them couldn't see the big picture. Even if they did get a whiff of it, many chose not to ask questions, to carry on with their comfortable lives.
Today, with mass media and the Internet, it is a lot easier for people to discover the truth if they look, but many are still reluctant to do so.
Consider, for example, the fingerprint scanners installed in British post offices and police stations to fingerprint foreigners and criminals (as if they have something in common). If all the post office staff refused to engage in racist conduct the fingerprint scanners would be put out of service. Nonetheless, these people carry on, just doing their job, just following orders. It was through many small abuses like this, rather than mass murder on every street corner, that Hitler motivated an entire nation to serve his evil purposes.
Technology like this is introduced in small steps: first it was used for serious criminals, then anybody accused of a crime, then people from Africa and next it appears they will try and apply it to all EU citizens remaining in the UK.
How will a British man married to a French woman explain to their children that mummy has to be fingerprinted by the border guard each time they return from vacation?
The Nazis pioneered biometric technology with the tracking numbers branded onto Jews. While today's technology is electronic and digital, isn't it performing the same function?
Yesterday Gammu 1.38.2 has been released. This is bugfix release fixing for example USSD or MMS decoding in some situations.
The Windows binaries are available as well. These are built using AppVeyor and will help bring Windows users back to latest versions.
Full list of changes and new features can be found on Gammu 1.38.2 release page.
Would you like to see more features in Gammu? You an support further Gammu development at Bountysource salt or by direct donation.
Filed under: Debian English Gammu 0 comments
DRM display resource leasing (kernel side)
So, you've got a fine head-mounted display and want to explore the
delights of virtual reality. Right now, on Linux, that means getting
the window system to cooperate because the window system is the DRM
master and holds sole access to all display resources. So, you
plug in your device, play with RandR to get it displaying bits from
the window system and then carefully configure your VR application to
use the whole monitor area and hope that the desktop will actually
grant you the boon of page flipping so that you will get reasonable
performance and maybe not even experience tearing. Results so far have
been mixed, and depend on a lot of pieces working in ways that aren't
exactly how they were designed to work.
We could just hack up the window system(s) and try to let applications
reserve the HMD monitors and somehow removing them from the normal
display area so that other applications don't randomly pop up in the
middle of the screen. That would probably work, and would take
advantage of much of the existing window system infrastructure for
setting video modes and performing page flips. However, we've got a
pretty spiffy standard API in the kernel for both of those, and
getting the window system entirely out of the way seems like something
worth trying.
I spent a few hours in Hobart chatting with Dave Airlie during LCA and
discussed how this might actually work.
Goals
int drmModeCreateLease(int fd,
const uint32_t *objects,
int num_objects,
int flags,
uint32_t *lessee_id);
Given an FD to a DRM master, and a list of objects to lease, a new DRM
master FD is returned that holds a lease to those objects. 'flags'
can be any combination of O_CLOEXEC and O_NONBLOCK for the newly
minted file descriptor.
Of course, the owner might want to take some resources back, or even
grant new resources to the lessee. So, I added an interface that
rewrites the terms of the lease with a new set of objects:
int drmModeChangeLease(int fd,
uint32_t lessee_id,
const uint32_t *objects,
int num_objects);
Note that nothing here makes any promises about the state of the
objects across changes in the lease status; the lessor and lessee are
expected to perform whatever modesetting is required for the objects
to be useful to them.
Window System Integration
There are two ways to integrate DRM leases into the window system
environment:
-Wl,--no-insert-timestamp to set it to 0 (though see caveats below):
$ i686-w64-mingw32.static-gcc -Wl,--no-insert-timestamp hello.c -o hello.exe
$ md5sum hello.exe
298f98d74e6e913628a8b74514eddcb2 hello.exe
$ /opt/mxe/usr/bin/i686-w64-mingw32.static-gcc -Wl,--no-insert-timestamp hello.c -o hello.exe
$ md5sum hello.exe
298f98d74e6e913628a8b74514eddcb2 hello.exe
$ cd repro/
$ i686-w64-mingw32.static-gcc hello.c -o hello.exe && i686-w64-mingw32.static-strip hello.exe
$ md5sum hello.exe
6e07736bf8a59e5397c16e799699168d hello.exe
$ i686-w64-mingw32.static-gcc hello.c -o hello.exe && i686-w64-mingw32.static-strip hello.exe
$ md5sum hello.exe
6e07736bf8a59e5397c16e799699168d hello.exe
$ cd ..
$ cp -a repro repro2/
$ cd repro2/
$ i686-w64-mingw32.static-gcc hello.c -o hello.exe && i686-w64-mingw32.static-strip hello.exe
$ md5sum hello.exe
6e07736bf8a59e5397c16e799699168d hello.exe
$ cd /opt/mxe/
$ cp -a ./usr/i686-w64-mingw32.static/lib/libSDL2.a /tmp
$ rm -rf * && git checkout .
$ make sdl2
$ md5sum ./usr/i686-w64-mingw32.static/lib/libSDL2.a /tmp/libSDL2.a
68909ab13181b1283bd1970a56d41482 ./usr/i686-w64-mingw32.static/lib/libSDL2.a
68909ab13181b1283bd1970a56d41482 /tmp/libSDL2.a
$ cd /usr/srx/mxe
$ make sdl2
$ md5sum usr/i686-w64-mingw32.static/lib/libSDL2.a /tmp/libSDL2.a
c6c368323927e2ae7adab7ee2a7223e9 usr/i686-w64-mingw32.static/lib/libSDL2.a
68909ab13181b1283bd1970a56d41482 /tmp/libSDL2.a
$ ls -l ./usr/i686-w64-mingw32.static/lib/libSDL2.a /tmp/libSDL2.a
-rw-r--r-- 1 me me 5861536 mars 23 21:04 /tmp/libSDL2.a
-rw-r--r-- 1 me me 5862488 mars 25 19:46 ./usr/i686-w64-mingw32.static/lib/libSDL2.a
$ apt-get install reprotest disorderfs faketime
$ reprotest 'make hello' 'hello'
...
will vary: environment
will vary: fileordering
will vary: home
will vary: kernel
will vary: locales
will vary: exec_path
will vary: time
will vary: timezone
will vary: umask
...
--- /tmp/tmpk5uipdle/control_artifact/
+++ /tmp/tmpk5uipdle/experiment_artifact/
--- /tmp/tmpk5uipdle/control_artifact/hello
+++ /tmp/tmpk5uipdle/experiment_artifact/hello
stat
@@ -1,8 +1,8 @@
Size: 8632 Blocks: 24 IO Block: 4096 regular file
Links: 1
-Access: (0755/-rwxr-xr-x) Uid: ( 1000/ me) Gid: ( 1000/ me)
+Access: (0775/-rwxrwxr-x) Uid: ( 1000/ me) Gid: ( 1000/ me)
Modify: 1970-01-01 00:00:00.000000000 +0000
Birth: -
# => OK except for permissions
$ reprotest 'make hello && chmod 755 hello' 'hello'
=======================
Reproduction successful
=======================
No differences in hello
c8f63b73265e69ab3b9d44dcee0ef1d2815cdf71df3c59635a2770e21cf462ec hello
$ reprotest 'make hello CFLAGS="-g -O2"' 'hello'
# => lots of differences, as expected
linux32 (because MXE would then recompile all the host compiler tools for 32-bit):
$ reprotest --dont-vary build_path,kernel 'touch src/sdl2.mk && make sdl2 && cp -a usr/i686-w64-mingw32.static/lib/libSDL2.a .' 'libSDL2.a'
=======================
Reproduction successful
=======================
No differences in libSDL2.a
d9a39785fbeee5a3ac278be489ac7bf3b99b5f1f7f3e27ebf3f8c60fe25086b5 libSDL2.a
$ reprotest --dont-vary build_path,kernel 'make clean && make sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_ttf libzip gettext nsis' 'usr'
# => changes in installation dates
# => timestamps in .exe files (dbus, ...)
# => libicu doesn't look reproducible (derb.exe, genbrk.exe, genccode.exe...)
# => apparently ar timestamp variations in libaclui
ar differences may go away at FreeDink link time since I'm aiming at a static build.
Let's try!
First let's see how FreeDink behaves with stable dependencies.-Wl,--no-insert-timestamp and strip the binaries in a first step.$ cd freedink/
$ reprotest --dont-vary build_path 'mkdir cross-woe-32/ && cd cross-woe-32/ && export PATH=/opt/mxe/usr/bin:$PATH && LDFLAGS='-Wl,--no-insert-timestamp' ../configure --host=i686-w64-mingw32.static --enable-static && make -j$(nproc) && make install-strip DESTDIR=$(pwd)/destdir' 'cross-woe-32/destdir/usr/local/bin'
# => executables are identical!
# Same again, just to make sure
$ reprotest --dont-vary build_path 'mkdir cross-woe-32/ && cd cross-woe-32/ && export PATH=/opt/mxe/usr/bin:$PATH && LDFLAGS='-Wl,--no-insert-timestamp' ../configure --host=i686-w64-mingw32.static --enable-static && make -j$(nproc) && make install-strip DESTDIR=$(pwd)/destdir' 'cross-woe-32/destdir/usr/local/bin'
--- /tmp/tmp2yw0sn4_/control_artifact/bin/freedink.exe
+++ /tmp/tmp2yw0sn4_/experiment_artifact/bin/freedink.exe
@@ -2,20 +2,20 @@
00000010: b800 0000 0000 0000 4000 0000 0000 0000 ........@.......
00000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000030: 0000 0000 0000 0000 0000 0000 8000 0000 ................
00000040: 0e1f ba0e 00b4 09cd 21b8 014c cd21 5468 ........!..L.!Th
00000050: 6973 2070 726f 6772 616d 2063 616e 6e6f is program canno
00000060: 7420 6265 2072 756e 2069 6e20 444f 5320 t be run in DOS
00000070: 6d6f 6465 2e0d 0d0a 2400 0000 0000 0000 mode....$.......
-00000080: 5045 0000 4c01 0a00 e534 0735 0000 0000 PE..L....4.5....
+00000080: 5045 0000 4c01 0a00 0000 0000 0000 0000 PE..L...........
00000090: 0000 0000 e000 0e03 0b01 0219 00f2 3400 ..............4.
000000a0: 0022 4e00 0050 3b00 c014 0000 0010 0000 ."N..P;.........
000000b0: 0010 3500 0000 4000 0010 0000 0002 0000 ..5...@.........
000000c0: 0400 0000 0100 0000 0400 0000 0000 0000 ................
-000000d0: 00e0 8900 0004 0000 7662 4e00 0200 0000 ........vbN.....
+000000d0: 00e0 8900 0004 0000 89f8 4e00 0200 0000 ..........N.....
000000e0: 0000 2000 0010 0000 0000 1000 0010 0000 .. .............
000000f0: 0000 0000 1000 0000 00a0 8700 b552 0000 .............R..
00000100: 0000 8800 d02d 0000 0050 8800 5006 0000 .....-...P..P...
00000110: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000120: 0060 8800 4477 0100 0000 0000 0000 0000 . ..Dw..........
00000130: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000140: 0440 8800 1800 0000 0000 0000 0000 0000 .@..............
stat
@@ -1,8 +1,8 @@
Size: 5121536 Blocks: 10008 IO Block: 4096 regular file
Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 1000/ me) Gid: ( 1000/ me)
-Modify: 2017-03-26 01:26:35.233841833 +0000
+Modify: 2017-03-26 01:27:01.829592505 +0000
Birth: -
# With MXE:
$ reprotest 'i686-w64-mingw32.static-gcc hello.c -I /opt/mxe/usr/i686-w64-mingw32.static/include -I/opt/mxe/usr/i686-w64-mingw32.static/include/SDL2 -L/opt/mxe/usr/i686-w64-mingw32.static/lib -lmingw32 -Dmain=SDL_main -lSDL2main -lSDL2 -lSDL2main -Wl,--no-insert-timestamp -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -o hello && chmod 700 hello' 'hello'
# => different
# => maybe because it imports the build timestamp from -lSDL2main
# With Debian's MinGW (but without SOURCE_DATE_EPOCH):
$ reprotest 'i686-w64-mingw32-gcc hello.c -I /opt/mxe/usr/i686-w64-mingw32.static/include -I/opt/mxe/usr/i686-w64-mingw32.static/include/SDL2 -L/opt/mxe/usr/i686-w64-mingw32.static/lib -lmingw32 -Dmain=SDL_main -lSDL2main -lSDL2 -lSDL2main -Wl,--no-insert-timestamp -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -o hello && chmod 700 hello' 'hello'
=======================
Reproduction successful
=======================
No differences in hello
0b2d99dc51e2ad68ad040d90405ed953a006c6e58599beb304f0c2164c7b83a2 hello
# Let's remove -Dmain=SDL_main and let our main() have precedence over the one in -lSDL2main:
$ reprotest 'i686-w64-mingw32.static-gcc hello.c -I /opt/mxe/usr/i686-w64-mingw32.static/include -I/opt/mxe/usr/i686-w64-mingw32.static/include/SDL2 -L/opt/mxe/usr/i686-w64-mingw32.static/lib -lmingw32 -lSDL2main -lSDL2 -lSDL2main -Wl,--no-insert-timestamp -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -o hello && chmod 700 hello' 'hello'
=======================
Reproduction successful
=======================
No differences in hello
6c05f75eec1904d58be222cc83055d078b4c3be8b7f185c7d3a08b9a83a2ef8d hello
$ LANG=C i686-w64-mingw32.static-ld --version # MXE
GNU ld (GNU Binutils) 2.25.1
Copyright (C) 2014 Free Software Foundation, Inc.
$ LANG=C i686-w64-mingw32-ld --version # Debian
GNU ld (GNU Binutils) 2.27.90.20161231
Copyright (C) 2016 Free Software Foundation, Inc.
main().
So FreeDink is nearly reproducible, except for this build timestamp issue that pops up in all kind of situations.
In the worse case I can zero it out, or patch MXE's binutils until they upgrade.
More importantly, what if I recompile FreeDink and the dependencies twice?
$ (cd /opt/mxe/ && make clean && make sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_ttf glm libzip gettext nsis)
$ (mkdir cross-woe-32/ && cd cross-woe-32/ \
&& export PATH=/opt/mxe/usr/bin:$PATH \
&& LDFLAGS="-Wl,--no-insert-timestamp" ../configure --host=i686-w64-mingw32.static --enable-static \
&& make V=1 -j$(nproc) \
&& make install-strip DESTDIR=$(pwd)/destdir)
$ mv cross-woe-32/ cross-woe-32-1/
# Same again...
$ mv cross-woe-32/ cross-woe-32-2/
$ diff -ru cross-woe-32-1/destdir/ cross-woe-32-2/destdir/
[nothing]
src/freedinkedit.exe.
make INSTALL="$(which install) install -p" could help for static files, but not generated ones.$ export SOURCE_DATE_EPOCH=$(date +%s) \
&& reprotest --dont-vary build_path \
'make ... && find destdir/ -newermt "@$ SOURCE_DATE_EPOCH " -print0 xargs -0r touch --no-dereference --date="@$ SOURCE_DATE_EPOCH "' 'cross-woe-32/destdir/'
make install MKDIR_P="mkdir -p -m 755" (1).mkdir -p -m ... does not set permissions for intermediate directories.
A new minor version of the nanotime package for working with nanosecond timestamps arrived yesterday on CRAN.
nanotime uses the RcppCCTZ package for (efficient) high(er) resolution time parsing and formatting up to nanosecond resolution, and the bit64 package for the actual integer64 arithmetic.
This release just arranges things neatly before Leonardo Silvestri and I may shake things up with a possible shift to doing it all in S4 as we may need the added rigour for nanotime object operations for use in his ztsdb project.
We also have a diff to the previous version thanks to CRANberries. More details and examples are at the nanotime page; code, issue tickets etc at the GitHub repository.Changes in version 0.1.2 (2017-03-27)
- The
as.integer64function is now exported as well.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
About a year ago I bought a new workstation computer for myself at
home. It s a Tuxedo XUX_Cube which is advertised as gaming PC. But I ordered a
slightly atypical non-gamer configuration:
cat
/proc/mdstat on that box.
So at some point I wanted something like smart-notifier, but
for Linux Software (MD) RAIDs. And since I found nothing, I did what
Open Source guys usually do in such cases: I wrote it myself
of course in Perl and called it systray-mdstat.
First I wondered about which build system would be most suitable for that
task, but in the end I once again went with Dist::Zilla for the upstream build
system and hence dh-dist-zilla for the Debian packaging.
Ideas for the actual implementation were taken from Wouter s fdpowermon for the systray icon framework in Perl and Myon s mdstat Xymon plugin for an already proven logic to
parse /proc/mdstat. (Both, Wouter and Myon have stated in
a GnuPG-signed e-mail that I copied less code than would validate
their copyrights, so I was able to license it under a single license,
namely GNU GPL version 3.)
As of now, systray-mdstat is also available as package in
Debian Unstable. It won t make it to Stretch as its first line of code
has been written after the soft-freeze for Stretch was already in
place.
Maintaining Debian packages of Perl modules usually can be done with
the common git-buildpackage (aka gbp) workflow with its three
git branches master (or debian),
upstream and pristine-tar:
upstream contains the upstream code as imported from
upstream s release tar-balls.pristine-tar contains the binary diffs between the
contents of the upstream branch and the original
tar-ball. This mostly contains meta-data (timestamps, permissions,
file owners, etc.) as git doesn t store them.master (or debian) which contains
upstream plus packaging.upstream branch is used (and then maybe called
master while the Debian packaging branch is then called
debian).
But the files needed for a proper so called CPAN distribution of a
Perl module often contain redundant information (version numbers,
required modules, etc.) which needs to be maintained. And for that,
many people prefer Don t Repeat Yourself (DRY) as a
principle.
Dist::Zilla
One nice and common tool for that is Dist::Zilla or short dzil. It generates most
redundant but required data out of a central source, e.g.
Dist::Zilla s dist.ini or the contained .pm
files, etc. dzil build creates tar ball which contains
all files necessary by CPAN.
But now we have a dilemma: Debian expects those generated files inside
the upstream branch while the files are only generated
from other files in that branch. There are multiple solutions, but all
of them involve committing generated files to the git repository:
upstream branch. Disadvantage:
You ll likely later forget which files were generated and which
weren t.master (original code), upstream (original
code + stuff generated by dzil build, maybe imported with
git-import-orig), pristine-tar and a
debian (based on upstream) branches.run-parts tool) was initially maintained in the latter
way.
But especially in cases where we just need a Perl module packaged as
.deb without uploading it to CPAN (e.g. project-internal
modules), this is a tedious workflow and overkill. It would be much
nicer if debhelper would just call dzil to generate all
the stuff it needs to build the package.
dh-dist-zilla
Well, you can
do that now, at least with Debian Jessie. This is what dh-dist-zilla does: It is a debhelper sequence plugin which calls
dzil build and dzil clean in the right
moment and takes care that all dh_auto_* commands look in
the directory with the generated files instead of the rather clean
project root directory.
To use dh-dist-zilla, you just need to add a build-dependency on it
and the Dist::Zilla plugins you use, and add --with
dist-zilla to your minimal dh-style
debian/rules file:
#!/usr/bin/make -f %: dh $@ --with dist-zillaThat s it. With regards to workflow and git branches, you may still want to use separate branches for upstream work and debian work, and you may want to continue to use pristine-tar, but you don t have to commit generated files to git anymore and you can maintain a clean master branch with nearly no redundancy. And if you need to generate to final upstream tar ball for you debian package, just call
dh get-orig-source or maybe easier to
use with tab completion dh_dist_zilla_origtar.
This is how the librun-parts-perl package is maintained
nowadays. There s otherwise not much difference to the old,
classically maintained versions.
More DRY
Next step in the DRY evolution is to reduce redundancies between
upstream (Dist::Zilla based) packaging and the Debian packaging. There
are a few tools available, partially brand new, partially not yet
packaged:
dh-dzil-refresh which combines
dh-make-perl s refresh subcommand with Dist::Zilla.
So I had been toying with the idea of getting back to the blog and more regularly writing / posting little tips and tricks. I even started taking some notes but because perfect is always the enemy of the good it never quite materialized.
But the relatively broad discussion spawned by last week's short rant on Suggests != Depends made a few things clear. There appears to be an audience. It doesn't have to be long. And it doesn't have to be too polished.
So with that, let's get the blogging back from micro-blogging.
This note forms post zero of what will a new segment I call R4 which is shorthand for relatively random R rambling.
Stay tuned.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
http://social.gl-como.it/photos/valhalla/image/81b600789aa02a91fdf62f54a71b1ba0Next.