Quick workflow to setup and cut an osm file with a polygon file
##install osmconvert
wget -O - http://m.m.i24.cc/osmconvert.c | cc -x c - -lz -O3 -o osmconvert
##move it to bin folder
cp osmconvert /usr/local/bin/osmconvert
##download ogr2poly.py
wget https://raw.githubusercontent.com/dalekunce/ogr2poly.py/master/ogr2poly.py
##convert json to poly file
ogr2poly.py -v src_datalayer
##download pbf file
wget http://download.geofabrik.de/africa-latest.osm.pbf
##cut osm file with poly layer
osmconvert src_osm_file.pbf -B=json.poly --complete-ways -o=output.pbf
#convert pbf to spatialite
ogr2ogr -f "SQLite" -dsco SPATIALLITE=YES output.db osmfile.pbf