Seven years of bitwise: a weekend project, a Hackernews front page, and the long road into Debian

I started bitwise for a petty reason. I spend my days in low-level code, and I was tired of reaching for the mouse to open the KDE calculator every time I needed to know which bit of a register dump was set. A terminal is already open. Why am I leaving it?

bitwise command line output

One number in, every representation out. This is the itch.

Seven years later the thing is in Debian, Fedora, openSUSE, Void, Alpine, FreeBSD, OpenBSD, Guix, Nix, Homebrew, MacPorts, the AUR, MSYS2, Buildroot and Yocto. Twenty-one other people have sent patches. It has a few hundred stars.

Writing it was the easy part. This is the story of the rest.

The first three weeks

Anyone who has written an ncurses form will recognise the shape of those first weeks: long stretches where nothing updates, then a sudden moment where the whole screen starts behaving and you can’t entirely explain why. Bit toggling took me two attempts and one evening of swearing.

bitwise interactive mode

Once it worked I added vim movement keys — hjkl to walk the binary row — almost as an afterthought. That afterthought turned out to be the feature people would compliment most often. Around the same time I pulled the curses code out of main so there could be a plain command-line mode, which is now how the majority of people actually use the tool. Neither decision felt important at the time. Both were.

I also threw away my hand-written Makefile for autotools and wrote a snapcraft file — the first of many hours spent on the packaging rather than the program, though I didn’t know that yet.

Then I tagged a release, wrote a short blog post, and posted it to Hacker News.

Four points. No comments.

The ten weeks nobody saw

That could have been the end of it. What’s interesting in hindsight is that bitwise became genuinely good during the stretch when nobody was watching.

That’s when it got a real expression parser, so you could type (0x40 | 3) << 2 instead of clicking bits:

C-style expression calculator

That’s when it got unit tests. A history window. A $ symbol that evaluates to your last result, which is the feature I personally use most. ASCII output. The distinction between KiB and kB, because 1024 and 1000 are not the same number and it bothered me.

None of that came from feedback, because there wasn’t any. It came from using my own tool every day and being annoyed by it.

Ten weeks after the first attempt I posted it to Hacker News again. Same link. New title — the first one had described what the program was, and the new one described what it did for you.

113 points. Front page.

I don’t have a clever theory about this. Same project, same URL. The title was more concrete and the software was considerably better than it had been. Both probably mattered. So did luck.

What the front page actually feels like

It is not a victory lap. It’s a firehose of people telling you, politely, everything that’s wrong with your program. And it is wonderful.

Ten issues opened that day. Strangers found real bugs within hours — not misunderstandings of the UI, actual defects I’d never hit because I only ever ran the program on my own machine, in my own terminal, in my own locale, at my own word size. I spent the day fixing integer format specifiers, missing includes, and colour handling on terminals I’d never seen. Every one of those was someone else’s computer telling me I’d been writing for an audience of one.

Three moments from that thread have stayed with me.

The compliment that was really about work. Someone wrote that they were forever rebuilding the same throwaway scripts in a REPL or in /tmp, and that generalising one of them into an actual tool “takes tons of work.” That’s the truest thing anyone has said about this project. Everybody has the hacky version. The distance between the hacky version and something a stranger can install is the entire job, and it is almost all of the effort.

The joke that came back as a patch. My README had a row in the install table for Windows that was essentially a shrug and a question mark. Someone quoted it back at me in the thread and suggested a serious approach. Someone else skipped the discussion entirely and just sent a pull request titled “Stopped be facecious about windows,” with a fixed build script attached. Point taken. It took until last year for another contributor to make the msys2 build genuinely work, and there’s a Windows CI job now.

The packaging failure, live on stage. That same day, somebody following my own README on Ubuntu under WSL got an uninstallable package: my PPA build had picked up the wrong readline. The most-read day in the project’s life, and the install instructions were broken.

That was my introduction to the part of this project that has been consistently harder than the code.

Distribution is the hard part

bitwise took a weekend to be useful and a few months to be good. Getting it to users has taken seven years and isn’t finished.

The channels I control were easy. A snap package took an afternoon. A PPA is a shell script. A release tarball is a git tag.

Everything else requires another human being — and to be clear, those human beings showed up. In most cases somebody packaged bitwise for their distribution without asking me, and then sent a pull request adding a line to my README so I’d know it existed. Fedora, Void, Nix, Alpine, the BSDs, Homebrew, MacPorts: all of them arrived that way. Repology lists around sixty repository entries now. I asked for almost none of it, and the generosity still surprises me.

Getting in was never the problem. Staying current is.

Upstream is at 0.70. Of those sixty-odd entries, the overwhelming majority say 0.50 — including rolling distributions that are supposed to be current. Ubuntu 20.04 still ships a binary I built in 2019. When I fixed a buffer overflow in the parser last month, I fixed it for the small number of people on Debian unstable or Homebrew. For everybody else that fix does not exist yet, and in some distributions it won’t for another year.

That gap — between “I fixed it” and “you have the fix” — is the number that actually matters for a project like this, and it’s the number I have the least control over.

Debian, specifically

Debian is where I’ve put the most effort, and it’s worth being precise about why it’s hard, because the difficulty is structural rather than anybody’s fault.

I filed an ITP — Intent To Package — back in 2019, and I’m listed as the package Maintainer. What I’m not is a Debian Developer.

That one fact shapes everything downstream. I cannot upload. Every release of bitwise that has ever entered Debian was signed by somebody else. The loop, each time, is: build the source package in a clean unstable environment, upload it to mentors.debian.net, file a request-for-sponsorship bug, and then wait for a Debian Developer to have a free evening, read your diff, and put their own name and reputation on your work.

They do it for free, for strangers, and they’re right to be careful about it. But the queue is long, and the latency compounds. One of my releases took the better part of a year to get from a git tag to Debian testing. Another I simply never uploaded at all — by the time I had the energy to deal with the process, the next version was nearly ready, so the archive skipped a release entirely.

And then Debian freezes. Each stable release ships whatever version of bitwise happened to be current when the freeze landed, and there it stays for years. If you’re on the current Debian stable, the program you can install is the one I considered finished a while ago, and nothing I do upstream changes that.

None of this is a complaint about Debian. The stability is the product. But it does mean that for a small upstream, “being in Debian” and “Debian users having your software” are two quite different achievements, and only the first one is a milestone you get to celebrate.

Coming back

After the last release the project went quiet for about three years — not because I’d lost interest, but because the to-do list had curdled. Everything left on it was the kind of task that’s tedious rather than hard: wire up sanitizers, write a fuzzer harness, replace CI that had been dead so long I’d stopped seeing the failure emails, fill in the files a project is supposed to have and mine never did. None of it was interesting. All of it was overdue. So for three years I opened the list, looked at it, and closed it again.

This summer I worked through most of that backlog with Claude, and the honest summary is that it collapsed the activation energy rather than the difficulty. The work was never beyond me; it was just never worth the evening. Having something to hand the boring half of each task to changed the maths — suddenly the tedious-but-overdue items cost little enough that they got done at all.

So they got done. Sanitizer builds, a fuzzer pointed at the expression parser, CI that actually runs on more than one platform, a rewritten README and man page, and the handful of genuine memory-safety bugs that turned up once something finally went looking — a buffer overflow in the tokenizer, undefined shifts, a few assumptions about signedness and byte order that had been wrong since the beginning and had simply never been triggered by the inputs I happened to type. I’d have found them eventually. I’d have found them in 2031.

The vim plugin got the same treatment, except there I threw the old one away. I created that repository two days after the Hacker News post, in a burst of enthusiasm, and then let it sit for seven years — and when I opened it again the original design was simply wrong. You invoked a command, it ran bitwise, and it put the answer in a buffer for you to go and read. That’s a lot of deliberate effort for a question you only half-wanted answered, and it’s why I never used my own plugin.

So vim-bitwise is a rewrite from scratch, and the whole thing is now a hover window. Rest the cursor on a numeric literal and its decimal, hex, octal and binary forms appear beside it — a floating window in Neovim, a popup in Vim — and it disappears the moment you move on. You never ask for it. It’s just there when you pause, which is exactly when you wanted it.

vim-bitwise hover window

It reads the literals real code contains, digit separators and size suffixes included, and it has the sense to stay quiet about identifiers that merely happen to have digits in them. The old <Leader>b operator is still there for when you want the full tool on a whole expression rather than a glance at one number.

That’s the plugin I should have written in 2019. It mostly took looking at it again with fresh eyes, and by this summer the eyes weren’t only mine.

Then the fun part. It turned out &, ^ and | had had the wrong precedence relative to each other for the entire life of the project. Nobody had reported it. Now they match C, which means an expression you lift straight out of a source file evaluates to the same thing in bitwise as it does in your compiler — which was always the point.

And I finally implemented this:

bitwise '0xdeadbeef[31:16]' # 0xdead

Verilog bit select. The field comes back right-aligned, the way a datasheet means it, instead of making you work out (0xdeadbeef >> 16) & 0xffff by hand. It’s the one place where the syntax deliberately isn’t C’s, and for a tool whose whole purpose is decoding registers it’s obviously correct.

Somebody requested that three and a half years ago, in a two-line issue with no explanation, and then waited. They were right, too.

What I’d tell myself at the start

Almost nobody gets this program from me. The release tarballs on GitHub are downloaded in the thousands; the distributions serve far more people than that, quietly, without ever telling me. That’s the goal — and it’s also exactly why the lag between fixing something and shipping it is the metric that matters.

So: build the thing for yourself first and keep using it, because the ten weeks when nobody was watching are what made it worth watching. Take the bug reports from strangers as the gift they are. Say yes to README pull requests from people packaging you for distributions you’ve never run.

And be patient with the last mile. The code is the part you control; getting it onto other people’s machines is a slower, more human process, and it keeps going long after the interesting problems are solved.


bitwise is on GitHub, GPL-3.0-or-later. apt install bitwise, dnf install bitwise, brew install bitwise — and if you’re on a stable release, 0.70 will reach you eventually.

Seven years of bitwise: a weekend project, a Hackernews front page, and the long road into Debian

Bitwise – Terminal based bit manipulator

I Recently complete a basic ncurses based terminal application for minglinng with bits.
I’m working low level most of the times and need to tinker with bits, masks and to translate between number bases (hex to dec, and vice verse).

As I’m working 99% of my time in a terminal, I found it very annoying to open the calculator application in Windows or KDE, so I decided to create a small app that I can use in the terminal window.

Well, here it is.

bitwise

https://github.com/mellowcandle/bitwise

If you like it, please star it on Github.

Thanks and goodbye.

Bitwise – Terminal based bit manipulator

Automatically placing Gerrit’s commit-msg hook in every new git repository

Sadly, when cloning a repository from Gerrit. the Gerrit’s commit-msg hook is not populated in the local repository git hooks folder.

Here’s a neat trick that I just learned that always puts that there.

scp -p -P 29418 <GERRIT_SERVER>:hooks/commit-msg ./
sudo mv ./commit-msg /usr/share/git-core/templates/hooks/

Hope you find it useful…

Automatically placing Gerrit’s commit-msg hook in every new git repository

git pre-commit hook for code beautification

Hi.

In this post I will share a git pre-commit hook I created for aiding with code beautification.

In Linux, I work in two different coding styles: User space and Kernel.

The Linux kernel has a very specific coding style and every commit to kernel must adhere to that style.
The Linux kernel provides a very neat script named checkpatch.pl that can be used to check if your patch adheres to the kernel style. It also works on complete files.

Usually, before I prepare an a patch for pushing upstream, I run the checkpatch script and fix all the errors (well, not all off them, 80 columns ? really ??)

but, can’t we automate this ? well, here’s come git hooks to the rescue.

Git has an option of providing a scripts that can run before or after certain workflow stages.
For instance, if you ever worked with Gerrit, you probably used Gerrit’s commit-msg hook provided to generate a unique Change-Id token embedded in the commit message.

One hook that is particularly interesting in this case is the pre-commit hook. As one might speculate, this scripts runs just before the commit action by Git and has access to Git objects.

The hook I’ve written, basically runs on all the file in the commit and runs astyle (Artistic style) against each of them.

astyle if a very cool command line tool that works on various platforms. It runs against a set rules describing how to do spacing, indentation and various other beautification stuff.
It then rewrites the original file with the fixed style.

You can grab the hook in Github.

Please feel free to fork and enhance it.

Possible improvements:
Currently astyle works on complete objects (files). I would prefer it will only work on the objects diff  in commits.

 

git pre-commit hook for code beautification

HOW TO SET LOCAL AOSP GERRIT SERVER – PART 3

Hi there.
This is the last post in the series of a local AOSP gerrit server setup.
In this post, We’ll finalize the configuration of Gerrit, add new branches for development and see how to maintain the setup.

In the last post, we’ve finished creating the project in Gerrit.
When we develop locally, we should work on our own branches. Basically, you choose a branch/tag that you want to use as a baseline and start working from there.
As we know, in Android, there are too many projects to do it by hand for each project.
Let’s see how we can do it for all of them in one command.

How to create a baseline

For that, we’ll use the following Gerrit command line: gerrit create-branch.
As we did before, we’ll apply this command inside a repo forall command, so our Gerrit command will be applied to all projects.

First, we need to decide on the baseline. For each release, Google releases a build code associated with a manifest branch. We’ll need that tag. build code / manifest branch pairs can be taken from here.

For this tutorial, we’ll take the following Lollipop build LMY48B, which suits Nexus 5 (Which I own).

According to google, the associated branch for it is: android-5.1.1_r3

Let us first init an empty repository with that branch, and of course, we’ll do it from our server.

repo init -u ssh://ramon@localhost:29418/android/platform/manifest -b android-5.1.1_r3

Great, don’t just do repo sync yet. we want to examine the manifest first.
Open the file .repo/manifests/default.xml

You should see the following lines in the beginning:

<remote name="aosp"
fetch=".." />
<default revision="refs/tags/android-5.1.1_r3"
remote="aosp"
sync-j="4" />

The default revision tells which tag to checkout for each project.

Let’s take the android-5.1.1_r3 tag and branch out of this tag to our own branch. This will be our baseline and we could push our changes directly to that branch.

To do so, let’s go back to the mirror on the server, we’ll need to do another repo batch command.

repo forall -c 'echo $REPO_PATH; ssh -p 29418 ramon@localhost gerrit create-branch android/$REPO_PATH my_baseline android-5.1.1_r3'

You should see sometimes the error message “fatal: invalid revision “android-5.1.1_r3“”. This is ok, it happens on project which don’t have the tag. This project are not included in the manifest we set our baseline on.

Now, when the new branches are let’s create our own manifest. We’ll go back to the place we initialized the repo.

This is a git repository, it’s actually a project, so let’s create our own branch.

git checkout -b my_manifest_branch

Edit default.xml

git add manifest.xml
git commit -m "My new manifest branch"


git push ssh://ramon@localhost:29418/android/platform/manifest HEAD:refs/for/my_baseline
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 341 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1)
remote: Processing changes: new: 1, refs: 1, done
remote:
remote: New Changes:
remote: http://localhost:8080/36 Set Manifest for myself
remote:
To ssh://ramon@localhost:29418/android/platform/manifest
* [new branch] HEAD -> refs/for/my_baseline

Done. now, open gerrit and merge that change. From now on, people should init the repo like this:

repo init -u ssh://ramon@localhost:29418/android/platform/manifest -b my_baseline

Great.


How to update gerrit

Let’s see now how we can update our gerrit and mirror and get upstream changes from Google.

This is very easy. go to the mirror folder and just do

repo sync -j6

And now, run the batch script we ran before.

$ repo forall -c 'echo $REPO_PATH; git push ssh://ramon@localhost:29418/android/$REPO_PATH +refs/heads/* +refs/tags/*;'


How to set Gerrit as a system service

Our setup can’t be finished until we know for certain that after reboot our gerrit server will start again.

To achieve that, we need to add Gerrit as a system service. I’ll show here how to do it in Ubuntu server (Debian like), for other dists like please find another tutorial online.
Basically, gerrit can be easily be installed by chkconfig. problem is that chkconfig is no longer supported in Ubuntu, which now uses upstart for it’s init process.
The right way, is to write a new Gerrit config for upstart and place it in /etc/init
Couldn’t find a it on the net, so I need to write it myself.
When it will be ready, I’ll post it in the blog.

Meanwhile, here’s an ugly, working way to achieve that.

I’m assuming that Gerrit installation resides on /opt/gerrit-review

echo "GERRIT_SITE=/opt/gerrit-review" >> /etc/default/gerritcodereview
ln -snf /opt/gerrit-review/bin/gerrit.sh /etc/init.d/gerrit
update-rc.d gerrit defaults

HOW TO SET LOCAL AOSP GERRIT SERVER – PART 3

HOW TO SET LOCAL AOSP GERRIT SERVER – PART 2

Hi. This is part 2 of the “How to set local AOSP Gerrit server”, you might want to start with part 1 here.

In part 1 we’ve downloaded all the necessary stuff and in this post we’re going to set it all up.

First thing, let’s bootstrap Gerrit.

Let’s create a Gerrit user:

$ sudo adduser --system --shell /bin/bash --gecos 'Gerrit Code Review User' --group --disabled-password --home /home/gerrit2 gerrit2

Gerrit needs to work with a database, it support various types of database. for this tutorial I chose MySQL.
Open a shell and type the following:

$ mysql -u root -p
CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
CREATE DATABASE reviewdb;
ALTER DATABASE reviewdb charset=latin1;
GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
FLUSH PRIVILEGES;
quit

This commands create a Gerrit user, a database and sets the required permissions for the Gerrit user.

Log in as the new user:
$ sudo su gerrit2

Copy the gerrit-2.11.war file you’ve downloaded in the previous post to gerrit2 home directory and run the following comand

$ java -jar ./gerrit-2.11.war init -d review_site

Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore

*** Gerrit Code Review 2.11
***

Create ‘/home/gerrit2/review_site’ [Y/n]?

*** Git Repositories
***

Location of Git repositories [git]:

*** SQL Database
***

Database server type [h2]: MySQL

Gerrit Code Review is not shipped with MySQL Connector/J 5.1.21
** This library is required for your configuration. **
Download and install it now [Y/n]?
Downloading http://repo2.maven.org/maven2/mysql/mysql-connector-java/5.1.21/mysql-connector-java-5.1.21.jar … OK
Checksum mysql-connector-java-5.1.21.jar OK
Server hostname [localhost]:
Server port [(mysql default)]:
Database name [reviewdb]:
Database username [gerrit2]: gerrit2
gerrit’s password :
confirm password :

*** Index
***

Type [LUCENE/?]:

*** User Authentication
***

Authentication method [OPENID/?]:

*** Review Labels
***

Install Verified label [y/N]?

*** Email Delivery
***

SMTP server hostname [localhost]:
SMTP server port [(default)]:
SMTP encryption [NONE/?]:
SMTP username :

*** Container Process
***

Run as [gerrit2]:
Java runtime [/usr/lib/jvm/java-8-openjdk-amd64/jre]:
Copy gerrit-2.11.war to /home/gerrit2/review_site/bin/gerrit.war [Y/n]?
Copying gerrit-2.11.war to /home/gerrit2/review_site/bin/gerrit.war

*** SSH Daemon
***

Listen on address [*]:
Listen on port [29418]:

Gerrit Code Review is not shipped with Bouncy Castle Crypto SSL v151
If available, Gerrit can take advantage of features
in the library, but will also function without it.
Download and install it now [Y/n]?
Downloading http://www.bouncycastle.org/download/bcpkix-jdk15on-151.jar … OK
Checksum bcpkix-jdk15on-151.jar OK
Generating SSH host key … rsa… dsa… done

*** HTTP Daemon
***

Behind reverse proxy [y/N]?
Use SSL (https://) [y/N]?
Listen on address [*]:
Listen on port [8080]:
Canonical URL [http://ubuntu:8080/]: http://10.0.0.9:8080

*** Plugins
***

Installing plugins.
Install plugin download-commands version v2.11 [y/N]?
Install plugin reviewnotes version v2.11 [y/N]?
Install plugin singleusergroup version v2.11 [y/N]?
Install plugin replication version v2.11 [y/N]?
Install plugin commit-message-length-validator version v2.11 [y/N]?
Initializing plugins.
No plugins found with init steps.

Initialized /home/gerrit2/review_site
Executing /home/gerrit2/review_site/bin/gerrit.sh start
Starting Gerrit Code Review: OK
Waiting for server on ubuntu:8080 … OK
Opening http://10.0.0.9:8080/#/admin/projects/ …FAILED
Open Gerrit with a JavaScript capable browser:
http://10.0.0.9:8080/#/admin/projects/

Allright. We’ve got Gerrit running now.
A thing worth mentioning, the first user that logs into Gerrit becomes an admin. so make sure to login first with the administrator user.

Gerrit can work with several authentication models. I chose OpenID for this tutorial.
If you don’t have OpenID server on your machine, you can use external service such as Yahoo for instance. (Lately Google stopped supporting OpenID)

Let’s get started. open up a browser and browse to Gerrit site.

In the upper right corner you should see Register and Login links.
Register first using OpenID and log in.

Gerrit welcome screen

Now, let’s set our SSH keys so we can work from command line. we’re doing it as the Admin user for the Ubuntu Server, not as the Gerrit user.

Generate an SSH key pair by doing the following:

serveradmin@ubuntu:$ ssh-keygen <ENTER>
Generating public/private rsa key pair.
Enter file in which to save the key (/home/serveradmin/.ssh/id_rsa):  <ENTER>
Enter passphrase (empty for no passphrase): <ENTER>
Enter same passphrase again: <ENTER>
Your identification has been saved in /home/serveradmin/.ssh/id_rsa.
Your public key has been saved in /home/serveradmin/.ssh/id_rsa.pub.
The key fingerprint is:
d5:7b:51:d8:22:0e:95:63:f9:0e:a2:22:1c:97:76:40 serveradmin@ubuntu
The key's randomart image is:
+---[RSA 2048]----+
| .E ..o o.|
| . ..* o..|
| o .+.+.. |
| . + ... o... |
| . + .S. ..o. |
| o . . .. |
| . . |
| |
| |
+-----------------+

serveradmin@ubuntu:~/aosp_mirror$ cat ~/.ssh/id_rsa.pub  <ENTER>
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDobCUbb8ExP9ci48ZCzCUE3P+IjoH6zrv/l88+4NOTf9FJWDAl4SHCXI+mrZoFEeZo9
uieKTuvHqUFQNpnVA9vfNY6bhaTucAAt0fX9Q1M1ZtNj2IxaQd7u9PnxjSGEig0BUtjqDEu4CMhMShXGWsGAwL7ju/qu7G7RF
iK/Wtcye6wUSjziXseCusb1DUZZ6dsOpxrPYEM3kwXpItQtAq1oEIQWsxEgj2nrOqRXm1UWdqIQU1X45XHQtg5iqi44PfLVNU
3alu453MeWn5PrpSS5dFw/7AkBW4KMPwrOvVnu8gb9xLA0TWtPf+sQ9ROEQC5SBeO+4Q9XRNf5YaswpLj serveradmin@ubuntu

Copy the entire blob to clipboard and paste switch back to Gerrit web interface.

On the upper right corner of the screen, click on your user name and then on Settings.
On the left menu that appears click on “SSH Public Keys” and paste the blob in the white box and press add.

 

Let’s test that we can access Gerrit now through SSH:

ssh -p 29418 admin@localhost <ENTER> <Change "admin" to your username in gerrit>

**** Welcome to Gerrit Code Review ****

Hi Administrator, you have successfully connected over SSH.

Unfortunately, interactive shells are disabled.
To clone a hosted Git repository, use:

git clone ssh://ramon@10.0.0.9:29418/REPOSITORY_NAME.git

Connection to localhost closed.

Now when we’re logged in. let’s create two groups:

“android-admin” and “android”

The former will be used for administration, it will have permissions to review, merge, delete, etc.
The latter will have only view and submit change-set permission.

On the menu, press on People –> Create New Group
Enter in group name “android-admin” (Without the quotes)

Do this again for “android”

Now, let’s create a parent project for all the AOSP tree. All configuration we apply to that project will be inherited to the children projects. if we skip this step, all AOSP projects will inherit from the default “All-Projects” project, which is too global.

On the Gerrit GUI, Press on Project -> Create New Project.
Fill in the following:

Project Name: Android
Rights Inherit From: All-Projects

Tick the “Only Serve As Parent For Other Projects” and press on “Create Project” button.

Now, when we’ve got our parent project. let’s set it’s access permissions:

Click on Projects -> List, and select the Android project.

Click on Access and Edit.

 

Now it’s time to push all Android projects to gerrit.

First command will create all the projects in gerrit. it should be rather quick.\
The Second command will change the parent project for all the projects we’ve just created.
The Third command will actually push all the code into the repositories, this should take a while…

Go into the folder where you’ve mirrored Android and type:
$ repo forall -c 'echo $REPO_PATH; ssh -p 29418 admin@localhost gerrit create-project --name android/$REPO_PATH --owner android;'

accessories/manifest
device/asus/deb
device/asus/flo
device/asus/flo-kernel
device/asus/fugu
device/asus/fugu-kernel
…

$ repo forall -c 'echo $REPO_PATH; ssh -p 29418 admin@localhost gerrit set-project-parent --parent Android android/$REPO_PATH;'

accessories/manifest
device/asus/deb
device/asus/flo
device/asus/flo-kernel
…

Go to Projects -> List
Select Android and Press on General.
Below on the page you should find a button called “Edit Config”
Press on it and paste the following:

[access "refs/*"]
read = group android
read = group android-admin
abandon = group android-admin
push = group android-admin
pushTag = group android-admin
pushSignedTag = group android-admin
label-Code-Review = -2..+2 group android-admin
submit = group android-admin
submitAs = group android-admin
forgeAuthor = group android-admin
forgeCommitter = group android-admin
pushMerge = group android-admin
rebase = group android-admin
editTopicName = group android-admin
[access "refs/heads/*"]
label-Code-Review = -2..+2 group android-admin
label-Code-Review = -1..+1 group android
read = group android
abandon = group android
rebase = group android
submit = group android
[access "refs/tags/*"]
pushTag = group android
pushSignedTag = group android

Press on Save.

In next step, which will take some time, we’re going to push all of git tags and objects to the projects we’ve created. It may fail, but if it is, you can run it again until it succeeds. I found that increasing the Virtual machine RAM solved the issue for me.


$ repo forall -c 'echo $REPO_PATH; git push ssh://ramon@localhost:29418/android/$REPO_PATH +refs/heads/* +refs/tags/*;'

Okay.
That’s it for this time, in the next part I’ll show you how to maintain the gerrit server. how to add it as a startup service, how to update the mirror and push new releases of Google in to it.
Cy’a

Ramon

Part 3 is ready, here’s the link.

HOW TO SET LOCAL AOSP GERRIT SERVER – PART 2

How to set local AOSP Gerrit server – Part 1

In this tutorial I’ll explain how to set a local gerrit server that hosts Android source code.

After completing the tutorial you’ll have a fully runnable local AOSP mirror with local Gerrit server.

First thing first. we need a Linux server. if you don’t have one available, you can use a pre-installed Ubuntu 15.04 Server I created – here.
Actually, this tutorial was tested on this machine, so you’re unlikely to get in trouble if you use that.

This tutorial assumes that package management is apt-get. If you’re using other, please do the appropriate adjustments.

Gerrit Prerequisites:

1. Java JDK > 1.7
2. Git
3. SSH server
4. DB

I choose to work with mySQL, put you can also work with various other DB software. consult the Gerrit documentation here.

Here is a short command to get you everything you need:

$ sudo apt-get install git openjdk-8-jre openssh-server mysql-server gitweb

Download and install Android repo

$ sudo curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo
$ sudo chmod a+x /usr/bin

Now we need to set a local mirror of Android. It will take a while, go do something else in the meanwhile…

$ mkdir -p /usr/local/aosp/mirror
$ cd /usr/local/aosp/mirror
$ repo init -u https://android.googlesource.com/mirror/manifest --mirror
$ repo sync

Download Gerrit.

You’re done with part one… Jump to part two of this tutorial

How to set local AOSP Gerrit server – Part 1

Ubuntu Server 15.04 Virtualbox Image

I created pre-installed Ubuntu Server 15.04 64bit Virtualbox image to be used for various server side setups.

It can be freely downloaded and used by you.
all packages were updated to the current date (9/5/15).
openssh server was installed and set to default port

File can be downloaded from here:

Link: UbuntuServer1504VboxImage.tar.bz2
MD5: eff64b08b8e2fc4ceb668a4e1a62b82d

The credentials are:
user: serveradmin
password: 123456

Please change the password immediately after you download the image for obvious security reasons.

You should change the following after booting

hostname (preset to “ubuntu”)
Date/Time (preset to Jerusalem – GMT+2)
Language / Keyboard setup (preset US English)

Notes:
1. Virtualbox Guest util is not installed.
2. The image was created with VirtualBox 4.3.26r98988
3. Audio / USB / serial port are disabled
4. HD size was set to 128GB, resized dynamically.

Ubuntu Server 15.04 Virtualbox Image