I have two input sources:
region.shp. Geometry type MultiPolygon. Currently contains 3 regions.
roads.gpkg. One layer, "road" with geometry field named "geom" with type LineString.
I want to create a new gpkg with all the roads that are within any of areas in region.shp. Preferably using ogr2ogr in a shell script.
I have found examples online that shows how to do this with two shape files. But I cant figure out how to do it with two dissimilar formats like gpkg and shp. Will I need to convert to the same format before doing any spatial operations/queries involving both data sources?
I reproduced your input creating a Geopackage file named "roads.gpkg" with only one Linestring layer named "road" with a couple of streets downloaded from OpenStreetMap. Also created a shapefile named "region.shp" with a one multipart polygon which has two parts and another singlepart polygon, which one of them representing surroudings of parks within a city downtown.
According to the ogr2ogr's documentation, you can clip your input file using another input file as a filter with this command:
ogr2ogr -nlt LINESTRING -clipsrc region.shp dst.gpkg roads.gpkg
The file outputted by the command is shown in the image below and I think it fits what you needed.